From b310216a479d41d946d875001517003dde03e2c9 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 20 Nov 2005 12:41:00 +0000 Subject: [PATCH] Patch provided by Stephan Kassemeyer. This fixes an error in the striding system, which was by default correcting path position backwards in time, which could give errors when a stride bone moves in the beginning of a path faster than the path moves. (Can you follow that? cool!) The patch checks for this case, it corrects by default forwards in time, unless we're at the end of a path. As bonus this fix will also ensure the character stays on the path closer. --- source/blender/blenkernel/intern/action.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 3074656d761..a9a369a116f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -754,7 +754,7 @@ static float stridechannel_frame(Object *ob, bActionStrip *strip, Path *path, fl if(foundvert && miny!=maxy) { float stridelen= fabs(maxy-miny), striptime; - float actiondist, pdist; + float actiondist, pdist, pdistNewNormalized; float vec1[4], vec2[4], dir[3]; /* amount path moves object */ @@ -764,12 +764,21 @@ static float stridechannel_frame(Object *ob, bActionStrip *strip, Path *path, fl /* amount stride bone moves */ actiondist= eval_icu(icu, minx + striptime*(maxx-minx)) - miny; - pdist = pdist - fabs(actiondist); + pdist = fabs(actiondist) - pdist; + pdistNewNormalized = (pathdist+pdist)/path->totdist; /* now we need to go pdist further (or less) on cu path */ where_on_path(ob, (pathdist)/path->totdist, vec1, dir); /* vec needs size 4 */ - where_on_path(ob, (pathdist+pdist)/path->totdist, vec2, dir); /* vec needs size 4 */ - VecSubf(stride_offset, vec1, vec2); + if (pdistNewNormalized <= 1) { + // search for correction in positive path-direction + where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ + VecSubf(stride_offset, vec2, vec1); + } + else { + // we reached the end of the path, search backwards instead + where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */ + VecSubf(stride_offset, vec1, vec2); + } Mat4Mul3Vecfl(ob->obmat, stride_offset); return striptime; }