Skip to content
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

Provide generic interface for XR hand tracking #88639

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Feb 21, 2024

This adds a generic interface for hand tracking similar to what PR #88312 added for face tracking, based on notes from @BastiaanOlij and @Malcolmnixon on RocketChat and Discord.

It deprecates OpenXRHand and the methods for accessing raw hand tracking data on OpenXRInterface.

While this does seem to work, it could use some testing - I plan to experiment with it some more myself, but testing from others would also be much appreciated as well!

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="XRHandTracker" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
Copy link
Contributor

Choose a reason for hiding this comment

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

How about classifying it as experimental just in case?

Suggested change
<class name="XRHandTracker" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="XRHandTracker" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd" experimental="">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps. But I don't know if it makes sense to mark this as experimental if we're also deprecated the older APIs. I feel like we should do one or the other: Mark the old APIs as deprecated OR mark the new APIs as experimental, but not both.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I think it's overkill, probably the original OpenXR implementation should have been called experimental, but since this is all based on the experience we gathered with this, I think we have a pretty solid grasp on it.

@dsnopek dsnopek force-pushed the xrserver-hand-tracker branch 3 times, most recently from 5950618 to 6d9d109 Compare February 21, 2024 19:31
doc/classes/XRHandModifier3D.xml Outdated Show resolved Hide resolved
doc/classes/XRHandModifier3D.xml Outdated Show resolved Hide resolved
doc/classes/XRHandModifier3D.xml Outdated Show resolved Hide resolved
doc/classes/XRHandTracker.xml Outdated Show resolved Hide resolved
doc/classes/XRHandTracker.xml Outdated Show resolved Hide resolved
doc/classes/XRHandTracker.xml Show resolved Hide resolved
doc/classes/XRHandTracker.xml Show resolved Hide resolved
doc/classes/XRHandTracker.xml Outdated Show resolved Hide resolved
doc/classes/XRHandTracker.xml Outdated Show resolved Hide resolved
doc/classes/XRHandTracker.xml Outdated Show resolved Hide resolved
Copy link
Contributor

@Malcolmnixon Malcolmnixon left a comment

Choose a reason for hiding this comment

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

This works well for me, and drops directly in to my Humanoid hand tests.

@dsnopek
Copy link
Contributor Author

dsnopek commented Feb 22, 2024

@Malcolmnixon @AThousandShips Thanks for the review! It should be addressed in my latest push

Copy link
Contributor

@BastiaanOlij BastiaanOlij left a comment

Choose a reason for hiding this comment

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

Perfect! Only two nitpicking things. This looks real good, thanks @dsnopek !

doc/classes/XRHandTracker.xml Outdated Show resolved Hide resolved
</members>
<constants>
<constant name="HAND_LEFT" value="0" enum="Hand">
A left hand.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've wondered about this for awhile seeing this comes back in a number of APIs. Should we add this constant to [XRServer] itself?

Copy link
Contributor Author

@dsnopek dsnopek Feb 23, 2024

Choose a reason for hiding this comment

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

Hm. Well, before this PR we have two left/right hand enums:

  • XRPositionalTracker.TrackerHand
  • OpenXRInterface.Hand

The 2nd of those is going to be deprecated after this PR, so I think we can mostly ignore it.

The 1st of those has different values: unknown (0), left (1) and right (2). That's a little inconvenient for hand tracking because their is no unknown and we can use left (0) and right (1) as array indexes, and the max value (2) for loops.

Given that, I feel like it's OK for XRHandTracker to have a hand enum that fits its purposes. And, even if we decided to consolidate to a single enum on XRServer, we can't change XRPositionalTracker to use it for backwards compatibility reasons. Maybe when we can break compatibility (like, Godot 5) we could consolidate on a single enum in XRServer? Although, given the different needs of the two enums, I personally still think I'd prefer to have the two of them for their different purposes.

@dsnopek
Copy link
Contributor Author

dsnopek commented Feb 23, 2024

@BastiaanOlij Thanks for the review!

Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

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

Looks good!

Added some minor feedback to address.

scene/3d/xr_hand_modifier_3d.cpp Outdated Show resolved Hide resolved
scene/3d/xr_hand_modifier_3d.cpp Show resolved Hide resolved
scene/3d/xr_hand_modifier_3d.cpp Outdated Show resolved Hide resolved
@akien-mga akien-mga merged commit 0d83267 into godotengine:master Feb 23, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants