Skip to content

Commit 36bdab4

Browse files
committed
Merge pull request godotengine#90759 from dsnopek/openxr-hand-revert
Revert `OpenXRHand` to its pre-`SkeletonModifier3D` state
2 parents 82b36cc + dfca388 commit 36bdab4

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

misc/extension_api_validation/4.2-stable.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ Removed VisualShaderNodeComment, which is replaced by VisualShaderNodeFrame.
263263

264264
GH-87888
265265
--------
266-
Validate extension JSON: API was removed: classes/OpenXRHand/methods/get_hand_skeleton
267-
Validate extension JSON: API was removed: classes/OpenXRHand/methods/set_hand_skeleton
268-
Validate extension JSON: API was removed: classes/OpenXRHand/properties/hand_skeleton
269266
Validate extension JSON: API was removed: classes/Skeleton3D/properties/animate_physical_bones
270267
Validate extension JSON: API was removed: classes/SkeletonIK3D/methods/get_interpolation
271268
Validate extension JSON: API was removed: classes/SkeletonIK3D/methods/set_interpolation

modules/openxr/doc_classes/OpenXRHand.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="OpenXRHand" inherits="SkeletonModifier3D" deprecated="Use [XRHandModifier3D] instead." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
2+
<class name="OpenXRHand" inherits="Node3D" deprecated="Use [XRHandModifier3D] instead." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
33
<brief_description>
44
Node supporting hand and finger tracking in OpenXR.
55
</brief_description>
@@ -18,11 +18,14 @@
1818
<member name="hand" type="int" setter="set_hand" getter="get_hand" enum="OpenXRHand.Hands" default="0">
1919
Specifies whether this node tracks the left or right hand of the player.
2020
</member>
21+
<member name="hand_skeleton" type="NodePath" setter="set_hand_skeleton" getter="get_hand_skeleton" default="NodePath(&quot;&quot;)">
22+
Set a [Skeleton3D] node for which the pose positions will be updated.
23+
</member>
2124
<member name="motion_range" type="int" setter="set_motion_range" getter="get_motion_range" enum="OpenXRHand.MotionRange" default="0">
2225
Set the motion range (if supported) limiting the hand motion.
2326
</member>
2427
<member name="skeleton_rig" type="int" setter="set_skeleton_rig" getter="get_skeleton_rig" enum="OpenXRHand.SkeletonRig" default="0">
25-
Set the type of skeleton rig the parent [Skeleton3D] is compliant with.
28+
Set the type of skeleton rig the [member hand_skeleton] is compliant with.
2629
</member>
2730
</members>
2831
<constants>

modules/openxr/scene/openxr_hand.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ void OpenXRHand::_bind_methods() {
4040
ClassDB::bind_method(D_METHOD("set_hand", "hand"), &OpenXRHand::set_hand);
4141
ClassDB::bind_method(D_METHOD("get_hand"), &OpenXRHand::get_hand);
4242

43+
ClassDB::bind_method(D_METHOD("set_hand_skeleton", "hand_skeleton"), &OpenXRHand::set_hand_skeleton);
44+
ClassDB::bind_method(D_METHOD("get_hand_skeleton"), &OpenXRHand::get_hand_skeleton);
45+
4346
ClassDB::bind_method(D_METHOD("set_motion_range", "motion_range"), &OpenXRHand::set_motion_range);
4447
ClassDB::bind_method(D_METHOD("get_motion_range"), &OpenXRHand::get_motion_range);
4548

@@ -51,6 +54,7 @@ void OpenXRHand::_bind_methods() {
5154

5255
ADD_PROPERTY(PropertyInfo(Variant::INT, "hand", PROPERTY_HINT_ENUM, "Left,Right"), "set_hand", "get_hand");
5356
ADD_PROPERTY(PropertyInfo(Variant::INT, "motion_range", PROPERTY_HINT_ENUM, "Unobstructed,Conform to controller"), "set_motion_range", "get_motion_range");
57+
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "hand_skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton3D"), "set_hand_skeleton", "get_hand_skeleton");
5458
ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton_rig", PROPERTY_HINT_ENUM, "OpenXR,Humanoid"), "set_skeleton_rig", "get_skeleton_rig");
5559
ADD_PROPERTY(PropertyInfo(Variant::INT, "bone_update", PROPERTY_HINT_ENUM, "Full,Rotation Only"), "set_bone_update", "get_bone_update");
5660

@@ -86,6 +90,12 @@ OpenXRHand::Hands OpenXRHand::get_hand() const {
8690
return hand;
8791
}
8892

93+
void OpenXRHand::set_hand_skeleton(const NodePath &p_hand_skeleton) {
94+
hand_skeleton = p_hand_skeleton;
95+
96+
// TODO if inside tree call _get_bones()
97+
}
98+
8999
void OpenXRHand::set_motion_range(MotionRange p_motion_range) {
90100
ERR_FAIL_INDEX(p_motion_range, MOTION_RANGE_MAX);
91101
motion_range = p_motion_range;
@@ -97,6 +107,10 @@ OpenXRHand::MotionRange OpenXRHand::get_motion_range() const {
97107
return motion_range;
98108
}
99109

110+
NodePath OpenXRHand::get_hand_skeleton() const {
111+
return hand_skeleton;
112+
}
113+
100114
void OpenXRHand::_set_motion_range() {
101115
if (!hand_tracking_ext) {
102116
return;
@@ -138,6 +152,20 @@ OpenXRHand::BoneUpdate OpenXRHand::get_bone_update() const {
138152
return bone_update;
139153
}
140154

155+
Skeleton3D *OpenXRHand::get_skeleton() {
156+
if (!has_node(hand_skeleton)) {
157+
return nullptr;
158+
}
159+
160+
Node *node = get_node(hand_skeleton);
161+
if (!node) {
162+
return nullptr;
163+
}
164+
165+
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
166+
return skeleton;
167+
}
168+
141169
void OpenXRHand::_get_joint_data() {
142170
// Table of bone names for different rig types.
143171
static const String bone_names[SKELETON_RIG_MAX][XR_HAND_JOINT_COUNT_EXT] = {
@@ -262,7 +290,7 @@ void OpenXRHand::_get_joint_data() {
262290
}
263291
}
264292

265-
void OpenXRHand::_process_modification() {
293+
void OpenXRHand::_update_skeleton() {
266294
if (openxr_api == nullptr || !openxr_api->is_initialized()) {
267295
return;
268296
} else if (hand_tracking_ext == nullptr || !hand_tracking_ext->get_active()) {
@@ -367,14 +395,21 @@ void OpenXRHand::_notification(int p_what) {
367395
switch (p_what) {
368396
case NOTIFICATION_ENTER_TREE: {
369397
_get_joint_data();
398+
399+
set_process_internal(true);
370400
} break;
371401
case NOTIFICATION_EXIT_TREE: {
402+
set_process_internal(false);
403+
372404
// reset
373405
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++) {
374406
joints[i].bone = -1;
375407
joints[i].parent_joint = -1;
376408
}
377409
} break;
410+
case NOTIFICATION_INTERNAL_PROCESS: {
411+
_update_skeleton();
412+
} break;
378413
default: {
379414
} break;
380415
}

modules/openxr/scene/openxr_hand.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
#ifndef OPENXR_HAND_H
3232
#define OPENXR_HAND_H
3333

34-
#include "scene/3d/skeleton_modifier_3d.h"
34+
#include "scene/3d/node_3d.h"
35+
#include "scene/3d/skeleton_3d.h"
3536

3637
#include <openxr/openxr.h>
3738

3839
class OpenXRAPI;
3940
class OpenXRHandTrackingExtension;
4041

41-
class OpenXRHand : public SkeletonModifier3D {
42-
GDCLASS(OpenXRHand, SkeletonModifier3D);
42+
class OpenXRHand : public Node3D {
43+
GDCLASS(OpenXRHand, Node3D);
4344

4445
public:
4546
enum Hands { // Deprecated, need to change this to OpenXRInterface::Hands.
@@ -85,13 +86,13 @@ class OpenXRHand : public SkeletonModifier3D {
8586

8687
void _set_motion_range();
8788

89+
Skeleton3D *get_skeleton();
8890
void _get_joint_data();
91+
void _update_skeleton();
8992

9093
protected:
9194
static void _bind_methods();
9295

93-
virtual void _process_modification() override;
94-
9596
public:
9697
OpenXRHand();
9798

@@ -101,6 +102,9 @@ class OpenXRHand : public SkeletonModifier3D {
101102
void set_motion_range(MotionRange p_motion_range);
102103
MotionRange get_motion_range() const;
103104

105+
void set_hand_skeleton(const NodePath &p_hand_skeleton);
106+
NodePath get_hand_skeleton() const;
107+
104108
void set_skeleton_rig(SkeletonRig p_skeleton_rig);
105109
SkeletonRig get_skeleton_rig() const;
106110

0 commit comments

Comments
 (0)