Skip to content

Conversation

devloglogan
Copy link
Collaborator

I use the demo project for testing stuff pretty often and I've wanted to update the code that hides/displays controller and hand models based on hand tracking for a while now, since going off of hand tracking source for everything seems incorrect. Now this should be the case:

  • If there is hand tracking data:
    • Hand meshes will display
    • Fb render model will display if loaded and the hand tracking data is inferred from controller data, otherwise controller models are hidden
  • If there is no hand tracking data:
    • Hand meshes are hidden
    • Controller models are shown

@devloglogan devloglogan added the enhancement New feature or request label Apr 11, 2025
hand_cube.hide()
else:
if render_model.has_render_model_node():
render_model.show()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to explicitly hide the hand cube here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm in my testing this wasn't a problem but I think you're right in that it should be here, so I've added it.


var hand_tracker: XRHandTracker = XRServer.get_tracker(hand_tracker_name)
if hand_tracker and hand_tracker.has_tracking_data:
if hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments describing the intended flow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments added.

@devloglogan devloglogan force-pushed the demo-hand-tracking-update branch from 970e830 to cfa92bf Compare April 15, 2025 20:09
@dsnopek
Copy link
Collaborator

dsnopek commented Apr 16, 2025

Rebasing on master should fix CI

@devloglogan devloglogan force-pushed the demo-hand-tracking-update branch from cfa92bf to dceb9d9 Compare April 16, 2025 19:26
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks great - the logic for hiding/showing the controller and hand meshes makes sense to me.

However, I have one suggestion: Use XRInterface.set_motion_range() to make the hand tracking data conform to the controller when showing both the controller and hand meshes.

I tested this out with this patch and it worked nicely:

diff --git a/demo/hand_controller.gd b/demo/hand_controller.gd
index 3d4b9c7..7ef993d 100644
--- a/demo/hand_controller.gd
+++ b/demo/hand_controller.gd
@@ -6,6 +6,10 @@ extends XRController3D
 func _process(_delta: float) -> void:
        var hand_tracker_name = "/user/hand_tracker/left" if tracker == "left_hand" \
                        else "/user/hand_tracker/right"
+       var hand_tracker_hand: OpenXRInterface.Hand = OpenXRInterface.HAND_LEFT if tracker == "left_hand" \
+                       else OpenXRInterface.HAND_RIGHT
+
+       var interface: OpenXRInterface = XRServer.find_interface("OpenXR")
 
        var hand_tracker: XRHandTracker = XRServer.get_tracker(hand_tracker_name)
        if hand_tracker and hand_tracker.has_tracking_data:
@@ -14,10 +18,13 @@ func _process(_delta: float) -> void:
                if hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER \
                                and render_model.has_render_model_node():
                        render_model.show()
+                       interface.set_motion_range(hand_tracker_hand, OpenXRInterface.HAND_MOTION_RANGE_CONFORM_TO_CONTROLLER)
+
                # If hand tracking data is not provided by controller,
                # and controller model is available, hide it.
                elif render_model.has_render_model_node():
                        render_model.hide()
+                       interface.set_motion_range(hand_tracker_hand, OpenXRInterface.HAND_MOTION_RANGE_UNOBSTRUCTED)
 
                # Always hide placeholder hand cubes if we have hand tracking data.
                hand_cube.hide()

@dsnopek dsnopek requested a review from m4gr3d April 16, 2025 21:08
@devloglogan devloglogan force-pushed the demo-hand-tracking-update branch from dceb9d9 to 484d14b Compare April 18, 2025 13:15
@devloglogan
Copy link
Collaborator Author

@dsnopek ah I'd wondered how this was supposed to be accomplished for a while, glad I know now. Works great. I've applied your patch, thank you!!

@dsnopek dsnopek merged commit 608e75d into GodotVR:master Apr 21, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants