summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawable.cpp')
-rw-r--r--indra/newview/lldrawable.cpp122
1 files changed, 62 insertions, 60 deletions
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 235da41998..2e3a9119b8 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -441,7 +441,7 @@ void LLDrawable::makeActive()
}
llassert(isAvatar() || isRoot() || mParent->isActive());
-}
+ }
void LLDrawable::makeStatic(BOOL warning_enabled)
@@ -455,7 +455,7 @@ void LLDrawable::makeStatic(BOOL warning_enabled)
//drawable became static with active parent, not acceptable
llassert(mParent.isNull() || !mParent->isActive() || !warning_enabled);
-
+
LLViewerObject::const_child_list_t& child_list = mVObjp->getChildren();
for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
iter != child_list.end(); iter++)
@@ -492,82 +492,95 @@ F32 LLDrawable::updateXform(BOOL undamped)
BOOL damped = !undamped;
// Position
- LLVector3 old_pos = mXform.getPosition();
-
- // get agent position or parent-relative position as appropriate
- //
- LLVector3 target_pos = mXform.isRoot() ? mVObjp->getPositionAgent() : mVObjp->getPosition();
-
+ LLVector3 old_pos(mXform.getPosition());
+ LLVector3 target_pos;
+ if (mXform.isRoot())
+ {
+ // get root position in your agent's region
+ target_pos = mVObjp->getPositionAgent();
+ }
+ else
+ {
+ // parent-relative position
+ target_pos = mVObjp->getPosition();
+ }
+
// Rotation
LLQuaternion old_rot(mXform.getRotation());
LLQuaternion target_rot = mVObjp->getRotation();
-
//scaling
LLVector3 target_scale = mVObjp->getScale();
LLVector3 old_scale = mCurrentScale;
- LLVector3 dest_scale = target_scale;
- LLVector3 scale_vec = old_scale-target_scale;
-
- static const F32 dot_threshold = 1.0f - FLT_EPSILON;
-
- F32 dist_squared = dist_vec_squared(old_pos, target_pos);
-
- bool translated = dist_squared > 0.0f;
- bool rotated = !mVObjp->getAngularVelocity().isExactlyZero() || (dot(old_rot, target_rot) < dot_threshold);
- bool scaled = (scale_vec * scale_vec) > MIN_INTERPOLATE_DISTANCE_SQUARED;
- // Damping
+ // Damping
+ F32 dist_squared = 0.f;
+ F32 camdist2 = (mDistanceWRTCamera * mDistanceWRTCamera);
+
if (damped && isVisible())
{
- F32 lerp_amt = LLCriticalDamp::getInterpolant(InterpDeltaObjectDampingConstant);
+ 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, old_pos);
+ dist_squared = dist_vec_squared(new_pos, target_pos);
LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot);
- dist_squared += fabs(1.f - dot(new_rot, old_rot)) * 10.f;
+ // 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, old_scale);
+ dist_squared += dist_vec_squared(new_scale, target_scale);
- // If our lerp isn't moving too far, substitue the lerp'd pos for our target for this frame
- //
- if (dist_squared <= MAX_INTERPOLATE_DISTANCE_SQUARED)
+ 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())
{
- llinfos << "skipping update due to overly large lerp" << llendl;
+ // 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
+ {
+ // The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275
+ // dist_squared = dist_vec_squared(old_pos, target_pos);
- if (translated || rotated || scaled)
- {
- if (scaled)
- {
- mCurrentScale = target_scale;
- }
+ // 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);
+ }
+ LLVector3 vec = mCurrentScale-target_scale;
+
+ if (vec*vec > MIN_INTERPOLATE_DISTANCE_SQUARED)
+ { //scale change requires immediate rebuild
+ mCurrentScale = target_scale;
+ gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
+ }
+ else if (!isRoot() &&
+ (!mVObjp->getAngularVelocity().isExactlyZero() ||
+ dist_squared > 0.f))
+ { //child prim moving relative to parent, tag as needing to be rendered atomically and rebuild
dist_squared = 1.f; //keep this object on the move list
-
- //child prim moving relative to parent, tag as needing to be rendered atomically
- //
- if (!isRoot() && !isState(LLDrawable::ANIMATED_CHILD))
+ if (!isState(LLDrawable::ANIMATED_CHILD))
{
setState(LLDrawable::ANIMATED_CHILD);
+ gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);
+ mVObjp->dirtySpatialGroup();
}
-
- // Mark any components that need to be rebuilt based on what change transpired
- //
- if (!rotated && !scaled)
+ }
+ else if (!isRoot() &&
+ ((dist_vec_squared(old_pos, target_pos) > 0.f)
+ || (1.f - dot(old_rot, target_rot)) > 0.f))
+ { //fix for BUG-840, MAINT-2275, MAINT-1742, MAINT-2247
gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
- else
- gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);
-
- mVObjp->dirtySpatialGroup();
}
else if (!getVOVolume() && !isAvatar())
{
@@ -634,20 +647,10 @@ BOOL LLDrawable::updateMove()
{
return FALSE;
}
-
+
makeActive();
- BOOL done;
-
- if (isState(MOVE_UNDAMPED))
- {
- done = updateMoveUndamped();
- }
- else
- {
- done = updateMoveDamped();
- }
- return done;
+ return isState(MOVE_UNDAMPED) ? updateMoveUndamped() : updateMoveDamped();
}
BOOL LLDrawable::updateMoveUndamped()
@@ -1233,7 +1236,6 @@ LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)
LLCamera ret = camera;
LLXformMatrix* mat = mDrawable->getXform();
LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix();
- LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix());
LLVector3 delta = ret.getOrigin() - center;
LLQuaternion rot = ~mat->getRotation();