Fix render model loading and expose model components #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses a very old TODO and makes render models load properly, as well as addressing a texture memory leak.
I've also added support for loading render model components, which provides access to each individual control on the model so buttons can be animated, etc. This is the version of the model used by the SteamVR dashboard. There is more information that isn't yet available like button movement axes which I haven't found a way to access except by directly reading the controller manifests. Adding an API to access this information is something I'd like to do, but I'm saving that for a future PR.
Because components come back as multiple meshes, it didn't make a lot of sense to add them as part of the OVRRenderModel class as it is a single MeshInstance3D. I took the pending major version as an opportunity to break compatibility by removing this class entirely. It wasn't really doing a whole lot that an ArrayMesh doesn't, and if users desire more automatic bookkeeping they were already encouraged to take the controller class from the demo as a starting point anyway. I could be convinced to put it or something similar back, perhaps as a VisualInstance3D instead for more flexibility.
Adding a friendlier way to use the components is something I'd like to do, at least as another demo scene. I have code for it in one of my projects, but it needs some untangling before I can upstream it and I didn't want this to sit around any longer.
There is an additional wrinkle in that render models may contain components with no visual representation, as well as some which are intended to be hidden by default and only shown when e.g. touching or scrolling on the trackpad. I haven't found an official API for getting this info either, but I suspect it must exist somewhere. The components without visual representation seem to always be poses and I'm just discarding them at the moment. If I did end up adding back a class to hold all the model information, they could live in there. I'm not entirely sure what you're intended to do with them, if anything.
Another future enhancement is adding a signal that the render model and all textures have actually finished loading in the background thread. Right now the mesh will become immediately visible which is mostly fine for the single-mesh model, but when using the components it causes them to pop into existence one at a time. In my project I used an awful hack of polling until all of the meshes had textures assigned before displaying the entire group, but I wouldn't sleep well at night knowing anyone else was using that code.
Finally, I did some more cleanup and fixing so the controller models are working in the demo again.