IK's were converting double -> float -> double's in a few places, since precision...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 27 Jul 2012 22:27:06 +0000 (22:27 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 27 Jul 2012 22:27:06 +0000 (22:27 +0000)
intern/iksolver/intern/IK_QJacobianSolver.cpp
intern/iksolver/intern/IK_QJacobianSolver.h
intern/iksolver/intern/IK_QSegment.cpp
intern/iksolver/intern/IK_QSegment.h
intern/iksolver/intern/IK_QTask.h
intern/iksolver/intern/IK_Solver.cpp

index fe5ecf8abe33540f249276e26a3a51bbb318306b..b310f2cdfdf2f60d32afa1e79a9050743303a9c3 100644 (file)
@@ -46,18 +46,18 @@ IK_QJacobianSolver::IK_QJacobianSolver()
 MT_Scalar IK_QJacobianSolver::ComputeScale()
 {
        std::vector<IK_QSegment*>::iterator seg;
-       float length = 0.0f;
+       MT_Scalar length = 0.0f;
 
        for (seg = m_segments.begin(); seg != m_segments.end(); seg++)
                length += (*seg)->MaxExtension();
        
-       if(length == 0.0f)
-               return 1.0f;
+       if(length == 0.0)
+               return 1.0;
        else
-               return 1.0f/length;
+               return 1.0 / length;
 }
 
-void IK_QJacobianSolver::Scale(float scale, std::list<IK_QTask*>& tasks)
+void IK_QJacobianSolver::Scale(MT_Scalar scale, std::list<IK_QTask*>& tasks)
 {
        std::list<IK_QTask*>::iterator task;
        std::vector<IK_QSegment*>::iterator seg;
@@ -172,8 +172,8 @@ void IK_QJacobianSolver::SetPoleVectorConstraint(IK_QSegment *tip, MT_Vector3& g
 static MT_Scalar safe_acos(MT_Scalar f)
 {
        // acos that does not return NaN with rounding errors
-       if (f <= -1.0f) return MT_PI;
-       else if (f >= 1.0f) return 0.0;
+       if (f <= -1.0) return MT_PI;
+       else if (f >= 1.0) return 0.0;
        else return acos(f);
 }
 
@@ -245,7 +245,7 @@ void IK_QJacobianSolver::ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTa
                // we compute the pole angle that to rotate towards the target
                m_poleangle = angle(mat[1], polemat[1]);
 
-               if(rootz.dot(mat[1]*cos(m_poleangle) + mat[0]*sin(m_poleangle)) > 0.0f)
+               if(rootz.dot(mat[1]*cos(m_poleangle) + mat[0]*sin(m_poleangle)) > 0.0)
                        m_poleangle = -m_poleangle;
 
                // solve again, with the pole angle we just computed
index cfcd2849fb20f184247206a2d2f94e16a0ccbf44..ead2b150b40fc427bc598254abeeb15c93de4135 100644 (file)
@@ -77,7 +77,7 @@ private:
        void ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTask*>& tasks);
 
        MT_Scalar ComputeScale();
-       void Scale(float scale, std::list<IK_QTask*>& tasks);
+       void Scale(MT_Scalar scale, std::list<IK_QTask*>& tasks);
 
 private:
 
index d81ed453037ebf8b9f6fa6a29bee8c851bab2ca5..710faa061cec8ba21e41e40640b6878da4889e10 100644 (file)
@@ -75,9 +75,9 @@ static MT_Scalar EulerAngleFromMatrix(const MT_Matrix3x3& R, int axis)
 
 static MT_Scalar safe_acos(MT_Scalar f)
 {
-       if (f <= -1.0f)
+       if (f <= -1.0)
                return MT_PI;
-       else if (f >= 1.0f)
+       else if (f >= 1.0)
                return 0.0;
        else
                return acos(f);
@@ -345,7 +345,7 @@ void IK_QSegment::PrependBasis(const MT_Matrix3x3& mat)
        m_basis = m_rest_basis.inverse() * mat * m_rest_basis * m_basis;
 }
 
-void IK_QSegment::Scale(float scale)
+void IK_QSegment::Scale(MT_Scalar scale)
 {
        m_start *= scale;
        m_translation *= scale;
@@ -1035,7 +1035,7 @@ void IK_QTranslateSegment::SetLimit(int axis, MT_Scalar lmin, MT_Scalar lmax)
        m_limit[axis]= true;
 }
 
-void IK_QTranslateSegment::Scale(float scale)
+void IK_QTranslateSegment::Scale(MT_Scalar scale)
 {
        int i;
 
index 68d40829137843d2bae17a44e45b744d568b6cf7..25a8fbc08041206db891d5de4c7b0a2ef5403a67 100644 (file)
@@ -170,7 +170,7 @@ public:
        void Reset();
 
        // scale
-       virtual void Scale(float scale);
+       virtual void Scale(MT_Scalar scale);
 
 protected:
 
@@ -338,7 +338,7 @@ public:
        void SetWeight(int axis, MT_Scalar weight);
        void SetLimit(int axis, MT_Scalar lmin, MT_Scalar lmax);
 
-       void Scale(float scale);
+       void Scale(MT_Scalar scale);
 
 private:
        int m_axis[3];
index 3d968cdfe38cee021615f4a6ffead7934b4114cd..45b1e59e606f50842a018f7a2fea37e268670987 100644 (file)
@@ -78,7 +78,7 @@ public:
 
        virtual bool PositionTask() const { return false; }
 
-       virtual void Scale(float) {}
+       virtual void Scale(MT_Scalar) {}
 
 protected:
        int m_id;
@@ -103,7 +103,7 @@ public:
        MT_Scalar Distance() const;
 
        bool PositionTask() const { return true; }
-       void Scale(float scale) { m_goal *= scale; m_clamp_length *= scale; }
+       void Scale(MT_Scalar scale) { m_goal *= scale; m_clamp_length *= scale; }
 
 private:
        MT_Vector3 m_goal;
@@ -141,7 +141,7 @@ public:
 
        MT_Scalar Distance() const;
 
-       void Scale(float scale) { m_goal_center *= scale; m_distance *= scale; }
+       void Scale(MT_Scalar scale) { m_goal_center *= scale; m_distance *= scale; }
 
 private:
        MT_Scalar ComputeTotalMass(const IK_QSegment *segment);
index 3876f26362c7c98d7efa0a2b75aa92fb52449237..7586e9e605739aa38f25cec1d4ab38e11b553215 100644 (file)
@@ -197,14 +197,14 @@ void IK_SetLimit(IK_Segment *seg, IK_SegmentAxis axis, float lmin, float lmax)
 
 void IK_SetStiffness(IK_Segment *seg, IK_SegmentAxis axis, float stiffness)
 {
-       if (stiffness < 0.0)
+       if (stiffness < 0.0f)
                return;
        
-       if (stiffness > 0.999)
-               stiffness = 0.999;
+       if (stiffness > 0.999f)
+               stiffness = 0.999f;
 
        IK_QSegment *qseg = (IK_QSegment*)seg;
-       MT_Scalar weight = 1.0-stiffness;
+       MT_Scalar weight = 1.0f - stiffness;
 
        if (axis >= IK_TRANS_X) {
                if(!qseg->Translational()) {