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
@@ -331,7 +331,14 @@ public partial class PhysicsArms : Node
|
||||
handElbow -= dir * handElbow.Dot(dir);
|
||||
float confidence = Mathf.Clamp(handElbow.Length() / (0.5f * radius + 1e-4f), 0f, 1f);
|
||||
if (handElbow.LengthSquared() > 1e-8f)
|
||||
targetAngle = Mathf.Atan2(handElbow.Dot(refB), handElbow.Dot(refN)) * PoleHandWeight * confidence;
|
||||
{
|
||||
// Read the suggestion as the representation NEAREST the current elbow angle:
|
||||
// pointing the controller down puts it at the ±180° seam, where jitter would
|
||||
// otherwise flip the clamped elbow to the other side.
|
||||
float raw = Mathf.Atan2(handElbow.Dot(refB), handElbow.Dot(refN));
|
||||
raw = _poleAngle[index] + Mathf.Wrap(raw - _poleAngle[index], -Mathf.Pi, Mathf.Pi);
|
||||
targetAngle = raw * PoleHandWeight * confidence;
|
||||
}
|
||||
}
|
||||
targetAngle = Mathf.Clamp(targetAngle, -PoleMaxAngle, PoleMaxAngle);
|
||||
float step = (targetAngle - _poleAngle[index]) * (1f - Mathf.Exp(-delta * PoleSmoothRate));
|
||||
|
||||
Reference in new issue
Block a user