Skip to content

Commit 01f5163

Browse files
committed
#2768: Fix for PBR texture animations sometimes not starting
1 parent cb80ce3 commit 01f5163

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

indra/newview/llvovolume.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,15 @@ void LLVOVolume::animateTextures()
641641
if (!facep->mTextureMatrix)
642642
{
643643
facep->mTextureMatrix = new LLMatrix4();
644+
if (facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
645+
{
646+
// Fix the one edge case missed in
647+
// LLVOVolume::updateTextureVirtualSize when the
648+
// mTextureMatrix is not yet present
649+
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
650+
mDrawable->getSpatialGroup()->dirtyGeom();
651+
gPipeline.markRebuild(mDrawable->getSpatialGroup());
652+
}
644653
}
645654

646655
LLMatrix4& tex_mat = *facep->mTextureMatrix;
@@ -832,12 +841,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
832841
// if the face has gotten small enough to turn off texture animation and texture
833842
// animation is running, rebuild the render batch for this face to turn off
834843
// texture animation
844+
// Do the opposite when the face gets big enough.
845+
// If a face is animatable, it will always have non-null mTextureMatrix
846+
// pointer defined after the first call to LLVOVolume::animateTextures,
847+
// although the animation is not always turned on.
835848
if (face->mTextureMatrix != NULL)
836849
{
837-
if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
838-
(vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
850+
if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
839851
{
840852
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
853+
// dirtyGeom+markRebuild tells the engine to call
854+
// LLVolumeGeometryManager::rebuildGeom, which rebuilds the
855+
// LLDrawInfo for the spatial group containing this LLFace,
856+
// safely copying the mTextureMatrix from the LLFace the the
857+
// LLDrawInfo. While it's not ideal to call it here, prims with
858+
// animated faces get moved to a smaller partition to reduce
859+
// side-effects of their updates (see shrinkWrap in
860+
// LLVOVolume::animateTextures).
861+
mDrawable->getSpatialGroup()->dirtyGeom();
862+
gPipeline.markRebuild(mDrawable->getSpatialGroup());
841863
}
842864
}
843865

0 commit comments

Comments
 (0)