diff --git a/slime-java-commons b/slime-java-commons index c6d07aecdd..23a977aefe 160000 --- a/slime-java-commons +++ b/slime-java-commons @@ -1 +1 @@ -Subproject commit c6d07aecdd5ff0205d4aeb35e35aeea463274474 +Subproject commit 23a977aefe5315e0ca8d97bd19967e3682b490aa diff --git a/src/main/java/dev/slimevr/autobone/AutoBone.java b/src/main/java/dev/slimevr/autobone/AutoBone.java index ed4b520dad..3166e337fd 100644 --- a/src/main/java/dev/slimevr/autobone/AutoBone.java +++ b/src/main/java/dev/slimevr/autobone/AutoBone.java @@ -194,7 +194,7 @@ public void reloadConfigValues(List trackers) { // Keep "feet" at ankles staticConfigs.put(SkeletonConfigValue.FOOT_LENGTH, 0f); - staticConfigs.put(SkeletonConfigValue.FOOT_OFFSET, 0f); + staticConfigs.put(SkeletonConfigValue.FOOT_SHIFT, 0f); staticConfigs.put(SkeletonConfigValue.SKELETON_OFFSET, 0f); } diff --git a/src/main/java/dev/slimevr/vr/processor/skeleton/BoneType.java b/src/main/java/dev/slimevr/vr/processor/skeleton/BoneType.java index d9b8c934fb..5f742844b4 100644 --- a/src/main/java/dev/slimevr/vr/processor/skeleton/BoneType.java +++ b/src/main/java/dev/slimevr/vr/processor/skeleton/BoneType.java @@ -4,9 +4,7 @@ /** - * Keys for all bones in the skeleton. TODO: Some bones are deprecated because - * they are still used as SkeletonNodeOffset, and represent both left and right - * offsets, but they should be split into two. + * Keys for all bones in the skeleton. */ public enum BoneType { @@ -20,52 +18,29 @@ public enum BoneType { HIP_TRACKER(BodyPart.HIP), LEFT_HIP, RIGHT_HIP, - @Deprecated - UPPER_LEG, LEFT_UPPER_LEG(BodyPart.LEFT_UPPER_LEG), RIGHT_UPPER_LEG(BodyPart.RIGHT_UPPER_LEG), - @Deprecated - KNEE_TRACKER, LEFT_KNEE_TRACKER, RIGHT_KNEE_TRACKER, - @Deprecated - LOWER_LEG, LEFT_LOWER_LEG(BodyPart.LEFT_LOWER_LEG), RIGHT_LOWER_LEG(BodyPart.RIGHT_LOWER_LEG), - @Deprecated - FOOT, LEFT_FOOT(BodyPart.LEFT_FOOT), RIGHT_FOOT(BodyPart.RIGHT_FOOT), - @Deprecated - FOOT_TRACKER, LEFT_FOOT_TRACKER(BodyPart.LEFT_FOOT), RIGHT_FOOT_TRACKER(BodyPart.RIGHT_FOOT), - @Deprecated - CONTROLLER, LEFT_CONTROLLER(BodyPart.LEFT_CONTROLLER), RIGHT_CONTROLLER(BodyPart.RIGHT_CONTROLLER), - @Deprecated - LOWER_ARM, LEFT_LOWER_ARM(BodyPart.LEFT_LOWER_ARM), RIGHT_LOWER_ARM(BodyPart.RIGHT_LOWER_ARM), - @Deprecated - LOWER_ARM_HMD, - @Deprecated - ELBOW_TRACKER, LEFT_ELBOW_TRACKER, RIGHT_ELBOW_TRACKER, - @Deprecated UPPER_ARM, LEFT_UPPER_ARM(BodyPart.LEFT_UPPER_ARM), RIGHT_UPPER_ARM(BodyPart.RIGHT_UPPER_ARM), LEFT_SHOULDER, RIGHT_SHOULDER, - @Deprecated - HAND, LEFT_HAND(BodyPart.LEFT_HAND), RIGHT_HAND(BodyPart.RIGHT_HAND), - @Deprecated - HAND_TRACKER, LEFT_HAND_TRACKER, RIGHT_HAND_TRACKER; diff --git a/src/main/java/dev/slimevr/vr/processor/skeleton/HumanSkeleton.java b/src/main/java/dev/slimevr/vr/processor/skeleton/HumanSkeleton.java index 6ed89003bb..1343d9cfe9 100644 --- a/src/main/java/dev/slimevr/vr/processor/skeleton/HumanSkeleton.java +++ b/src/main/java/dev/slimevr/vr/processor/skeleton/HumanSkeleton.java @@ -120,7 +120,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback { false ); // #endregion - protected final Quaternion kneeRotation = new Quaternion(); // #region Buffers private final Vector3f posBuf = new Vector3f(); private final Quaternion rotBuf1 = new Quaternion(); @@ -129,8 +128,6 @@ public class HumanSkeleton extends Skeleton implements SkeletonConfigCallback { private final Quaternion rotBuf4 = new Quaternion(); protected boolean hasSpineTracker; protected boolean hasKneeTrackers; - protected float minKneePitch = 0f * FastMath.DEG_TO_RAD; - protected float maxKneePitch = 90f * FastMath.DEG_TO_RAD; static final Quaternion FORWARD_QUATERNION = new Quaternion() .fromAngles(FastMath.HALF_PI, 0, 0); static final float FLOOR_OFFSET = 0.05f; @@ -1223,49 +1220,46 @@ public void updateNodeOffset(BoneType nodeOffset, Vector3f offset) { case RIGHT_HIP: rightHipNode.localTransform.setTranslation(offset); break; - case UPPER_LEG: case LEFT_UPPER_LEG: case RIGHT_UPPER_LEG: leftKneeNode.localTransform.setTranslation(offset); rightKneeNode.localTransform.setTranslation(offset); break; - case KNEE_TRACKER: case LEFT_KNEE_TRACKER: case RIGHT_KNEE_TRACKER: trackerLeftKneeNode.localTransform.setTranslation(offset); trackerRightKneeNode.localTransform.setTranslation(offset); break; - case LOWER_LEG: case LEFT_LOWER_LEG: case RIGHT_LOWER_LEG: leftAnkleNode.localTransform.setTranslation(offset); rightAnkleNode.localTransform.setTranslation(offset); break; - case FOOT: case LEFT_FOOT: case RIGHT_FOOT: leftFootNode.localTransform.setTranslation(offset); rightFootNode.localTransform.setTranslation(offset); break; - case FOOT_TRACKER: case LEFT_FOOT_TRACKER: case RIGHT_FOOT_TRACKER: trackerLeftFootNode.localTransform.setTranslation(offset); trackerRightFootNode.localTransform.setTranslation(offset); break; - case CONTROLLER: case LEFT_CONTROLLER: case RIGHT_CONTROLLER: leftWristNodeContrl.localTransform.setTranslation(offset); rightWristNodeContrl.localTransform.setTranslation(offset); break; - case LOWER_ARM: case LEFT_LOWER_ARM: case RIGHT_LOWER_ARM: leftElbowNodeContrl.localTransform.setTranslation(offset); rightElbowNodeContrl.localTransform.setTranslation(offset); + // Dirty hack: from HMD goes the opposite way as from + // controllers, so we negate the offset. + Vector3f negatedOffset = offset.negate(); + leftWristNodeHmd.localTransform.setTranslation(negatedOffset); + rightWristNodeHmd.localTransform.setTranslation(negatedOffset); break; - case ELBOW_TRACKER: case LEFT_ELBOW_TRACKER: case RIGHT_ELBOW_TRACKER: trackerLeftElbowNodeContrl.localTransform.setTranslation(offset); @@ -1279,22 +1273,16 @@ public void updateNodeOffset(BoneType nodeOffset, Vector3f offset) { case RIGHT_SHOULDER: rightShoulderNodeHmd.localTransform.setTranslation(offset); break; - case HAND: case LEFT_HAND: case RIGHT_HAND: leftHandNodeHmd.localTransform.setTranslation(offset); rightHandNodeHmd.localTransform.setTranslation(offset); break; - case UPPER_ARM: case LEFT_UPPER_ARM: case RIGHT_UPPER_ARM: leftElbowNodeHmd.localTransform.setTranslation(offset); rightElbowNodeHmd.localTransform.setTranslation(offset); break; - case LOWER_ARM_HMD: - leftWristNodeHmd.localTransform.setTranslation(offset); - rightWristNodeHmd.localTransform.setTranslation(offset); - break; default: break; } @@ -1349,7 +1337,7 @@ public void updatePoseAffectedByConfig(SkeletonConfigValue config) { rightFootNode.update(); updateComputedTrackers(); break; - case FOOT_OFFSET: + case FOOT_SHIFT: leftAnkleNode.update(); rightAnkleNode.update(); updateComputedTrackers(); @@ -1476,8 +1464,8 @@ public void resetSkeletonConfig(SkeletonConfigValue config) { case FOOT_LENGTH: skeletonConfig.setConfig(SkeletonConfigValue.FOOT_LENGTH, null); break; - case FOOT_OFFSET: - skeletonConfig.setConfig(SkeletonConfigValue.FOOT_OFFSET, null); + case FOOT_SHIFT: + skeletonConfig.setConfig(SkeletonConfigValue.FOOT_SHIFT, null); break; case SKELETON_OFFSET: skeletonConfig.setConfig(SkeletonConfigValue.SKELETON_OFFSET, null); diff --git a/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfig.java b/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfig.java index 8a71fe788a..49ba500f83 100644 --- a/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfig.java +++ b/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfig.java @@ -294,15 +294,14 @@ public void computeNodeOffset(BoneType nodeOffset) { -getConfig(SkeletonConfigValue.SKELETON_OFFSET) ); break; - case LEFT_HIP: setNodeOffset(nodeOffset, -getConfig(SkeletonConfigValue.HIPS_WIDTH) / 2f, 0, 0); break; case RIGHT_HIP: setNodeOffset(nodeOffset, getConfig(SkeletonConfigValue.HIPS_WIDTH) / 2f, 0, 0); break; - - case UPPER_LEG: + case LEFT_UPPER_LEG: + case RIGHT_UPPER_LEG: setNodeOffset( nodeOffset, 0, @@ -311,25 +310,29 @@ public void computeNodeOffset(BoneType nodeOffset) { 0 ); break; - case KNEE_TRACKER: + case LEFT_KNEE_TRACKER: + case RIGHT_KNEE_TRACKER: setNodeOffset(nodeOffset, 0, 0, -getConfig(SkeletonConfigValue.SKELETON_OFFSET)); break; - case LOWER_LEG: + case LEFT_LOWER_LEG: + case RIGHT_LOWER_LEG: setNodeOffset( nodeOffset, 0, -getConfig(SkeletonConfigValue.KNEE_HEIGHT), - -getConfig(SkeletonConfigValue.FOOT_OFFSET) + -getConfig(SkeletonConfigValue.FOOT_SHIFT) ); break; - case FOOT: + case LEFT_FOOT: + case RIGHT_FOOT: setNodeOffset(nodeOffset, 0, 0, -getConfig(SkeletonConfigValue.FOOT_LENGTH)); break; - case FOOT_TRACKER: + case LEFT_FOOT_TRACKER: + case RIGHT_FOOT_TRACKER: setNodeOffset(nodeOffset, 0, 0, -getConfig(SkeletonConfigValue.SKELETON_OFFSET)); break; - - case CONTROLLER: + case LEFT_CONTROLLER: + case RIGHT_CONTROLLER: setNodeOffset( nodeOffset, 0, @@ -337,7 +340,8 @@ public void computeNodeOffset(BoneType nodeOffset) { getConfig(SkeletonConfigValue.CONTROLLER_DISTANCE_Z) ); break; - case HAND: + case LEFT_HAND: + case RIGHT_HAND: setNodeOffset( nodeOffset, 0, @@ -345,16 +349,16 @@ public void computeNodeOffset(BoneType nodeOffset) { -getConfig(SkeletonConfigValue.CONTROLLER_DISTANCE_Z) ); break; - case LOWER_ARM: + case LEFT_LOWER_ARM: + case RIGHT_LOWER_ARM: setNodeOffset(nodeOffset, 0, getConfig(SkeletonConfigValue.LOWER_ARM_LENGTH), 0); break; - case LOWER_ARM_HMD: - setNodeOffset(nodeOffset, 0, -getConfig(SkeletonConfigValue.LOWER_ARM_LENGTH), 0); - break; - case ELBOW_TRACKER: + case LEFT_ELBOW_TRACKER: + case RIGHT_ELBOW_TRACKER: setNodeOffset(nodeOffset, 0, getConfig(SkeletonConfigValue.ELBOW_OFFSET), 0); break; - case UPPER_ARM: + case LEFT_UPPER_ARM: + case RIGHT_UPPER_ARM: setNodeOffset(nodeOffset, 0, -getConfig(SkeletonConfigValue.UPPER_ARM_LENGTH), 0); break; case LEFT_SHOULDER: diff --git a/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfigValue.java b/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfigValue.java index 7090d75baf..3cf6d9a53d 100644 --- a/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfigValue.java +++ b/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonConfigValue.java @@ -68,7 +68,7 @@ public enum SkeletonConfigValue { "legsLength", "Legs length", 0.92f, - new BoneType[] { BoneType.UPPER_LEG } + new BoneType[] { BoneType.LEFT_UPPER_LEG, BoneType.RIGHT_UPPER_LEG } ), KNEE_HEIGHT( 9, @@ -76,7 +76,8 @@ public enum SkeletonConfigValue { "kneeHeight", "Knee height", 0.50f, - new BoneType[] { BoneType.UPPER_LEG, BoneType.LOWER_LEG } + new BoneType[] { BoneType.LEFT_UPPER_LEG, BoneType.RIGHT_UPPER_LEG, + BoneType.LEFT_LOWER_LEG, BoneType.RIGHT_LOWER_LEG } ), FOOT_LENGTH( 10, @@ -84,15 +85,15 @@ public enum SkeletonConfigValue { "footLength", "Foot length", 0.05f, - new BoneType[] { BoneType.FOOT } + new BoneType[] { BoneType.LEFT_FOOT, BoneType.RIGHT_FOOT } ), - FOOT_OFFSET( + FOOT_SHIFT( 11, - "Foot offset", - "footOffset", - "Foot offset", + "Foot shift", + "footShift", + "Foot shift", -0.05f, - new BoneType[] { BoneType.LOWER_LEG } + new BoneType[] { BoneType.LEFT_LOWER_LEG, BoneType.RIGHT_LOWER_LEG } ), SKELETON_OFFSET( 12, @@ -101,32 +102,34 @@ public enum SkeletonConfigValue { "Skeleton offset", 0.0f, new BoneType[] { BoneType.CHEST_TRACKER, BoneType.HIP_TRACKER, - BoneType.KNEE_TRACKER, BoneType.FOOT_TRACKER } + BoneType.LEFT_KNEE_TRACKER, BoneType.RIGHT_KNEE_TRACKER, + BoneType.LEFT_FOOT_TRACKER, BoneType.RIGHT_KNEE_TRACKER } ), CONTROLLER_DISTANCE_Z( 13, "Controller distance z", "controllerDistanceZ", "Controller distance z", - 0.15f, - new BoneType[] { BoneType.CONTROLLER, BoneType.HAND } + 0.13f, + new BoneType[] { BoneType.LEFT_CONTROLLER, BoneType.RIGHT_CONTROLLER, + BoneType.LEFT_HAND, BoneType.RIGHT_HAND } ), CONTROLLER_DISTANCE_Y( 14, "Controller distance y", "controllerDistanceY", "Controller distance y", - 0.05f, - new BoneType[] { BoneType.CONTROLLER, BoneType.HAND } + 0.035f, + new BoneType[] { BoneType.LEFT_CONTROLLER, BoneType.RIGHT_CONTROLLER, + BoneType.LEFT_HAND, BoneType.RIGHT_HAND } ), LOWER_ARM_LENGTH( 15, - "Forearm length", - "forearmLength", - "Forearm length", + "Lower arm length", + "lowerArmLength", + "Lower arm length", 0.25f, - new BoneType[] { BoneType.LOWER_ARM, - BoneType.LOWER_ARM_HMD } + new BoneType[] { BoneType.LEFT_LOWER_ARM, BoneType.RIGHT_LOWER_ARM } ), SHOULDERS_DISTANCE( 16, @@ -134,8 +137,7 @@ public enum SkeletonConfigValue { "shoulersDistance", "Shoulders distance", 0.08f, - new BoneType[] { BoneType.LEFT_SHOULDER, - BoneType.RIGHT_SHOULDER } + new BoneType[] { BoneType.LEFT_SHOULDER, BoneType.RIGHT_SHOULDER } ), SHOULDERS_WIDTH( 17, @@ -143,8 +145,7 @@ public enum SkeletonConfigValue { "shoulersWidth", "Shoulders width", 0.36f, - new BoneType[] { BoneType.LEFT_SHOULDER, - BoneType.RIGHT_SHOULDER } + new BoneType[] { BoneType.LEFT_SHOULDER, BoneType.RIGHT_SHOULDER } ), UPPER_ARM_LENGTH( 18, @@ -152,7 +153,7 @@ public enum SkeletonConfigValue { "upperArmLength", "Upper arm length", 0.25f, - new BoneType[] { BoneType.UPPER_ARM } + new BoneType[] { BoneType.LEFT_UPPER_ARM, BoneType.RIGHT_UPPER_ARM } ), ELBOW_OFFSET( 19, @@ -160,7 +161,7 @@ public enum SkeletonConfigValue { "elbowOffset", "Elbow offset", 0f, - new BoneType[] { BoneType.ELBOW_TRACKER } + new BoneType[] { BoneType.LEFT_ELBOW_TRACKER, BoneType.RIGHT_ELBOW_TRACKER } ),; public static final SkeletonConfigValue[] values = values(); diff --git a/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonData.java b/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonData.java index e58a32e81c..9f30f55d42 100644 --- a/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonData.java +++ b/src/main/java/dev/slimevr/vr/processor/skeleton/SkeletonData.java @@ -85,24 +85,24 @@ public void assembleNodeHierarchy() { hipJoint.attachJoint(leftHipJoint, BoneType.LEFT_HIP); hipJoint.attachJoint(rightHipJoint, BoneType.RIGHT_HIP); - leftHipJoint.attachJoint(leftKneeJoint, BoneType.UPPER_LEG); - rightHipJoint.attachJoint(rightKneeJoint, BoneType.UPPER_LEG); + leftHipJoint.attachJoint(leftKneeJoint, BoneType.LEFT_UPPER_LEG); + rightHipJoint.attachJoint(rightKneeJoint, BoneType.RIGHT_UPPER_LEG); - leftKneeJoint.attachJoint(leftAnkleJoint, BoneType.LOWER_LEG); - rightKneeJoint.attachJoint(rightAnkleJoint, BoneType.LOWER_LEG); + leftKneeJoint.attachJoint(leftAnkleJoint, BoneType.LEFT_LOWER_LEG); + rightKneeJoint.attachJoint(rightAnkleJoint, BoneType.RIGHT_LOWER_LEG); - leftAnkleJoint.attachJoint(leftFootJoint, BoneType.FOOT); - rightAnkleJoint.attachJoint(rightFootJoint, BoneType.FOOT); + leftAnkleJoint.attachJoint(leftFootJoint, BoneType.LEFT_FOOT); + rightAnkleJoint.attachJoint(rightFootJoint, BoneType.RIGHT_FOOT); // #endregion // #region Assemble skeleton arms from controllers // TODO : Rebuild skeleton depending on if it's from controllers or from // shoulders // if (fromControllers) - leftHandJoint.attachJoint(leftWristJoint, BoneType.HAND); - rightHandJoint.attachJoint(rightWristJoint, BoneType.HAND); - rightWristJoint.attachJoint(leftElbowJoint, BoneType.LOWER_ARM); - leftWristJoint.attachJoint(rightElbowJoint, BoneType.LOWER_ARM); + leftHandJoint.attachJoint(leftWristJoint, BoneType.LEFT_HAND); + rightHandJoint.attachJoint(rightWristJoint, BoneType.RIGHT_HAND); + rightWristJoint.attachJoint(leftElbowJoint, BoneType.LEFT_LOWER_ARM); + leftWristJoint.attachJoint(rightElbowJoint, BoneType.RIGHT_LOWER_ARM); // } else { // #endregion @@ -110,14 +110,14 @@ public void assembleNodeHierarchy() { chestJoint.attachJoint(leftShoulderJoint, BoneType.LEFT_SHOULDER); chestJoint.attachJoint(rightShoulderJoint, BoneType.RIGHT_SHOULDER); - leftShoulderJoint.attachJoint(leftElbowJoint, BoneType.LOWER_ARM); - rightShoulderJoint.attachJoint(rightElbowJoint, BoneType.LOWER_ARM); + leftShoulderJoint.attachJoint(leftElbowJoint, BoneType.LEFT_LOWER_ARM); + rightShoulderJoint.attachJoint(rightElbowJoint, BoneType.RIGHT_LOWER_ARM); - leftElbowJoint.attachJoint(leftWristJoint, BoneType.HAND); - rightElbowJoint.attachJoint(rightWristJoint, BoneType.HAND); + leftElbowJoint.attachJoint(leftWristJoint, BoneType.LEFT_HAND); + rightElbowJoint.attachJoint(rightWristJoint, BoneType.RIGHT_HAND); - leftWristJoint.attachJoint(leftHandJoint, BoneType.HAND); - rightWristJoint.attachJoint(rightHandJoint, BoneType.HAND); + leftWristJoint.attachJoint(leftHandJoint, BoneType.LEFT_HAND); + rightWristJoint.attachJoint(rightHandJoint, BoneType.RIGHT_HAND); // } // #endregion @@ -125,17 +125,17 @@ public void assembleNodeHierarchy() { chestJoint.attachJoint(trackerChestJoint, BoneType.CHEST_TRACKER); hipJoint.attachJoint(trackerWaistJoint, BoneType.WAIST_TRACKER); - leftKneeJoint.attachJoint(trackerLeftKneeJoint, BoneType.KNEE_TRACKER); - rightKneeJoint.attachJoint(trackerRightKneeJoint, BoneType.KNEE_TRACKER); + leftKneeJoint.attachJoint(trackerLeftKneeJoint, BoneType.LEFT_KNEE_TRACKER); + rightKneeJoint.attachJoint(trackerRightKneeJoint, BoneType.RIGHT_KNEE_TRACKER); - leftFootJoint.attachJoint(trackerLeftFootJoint, BoneType.FOOT_TRACKER); - rightFootJoint.attachJoint(trackerRightFootJoint, BoneType.FOOT_TRACKER); + leftFootJoint.attachJoint(trackerLeftFootJoint, BoneType.LEFT_FOOT_TRACKER); + rightFootJoint.attachJoint(trackerRightFootJoint, BoneType.RIGHT_FOOT_TRACKER); - leftElbowJoint.attachJoint(trackerLeftElbowJoint, BoneType.ELBOW_TRACKER); - rightElbowJoint.attachJoint(trackerRightElbowJoint, BoneType.ELBOW_TRACKER); + leftElbowJoint.attachJoint(trackerLeftElbowJoint, BoneType.LEFT_ELBOW_TRACKER); + rightElbowJoint.attachJoint(trackerRightElbowJoint, BoneType.RIGHT_ELBOW_TRACKER); - leftHandJoint.attachJoint(trackerLeftHandJoint, BoneType.HAND_TRACKER); - rightHandJoint.attachJoint(trackerRightHandJoint, BoneType.HAND_TRACKER); + leftHandJoint.attachJoint(trackerLeftHandJoint, BoneType.LEFT_HAND_TRACKER); + rightHandJoint.attachJoint(trackerRightHandJoint, BoneType.RIGHT_HAND_TRACKER); // #endregion }