From 27e13e7330ad4c93b0c6e38398588e9a130c5ea9 Mon Sep 17 00:00:00 2001 From: Kelly Washington Date: Thu, 24 Jan 2013 09:17:02 -0800 Subject: MAINT-2275 Child prims are "left behind" by animated, moving (physical) linksets --- indra/newview/lldrawable.cpp | 59 +++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'indra/newview/lldrawable.cpp') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 647c3355ca..d394ce5b21 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -517,42 +517,45 @@ F32 LLDrawable::updateXform(BOOL undamped) F32 dist_squared = 0.f; F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); - if (damped && isVisible()) + if (isVisible()) { - F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); - LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); - dist_squared = dist_vec_squared(new_pos, target_pos); + if (damped) + { + F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); + LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); + dist_squared = dist_vec_squared(new_pos, target_pos); - LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); - dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; + LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); + dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; - LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); - dist_squared += dist_vec_squared(new_scale, target_scale); + LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); + dist_squared += dist_vec_squared(new_scale, target_scale); - if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && - (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) - { - // interpolate - target_pos = new_pos; - target_rot = new_rot; - target_scale = new_scale; + if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && + (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) + { + // interpolate + target_pos = new_pos; + target_rot = new_rot; + target_scale = new_scale; + } + else if (mVObjp->getAngularVelocity().isExactlyZero()) + { + // snap to final position (only if no target omega is applied) + dist_squared = 0.0f; + if (getVOVolume() && !isRoot()) + { //child prim snapping to some position, needs a rebuild + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } + } } - else if (mVObjp->getAngularVelocity().isExactlyZero()) + else { - // snap to final position (only if no target omega is applied) - dist_squared = 0.0f; - if (getVOVolume() && !isRoot()) - { //child prim snapping to some position, needs a rebuild - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - } + dist_squared = dist_vec_squared(old_pos, target_pos); + dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; + dist_squared += dist_vec_squared(old_scale, target_scale); } } - else - { - dist_squared = dist_vec_squared(old_pos, target_pos); - dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; - dist_squared += dist_vec_squared(old_scale, target_scale); - } LLVector3 vec = mCurrentScale-target_scale; -- cgit v1.2.3 From aee0766f35d724bfddc4be6b6f0b100467f3b1f4 Mon Sep 17 00:00:00 2001 From: Kelly Washington Date: Thu, 24 Jan 2013 13:21:45 -0800 Subject: MAINT-2275 Child prims are "left behind" by animated, moving (physical) linksets * A fix that doesn't break doors. Reverst MAINT-2247 --- indra/newview/lldrawable.cpp | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'indra/newview/lldrawable.cpp') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index d394ce5b21..b15ffec9e3 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -517,45 +517,45 @@ F32 LLDrawable::updateXform(BOOL undamped) F32 dist_squared = 0.f; F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera); - if (isVisible()) + if (damped && isVisible()) { - if (damped) - { - F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); - LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); - dist_squared = dist_vec_squared(new_pos, target_pos); + F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); + LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); + dist_squared = dist_vec_squared(new_pos, target_pos); - LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); - dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; + LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); + // FIXME: This can be negative! It is be possible for some rots to 'cancel out' pos or size changes. + dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f; - LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); - dist_squared += dist_vec_squared(new_scale, target_scale); + LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); + dist_squared += dist_vec_squared(new_scale, target_scale); - if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && - (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) - { - // interpolate - target_pos = new_pos; - target_rot = new_rot; - target_scale = new_scale; - } - else if (mVObjp->getAngularVelocity().isExactlyZero()) - { - // snap to final position (only if no target omega is applied) - dist_squared = 0.0f; - if (getVOVolume() && !isRoot()) - { //child prim snapping to some position, needs a rebuild - gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); - } - } + if ((dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED * camdist2) && + (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)) + { + // interpolate + target_pos = new_pos; + target_rot = new_rot; + target_scale = new_scale; } - else + else if (mVObjp->getAngularVelocity().isExactlyZero()) { - dist_squared = dist_vec_squared(old_pos, target_pos); - dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; - dist_squared += dist_vec_squared(old_scale, target_scale); + // snap to final position (only if no target omega is applied) + dist_squared = 0.0f; + if (getVOVolume() && !isRoot()) + { //child prim snapping to some position, needs a rebuild + gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); + } } } + else + { + dist_squared = dist_vec_squared(old_pos, target_pos); + + // The following "makes sense" and fixes MAINT-2247 but causes MAINT-2275 + //dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; + //dist_squared += dist_vec_squared(old_scale, target_scale); + } LLVector3 vec = mCurrentScale-target_scale; -- cgit v1.2.3 From 4d589df2fd9a19cef248987e9f1f71b9be1f9aaa Mon Sep 17 00:00:00 2001 From: Kelly Washington Date: Thu, 24 Jan 2013 15:32:36 -0800 Subject: MAINT-2275 Child prims are "left behind" by animated, moving (physical) linksets * A fix that doesn't break tanks. Reverts MAINT-1742 --- indra/newview/lldrawable.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/lldrawable.cpp') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index b15ffec9e3..d041baea90 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -550,9 +550,10 @@ F32 LLDrawable::updateXform(BOOL undamped) } else { - dist_squared = dist_vec_squared(old_pos, target_pos); + // The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275 + // dist_squared = dist_vec_squared(old_pos, target_pos); - // The following "makes sense" and fixes MAINT-2247 but causes MAINT-2275 + // The following fixes MAINT-2247 but causes MAINT-2275 //dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; //dist_squared += dist_vec_squared(old_scale, target_scale); } -- cgit v1.2.3