Skip to content

Commit d4b499e

Browse files
committed
working on more IK arm changes
1 parent 6b670cc commit d4b499e

3 files changed

Lines changed: 2 additions & 100 deletions

File tree

Basis/Packages/com.basis.framework/Avatar/BasisAvatarIKStageCalibration.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,6 @@ public static void ComputeHints(Dictionary<BasisBoneTrackedRole, Transform> stor
12071207

12081208
// Choose push magnitudes (tweakable)
12091209
float hs = BasisHeightDriver.ScaledToMatchValue;
1210-
1211-
float elbowPush = 0.12f * hs;
12121210
float kneePush = 0.10f * hs;
12131211
float headPush = 0.08f * hs;
12141212

@@ -1226,24 +1224,6 @@ public static void ComputeHints(Dictionary<BasisBoneTrackedRole, Transform> stor
12261224

12271225
BasisHintBiasStore.Set(BasisBoneTrackedRole.Chest, localOffset);
12281226
}
1229-
1230-
// Elbow hints (lower arms)
1231-
{
1232-
{
1233-
var lla = BasisLocalBoneDriver.LeftLowerArmControl;
1234-
Quaternion trackerRot = lla.OutgoingWorldData.rotation;
1235-
Vector3 localOffset = ComputeHintBiasLocal(trackerRot, chestRefRot, isLeft: true, distanceMeters: elbowPush, outWeight: 0.85f, upWeight: 0.35f, fwdWeight: 0.15f);
1236-
localOffset = Vector3.ClampMagnitude(localOffset, maxPush);
1237-
BasisHintBiasStore.Set(BasisBoneTrackedRole.LeftLowerArm, localOffset);
1238-
}
1239-
{
1240-
var rla = BasisLocalBoneDriver.RightLowerArmControl;
1241-
Quaternion trackerRot = rla.OutgoingWorldData.rotation;
1242-
Vector3 localOffset = ComputeHintBiasLocal(trackerRot, chestRefRot, isLeft: false, distanceMeters: elbowPush, outWeight: 0.85f, upWeight: 0.35f, fwdWeight: 0.15f);
1243-
localOffset = Vector3.ClampMagnitude(localOffset, maxPush);
1244-
BasisHintBiasStore.Set(BasisBoneTrackedRole.RightLowerArm, localOffset);
1245-
}
1246-
}
12471227
// Knee hints (lower legs) — often better with a touch of forward
12481228
{
12491229
var lll = BasisLocalBoneDriver.LeftLowerLegControl;

Basis/Packages/com.basis.framework/Drivers/Local/BasisLocalRigDriver.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,11 @@ public void SimulateIKDestinations(float deltaTime)
621621
// ── LOWER ARMS (elbow hints) ──
622622
llaPos = pOut[S_LeftLowerArm];
623623
llaRot = rOut[S_LeftLowerArm];
624-
llaPos = ApplyHintBias(BasisBoneTrackedRole.LeftLowerArm, llaPos, llaRot);
625624
data.LeftLowerArmPosition = llaPos;
626625
data.LeftLowerArmRotation = llaRot;
627626

628627
rlaPos = pOut[S_RightLowerArm];
629628
rlaRot = rOut[S_RightLowerArm];
630-
rlaPos = ApplyHintBias(BasisBoneTrackedRole.RightLowerArm, rlaPos, rlaRot);
631629
data.RightLowerArmPosition = rlaPos;
632630
data.RightLowerArmRotation = rlaRot;
633631

@@ -646,12 +644,6 @@ public void SimulateIKDestinations(float deltaTime)
646644
Vector3 fwdC = chestRot * Vector3.forward;
647645
Vector3 outC = chestRot * Vector3.right;
648646
Vector3 upC = chestRot * Vector3.up;
649-
data.ElbowBendPrefLeft = (fwdC * elbowBendPrefLeftWeights.x
650-
+ outC * elbowBendPrefLeftWeights.y
651-
+ upC * elbowBendPrefLeftWeights.z).normalized;
652-
data.ElbowBendPrefRight = (fwdC * elbowBendPrefRightWeights.x
653-
+ outC * elbowBendPrefRightWeights.y
654-
+ upC * elbowBendPrefRightWeights.z).normalized;
655647

656648
Vector3 fwd = hipsRot * Vector3.forward;
657649
Vector3 outR = hipsRot * Vector3.right;
@@ -671,8 +663,6 @@ public void SimulateIKDestinations(float deltaTime)
671663
Builder.SyncLayers();
672664
PlayableGraph.Evaluate(deltaTime);
673665
}
674-
[SerializeField] private Vector3 elbowBendPrefLeftWeights = new Vector3(0, 1, 0);
675-
[SerializeField] private Vector3 elbowBendPrefRightWeights = new Vector3(0, 1, 0);
676666
[SerializeField] private Vector3 spineBendNormalWeights = new Vector3(1f, 0f, 0f);
677667
public static Vector3 ApplyHintBias(BasisBoneTrackedRole hintRole, Vector3 rawPos, Quaternion rawRot)
678668
{

Basis/Packages/com.basis.framework/IK/BasisFullBodyIK.cs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,6 @@ public bool
249249
[SyncSceneToStream, SerializeField] public Vector3 SpineBendNormal;
250250
[SyncSceneToStream, SerializeField] public Vector3 PlayerUp;
251251

252-
[SyncSceneToStream, SerializeField] public Vector3 ElbowBendPrefLeft;
253-
[SyncSceneToStream, SerializeField] public Vector3 ElbowBendPrefRight;
254-
255252
[SyncSceneToStream, SerializeField] public Vector3 KneeBendPrefLeft;
256253
[SyncSceneToStream, SerializeField] public Vector3 KneeBendPrefRight;
257254

@@ -416,8 +413,6 @@ public bool
416413
public string PlayerUpProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(PlayerUp));
417414
public string KneeBendPrefLeftProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(KneeBendPrefLeft));
418415
public string KneeBendPrefRightProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(KneeBendPrefRight));
419-
public string ElbowBendPrefLeftProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(ElbowBendPrefLeft));
420-
public string ElbowBendPrefRightProperty => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(ElbowBendPrefRight));
421416
public string EnabledPropertyLeftLowerLeg => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_LeftLowerLegEnabled));
422417
public string HintWeightBoolPropertyLeftLowerLeg => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(m_HintLeftLowerLegEnabled));
423418
public string TargetPositionPropertyLeftLowerLeg => ConstraintsUtils.ConstructConstraintDataPropertyName(nameof(LeftFootPosition));
@@ -920,7 +915,7 @@ public struct BasisFullIKConstraintJob : IWeightedAnimationJob
920915
HandleLeftUpperArmTwist, HandleLeftLowerArmTwist,
921916
HandleRightUpperArmTwist, HandleRightLowerArmTwist;
922917

923-
public Vector3Property targetPositionHead, TargetChestPosition, bendNormalHead, playerUp, KneeBendPrefLeft, KneeBendPrefRight, ElbowBendPrefLeft, ElbowBendPrefRight,
918+
public Vector3Property targetPositionHead, TargetChestPosition, bendNormalHead, playerUp, KneeBendPrefLeft, KneeBendPrefRight,
924919
targetPositionLeftLowerLeg, hintPositionLeftLowerLeg,
925920
targetPositionRightLowerLeg, hintPositionRightLowerLeg,
926921
targetPositionHips,
@@ -2640,10 +2635,6 @@ public void SolveLegs(AnimationStream stream, FloatProperty enabledProp, ReadWri
26402635
{
26412636
return;
26422637
}
2643-
2644-
// Save the pre-solve (animation) transforms so we can blend back toward them.
2645-
// Reading tip/mid/root positions BEFORE the solve gives us the true animation pose,
2646-
// not a stale IK-modified pose from a previous frame.
26472638
Vector3 origRootPos = root.GetPosition(stream);
26482639
Quaternion origRootRot = root.GetRotation(stream);
26492640
Quaternion origMidRot = mid.GetRotation(stream);
@@ -2660,9 +2651,6 @@ public void SolveLegs(AnimationStream stream, FloatProperty enabledProp, ReadWri
26602651
Vector3 bendNormal = bendNormalProp.Get(stream);
26612652

26622653
SolveTwoBone(stream, root, mid, tip, target, hint, hintW, targetOffset, bendNormal);
2663-
2664-
// Blend the solved result back toward the original animation pose using the weight.
2665-
// At weight 1: fully IK. At weight 0.5: halfway. Near 0: almost pure animation.
26662654
if (posWeight < 1f)
26672655
{
26682656
root.SetPosition(stream, Vector3.Lerp(origRootPos, root.GetPosition(stream), posWeight));
@@ -2711,12 +2699,6 @@ public void SolveHand(AnimationStream stream, BoolProperty enabledProp, ReadWrit
27112699
var hint = new AffineTransform(hintPos, hintRot);
27122700
bool hasHint = hintWeightProp.Get(stream);
27132701

2714-
// Elbow bend direction. hasHint is true only when a real lower-arm (elbow) tracker is
2715-
// assigned, and in that case it wins at full weight: leave its position as the pole
2716-
// unblended, since the lookup grid is only an estimator and must not override a
2717-
// measured elbow. With no elbow tracker, drive the pole from the chest-relative lookup
2718-
// grid (VRIK-style) and flag it so the solver actually applies it, instead of falling
2719-
// back to the raw animated bend plane.
27202702
if (!hasHint && HasArmBendLookup)
27212703
{
27222704
Vector3 shoulderPos = root.GetPosition(stream);
@@ -2727,30 +2709,9 @@ public void SolveHand(AnimationStream stream, BoolProperty enabledProp, ReadWrit
27272709

27282710
Vector3 lookupBend = ComputeArmBendFromLookup(stream, shoulderPos, tgtPos, armLen, isLeft);
27292711
hint = new AffineTransform(shoulderPos + 0.5f * armLen * lookupBend, hintRot);
2730-
hasHint = true; // apply the synthesized pole in the solve below
2712+
hasHint = true;
27312713
}
2732-
2733-
// Solve arm — hand lands exactly at controller position.
2734-
// Collision NEVER influences the IK solve. The hand must match the controller 1:1.
27352714
SolveTwoBoneIKArms(stream, root, mid, tip, target, hint, hasHint, targetOffset);
2736-
2737-
// Post-solve: swing the elbow around the shoulder→hand axis to a position
2738-
// outside the torso. The hand sits on the swing axis so its position is
2739-
// preserved exactly — only the elbow's angular position changes, staying on
2740-
// its fixed-radius circle (bone lengths unchanged).
2741-
//
2742-
// Torso is modeled as three stacked capsules along the spine chain
2743-
// (hips→spine, spine→chest, chest→neck) with radii multiplied off chestRadius
2744-
// to approximate a human shape — widest at hips, narrowest at the waist.
2745-
//
2746-
// Direction strategy: we use capsule-capsule for detection (so upper-arm
2747-
// mid-segment penetration is caught), but for the push direction we take the
2748-
// vector from the chest axis to the elbow. That direction is always
2749-
// arm-side-correct — for the right arm it points right, for the left arm it
2750-
// points left — because the elbow naturally lives on its arm's side of the
2751-
// body. Using CapsuleCapsuleResolve's normal directly can flip in deep
2752-
// penetration (its fallback uses a body-relative axis cross product that
2753-
// doesn't know which arm is being solved).
27542715
int collisionState = 0;
27552716
bool doCollisions = collisionsEnabled.Get(stream) && chestStart.IsValid(stream) && chestEnd.IsValid(stream);
27562717
if (doCollisions && protectElbow.Get(stream))
@@ -2770,9 +2731,6 @@ public void SolveHand(AnimationStream stream, BoolProperty enabledProp, ReadWrit
27702731

27712732
if (elbowRadius > k_Epsilon)
27722733
{
2773-
// Upper arm sits a bit wider than the hand/forearm capsule
2774-
// (1.2× handRadius); approximates a human silhouette without
2775-
// adding a dedicated field yet.
27762734
float upperArmR = Mathf.Max(0f, (handRadius.Get(stream) + handSkin.Get(stream)) * 1.2f);
27772735

27782736
float chestRBase = chestRadius.Get(stream);
@@ -2789,10 +2747,6 @@ public void SolveHand(AnimationStream stream, BoolProperty enabledProp, ReadWrit
27892747

27902748
Vector3 chestPos = chestStart.GetPosition(stream);
27912749
Vector3 neckPos = chestEnd.GetPosition(stream);
2792-
2793-
// Aggregate penetration across all torso segments. We only need
2794-
// a "is there overlap" test; the push direction is anatomical
2795-
// (shoulder-derived), not per-segment.
27962750
float worstPen = 0f;
27972751
if (HandleHips.IsValid(stream) && HandleSpine.IsValid(stream))
27982752
{
@@ -2812,12 +2766,6 @@ public void SolveHand(AnimationStream stream, BoolProperty enabledProp, ReadWrit
28122766

28132767
if (worstPen > k_Epsilon)
28142768
{
2815-
// Natural-side direction comes from the SHOULDER, not the
2816-
// elbow. The shoulder is rigidly attached to the chest, so
2817-
// its offset from the chest axis is always on its arm's
2818-
// own side. The elbow may have been pushed through to the
2819-
// wrong side by an extreme controller pose; using its own
2820-
// offset as the direction would keep it stuck there.
28212769
Vector3 shoulderClosest = ClosestPointOnSegment(shoulderPos, chestPos, neckPos);
28222770
Vector3 shoulderOutDir = shoulderPos - shoulderClosest;
28232771
Vector3 shoulderPerp = shoulderOutDir - acDir * Vector3.Dot(shoulderOutDir, acDir);
@@ -2827,25 +2775,12 @@ public void SolveHand(AnimationStream stream, BoolProperty enabledProp, ReadWrit
28272775
{
28282776
Vector3 targetDir = shoulderPerp / Mathf.Sqrt(shoulderPerpSqr);
28292777
Vector3 currentDir = (elbowPos - elbowCenter) / elbowRadius;
2830-
2831-
// If the elbow is on the wrong side of the body (would
2832-
// require the arm to pass through the torso to get to
2833-
// a "blended halfway" position), no smooth path exists
2834-
// — snap fully to the natural side. Smoothing across
2835-
// an anatomically impossible region just leaves the arm
2836-
// stuck in the middle.
28372778
float sideDot = Vector3.Dot(currentDir, targetDir);
28382779
float blend = sideDot < 0f ? 1f : k_ElbowCollisionBlend;
28392780
collisionState = sideDot < 0f ? 2 : 1;
28402781

28412782
Vector3 blendedDir = Vector3.Slerp(currentDir, targetDir, blend);
28422783
Vector3 desiredElbow = elbowCenter + blendedDir * elbowRadius;
2843-
2844-
// SwingElbowAroundAC rotates the shoulder; the hand inherits
2845-
// that rotation through the arm hierarchy. Capture the
2846-
// controller-matched hand pose set by SolveTwoBoneIKArms and
2847-
// restore it after the swing — the hand must match the
2848-
// tracker exactly in both position and rotation.
28492784
Vector3 preservedHandPos = tip.GetPosition(stream);
28502785
Quaternion preservedHandRot = tip.GetRotation(stream);
28512786
SwingElbowAroundAC(stream, root, mid, tip, desiredElbow);
@@ -2914,9 +2849,6 @@ public override BasisFullIKConstraintJob Create(Animator animator, ref BasisFull
29142849
KneeBendPrefLeft = Vector3Property.Bind(animator, component, data.KneeBendPrefLeftProperty),
29152850
KneeBendPrefRight = Vector3Property.Bind(animator, component, data.KneeBendPrefRightProperty),
29162851

2917-
ElbowBendPrefLeft = Vector3Property.Bind(animator, component, data.ElbowBendPrefLeftProperty),
2918-
ElbowBendPrefRight = Vector3Property.Bind(animator, component, data.ElbowBendPrefRightProperty),
2919-
29202852
targetPositionLeftLowerLeg = Vector3Property.Bind(animator, component, data.TargetPositionPropertyLeftLowerLeg),
29212853
hintPositionLeftLowerLeg = Vector3Property.Bind(animator, component, data.HintPositionPropertyLeftLowerLeg),
29222854
targetPositionRightLowerLeg = Vector3Property.Bind(animator, component, data.TargetPositionPropertyRightLowerLeg),

0 commit comments

Comments
 (0)