Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2010-11-25 02:36:36 +0300
committerJoshua Leung <aligorith@gmail.com>2010-11-25 02:36:36 +0300
commit9f18e066fc373d39dea40f288dcaf10e9a049e6e (patch)
tree55ba3a9048ea99cb76dec95f02779b2e91fd8d1a
parent49f63589aba07fa772fbec95b58bcfb0d0d95eec (diff)
Spline IK Bugfix:
Binding code had off-by-1 error, which meant that when "Even Divisions" was disabled the length of the wrong bone would get used. This error was most noticeable when the lengths of the bones were quite different - for example, a chain with 3 bones of increasing length. Thanks to "Julius" on BlenderArtists for catching this. Cheers! --- Also, simplified the binding code loop a bit to prevent this sort of error in future.
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c2
-rw-r--r--source/blender/blenkernel/intern/armature.c29
2 files changed, 14 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 580f94ba3b8..ae683dab7b2 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1654,7 +1654,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
/* make dummy NLA strip, and add that to the stack */
NlaStrip dummy_strip= {0};
ListBase dummy_trackslist;
-
+
dummy_trackslist.first= dummy_trackslist.last= &dummy_strip;
if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) {
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 1943c82766e..d2861a8942c 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1730,28 +1730,25 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
ikData->numpoints= ikData->chainlen+1;
ikData->points= MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding");
+ /* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */
+ ikData->points[0] = 1.0f;
+
/* perform binding of the joints to parametric positions along the curve based
* proportion of the total length that each bone occupies
*/
for (i = 0; i < segcount; i++) {
- if (i != 0) {
- /* 'head' joints
- * - 2 methods; the one chosen depends on whether we've got usable lengths
- */
- if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) {
- /* 1) equi-spaced joints */
- ikData->points[i]= ikData->points[i-1] - segmentLen;
- }
- else {
- /* 2) to find this point on the curve, we take a step from the previous joint
- * a distance given by the proportion that this bone takes
- */
- ikData->points[i]= ikData->points[i-1] - (boneLengths[i] / totLength);
- }
+ /* 'head' joints, travelling towards the root of the chain
+ * - 2 methods; the one chosen depends on whether we've got usable lengths
+ */
+ if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) {
+ /* 1) equi-spaced joints */
+ ikData->points[i+1]= ikData->points[i] - segmentLen;
}
else {
- /* 'tip' of chain, special exception for the first joint */
- ikData->points[0]= 1.0f;
+ /* 2) to find this point on the curve, we take a step from the previous joint
+ * a distance given by the proportion that this bone takes
+ */
+ ikData->points[i+1]= ikData->points[i] - (boneLengths[i] / totLength);
}
}