Преглед изворни кода

Merge pull request #107220 from devloglogan/body-tracker-joints

Add new joints to `XrBodyTracker`
Rémi Verschelde пре 2 месеци
родитељ
комит
c171166b6e

+ 34 - 1
doc/classes/XRBodyTracker.xml

@@ -289,7 +289,40 @@
 		<constant name="JOINT_RIGHT_PINKY_FINGER_TIP" value="75" enum="Joint">
 			Right pinky finger tip joint.
 		</constant>
-		<constant name="JOINT_MAX" value="76" enum="Joint">
+		<constant name="JOINT_LOWER_CHEST" value="76" enum="Joint">
+			Lower chest joint.
+		</constant>
+		<constant name="JOINT_LEFT_SCAPULA" value="77" enum="Joint">
+			Left scapula joint.
+		</constant>
+		<constant name="JOINT_LEFT_WRIST_TWIST" value="78" enum="Joint">
+			Left wrist twist joint.
+		</constant>
+		<constant name="JOINT_RIGHT_SCAPULA" value="79" enum="Joint">
+			Right scapula joint.
+		</constant>
+		<constant name="JOINT_RIGHT_WRIST_TWIST" value="80" enum="Joint">
+			Right wrist twist joint.
+		</constant>
+		<constant name="JOINT_LEFT_ANKLE_TWIST" value="81" enum="Joint">
+			Left ankle twist joint.
+		</constant>
+		<constant name="JOINT_LEFT_ANKLE" value="82" enum="Joint">
+			Left ankle joint.
+		</constant>
+		<constant name="JOINT_LEFT_MIDDLE_FOOT" value="83" enum="Joint">
+			Left middle foot joint.
+		</constant>
+		<constant name="JOINT_RIGHT_ANKLE_TWIST" value="84" enum="Joint">
+			Right ankle twist joint.
+		</constant>
+		<constant name="JOINT_RIGHT_ANKLE" value="85" enum="Joint">
+			Right ankle joint.
+		</constant>
+		<constant name="JOINT_RIGHT_MIDDLE_FOOT" value="86" enum="Joint">
+			Right middle foot joint.
+		</constant>
+		<constant name="JOINT_MAX" value="87" enum="Joint">
 			Represents the size of the [enum Joint] enum.
 		</constant>
 		<constant name="JOINT_FLAG_ORIENTATION_VALID" value="1" enum="JointFlags" is_bitfield="true">

+ 14 - 1
scene/3d/xr/xr_body_modifier_3d.cpp

@@ -82,7 +82,7 @@ XRBodyModifier3D::BoneUpdate XRBodyModifier3D::get_bone_update() const {
 }
 
 void XRBodyModifier3D::_get_joint_data() {
-	// Table of Godot Humanoid bone names.
+	// Table of Godot Humanoid bone names with some additions.
 	static const String bone_names[XRBodyTracker::JOINT_MAX] = {
 		"Root", // XRBodyTracker::JOINT_ROOT
 
@@ -168,6 +168,19 @@ void XRBodyModifier3D::_get_joint_data() {
 		"RightLittleIntermediate", // XRBodyTracker::JOINT_RIGHT_PINKY_FINGER_PHALANX_INTERMEDIATE
 		"RightLittleDistal", // XRBodyTracker::JOINT_RIGHT_PINKY_FINGER_PHALANX_DISTAL
 		"RightLittleTip", // XRBodyTracker::JOINT_RIGHT_PINKY_FINGER_TIP
+
+		// Extra Joints.
+		"LowerChest", // XRBodyTracker::JOINT_LOWER_CHEST
+		"LeftScapula", // XRBodyTracker::JOINT_LEFT_SCAPULA
+		"LeftWristTwist", // XRBodyTracker::JOINT_LEFT_WRIST_TWIST
+		"RightScapula", // XRBodyTracker::JOINT_RIGHT_SCAPULA
+		"RightWristTwist", // XRBodyTracker::JOINT_RIGHT_WRIST_TWIST
+		"LeftAnkleTwist", // XRBodyTracker::JOINT_LEFT_ANKLE_TWIST
+		"LeftAnkle", // XRBodyTracker::JOINT_LEFT_ANKLE
+		"LeftMiddleFoot", // XRBodyTracker::JOINT_LEFT_MIDDLE_FOOT
+		"RightAnkleTwist", // XRBodyTracker::JOINT_RIGHT_ANKLE_TWIST
+		"RightAnkle", // XRBodyTracker::JOINT_RIGHT_ANKLE
+		"RightMiddleFoot", // XRBodyTracker::JOINT_RIGHT_MIDDLE_FOOT
 	};
 
 	// reset JIC.

+ 11 - 0
servers/xr/xr_body_tracker.cpp

@@ -126,6 +126,17 @@ void XRBodyTracker::_bind_methods() {
 	BIND_ENUM_CONSTANT(JOINT_RIGHT_PINKY_FINGER_PHALANX_INTERMEDIATE);
 	BIND_ENUM_CONSTANT(JOINT_RIGHT_PINKY_FINGER_PHALANX_DISTAL);
 	BIND_ENUM_CONSTANT(JOINT_RIGHT_PINKY_FINGER_TIP);
+	BIND_ENUM_CONSTANT(JOINT_LOWER_CHEST);
+	BIND_ENUM_CONSTANT(JOINT_LEFT_SCAPULA);
+	BIND_ENUM_CONSTANT(JOINT_LEFT_WRIST_TWIST);
+	BIND_ENUM_CONSTANT(JOINT_RIGHT_SCAPULA);
+	BIND_ENUM_CONSTANT(JOINT_RIGHT_WRIST_TWIST);
+	BIND_ENUM_CONSTANT(JOINT_LEFT_ANKLE_TWIST);
+	BIND_ENUM_CONSTANT(JOINT_LEFT_ANKLE);
+	BIND_ENUM_CONSTANT(JOINT_LEFT_MIDDLE_FOOT);
+	BIND_ENUM_CONSTANT(JOINT_RIGHT_ANKLE_TWIST);
+	BIND_ENUM_CONSTANT(JOINT_RIGHT_ANKLE);
+	BIND_ENUM_CONSTANT(JOINT_RIGHT_MIDDLE_FOOT);
 	BIND_ENUM_CONSTANT(JOINT_MAX);
 
 	BIND_BITFIELD_FLAG(JOINT_FLAG_ORIENTATION_VALID);

+ 13 - 0
servers/xr/xr_body_tracker.h

@@ -129,6 +129,19 @@ public:
 		JOINT_RIGHT_PINKY_FINGER_PHALANX_DISTAL,
 		JOINT_RIGHT_PINKY_FINGER_TIP,
 
+		// Extra joints that aren't part of the Godot humanoid skeleton, but are commonly used in some VR avatars.
+		JOINT_LOWER_CHEST,
+		JOINT_LEFT_SCAPULA,
+		JOINT_LEFT_WRIST_TWIST,
+		JOINT_RIGHT_SCAPULA,
+		JOINT_RIGHT_WRIST_TWIST,
+		JOINT_LEFT_ANKLE_TWIST,
+		JOINT_LEFT_ANKLE,
+		JOINT_LEFT_MIDDLE_FOOT,
+		JOINT_RIGHT_ANKLE_TWIST,
+		JOINT_RIGHT_ANKLE,
+		JOINT_RIGHT_MIDDLE_FOOT,
+
 		JOINT_MAX,
 	};