diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-09-08 13:41:15 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-09-08 13:41:15 +0400 |
commit | 5ce8b1f70476626aae9a5a818398cf9e55a679af (patch) | |
tree | 61d192e011150860a2fa91c2a558c4204c31ed38 /source/blender/blenkernel/intern/constraint.c | |
parent | b9816c98bc0ffaa4992362aca0239c0f6832eccd (diff) |
2.5 - FollowPath Constraint + File Loading Bugfix
* Added a new option ('Fixed Position') for Follow Path constraint which allows you to constrain an object/bone to some fixed position along the curve. Unlike the default mode of operation, this doesn't depend on time unless you explicitly animate the offset percentage parameter associated with this.
* Made old (pre 2.5) files saved with armatures in pose mode load in pose mode again.
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0f7767a1808..dfbcc51a93c 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1178,17 +1178,26 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr makeDispListCurveTypes(cob->scene, ct->tar, 0); if (cu->path && cu->path->data) { - curvetime= bsystem_time(cob->scene, ct->tar, (float)ctime, 0.0) - data->offset; - -#if 0 // XXX old animation system - if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) { - curvetime /= cu->pathlen; + if ((data->followflag & FOLLOWPATH_STATIC) == 0) { + /* animated position along curve depending on time */ + curvetime= bsystem_time(cob->scene, ct->tar, ctime, 0.0) - data->offset; + + /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, + * but this will only work if it actually is animated... + * + * we firstly calculate the modulus of cu->ctime/cu->pathlen to clamp ctime within the 0.0 to 1.0 times pathlen + * range, then divide this (the modulus) by pathlen to get a value between 0.0 and 1.0 + */ + curvetime= fmod(cu->ctime, cu->pathlen) / cu->pathlen; CLAMP(curvetime, 0.0, 1.0); } -#endif // XXX old animation system + else { + /* fixed position along curve */ + curvetime= data->offset; // XXX might need a more sensible value + } if ( where_on_path(ct->tar, curvetime, vec, dir) ) { - if (data->followflag) { + if (data->followflag & FOLLOWPATH_FOLLOW) { vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat); Normalize(dir); |