diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-29 19:41:58 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-03-29 19:41:58 +0400 |
commit | ae33503d0304e8efcde9532f7acc23773fc810a6 (patch) | |
tree | 6e322b231ddd166172853268a05ecd23cfdff65e /source/blender/blenkernel/intern/constraint.c | |
parent | 81efab83f05034fe67bc1154292f986e8b5cd421 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0126f1dc416..8177d09c7e3 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3188,25 +3188,15 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* 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); } |