From baccb556e86faa4a59ddc47e180311fa90d1a132 Mon Sep 17 00:00:00 2001 From: Louka Date: Mon, 29 Nov 2021 20:08:08 -0500 Subject: [PATCH] autobone hip-only doesn't affect waist distance anymore - Now autobone checks if user has BOTH waist and hip tracker to add the waist distance value. - Also renamed certain variable, replacing "hip" by "torso" --- src/main/java/dev/slimevr/autobone/AutoBone.java | 10 +++++----- src/main/java/dev/slimevr/autobone/SimpleSkeleton.java | 10 +++++----- src/main/java/dev/slimevr/bridge/ProtobufMessages.java | 2 +- src/main/java/dev/slimevr/gui/AutoBoneWindow.java | 10 +++++----- .../io/eiren/vr/processor/HumanSkeletonWithLegs.java | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/dev/slimevr/autobone/AutoBone.java b/src/main/java/dev/slimevr/autobone/AutoBone.java index 11e598e16..2b2f0d9fd 100644 --- a/src/main/java/dev/slimevr/autobone/AutoBone.java +++ b/src/main/java/dev/slimevr/autobone/AutoBone.java @@ -62,7 +62,7 @@ public class AutoBone { // Assume these to be approximately half public float kneeLegRatio = 0.5f; - public float chestHipRatio = 0.5f; + public float chestTorsoRatio = 0.5f; protected final VRServer server; @@ -99,8 +99,8 @@ public class AutoBone { configs.remove("Chest"); staticConfigs.put("Chest", server.config.getFloat("body.chestDistance", 0.35f)); } - if(server.config.getBoolean("autobone.forceHipTracker", false) || (frame != null && TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.HIP) != null) || TrackerUtils.findTrackerForBodyPosition(server.getAllTrackers(), TrackerPosition.HIP) != null) { - // If force enabled or has a hip tracker + if(server.config.getBoolean("autobone.forceHipTracker", false) || (frame != null && TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.HIP) != null && TrackerUtils.findTrackerForBodyPosition(frame, TrackerPosition.WAIST) != null) || (TrackerUtils.findTrackerForBodyPosition(server.getAllTrackers(), TrackerPosition.HIP) != null && TrackerUtils.findTrackerForBodyPosition(server.getAllTrackers(), TrackerPosition.WAIST) != null)) { + // If force enabled or has a hip tracker and waist tracker configs.put("Waist", server.config.getFloat("body.waistDistance", 0.1f)); } else { // Otherwise, make sure it's not used @@ -404,7 +404,7 @@ public class AutoBone { Float legsLength = skeleton.getSkeletonConfig("Legs length"); Float kneeHeight = skeleton.getSkeletonConfig("Knee height"); - float chestHip = chestLength != null && torsoLength != null ? Math.abs((chestLength / torsoLength) - chestHipRatio) : 0f; + float chestTorso = chestLength != null && torsoLength != null ? Math.abs((chestLength / torsoLength) - chestTorsoRatio) : 0f; float legBody = legsLength != null && torsoLength != null && neckLength != null ? Math.abs((legsLength / (torsoLength + neckLength)) - legBodyRatio) : 0f; float kneeLeg = kneeHeight != null && legsLength != null ? Math.abs((kneeHeight / legsLength) - kneeLegRatio) : 0f; @@ -414,7 +414,7 @@ public class AutoBone { legBody -= legBodyRatioRange; } - return (chestHip + legBody + kneeLeg) / 3f; + return (chestTorso + legBody + kneeLeg) / 3f; } // The distance of any points to the corresponding absolute position diff --git a/src/main/java/dev/slimevr/autobone/SimpleSkeleton.java b/src/main/java/dev/slimevr/autobone/SimpleSkeleton.java index d304ce961..3ff1c3706 100644 --- a/src/main/java/dev/slimevr/autobone/SimpleSkeleton.java +++ b/src/main/java/dev/slimevr/autobone/SimpleSkeleton.java @@ -17,7 +17,7 @@ import io.eiren.yaml.YamlFile; public class SimpleSkeleton { - // Waist + // Upper body (torso) protected final TransformNode hmdNode = new TransformNode("HMD", false); protected final TransformNode headNode = new TransformNode("Head", false); protected final TransformNode neckNode = new TransformNode("Neck", false); @@ -46,7 +46,7 @@ public class SimpleSkeleton { */ protected float headShift = HumanSkeletonWithWaist.HEAD_SHIFT_DEFAULT; - // Legs + // Lower body (legs) protected final TransformNode leftHipNode = new TransformNode("Left-Hip", false); protected final TransformNode leftKneeNode = new TransformNode("Left-Knee", false); protected final TransformNode leftAnkleNode = new TransformNode("Left-Ankle", false); @@ -59,11 +59,11 @@ public class SimpleSkeleton { */ protected float hipsWidth = HumanSkeletonWithLegs.HIPS_WIDTH_DEFAULT; /** - * Length from waist to knees + * Length from hip to knees */ protected float kneeHeight = 0.42f; /** - * Distance from waist to ankle + * Distance from hip to ankle */ protected float legsLength = 0.84f; @@ -73,7 +73,7 @@ public class SimpleSkeleton { private Quaternion rotBuf2 = new Quaternion(); public SimpleSkeleton() { - // Assemble skeleton to waist + // Assemble skeleton to hip hmdNode.attachChild(headNode); headNode.localTransform.setTranslation(0, 0, headShift); diff --git a/src/main/java/dev/slimevr/bridge/ProtobufMessages.java b/src/main/java/dev/slimevr/bridge/ProtobufMessages.java index bcc2d7974..21322bda1 100644 --- a/src/main/java/dev/slimevr/bridge/ProtobufMessages.java +++ b/src/main/java/dev/slimevr/bridge/ProtobufMessages.java @@ -2506,7 +2506,7 @@ public final class ProtobufMessages { } private com.google.protobuf.MapField internalGetMutableActionArguments() { - onChanged();; + onChanged(); if (actionArguments_ == null) { actionArguments_ = com.google.protobuf.MapField.newMapField( ActionArgumentsDefaultEntryHolder.defaultEntry); diff --git a/src/main/java/dev/slimevr/gui/AutoBoneWindow.java b/src/main/java/dev/slimevr/gui/AutoBoneWindow.java index 8a944aa0f..c2f1cfd84 100644 --- a/src/main/java/dev/slimevr/gui/AutoBoneWindow.java +++ b/src/main/java/dev/slimevr/gui/AutoBoneWindow.java @@ -346,14 +346,14 @@ public class AutoBoneWindow extends JFrame { Float legsLength = autoBone.getConfig("Legs length"); Float kneeHeight = autoBone.getConfig("Knee height"); - float neckHip = neckLength != null && torsoLength != null ? neckLength / torsoLength : 0f; - float chestHip = chestDistance != null && torsoLength != null ? chestDistance / torsoLength : 0f; - float hipWaist = hipWidth != null && torsoLength != null ? hipWidth / torsoLength : 0f; - float legWaist = legsLength != null && torsoLength != null ? legsLength / torsoLength : 0f; + float neckTorso = neckLength != null && torsoLength != null ? neckLength / torsoLength : 0f; + float chestTorso = chestDistance != null && torsoLength != null ? chestDistance / torsoLength : 0f; + float torsoWaist = hipWidth != null && torsoLength != null ? hipWidth / torsoLength : 0f; + float legTorso = legsLength != null && torsoLength != null ? legsLength / torsoLength : 0f; float legBody = legsLength != null && torsoLength != null && neckLength != null ? legsLength / (torsoLength + neckLength) : 0f; float kneeLeg = kneeHeight != null && legsLength != null ? kneeHeight / legsLength : 0f; - LogManager.log.info("[AutoBone] Ratios: [{Neck-Hip: " + StringUtils.prettyNumber(neckHip) + "}, {Chest-Hip: " + StringUtils.prettyNumber(chestHip) + "}, {Hip-Waist: " + StringUtils.prettyNumber(hipWaist) + "}, {Leg-Hip: " + StringUtils.prettyNumber(legWaist) + "}, {Leg-Body: " + StringUtils.prettyNumber(legBody) + "}, {Knee-Leg: " + StringUtils.prettyNumber(kneeLeg) + "}]"); + LogManager.log.info("[AutoBone] Ratios: [{Neck-Torso: " + StringUtils.prettyNumber(neckTorso) + "}, {Chest-Torso: " + StringUtils.prettyNumber(chestTorso) + "}, {Torso-Waist: " + StringUtils.prettyNumber(torsoWaist) + "}, {Leg-Torso: " + StringUtils.prettyNumber(legTorso) + "}, {Leg-Body: " + StringUtils.prettyNumber(legBody) + "}, {Knee-Leg: " + StringUtils.prettyNumber(kneeLeg) + "}]"); String lengthsString = getLengthsString(); LogManager.log.info("[AutoBone] Length values: " + lengthsString); diff --git a/src/main/java/io/eiren/vr/processor/HumanSkeletonWithLegs.java b/src/main/java/io/eiren/vr/processor/HumanSkeletonWithLegs.java index e6ecd0674..bb94545aa 100644 --- a/src/main/java/io/eiren/vr/processor/HumanSkeletonWithLegs.java +++ b/src/main/java/io/eiren/vr/processor/HumanSkeletonWithLegs.java @@ -51,11 +51,11 @@ public class HumanSkeletonWithLegs extends HumanSkeletonWithWaist { */ protected float hipsWidth = HIPS_WIDTH_DEFAULT; /** - * Length from waist to knees + * Length from hip to knees */ protected float kneeHeight = 0.42f; /** - * Distance from waist to ankle + * Distance from hip to ankle */ protected float legsLength = 0.84f; protected float footLength = FOOT_LENGTH_DEFAULT;