Merged in SL-17448 (pull request #1044)
SL-17448: Fix LOD/octree update feedback loops causing LOD fluctuations. Approved-by: Andrey Lihatskiymaster
commit
2f5a5f4151
|
|
@ -1682,7 +1682,7 @@ void LLVOVolume::regenFaces()
|
|||
}
|
||||
}
|
||||
|
||||
BOOL LLVOVolume::genBBoxes(BOOL force_global)
|
||||
BOOL LLVOVolume::genBBoxes(BOOL force_global, BOOL should_update_octree_bounds)
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED;
|
||||
BOOL res = TRUE;
|
||||
|
|
@ -1758,20 +1758,9 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
|
|||
}
|
||||
}
|
||||
|
||||
bool rigged = false;
|
||||
|
||||
if (!isAnimatedObject())
|
||||
{
|
||||
rigged = isRiggedMesh() && isAttachment();
|
||||
}
|
||||
else
|
||||
{
|
||||
rigged = isRiggedMesh() && getControlAvatar() && getControlAvatar()->mPlaying;
|
||||
}
|
||||
|
||||
if (any_valid_boxes)
|
||||
{
|
||||
if (rebuild)
|
||||
if (rebuild && should_update_octree_bounds)
|
||||
{
|
||||
//get the Avatar associated with this object if it's rigged
|
||||
LLVOAvatar* avatar = nullptr;
|
||||
|
|
@ -1933,7 +1922,7 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
|
|||
}
|
||||
}
|
||||
|
||||
bool LLVOVolume::lodOrSculptChanged(LLDrawable *drawable, BOOL &compiled)
|
||||
bool LLVOVolume::lodOrSculptChanged(LLDrawable *drawable, BOOL &compiled, BOOL &should_update_octree_bounds)
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
|
||||
bool regen_faces = false;
|
||||
|
|
@ -1965,6 +1954,9 @@ bool LLVOVolume::lodOrSculptChanged(LLDrawable *drawable, BOOL &compiled)
|
|||
}
|
||||
|
||||
compiled = TRUE;
|
||||
// new_lod > old_lod breaks a feedback loop between LOD updates and
|
||||
// bounding box updates.
|
||||
should_update_octree_bounds = should_update_octree_bounds || mSculptChanged || new_lod > old_lod;
|
||||
sNumLODChanges += new_num_faces;
|
||||
|
||||
if ((S32)getNumTEs() != getVolume()->getNumFaces())
|
||||
|
|
@ -2024,8 +2016,6 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
|
|||
group->dirtyMesh();
|
||||
}
|
||||
|
||||
BOOL compiled = FALSE;
|
||||
|
||||
updateRelativeXform();
|
||||
|
||||
if (mDrawable.isNull()) // Not sure why this is happening, but it is...
|
||||
|
|
@ -2033,49 +2023,55 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
|
|||
return TRUE; // No update to complete
|
||||
}
|
||||
|
||||
BOOL compiled = FALSE;
|
||||
// This should be true in most cases, unless we're sure no octree update is
|
||||
// needed.
|
||||
BOOL should_update_octree_bounds = bool(getRiggedVolume()) || mDrawable->isState(LLDrawable::REBUILD_POSITION) || !mDrawable->getSpatialExtents()->isFinite3();
|
||||
|
||||
if (mVolumeChanged || mFaceMappingChanged)
|
||||
{
|
||||
dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1));
|
||||
|
||||
bool was_regen_faces = false;
|
||||
should_update_octree_bounds = true;
|
||||
|
||||
if (mVolumeChanged)
|
||||
{
|
||||
was_regen_faces = lodOrSculptChanged(drawable, compiled);
|
||||
was_regen_faces = lodOrSculptChanged(drawable, compiled, should_update_octree_bounds);
|
||||
drawable->setState(LLDrawable::REBUILD_VOLUME);
|
||||
}
|
||||
else if (mSculptChanged || mLODChanged || mColorChanged)
|
||||
{
|
||||
compiled = TRUE;
|
||||
was_regen_faces = lodOrSculptChanged(drawable, compiled);
|
||||
was_regen_faces = lodOrSculptChanged(drawable, compiled, should_update_octree_bounds);
|
||||
}
|
||||
|
||||
if (!was_regen_faces) {
|
||||
regenFaces();
|
||||
}
|
||||
|
||||
genBBoxes(FALSE);
|
||||
}
|
||||
else if (mLODChanged || mSculptChanged || mColorChanged)
|
||||
{
|
||||
dirtySpatialGroup(drawable->isState(LLDrawable::IN_REBUILD_Q1));
|
||||
compiled = TRUE;
|
||||
lodOrSculptChanged(drawable, compiled);
|
||||
lodOrSculptChanged(drawable, compiled, should_update_octree_bounds);
|
||||
|
||||
if(drawable->isState(LLDrawable::REBUILD_RIGGED | LLDrawable::RIGGED))
|
||||
{
|
||||
updateRiggedVolume(false);
|
||||
}
|
||||
genBBoxes(FALSE);
|
||||
}
|
||||
// it has its own drawable (it's moved) or it has changed UVs or it has changed xforms from global<->local
|
||||
else
|
||||
{
|
||||
compiled = TRUE;
|
||||
// All it did was move or we changed the texture coordinate offset
|
||||
genBBoxes(FALSE);
|
||||
}
|
||||
|
||||
// Generate bounding boxes if needed, and update the object's size in the
|
||||
// octree
|
||||
genBBoxes(FALSE, should_update_octree_bounds);
|
||||
|
||||
// Update face flags
|
||||
updateFaceFlags();
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public:
|
|||
|
||||
void updateFaceFlags();
|
||||
void regenFaces();
|
||||
BOOL genBBoxes(BOOL force_global);
|
||||
BOOL genBBoxes(BOOL force_global, BOOL should_update_octree_bounds = FALSE);
|
||||
void preRebuild();
|
||||
virtual void updateSpatialExtents(LLVector4a& min, LLVector4a& max);
|
||||
virtual F32 getBinRadius();
|
||||
|
|
@ -393,7 +393,7 @@ protected:
|
|||
void removeMediaImpl(S32 texture_index) ;
|
||||
|
||||
private:
|
||||
bool lodOrSculptChanged(LLDrawable *drawable, BOOL &compiled);
|
||||
bool lodOrSculptChanged(LLDrawable *drawable, BOOL &compiled, BOOL &shouldUpdateOctreeBounds);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue