mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
IK's were converting double -> float -> double's in a few places, since precision is important and doubles are used a lot here anyway. just use doubles, also quiet some double promotion warnings.
This commit is contained in:
parent
f02254f026
commit
e2360ab495
6 changed files with 22 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue