[Bf-committers] PATCH: Avoid throwing an assert for IK constraint.
Kester Maddock
bf-committers@blender.org
Wed, 26 Nov 2003 16:43:02 +1300
This patch stops blender from crashing when creating an IK constraint:
To reproduce:
Add an armature.
Add three bones (upper arm, forearm, hand)
Extrude an IK controller from the wrist.
Switch to pose mode.
Select the hand bone and create an IK constraint.
Type the armature's name ("Armature") into the object box.
Blender assertion !MT_FuzzyZero fails.
This is because in IK_QJacobianSolver.cpp function
IK_QJacobianSolver::Solve goal_dir.normalize(); is executed with
goal_dir == {0., 0., 0.}
This patch checks for that condition.
Kester
Index: intern/iksolver/intern/IK_QJacobianSolver.cpp
===================================================================
RCS file:
/cvsroot/bf-blender/blender/intern/iksolver/intern/IK_QJacobianSolver.cpp,v
retrieving revision 1.4
diff -u -3 -b -B -r1.4 IK_QJacobianSolver.cpp
--- intern/iksolver/intern/IK_QJacobianSolver.cpp 1 May 2003
19:52:20 -0000 1.4
+++ intern/iksolver/intern/IK_QJacobianSolver.cpp 26 Nov 2003
03:36:52 -0000
@@ -65,6 +65,7 @@
MT_Vector3 goal_dir = g_position - segs[0].GlobalSegmentStart();
+ if (goal_dir.length() < tolerance) return false;
const MT_Scalar chain_max_extension = chain.MaxExtension();