Skip to content

Commit

Permalink
Putitfix for headEffector.pull > IKEpsilon (Stable fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora authored and Nora committed Mar 17, 2016
1 parent 5817f93 commit e71909e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Scripts/FullBodyIK/BodyIK.cs
Expand Up @@ -2110,8 +2110,9 @@ public bool UpperSolve()
if( headPull > IKEpsilon || neckPull > IKEpsilon ) {
if( headMovingfixRate < 1.0f - IKEpsilon && headPull > IKEpsilon ) {
Vector3 tempNeckPos = _upperSolverPreArmsTemp.neckPos;
_KeepLength( ref tempNeckPos, ref _upperSolverTemp.targetHeadPos, _solverCaches.neckToHeadLength );
_upperSolverPreArmsTemp.neckPos = Vector3.Lerp( _upperSolverPreArmsTemp.neckPos, tempNeckPos, headPull );
if( _KeepMaxLength( ref tempNeckPos, ref _upperSolverTemp.targetHeadPos, _solverCaches.neckToHeadLength ) ) { // Not KeepLength
_upperSolverPreArmsTemp.neckPos = Vector3.Lerp( _upperSolverPreArmsTemp.neckPos, tempNeckPos, headPull );
}
}
for( int i = 0; i != 2; ++i ) {
if( bodyMovingfixRate < 1.0f - IKEpsilon && neckPull > IKEpsilon ) {
Expand Down Expand Up @@ -2642,6 +2643,19 @@ public void SolveShoulderToArmInternal( int i, ref Vector3 destArmPos )

//----------------------------------------------------------------------------------------------------------------------------------------

static bool _KeepMaxLength( ref Vector3 posTo, ref Vector3 posFrom, float keepLength )
{
Vector3 v = posTo - posFrom;
float len = SAFBIKVecLength( ref v );
if( len > IKEpsilon && len > keepLength ) {
v = v * (keepLength / len);
posTo = posFrom + v;
return true;
}

return false;
}

static bool _KeepMaxLength( ref Vector3 posTo, ref Vector3 posFrom, ref FastLength keepLength )
{
Vector3 v = posTo - posFrom;
Expand Down

0 comments on commit e71909e

Please sign in to comment.