Elbow: read the hand-suggested angle nearest the current one (fixes side-switching when pointing the controller down: 45 -> 0 switches); point-down spike phase
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7bc6a866eb
commit
3f912367ff
2 files changed
+30
-3
No files matched your search
+22
-2
@@ -53,6 +53,8 @@ public partial class ArmSpike : Node3D
|
||||
private float _maxElbowStep;
|
||||
private Vector3 _lastElbow;
|
||||
private float _maxPinHandLag;
|
||||
private float _downSide;
|
||||
private int _downSideSwitches;
|
||||
private float _restBodyPen;
|
||||
private float _restDrawnPen;
|
||||
private float _restAnvilMove;
|
||||
@@ -178,13 +180,31 @@ public partial class ArmSpike : Node3D
|
||||
Vector3 axis = (handPos - _arms.Shoulder(1)).Normalized();
|
||||
Vector3 perp = axis.Cross(Vector3.Up).Normalized();
|
||||
Vector3 fwd = (axis * Mathf.Cos(1.22f) + perp.Rotated(axis, Mathf.Tau * _phaseT) * Mathf.Sin(1.22f)).Normalized();
|
||||
_handTarget[1] = new Transform3D(Basis.LookingAt(fwd, Mathf.Abs(fwd.Y) > 0.95f ? Vector3.Forward : Vector3.Up), handPos);
|
||||
if (_phaseT <= 3.5f)
|
||||
_handTarget[1] = new Transform3D(Basis.LookingAt(fwd, Mathf.Abs(fwd.Y) > 0.95f ? Vector3.Forward : Vector3.Up), handPos);
|
||||
Vector3 elbow = _arms.ElbowTarget(1);
|
||||
if (_phaseT > 0.5f)
|
||||
_maxElbowStep = Mathf.Max(_maxElbowStep, elbow.DistanceTo(_lastElbow));
|
||||
_lastElbow = elbow;
|
||||
if (_phaseT > 3.5f)
|
||||
if (_phaseT > 3.5f && _phaseT <= 5.5f)
|
||||
{
|
||||
// Controller pointing straight down with tracker-like wobble: the elbow
|
||||
// must stay on one side.
|
||||
Vector3 wobble = new Vector3(Mathf.Sin(5f * _phaseT), 0f, Mathf.Cos(3.7f * _phaseT)) * 0.5f;
|
||||
Vector3 down = (Vector3.Down + wobble).Normalized();
|
||||
_handTarget[1] = new Transform3D(Basis.LookingAt(down, Vector3.Forward), handPos);
|
||||
float sideNow = Mathf.Sign((_arms.ElbowTarget(1) - _arms.Shoulder(1)).Dot(_torso.Body.GlobalTransform.Basis.X));
|
||||
if (_phaseT > 4f)
|
||||
{
|
||||
if (_downSide == 0f)
|
||||
_downSide = sideNow;
|
||||
else if (sideNow != _downSide)
|
||||
_downSideSwitches++;
|
||||
}
|
||||
}
|
||||
if (_phaseT > 5.5f)
|
||||
{
|
||||
Record($"point-down: elbow keeps its side under wobble (switches {_downSideSwitches})", _downSideSwitches == 0);
|
||||
Record($"flip: elbow never jumps (max step {_maxElbowStep:F4} m/tick, limit {FlipElbowStepLimit})", _maxElbowStep < FlipElbowStepLimit);
|
||||
_handTarget[1] = new Transform3D(Basis.Identity, _handRest[1]);
|
||||
_maxHoldPenetration = 0f;
|
||||
|
||||
Reference in new issue
Block a user