public static bool _LimitToPlaneDirY( ref Vector3 dir, Vector3 planeDir, float thetaY )
{
float d = Vector3.Dot( dir, planeDir );
if( d <= IKEpsilon && d >= -IKEpsilon ) {
return false;
}
if( d <= thetaY && d >= -thetaY ) {
return true;
}
Vector3 tmp = dir - planeDir * d;
float tmpLen = SAFBIKVecLength( ref tmp );
if( tmpLen <= FLOAT_EPSILON ) {
return false;
}
float targetLen = SAFBIKSqrt( 1.0f - thetaY * thetaY );
tmp *= targetLen / tmpLen;
dir = tmp;
if( d >= 0.0f ) {
dir += planeDir * thetaY;
} else {
dir -= planeDir * thetaY;
}
return true;
}