From cf2baa585cc8788b29147d6e34fa8c46609e5bf9 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Thu, 8 Apr 2021 15:51:08 +0200 Subject: Fix T81707: Spline IK Joints "Floating" above curve The issue was that where_on_path uses a resampled curve to get the data from the curve. This leads to disconnects between the curve the user sees and the evaluated location data. To fix this we simply use the actual curve data the user can see. The older code needed a cleanup either way as there were hacks in other parts of the code trying to work around some brokenness. This is now fixed and we no longer need to clamp the evaluation range to 0-1 or make helper functions to make it do what we actually want. Reviewed By: Campbell, Sybren Differential Revision: http://developer.blender.org/D10898 --- source/blender/blenkernel/intern/constraint.c | 35 ++++++++------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern/constraint.c') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index d04a27adec8..2ee030ca83f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1463,12 +1463,10 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph), * currently for paths to work it needs to go through the bevlist/displist system (ton) */ - if (ct->tar->runtime.curve_cache && ct->tar->runtime.curve_cache->path && - ct->tar->runtime.curve_cache->path->data) { + if (ct->tar->runtime.curve_cache && ct->tar->runtime.curve_cache->anim_path_accum_length) { 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 @@ -1477,31 +1475,19 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph), * we divide the curvetime calculated in the previous step by the length of the path, * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range. */ curvetime /= cu->pathlen; - - 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 -= floorf(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 */ curvetime = data->offset_fac; } - if (where_on_path(ct->tar, - curvetime, - vec, - dir, - (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, - &radius, - NULL)) { /* quat_pt is quat or NULL*/ + if (BKE_where_on_path(ct->tar, + curvetime, + vec, + dir, + (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, + &radius, + NULL)) { /* quat_pt is quat or NULL*/ float totmat[4][4]; unit_m4(totmat); @@ -3784,8 +3770,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar BKE_object_minmax(ct->tar, curveMin, curveMax, true); /* get targetmatrix */ - if (data->tar->runtime.curve_cache && data->tar->runtime.curve_cache->path && - data->tar->runtime.curve_cache->path->data) { + if (data->tar->runtime.curve_cache && data->tar->runtime.curve_cache->anim_path_accum_length) { float vec[4], dir[3], totmat[4][4]; float curvetime; short clamp_axis; @@ -3869,7 +3854,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar } /* 3. position on curve */ - if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL)) { + if (BKE_where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL)) { unit_m4(totmat); copy_v3_v3(totmat[3], vec); -- cgit v1.2.3