defines to make it easier to manage ik stretch constants (these may need to be tweake...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 27 Jul 2012 23:16:33 +0000 (23:16 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 27 Jul 2012 23:16:33 +0000 (23:16 +0000)
intern/iksolver/extern/IK_solver.h
intern/iksolver/intern/IK_Solver.cpp
source/blender/ikplugin/intern/iksolver_plugin.c

index 7f780a0a17fcf19ad8aa004debdf5b5a9d1469b9..a3f599e06c83ef3facdcf810981ab4eac8424f26 100644 (file)
@@ -163,6 +163,9 @@ float IK_SolverGetPoleAngle(IK_Solver *solver);
 
 int IK_Solve(IK_Solver *solver, float tolerance, int max_iterations);
 
+#define IK_STRETCH_STIFF_EPS 0.001f
+#define IK_STRETCH_STIFF_MIN 0.001f
+#define IK_STRETCH_STIFF_MAX 1e10
 
 #ifdef __cplusplus
 }
index 8c19c0e2a74a322084481f567fc6f828e03b7da9..6c2e30932bbfab735abec14b4d0cb43bb9a9457e 100644 (file)
@@ -201,8 +201,8 @@ void IK_SetStiffness(IK_Segment *seg, IK_SegmentAxis axis, float stiffness)
        if (stiffness < 0.0f)
                return;
        
-       if (stiffness > 0.999f)
-               stiffness = 0.999f;
+       if (stiffness > (1.0 - IK_STRETCH_STIFF_EPS))
+               stiffness = (1.0 - IK_STRETCH_STIFF_EPS);
 
        IK_QSegment *qseg = (IK_QSegment *)seg;
        MT_Scalar weight = 1.0f - stiffness;
index 21d50e4a71d48559e093e036cd19701a835b6453..86bdc7e1ab6af2bf944c6bd076e2ab66e3d9b460 100644 (file)
@@ -334,9 +334,9 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
                IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]);
 
                if (tree->stretch && (pchan->ikstretch > 0.0f)) {
-                       float ikstretch = pchan->ikstretch * pchan->ikstretch;
-                       IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0f - ikstretch, 0.99f));
-                       IK_SetLimit(seg, IK_TRANS_Y, 0.001, 1e10);
+                       double ikstretch = (double)pchan->ikstretch * (double)pchan->ikstretch;
+                       IK_SetStiffness(seg, IK_TRANS_Y, 1.0f - ikstretch);
+                       IK_SetLimit(seg, IK_TRANS_Y, IK_STRETCH_STIFF_MIN, IK_STRETCH_STIFF_MAX);
                }
        }