Skip to content

Conversation

vilhalmer
Copy link
Collaborator

@vilhalmer vilhalmer commented Oct 8, 2025

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.

vilhalmer and others added 8 commits October 7, 2025 13:25
I've added an override for which render model gets loaded into an
OVRRenderModel3D. The fallback for autodetection based on a parent
controller node doesn't actually work yet.
I've removed the OpenVRRenderModel type in favor of two new top-level
functions to return ArrayMeshes directly, to make the interface for
components and single-model symmetrical. The subclass didn't have any
metadata on it anyway.

I might bring back something like it but that isn't a VisualInstance3D
at all, because there are components which have no visual
representation. This would provide a convenient place to expose
RenderModel_ComponentState_t data.
If the Ref isn't valid, it means the caller discarded the mesh before
the next frame came around and thus we can just skip loading that model.
Before this change, the VR Compositor memory use grew after each texture
load. Now it jumps up while loading and then returns to approximately
where it was.
Use signals from XRServer to trigger reloading render models from OpenVR
when needed. Also removed the generic_controller fallback, as we don't
currently have a way to actually signal failure from the deferred
loading in openvr_data.
No need to track this by hand anymore.
Unsure why grip isn't getting tracking data, but the controllers match
up perfectly with the dashboard overlay versions using the default pose.

The demo still isn't fully working again, but this is another step in
that direction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant