Disable leg tweaks on proportions (#627)

This commit is contained in:
Collin Kees authored and GitHub committed 2023-03-26 00:41:10 +03:00
1 parent 56d47996f0
commit ab425f41cd
8 files changed
+160 -26

No files matched your search

@@ -78,6 +78,10 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader>
registerPacketListener(RpcMessage.ServerInfosRequest, this::onServerInfosRequest);
registerPacketListener(RpcMessage.LegTweaksTmpChange, this::onLegTweaksTmpChange);
registerPacketListener(RpcMessage.LegTweaksTmpClear, this::onLegTweaksTmpClear);
this.api.server.getAutoBoneHandler().addListener(this);
}
@@ -259,6 +263,43 @@ public class RPCHandler extends ProtocolHandler<RpcMessageHeader>
this.api.server.clearTrackersDriftCompensation();
}
public void onLegTweaksTmpChange(
GenericConnection conn,
RpcMessageHeader messageHeader
) {
LegTweaksTmpChange req = (LegTweaksTmpChange) messageHeader
.message(new LegTweaksTmpChange());
if (req == null)
return;
this.api.server.humanPoseManager
.setLegTweaksStateTemp(
req.skatingCorrection(),
req.floorClip(),
req.toeSnap(),
req.footPlant()
);
}
public void onLegTweaksTmpClear(
GenericConnection conn,
RpcMessageHeader messageHeader
) {
LegTweaksTmpClear req = (LegTweaksTmpClear) messageHeader
.message(new LegTweaksTmpClear());
if (req == null)
return;
this.api.server.humanPoseManager
.clearLegTweaksStateTemp(
req.skatingCorrection(),
req.floorClip(),
req.toeSnap(),
req.footPlant()
);
}
@Override
public void onMessage(GenericConnection conn, RpcMessageHeader message) {
BiConsumer<GenericConnection, RpcMessageHeader> consumer = this.handlers[message
@@ -601,6 +601,26 @@ public class HumanPoseManager {
}
}
public void setLegTweaksStateTemp(
boolean skatingCorrection,
boolean floorClip,
boolean toeSnap,
boolean footPlant
) {
if (isSkeletonPresent())
skeleton.setLegTweaksStateTemp(skatingCorrection, floorClip, toeSnap, footPlant);
}
public void clearLegTweaksStateTemp(
boolean skatingCorrection,
boolean floorClip,
boolean toeSnap,
boolean footPlant
) {
if (isSkeletonPresent())
skeleton.clearLegTweaksStateTemp(skatingCorrection, floorClip, toeSnap, footPlant);
}
public void updateTapDetectionConfig() {
if (isSkeletonPresent())
skeleton.updateTapDetectionConfig();
@@ -1240,8 +1240,8 @@ public class HumanSkeleton {
case SKATING_CORRECTION -> legTweaks.setSkatingReductionEnabled(newValue);
case FLOOR_CLIP -> legTweaks.setFloorclipEnabled(newValue);
case VIVE_EMULATION -> viveEmulation.setEnabled(newValue);
case TOE_SNAP -> legTweaks.setToeSnap(newValue);
case FOOT_PLANT -> legTweaks.setFootPlant(newValue);
case TOE_SNAP -> legTweaks.setToeSnapEnabled(newValue);
case FOOT_PLANT -> legTweaks.setFootPlantEnabled(newValue);
}
}
@@ -1710,10 +1710,50 @@ public class HumanSkeleton {
legTweaks.updateConfig();
}
// does not save to config
public void setLegTweaksStateTemp(
boolean skatingCorrection,
boolean floorClip,
boolean toeSnap,
boolean footPlant
) {
this.legTweaks.setSkatingReductionEnabled(skatingCorrection);
this.legTweaks.setFloorclipEnabled(floorClip);
this.legTweaks.setToeSnapEnabled(toeSnap);
this.legTweaks.setFootPlantEnabled(footPlant);
}
// resets to config values
public void clearLegTweaksStateTemp(
boolean skatingCorrection,
boolean floorClip,
boolean toeSnap,
boolean footPlant
) {
// only reset the true values as they are a mask for what to reset
if (skatingCorrection)
this.legTweaks
.setSkatingReductionEnabled(
humanPoseManager.getToggle(SkeletonConfigToggles.SKATING_CORRECTION)
);
if (floorClip)
this.legTweaks
.setFloorclipEnabled(humanPoseManager.getToggle(SkeletonConfigToggles.FLOOR_CLIP));
if (toeSnap)
this.legTweaks
.setToeSnapEnabled(humanPoseManager.getToggle(SkeletonConfigToggles.TOE_SNAP));
if (footPlant)
this.legTweaks
.setFootPlantEnabled(humanPoseManager.getToggle(SkeletonConfigToggles.FOOT_PLANT));
}
public boolean[] getLegTweaksState() {
boolean[] state = new boolean[2];
boolean[] state = new boolean[4];
state[0] = this.legTweaks.getFloorclipEnabled();
state[1] = this.legTweaks.getSkatingReductionEnabled();
state[2] = this.legTweaks.getToeSnapEnabled();
state[3] = this.legTweaks.getFootPlantEnabled();
return state;
}
@@ -77,8 +77,8 @@ public class LegTweaks {
private boolean enabled = true; // master switch
private boolean floorclipEnabled = false;
private boolean skatingCorrectionEnabled = false;
private boolean toeSnap = false;
private boolean footPlant = false;
private boolean toeSnapEnabled = false;
private boolean footPlantEnabled = false;
private boolean active = false;
private boolean rightLegActive = false;
private boolean leftLegActive = false;
@@ -213,12 +213,12 @@ public class LegTweaks {
this.bufferInvalid = true;
}
public void setToeSnap(boolean val) {
this.toeSnap = val;
public void setToeSnapEnabled(boolean val) {
this.toeSnapEnabled = val;
}
public void setFootPlant(boolean val) {
this.footPlant = val;
public void setFootPlantEnabled(boolean val) {
this.footPlantEnabled = val;
}
public boolean getEnabled() {
@@ -233,12 +233,12 @@ public class LegTweaks {
return this.skatingCorrectionEnabled;
}
public boolean getToeSnap() {
return this.toeSnap;
public boolean getToeSnapEnabled() {
return this.toeSnapEnabled;
}
public boolean getFootPlant() {
return this.footPlant;
public boolean getFootPlantEnabled() {
return this.footPlantEnabled;
}
public void resetBuffer() {
@@ -256,8 +256,8 @@ public class LegTweaks {
floorclipEnabled = skeleton.humanPoseManager.getToggle(SkeletonConfigToggles.FLOOR_CLIP);
skatingCorrectionEnabled = skeleton.humanPoseManager
.getToggle(SkeletonConfigToggles.SKATING_CORRECTION);
toeSnap = skeleton.humanPoseManager.getToggle(SkeletonConfigToggles.TOE_SNAP);
footPlant = skeleton.humanPoseManager.getToggle(SkeletonConfigToggles.FOOT_PLANT);
toeSnapEnabled = skeleton.humanPoseManager.getToggle(SkeletonConfigToggles.TOE_SNAP);
footPlantEnabled = skeleton.humanPoseManager.getToggle(SkeletonConfigToggles.FOOT_PLANT);
}
// update the hyperparameters with the config
@@ -344,8 +344,10 @@ public class LegTweaks {
footLength = skeleton.leftFootNode.localTransform.getTranslation().length();
// if not enabled, do nothing and return false
if (!enabled)
if (!enabled) {
bufferInvalid = true;
return false;
}
// if the user is standing start checking for a good time to enable leg
// tweaks
@@ -778,7 +780,7 @@ public class LegTweaks {
float masterWeightR = getMasterWeight(kneeAngleR);
// corrects rotations when planted firmly on the ground
if (footPlant) {
if (footPlantEnabled) {
// prepare the weight vars for this correction step
float weightL = 0.0f;
float weightR = 0.0f;
@@ -812,7 +814,7 @@ public class LegTweaks {
// corrects rotations when the foot is in the air by rotating the foot
// down so that the toes are touching
if (toeSnap) {
if (toeSnapEnabled) {
// this correction step has its own weight vars
float weightL = 0.0f;
float weightR = 0.0f;