Revision: 38232
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38232
Author:   blendix
Date:     2011-07-08 12:18:54 +0000 (Fri, 08 Jul 2011)
Log Message:
-----------
Fix #27891: IK stretch gives inaccurate results. Tweaked translation segment
convergence weight a bit to match angles better at typical scales.

Modified Paths:
--------------
    trunk/blender/intern/iksolver/intern/IK_QJacobian.cpp
    trunk/blender/intern/iksolver/intern/IK_QJacobian.h
    trunk/blender/intern/iksolver/intern/IK_QTask.cpp

Modified: trunk/blender/intern/iksolver/intern/IK_QJacobian.cpp
===================================================================
--- trunk/blender/intern/iksolver/intern/IK_QJacobian.cpp       2011-07-08 
12:05:34 UTC (rev 38231)
+++ trunk/blender/intern/iksolver/intern/IK_QJacobian.cpp       2011-07-08 
12:18:54 UTC (rev 38232)
@@ -59,6 +59,7 @@
 
        m_d_theta.newsize(dof);
        m_d_theta_tmp.newsize(dof);
+       m_d_norm_weight.newsize(dof);
 
        m_norm.newsize(dof);
        m_norm = 0.0;
@@ -111,11 +112,13 @@
        m_beta[id+2] = v.z();
 }
 
-void IK_QJacobian::SetDerivatives(int id, int dof_id, const MT_Vector3& v)
+void IK_QJacobian::SetDerivatives(int id, int dof_id, const MT_Vector3& v, 
MT_Scalar norm_weight)
 {
        m_jacobian[id][dof_id] = v.x()*m_weight_sqrt[dof_id];
        m_jacobian[id+1][dof_id] = v.y()*m_weight_sqrt[dof_id];
        m_jacobian[id+2][dof_id] = v.z()*m_weight_sqrt[dof_id];
+
+       m_d_norm_weight[dof_id] = norm_weight;
 }
 
 void IK_QJacobian::Invert()
@@ -429,7 +432,7 @@
        MT_Scalar mx = 0.0, dtheta_abs;
 
        for (i = 0; i < m_d_theta.size(); i++) {
-               dtheta_abs = MT_abs(m_d_theta[i]);
+               dtheta_abs = MT_abs(m_d_theta[i]*m_d_norm_weight[i]);
                if (dtheta_abs > mx)
                        mx = dtheta_abs;
        }

Modified: trunk/blender/intern/iksolver/intern/IK_QJacobian.h
===================================================================
--- trunk/blender/intern/iksolver/intern/IK_QJacobian.h 2011-07-08 12:05:34 UTC 
(rev 38231)
+++ trunk/blender/intern/iksolver/intern/IK_QJacobian.h 2011-07-08 12:18:54 UTC 
(rev 38232)
@@ -56,7 +56,7 @@
 
        // Iteratively called
        void SetBetas(int id, int size, const MT_Vector3& v);
-       void SetDerivatives(int id, int dof_id, const MT_Vector3& v);
+       void SetDerivatives(int id, int dof_id, const MT_Vector3& v, MT_Scalar 
norm_weight);
 
        void Invert();
 
@@ -89,6 +89,7 @@
 
        /// the vector of computed angle changes
        TVector m_d_theta;
+       TVector m_d_norm_weight;
 
        /// space required for SVD computation
 

Modified: trunk/blender/intern/iksolver/intern/IK_QTask.cpp
===================================================================
--- trunk/blender/intern/iksolver/intern/IK_QTask.cpp   2011-07-08 12:05:34 UTC 
(rev 38231)
+++ trunk/blender/intern/iksolver/intern/IK_QTask.cpp   2011-07-08 12:18:54 UTC 
(rev 38232)
@@ -95,10 +95,10 @@
                        MT_Vector3 axis = seg->Axis(i)*m_weight;
 
                        if (seg->Translational())
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
axis);
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
axis, 1e2);
                        else {
                                MT_Vector3 pa = p.cross(axis);
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
pa);
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
pa, 1e0);
                        }
                }
        }
@@ -147,10 +147,10 @@
                for (i = 0; i < seg->NumberOfDoF(); i++) {
 
                        if (seg->Translational())
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
MT_Vector3(0, 0, 0));
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
MT_Vector3(0, 0, 0), 1e2);
                        else {
                                MT_Vector3 axis = seg->Axis(i)*m_weight;
-                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
axis);
+                               jacobian.SetDerivatives(m_id, seg->DoFId()+i, 
axis, 1e0);
                        }
                }
 }
@@ -202,10 +202,10 @@
                axis *= /*segment->Mass()**/m_total_mass_inv;
                
                if (segment->Translational())
-                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, axis);
+                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, axis, 
1e2);
                else {
                        MT_Vector3 pa = axis.cross(p);
-                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, pa);
+                       jacobian.SetDerivatives(m_id, segment->DoFId()+i, pa, 
1e0);
                }
        }
        

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to