Igalia / wolvic

A fast and secure browser for standalone virtual-reality and augmented-reality headsets.
https://wolvic.org
Mozilla Public License 2.0
796 stars 100 forks source link

Load controller 3D models even with multiple interaction profiles #1446

Closed svillar closed 3 months ago

svillar commented 3 months ago

Now that hand interaction profile is available for some devices it might happen that the user uses it at start time. That profile, as it's meant to be used for hand tracking, does not require any 3D model (the hand 3D model uses hand tracking joints that are not related to the hand interaction profile). This means that the callback of OnControllersReady() in BrowserWorld will not load any 3D model, and then DeviceDelegateOpenXR will uninstall the callback. Then if the user ever grabs a physical controller, the interaction profile will be updated (as we get notified by the runtime), but no 3D models would be ever loaded for those controllers as the callback is now null.

In order to fix that, the callback for OnControllersReady now returns a boolean representing whether or not the 3D models where loaded. If it's true then we can uninstall the callback after completion. If it's false then we leave the callback ready for eventual interaction profile changes.

Note that this do not support having multiple physical controllers for a single device, but that scenario is unlikely to happen.

We have also moved the callback signature to a typedef, that is not really required but it's better for robustness and maintenance as it allows us to modify it in a single place.

Fixes #1445