summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2012-04-19 14:16:49 -0500
committerDave Parks <davep@lindenlab.com>2012-04-19 14:16:49 -0500
commit5334c410ea7552ebc2c758ee8911b3235f76824a (patch)
tree1e088bea09979c561fc920a382bc914c0c8e5bec /indra
parent06bd74502713200d2103b576f7b97e715c1992c1 (diff)
MAINT-775 Don't thrash vertex buffers on animated prims (flexis, spinners, etc).
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/lldrawable.cpp38
-rw-r--r--indra/newview/lldrawable.h1
-rw-r--r--indra/newview/llflexibleobject.cpp8
-rw-r--r--indra/newview/llvovolume.cpp24
-rw-r--r--indra/newview/pipeline.cpp2
5 files changed, 48 insertions, 25 deletions
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 21b21c152a..3b55ac4a3b 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -182,7 +182,7 @@ LLVOVolume* LLDrawable::getVOVolume() const
const LLMatrix4& LLDrawable::getRenderMatrix() const
{
- return isRoot() ? getWorldMatrix() : getParent()->getWorldMatrix();
+ return isRoot() || isState(LLDrawable::ANIMATED_CHILD) ? getWorldMatrix() : getParent()->getWorldMatrix();
}
BOOL LLDrawable::isLight() const
@@ -450,7 +450,7 @@ void LLDrawable::makeStatic(BOOL warning_enabled)
{
if (isState(ACTIVE))
{
- clearState(ACTIVE);
+ clearState(ACTIVE | ANIMATED_CHILD);
if (mParent.notNull() && mParent->isActive() && warning_enabled)
{
@@ -542,21 +542,32 @@ F32 LLDrawable::updateXform(BOOL undamped)
{
// snap to final position
dist_squared = 0.0f;
- if (getVOVolume() && !isRoot())
+ if (getVOVolume() && !isRoot() && !isState(LLDrawable::ANIMATED_CHILD))
{ //child prim snapping to some position, needs a rebuild
+ setState(LLDrawable::ANIMATED_CHILD);
gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
}
}
}
- if ((mCurrentScale != target_scale) ||
- (!isRoot() &&
+ 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() &&
(dist_squared >= MIN_INTERPOLATE_DISTANCE_SQUARED ||
!mVObjp->getAngularVelocity().isExactlyZero() ||
target_pos != mXform.getPosition() ||
- target_rot != mXform.getRotation())))
- { //child prim moving or scale change requires immediate rebuild
- gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
+ target_rot != mXform.getRotation()))
+ { //child prim moving relative to parent, tag as needing to be rendered atomically and rebuild
+ if (!isState(LLDrawable::ANIMATED_CHILD))
+ {
+ setState(LLDrawable::ANIMATED_CHILD);
+ gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE);
+ }
}
else if (!getVOVolume() && !isAvatar())
{
@@ -568,9 +579,7 @@ F32 LLDrawable::updateXform(BOOL undamped)
mXform.setRotation(target_rot);
mXform.setScale(LLVector3(1,1,1)); //no scale in drawable transforms (IT'S A RULE!)
mXform.updateMatrix();
-
- mCurrentScale = target_scale;
-
+
if (mSpatialBridge)
{
gPipeline.markMoved(mSpatialBridge, FALSE);
@@ -651,7 +660,6 @@ BOOL LLDrawable::updateMoveUndamped()
}
mVObjp->clearChanged(LLXform::MOVED);
-
return TRUE;
}
@@ -1529,10 +1537,10 @@ BOOL LLDrawable::isAnimating() const
return TRUE;
}
- if (!isRoot() && !mVObjp->getAngularVelocity().isExactlyZero())
- {
+ /*if (!isRoot() && !mVObjp->getAngularVelocity().isExactlyZero())
+ { //target omega
return TRUE;
- }
+ }*/
return FALSE;
}
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index e268640a21..6a3d15db7f 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -277,6 +277,7 @@ public:
HAS_ALPHA = 0x04000000,
RIGGED = 0x08000000,
PARTITION_MOVE = 0x10000000,
+ ANIMATED_CHILD = 0x20000000,
} EDrawableFlags;
private: //aligned members
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 32a533570a..1876d2dc33 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -368,7 +368,7 @@ void LLVolumeImplFlexible::doFlexibleUpdate()
LLPath *path = &volume->getPath();
if ((mSimulateRes == 0 || !mInitialized) && mVO->mDrawable->isVisible())
{
- mVO->markForUpdate(TRUE);
+ //mVO->markForUpdate(TRUE);
if (!doIdleUpdate(gAgent, *LLWorld::getInstance(), 0.0))
{
return; // we did not get updated or initialized, proceeding without can be dangerous
@@ -729,7 +729,11 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
else if (!mUpdated || rotated)
{
volume->mDrawable->setState(LLDrawable::REBUILD_POSITION);
- volume->dirtyMesh();
+ LLSpatialGroup* group = volume->mDrawable->getSpatialGroup();
+ if (group)
+ {
+ group->dirtyMesh();
+ }
volume->genBBoxes(isVolumeGlobal());
}
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 1193aa50f9..102fe4bab6 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -691,9 +691,9 @@ void LLVOVolume::updateTextures()
{
group->destroyGL(true);
- //flag the group as having changed draw info state so it gets a rebuild next time
+ //flag the group as having changed geometry so it gets a rebuild next time
//it becomes visible
- group->setState(LLSpatialGroup::NEW_DRAWINFO);
+ group->setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO);
}
}
@@ -1524,8 +1524,9 @@ void LLVOVolume::updateRelativeXform()
LLVector3 delta_pos, delta_scale;
//matrix from local space to parent relative/global space
- delta_rot = drawable->isSpatialRoot() ? LLQuaternion() : mDrawable->getRotation();
- delta_pos = drawable->isSpatialRoot() ? LLVector3(0,0,0) : mDrawable->getPosition();
+ bool use_identity = drawable->isSpatialRoot() || drawable->isState(LLDrawable::ANIMATED_CHILD);
+ delta_rot = use_identity ? LLQuaternion() : mDrawable->getRotation();
+ delta_pos = use_identity ? LLVector3(0,0,0) : mDrawable->getPosition();
delta_scale = mDrawable->getScale();
// Vertex transform (4x4)
@@ -1626,7 +1627,11 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
return res;
}
- dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1));
+ LLSpatialGroup* group = drawable->getSpatialGroup();
+ if (group)
+ {
+ group->dirtyMesh();
+ }
BOOL compiled = FALSE;
@@ -1639,6 +1644,8 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
if (mVolumeChanged || mFaceMappingChanged )
{
+ dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1));
+
compiled = TRUE;
if (mVolumeChanged)
@@ -1657,6 +1664,8 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
}
else if ((mLODChanged) || (mSculptChanged))
{
+ dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1));
+
LLVolume *old_volumep, *new_volumep;
F32 old_lod, new_lod;
S32 old_num_faces, new_num_faces ;
@@ -3957,9 +3966,10 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
const LLMatrix4* model_mat = NULL;
LLDrawable* drawable = facep->getDrawable();
+
if (drawable->isActive())
{
- model_mat = &(drawable->getRenderMatrix());
+ model_mat = &drawable->getRenderMatrix();
}
else
{
@@ -4667,7 +4677,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO);
}
- llassert(!group || !group->isState(LLSpatialGroup::NEW_DRAWINFO));
+// llassert(!group || !group->isState(LLSpatialGroup::NEW_DRAWINFO));
}
struct CompareBatchBreakerModified
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index de7296b2dc..5d4258ee30 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1793,7 +1793,7 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list)
drawablep->clearState(LLDrawable::EARLY_MOVE | LLDrawable::MOVE_UNDAMPED);
if (done)
{
- drawablep->clearState(LLDrawable::ON_MOVE_LIST);
+ drawablep->clearState(LLDrawable::ON_MOVE_LIST | LLDrawable::ANIMATED_CHILD);
iter = moved_list.erase(curiter);
}
}