-
Notifications
You must be signed in to change notification settings - Fork 33
Improve hand tracking related code in demo project #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
hand_cube.hide() | ||
else: | ||
if render_model.has_render_model_node(): | ||
render_model.show() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments added.
970e830
to
cfa92bf
Compare
Rebasing on |
cfa92bf
to
dceb9d9
Compare
There was a problem hiding this 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()
dceb9d9
to
484d14b
Compare
@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!! |
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: