[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43005] trunk/blender/source/blender/ blenkernel/intern/constraint.c: patch [#29726] Enable looping with Follow Path constraint and cyclic curves.

Campbell Barton ideasman42 at gmail.com
Fri Dec 30 15:52:07 CET 2011


Revision: 43005
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43005
Author:   campbellbarton
Date:     2011-12-30 14:52:03 +0000 (Fri, 30 Dec 2011)
Log Message:
-----------
patch [#29726] Enable looping with Follow Path constraint and cyclic curves.   by Peter Amstutz (tetron)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-12-30 14:17:11 UTC (rev 43004)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2011-12-30 14:52:03 UTC (rev 43005)
@@ -1255,6 +1255,7 @@
 			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 @@
 				 * 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 */




More information about the Bf-blender-cvs mailing list