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:
authorCampbell Barton <ideasman42@gmail.com>2011-12-30 18:52:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-12-30 18:52:03 +0400
commit532afede0236bdf6e29dd4dfc746a1ee0959d8a5 (patch)
tree0106a4beb63a850d82c4fe1410053cc1aba78c20 /source/blender/blenkernel
parentd7d856a23de2b6751a46632130f941a71377d134 (diff)
patch [#29726] Enable looping with Follow Path constraint and cyclic curves. by Peter Amstutz (tetron)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/constraint.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 927a98c174f..79986525e2e 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1255,6 +1255,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
float quat[4];
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
/* animated position along curve depending on time */
+ Nurb *nu = cu->nurb.first;
curvetime= cu->ctime - data->offset;
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
@@ -1264,7 +1265,18 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
* factor, which then gets clamped to lie within 0.0 - 1.0 range
*/
curvetime /= cu->pathlen;
- CLAMP(curvetime, 0.0f, 1.0f);
+
+ if (nu && nu->flagu & CU_NURB_CYCLIC) {
+ /* If the curve is cyclic, enable looping around if the time is
+ * outside the bounds 0..1 */
+ if ((curvetime < 0.0f) || (curvetime > 1.0f)) {
+ curvetime -= floor(curvetime);
+ }
+ }
+ else {
+ /* The curve is not cyclic, so clamp to the begin/end points. */
+ CLAMP(curvetime, 0.0f, 1.0f);
+ }
}
else {
/* fixed position along curve */