diff options
author | Malcolm Nixon <Malcolm.nixon@gmail.com> | 2024-04-24 19:57:57 -0400 |
---|---|---|
committer | Malcolm Nixon <Malcolm.nixon@gmail.com> | 2024-04-25 19:38:57 -0400 |
commit | e00e5c03866be37bfe77ff66948d59a7a08bb0d2 (patch) | |
tree | c68b381709655b12ed3f5e79a52c03479cabdee8 | |
parent | 4bca2d8bc64e84a764ee656b9c42443b24448f53 (diff) | |
download | redot-engine-e00e5c03866be37bfe77ff66948d59a7a08bb0d2.tar.gz |
Remove the Hand enum from XRHandTracker to fix name-collision with the hand property of the base class.
Co-Authored-By: David Snopek <191561+dsnopek@users.noreply.github.com>
-rw-r--r-- | doc/classes/XRHandTracker.xml | 23 | ||||
-rw-r--r-- | modules/openxr/extensions/openxr_hand_tracking_extension.cpp | 2 | ||||
-rw-r--r-- | modules/webxr/webxr_interface_js.cpp | 2 | ||||
-rw-r--r-- | servers/xr/xr_hand_tracker.cpp | 52 | ||||
-rw-r--r-- | servers/xr/xr_hand_tracker.h | 11 |
5 files changed, 6 insertions, 84 deletions
diff --git a/doc/classes/XRHandTracker.xml b/doc/classes/XRHandTracker.xml index 69390df696..636af6625b 100644 --- a/doc/classes/XRHandTracker.xml +++ b/doc/classes/XRHandTracker.xml @@ -11,12 +11,6 @@ <link title="XR documentation index">$DOCS_URL/tutorials/xr/index.html</link> </tutorials> <methods> - <method name="get_hand" qualifiers="const"> - <return type="int" enum="XRHandTracker.Hand" /> - <description> - Returns the type of hand. - </description> - </method> <method name="get_hand_joint_angular_velocity" qualifiers="const"> <return type="Vector3" /> <param index="0" name="joint" type="int" enum="XRHandTracker.HandJoint" /> @@ -52,13 +46,6 @@ Returns the transform for the given hand joint. </description> </method> - <method name="set_hand"> - <return type="void" /> - <param index="0" name="hand" type="int" enum="XRHandTracker.Hand" /> - <description> - Sets the type of hand. - </description> - </method> <method name="set_hand_joint_angular_velocity"> <return type="void" /> <param index="0" name="joint" type="int" enum="XRHandTracker.HandJoint" /> @@ -101,6 +88,7 @@ </method> </methods> <members> + <member name="hand" type="int" setter="set_tracker_hand" getter="get_tracker_hand" overrides="XRPositionalTracker" enum="XRPositionalTracker.TrackerHand" default="1" /> <member name="hand_tracking_source" type="int" setter="set_hand_tracking_source" getter="get_hand_tracking_source" enum="XRHandTracker.HandTrackingSource" default="0"> The source of the hand tracking data. </member> @@ -110,15 +98,6 @@ <member name="type" type="int" setter="set_tracker_type" getter="get_tracker_type" overrides="XRTracker" enum="XRServer.TrackerType" default="16" /> </members> <constants> - <constant name="HAND_LEFT" value="0" enum="Hand"> - A left hand. - </constant> - <constant name="HAND_RIGHT" value="1" enum="Hand"> - A right hand. - </constant> - <constant name="HAND_MAX" value="2" enum="Hand"> - Represents the size of the [enum Hand] enum. - </constant> <constant name="HAND_TRACKING_SOURCE_UNKNOWN" value="0" enum="HandTrackingSource"> The source of hand tracking data is unknown. </constant> diff --git a/modules/openxr/extensions/openxr_hand_tracking_extension.cpp b/modules/openxr/extensions/openxr_hand_tracking_extension.cpp index f8cc3d1d8c..12fa3bed7e 100644 --- a/modules/openxr/extensions/openxr_hand_tracking_extension.cpp +++ b/modules/openxr/extensions/openxr_hand_tracking_extension.cpp @@ -195,7 +195,7 @@ void OpenXRHandTrackingExtension::on_process() { Ref<XRHandTracker> godot_tracker; godot_tracker.instantiate(); - godot_tracker->set_hand(i == 0 ? XRHandTracker::HAND_LEFT : XRHandTracker::HAND_RIGHT); + godot_tracker->set_tracker_hand(i == 0 ? XRPositionalTracker::TRACKER_HAND_LEFT : XRPositionalTracker::TRACKER_HAND_RIGHT); godot_tracker->set_tracker_name(i == 0 ? "/user/hand_tracker/left" : "/user/hand_tracker/right"); XRServer::get_singleton()->add_tracker(godot_tracker); hand_trackers[i].godot_tracker = godot_tracker; diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 535d464d6f..45c1d8ec06 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -713,7 +713,7 @@ void WebXRInterfaceJS::_update_input_source(int p_input_source_id) { if (unlikely(hand_tracker.is_null())) { hand_tracker.instantiate(); - hand_tracker->set_hand(p_input_source_id == 0 ? XRHandTracker::HAND_LEFT : XRHandTracker::HAND_RIGHT); + hand_tracker->set_tracker_hand(p_input_source_id == 0 ? XRPositionalTracker::TRACKER_HAND_LEFT : XRPositionalTracker::TRACKER_HAND_RIGHT); hand_tracker->set_tracker_name(p_input_source_id == 0 ? "/user/hand_tracker/left" : "/user/hand_tracker/right"); // These flags always apply, since WebXR doesn't give us enough insight to be more fine grained. diff --git a/servers/xr/xr_hand_tracker.cpp b/servers/xr/xr_hand_tracker.cpp index cb0fbfb35f..abfe2e9867 100644 --- a/servers/xr/xr_hand_tracker.cpp +++ b/servers/xr/xr_hand_tracker.cpp @@ -33,9 +33,6 @@ #include "xr_body_tracker.h" void XRHandTracker::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_hand", "hand"), &XRHandTracker::set_hand); - ClassDB::bind_method(D_METHOD("get_hand"), &XRHandTracker::get_hand); - ClassDB::bind_method(D_METHOD("set_has_tracking_data", "has_data"), &XRHandTracker::set_has_tracking_data); ClassDB::bind_method(D_METHOD("get_has_tracking_data"), &XRHandTracker::get_has_tracking_data); @@ -60,10 +57,6 @@ void XRHandTracker::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "has_tracking_data", PROPERTY_HINT_NONE), "set_has_tracking_data", "get_has_tracking_data"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hand_tracking_source", PROPERTY_HINT_ENUM, "Unknown,Unobstructed,Controller"), "set_hand_tracking_source", "get_hand_tracking_source"); - BIND_ENUM_CONSTANT(HAND_LEFT); - BIND_ENUM_CONSTANT(HAND_RIGHT); - BIND_ENUM_CONSTANT(HAND_MAX); - BIND_ENUM_CONSTANT(HAND_TRACKING_SOURCE_UNKNOWN); BIND_ENUM_CONSTANT(HAND_TRACKING_SOURCE_UNOBSTRUCTED); BIND_ENUM_CONSTANT(HAND_TRACKING_SOURCE_CONTROLLER); @@ -110,48 +103,8 @@ void XRHandTracker::set_tracker_type(XRServer::TrackerType p_type) { } void XRHandTracker::set_tracker_hand(const XRPositionalTracker::TrackerHand p_hand) { - ERR_FAIL_INDEX(p_hand, TRACKER_HAND_MAX); - - switch (p_hand) { - case TRACKER_HAND_LEFT: - tracker_hand = TRACKER_HAND_LEFT; - hand = HAND_LEFT; - break; - - case TRACKER_HAND_RIGHT: - tracker_hand = TRACKER_HAND_RIGHT; - hand = HAND_RIGHT; - break; - - case TRACKER_HAND_UNKNOWN: - default: - ERR_FAIL_MSG("XRHandTracker must specify hand"); - break; - } -} - -void XRHandTracker::set_hand(XRHandTracker::Hand p_hand) { - ERR_FAIL_INDEX(p_hand, HAND_MAX); - - switch (p_hand) { - case HAND_LEFT: - tracker_hand = TRACKER_HAND_LEFT; - hand = HAND_LEFT; - break; - - case HAND_RIGHT: - tracker_hand = TRACKER_HAND_RIGHT; - hand = HAND_RIGHT; - break; - - default: - ERR_FAIL_MSG("XRHandTracker must specify hand"); - break; - } -} - -XRHandTracker::Hand XRHandTracker::get_hand() const { - return hand; + ERR_FAIL_COND_MSG(p_hand != TRACKER_HAND_LEFT && p_hand != TRACKER_HAND_RIGHT, "XRHandTracker must specify hand."); + tracker_hand = p_hand; } void XRHandTracker::set_has_tracking_data(bool p_has_tracking_data) { @@ -222,4 +175,5 @@ Vector3 XRHandTracker::get_hand_joint_angular_velocity(XRHandTracker::HandJoint XRHandTracker::XRHandTracker() { type = XRServer::TRACKER_HAND; + tracker_hand = TRACKER_HAND_LEFT; } diff --git a/servers/xr/xr_hand_tracker.h b/servers/xr/xr_hand_tracker.h index 8ef3c229c3..c7c18a31f8 100644 --- a/servers/xr/xr_hand_tracker.h +++ b/servers/xr/xr_hand_tracker.h @@ -38,12 +38,6 @@ class XRHandTracker : public XRPositionalTracker { _THREAD_SAFE_CLASS_ public: - enum Hand { - HAND_LEFT, - HAND_RIGHT, - HAND_MAX, - }; - enum HandTrackingSource { HAND_TRACKING_SOURCE_UNKNOWN, HAND_TRACKING_SOURCE_UNOBSTRUCTED, @@ -93,9 +87,6 @@ public: void set_tracker_type(XRServer::TrackerType p_type) override; void set_tracker_hand(const XRPositionalTracker::TrackerHand p_hand) override; - void set_hand(Hand p_hand); - Hand get_hand() const; - void set_has_tracking_data(bool p_has_tracking_data); bool get_has_tracking_data() const; @@ -123,7 +114,6 @@ protected: static void _bind_methods(); private: - Hand hand = HAND_LEFT; bool has_tracking_data = false; HandTrackingSource hand_tracking_source = HAND_TRACKING_SOURCE_UNKNOWN; @@ -134,7 +124,6 @@ private: Vector3 hand_joint_angular_velocities[HAND_JOINT_MAX]; }; -VARIANT_ENUM_CAST(XRHandTracker::Hand) VARIANT_ENUM_CAST(XRHandTracker::HandTrackingSource) VARIANT_ENUM_CAST(XRHandTracker::HandJoint) VARIANT_BITFIELD_CAST(XRHandTracker::HandJointFlags) |