summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerobject.cpp
diff options
context:
space:
mode:
authorLogan Dethrow <log@lindenlab.com>2012-12-07 17:50:37 -0500
committerLogan Dethrow <log@lindenlab.com>2012-12-07 17:50:37 -0500
commitb6a7c8fcfdaf9220accf832a4dc07efcd08c6eeb (patch)
tree621f992abc5e2d0ccc596a824ba70828c463ae87 /indra/newview/llviewerobject.cpp
parent954200e97f0283a2f16d19601129d64fb16449c2 (diff)
parenta15ec8d014307da35b792659964cd5478d1aafe7 (diff)
Merge in backed out changes.
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
-rw-r--r--indra/newview/llviewerobject.cpp209
1 files changed, 42 insertions, 167 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 97783d843e..b2bd547811 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -199,6 +199,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
mID(id),
mLocalID(0),
mTotalCRC(0),
+ mListIndex(-1),
mTEImages(NULL),
mGLName(0),
mbCanSelect(TRUE),
@@ -237,7 +238,6 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
mRotTime(0.f),
mAngularVelocityRot(),
mPreviousRotation(),
- mJointInfo(NULL),
mState(0),
mMedia(NULL),
mClickAction(0),
@@ -283,12 +283,6 @@ LLViewerObject::~LLViewerObject()
mInventory = NULL;
}
- if (mJointInfo)
- {
- delete mJointInfo;
- mJointInfo = NULL;
- }
-
if (mPartSourcep)
{
mPartSourcep->setDead();
@@ -339,9 +333,6 @@ void LLViewerObject::markDead()
if (getParent())
{
((LLViewerObject *)getParent())->removeChild(this);
- // go ahead and delete any jointinfo's that we find
- delete mJointInfo;
- mJointInfo = NULL;
}
// Mark itself as dead
@@ -744,7 +735,7 @@ void LLViewerObject::addThisAndNonJointChildren(std::vector<LLViewerObject*>& ob
iter != mChildList.end(); iter++)
{
LLViewerObject* child = *iter;
- if ( (!child->isAvatar()) && (!child->isJointChild()))
+ if ( (!child->isAvatar()))
{
child->addThisAndNonJointChildren(objects);
}
@@ -795,6 +786,12 @@ BOOL LLViewerObject::setDrawableParent(LLDrawable* parentp)
LLDrawable* old_parent = mDrawable->mParent;
mDrawable->mParent = parentp;
+ if (parentp && mDrawable->isActive())
+ {
+ parentp->makeActive();
+ parentp->setState(LLDrawable::ACTIVE_CHILD);
+ }
+
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE);
if( (old_parent != parentp && old_parent)
|| (parentp && parentp->isActive()))
@@ -1235,12 +1232,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
coloru.mV[3] = 255 - coloru.mV[3];
mText->setColor(LLColor4(coloru));
mText->setString(temp_string);
-
- if (mDrawable.notNull())
- {
- setChanged(MOVED | SILHOUETTE);
- gPipeline.markMoved(mDrawable, FALSE); // undamped
- }
+
+ setChanged(MOVED | SILHOUETTE);
}
else if (mText.notNull())
{
@@ -1297,26 +1290,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
}
}
- U8 joint_type = 0;
- mesgsys->getU8Fast(_PREHASH_ObjectData, _PREHASH_JointType, joint_type, block_num);
- if (joint_type)
- {
- // create new joint info
- if (!mJointInfo)
- {
- mJointInfo = new LLVOJointInfo;
- }
- mJointInfo->mJointType = (EHavokJointType) joint_type;
- mesgsys->getVector3Fast(_PREHASH_ObjectData, _PREHASH_JointPivot, mJointInfo->mPivot, block_num);
- mesgsys->getVector3Fast(_PREHASH_ObjectData, _PREHASH_JointAxisOrAnchor, mJointInfo->mAxisOrAnchor, block_num);
- }
- else if (mJointInfo)
- {
- // this joint info is no longer needed
- delete mJointInfo;
- mJointInfo = NULL;
- }
-
break;
}
@@ -1435,8 +1408,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
val = (U16 *) &data[count];
#endif
new_angv.set(U16_to_F32(val[VX], -size, size),
- U16_to_F32(val[VY], -size, size),
- U16_to_F32(val[VZ], -size, size));
+ U16_to_F32(val[VY], -size, size),
+ U16_to_F32(val[VZ], -size, size));
setAngularVelocity(new_angv);
break;
@@ -1462,8 +1435,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
new_rot.mQ[VW] = U8_to_F32(data[12], -1.f, 1.f);
new_angv.set(U8_to_F32(data[13], -size, size),
- U8_to_F32(data[14], -size, size),
- U8_to_F32(data[15], -size, size));
+ U8_to_F32(data[14], -size, size),
+ U8_to_F32(data[15], -size, size) );
setAngularVelocity(new_angv);
break;
}
@@ -1537,8 +1510,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
dp->unpackU16(val[VY], "AccY");
dp->unpackU16(val[VZ], "AccZ");
new_angv.set(U16_to_F32(val[VX], -64.f, 64.f),
- U16_to_F32(val[VY], -64.f, 64.f),
- U16_to_F32(val[VZ], -64.f, 64.f));
+ U16_to_F32(val[VY], -64.f, 64.f),
+ U16_to_F32(val[VZ], -64.f, 64.f));
setAngularVelocity(new_angv);
}
break;
@@ -1967,14 +1940,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
cur_parentp->removeChild(this);
- if (mJointInfo && !parent_id)
- {
- // since this object is no longer parent-relative
- // we make sure we delete any joint info
- delete mJointInfo;
- mJointInfo = NULL;
- }
-
setChanged(MOVED | SILHOUETTE);
if (mDrawable.notNull())
@@ -2082,7 +2047,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
}
else if (new_angv != old_angv)
{
- if (flagUsePhysics() || new_angv.isExactlyZero())
+ if (flagUsePhysics())
{
resetRot();
}
@@ -2100,7 +2065,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
setChanged(ROTATED | SILHOUETTE);
}
-
if ( gShowObjectUpdates )
{
LLColor4 color;
@@ -2115,9 +2079,15 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
gPipeline.addDebugBlip(getPositionAgent(), color);
}
- if ((0.0f == vel_mag_sq) &&
- (0.0f == accel_mag_sq) &&
- (0.0f == getAngularVelocity().magVecSquared()))
+ const F32 MAG_CUTOFF = F_APPROXIMATELY_ZERO;
+
+ llassert(vel_mag_sq >= 0.f);
+ llassert(accel_mag_sq >= 0.f);
+ llassert(getAngularVelocity().magVecSquared() >= 0.f);
+
+ if ((MAG_CUTOFF >= vel_mag_sq) &&
+ (MAG_CUTOFF >= accel_mag_sq) &&
+ (MAG_CUTOFF >= getAngularVelocity().magVecSquared()))
{
mStatic = TRUE; // This object doesn't move!
}
@@ -2188,17 +2158,13 @@ BOOL LLViewerObject::isActive() const
-BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
+void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
{
- static LLFastTimer::DeclareTimer ftm("Viewer Object");
- LLFastTimer t(ftm);
+ //static LLFastTimer::DeclareTimer ftm("Viewer Object");
+ //LLFastTimer t(ftm);
- if (mDead)
+ if (!mDead)
{
- // It's dead. Don't update it.
- return TRUE;
- }
-
// CRO - don't velocity interp linked objects!
// Leviathan - but DO velocity interp joints
if (!mStatic && sVelocityInterpolate && !isSelected())
@@ -2207,88 +2173,12 @@ BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
F32 dt_raw = (F32)(time - mLastInterpUpdateSecs);
F32 dt = mTimeDilation * dt_raw;
- if (!mJointInfo)
- {
applyAngularVelocity(dt);
- }
- LLViewerObject *parentp = (LLViewerObject *) getParent();
- if (mJointInfo)
- {
- if (parentp)
- {
- // do parent-relative stuff
- LLVector3 ang_vel = getAngularVelocity();
- F32 omega = ang_vel.magVecSquared();
- F32 angle = 0.0f;
- LLQuaternion dQ;
- if (omega > 0.00001f)
+ if (isAttachment())
{
- omega = sqrt(omega);
- angle = omega * dt;
- dQ.setQuat(angle, ang_vel);
- }
- LLVector3 pos = getPosition();
-
- if (HJT_HINGE == mJointInfo->mJointType)
- {
- // hinge = uniform circular motion
- LLVector3 parent_pivot = getVelocity();
- LLVector3 parent_axis = getAcceleration();
-
- angle = dt * (ang_vel * mJointInfo->mAxisOrAnchor); // AxisOrAnchor = axis
- dQ.setQuat(angle, mJointInfo->mAxisOrAnchor); // AxisOrAnchor = axis
- LLVector3 pivot_offset = pos - mJointInfo->mPivot; // pos in pivot-frame
- pivot_offset = pivot_offset * dQ; // new rotated pivot-frame pos
- pos = mJointInfo->mPivot + pivot_offset; // parent-frame
- LLViewerObject::setPosition(pos);
- LLQuaternion Q_PC = getRotation();
- setRotation(Q_PC * dQ);
mLastInterpUpdateSecs = time;
- }
- else if (HJT_POINT == mJointInfo->mJointType)
- // || HJT_LPOINT == mJointInfo->mJointType)
- {
- // point-to-point = spin about axis and uniform circular motion
- // of axis about the pivot point
- //
- // NOTE: this interpolation scheme is not quite good enough to
- // reduce the bandwidth -- needs a gravitational correction.
- // Similarly for hinges with axes that deviate from vertical.
-
- LLQuaternion Q_PC = getRotation();
- Q_PC = Q_PC * dQ;
- setRotation(Q_PC);
-
- LLVector3 pivot_to_child = - mJointInfo->mAxisOrAnchor; // AxisOrAnchor = anchor
- pos = mJointInfo->mPivot + pivot_to_child * Q_PC;
- LLViewerObject::setPosition(pos);
- mLastInterpUpdateSecs = time;
- }
- /* else if (HJT_WHEEL == mJointInfo->mJointInfo)
- {
- // wheel = uniform rotation about axis, with linear
- // velocity interpolation (if any)
- LLVector3 parent_axis = getAcceleration(); // HACK -- accel stores the parent-axis (parent-frame)
-
- LLQuaternion Q_PC = getRotation();
-
- angle = dt * (parent_axis * ang_vel);
- dQ.setQuat(angle, parent_axis);
-
- Q_PC = Q_PC * dQ;
- setRotation(Q_PC);
-
- pos = getPosition() + dt * getVelocity();
- LLViewerObject::setPosition(pos);
- mLastInterpUpdateSecs = time;
- }*/
- }
- }
- else if (isAttachment())
- {
- mLastInterpUpdateSecs = time;
- return TRUE;
+ return;
}
else
{ // Move object based on it's velocity and rotation
@@ -2297,8 +2187,7 @@ BOOL LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
}
updateDrawable(FALSE);
-
- return TRUE;
+ }
}
@@ -3888,15 +3777,6 @@ void LLViewerObject::setPositionEdit(const LLVector3 &pos_edit, BOOL damped)
((LLViewerObject *)getParent())->setPositionEdit(pos_edit - position_offset);
updateDrawable(damped);
}
- else if (isJointChild())
- {
- // compute new parent-relative position
- LLViewerObject *parent = (LLViewerObject *) getParent();
- LLQuaternion inv_parent_rot = parent->getRotation();
- inv_parent_rot.transQuat();
- LLVector3 pos_parent = (pos_edit - parent->getPositionRegion()) * inv_parent_rot;
- LLViewerObject::setPosition(pos_parent, damped);
- }
else
{
LLViewerObject::setPosition(pos_edit, damped);
@@ -3910,8 +3790,7 @@ LLViewerObject* LLViewerObject::getRootEdit() const
{
const LLViewerObject* root = this;
while (root->mParent
- && !(root->mJointInfo
- || ((LLViewerObject*)root->mParent)->isAvatar()) )
+ && !((LLViewerObject*)root->mParent)->isAvatar())
{
root = (LLViewerObject*)root->mParent;
}
@@ -4620,19 +4499,11 @@ void LLViewerObject::clearIcon()
LLViewerObject* LLViewerObject::getSubParent()
{
- if (isJointChild())
- {
- return this;
- }
return (LLViewerObject*) getParent();
}
const LLViewerObject* LLViewerObject::getSubParent() const
{
- if (isJointChild())
- {
- return this;
- }
return (const LLViewerObject*) getParent();
}
@@ -4811,9 +4682,11 @@ void LLViewerObject::deleteParticleSource()
// virtual
void LLViewerObject::updateDrawable(BOOL force_damped)
{
- if (mDrawable.notNull() &&
- !mDrawable->isState(LLDrawable::ON_MOVE_LIST) &&
- isChanged(MOVED))
+ if (!isChanged(MOVED))
+ { //most common case, having an empty if case here makes for better branch prediction
+ }
+ else if (mDrawable.notNull() &&
+ !mDrawable->isState(LLDrawable::ON_MOVE_LIST))
{
BOOL damped_motion =
!isChanged(SHIFTED) && // not shifted between regions this frame and...
@@ -5500,9 +5373,12 @@ BOOL LLViewerObject::setFlagsWithoutUpdate(U32 flags, BOOL state)
void LLViewerObject::setPhysicsShapeType(U8 type)
{
mPhysicsShapeUnknown = false;
+ if (type != mPhysicsShapeType)
+ {
mPhysicsShapeType = type;
mCostStale = true;
}
+}
void LLViewerObject::setPhysicsGravity(F32 gravity)
{
@@ -5528,7 +5404,6 @@ U8 LLViewerObject::getPhysicsShapeType() const
{
if (mPhysicsShapeUnknown)
{
- mPhysicsShapeUnknown = false;
gObjectList.updatePhysicsFlags(this);
}