[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45263] trunk/blender/source/blender/ blenkernel/intern/constraint.c: Fix #30716: Clamp To Constraint Locks up Blender after a while.

Sergey Sharybin sergey.vfx at gmail.com
Thu Mar 29 17:42:05 CEST 2012


Revision: 45263
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45263
Author:   nazgul
Date:     2012-03-29 15:41:58 +0000 (Thu, 29 Mar 2012)
Log Message:
-----------
Fix #30716: Clamp To Constraint Locks up Blender after a while.

Issue was caused by object moved really far away (not just actually issue,
it's just about long mouse gesture and X-axis orientation which projects
position to quite large X-axis value) and for this location start offset
from curve length was calculating iteratively which takes plenty of time for
short curves.

Replace iterative search of offset with formula which seems to be working
in the same way and should be a bit more accurate.

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	2012-03-29 15:04:54 UTC (rev 45262)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2012-03-29 15:41:58 UTC (rev 45263)
@@ -3188,25 +3188,15 @@
 					/* find bounding-box range where target is located */
 					if (ownLoc[clamp_axis] < curveMin[clamp_axis]) {
 						/* bounding-box range is before */
-						offset= curveMin[clamp_axis];
-						
-						while (ownLoc[clamp_axis] < offset)
-							offset -= len;
-						
+						offset = curveMin[clamp_axis] - ceil((curveMin[clamp_axis] - ownLoc[clamp_axis]) / len) * len;
+
 						/* now, we calculate as per normal, except using offset instead of curveMin[clamp_axis] */
 						curvetime = (ownLoc[clamp_axis] - offset) / (len);
 					}
 					else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
 						/* bounding-box range is after */
-						offset= curveMax[clamp_axis];
-						
-						while (ownLoc[clamp_axis] > offset) {
-							if ((offset + len) > ownLoc[clamp_axis])
-								break;
-							else
-								offset += len;
-						}
-						
+						offset= curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
+
 						/* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */
 						curvetime = (ownLoc[clamp_axis] - offset) / (len);
 					}




More information about the Bf-blender-cvs mailing list