Skip to content

Commit ff856af

Browse files
committed
#2768: Fix for PBR texture animations sometimes not starting
1 parent 5d62cdb commit ff856af

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
@@ -639,6 +639,15 @@ void LLVOVolume::animateTextures()
639639
if (!facep->mTextureMatrix)
640640
{
641641
facep->mTextureMatrix = new LLMatrix4();
642+
if (facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
643+
{
644+
// Fix the one edge case missed in
645+
// LLVOVolume::updateTextureVirtualSize when the
646+
// mTextureMatrix is not yet present
647+
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
648+
mDrawable->getSpatialGroup()->dirtyGeom();
649+
gPipeline.markRebuild(mDrawable->getSpatialGroup());
650+
}
642651
}
643652

644653
LLMatrix4& tex_mat = *facep->mTextureMatrix;
@@ -829,12 +838,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
829838
// if the face has gotten small enough to turn off texture animation and texture
830839
// animation is running, rebuild the render batch for this face to turn off
831840
// texture animation
841+
// Do the opposite when the face gets big enough.
842+
// If a face is animatable, it will always have non-null mTextureMatrix
843+
// pointer defined after the first call to LLVOVolume::animateTextures,
844+
// although the animation is not always turned on.
832845
if (face->mTextureMatrix != NULL)
833846
{
834-
if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
835-
(vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
847+
if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
836848
{
837849
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
850+
// dirtyGeom+markRebuild tells the engine to call
851+
// LLVolumeGeometryManager::rebuildGeom, which rebuilds the
852+
// LLDrawInfo for the spatial group containing this LLFace,
853+
// safely copying the mTextureMatrix from the LLFace the the
854+
// LLDrawInfo. While it's not ideal to call it here, prims with
855+
// animated faces get moved to a smaller partition to reduce
856+
// side-effects of their updates (see shrinkWrap in
857+
// LLVOVolume::animateTextures).
858+
mDrawable->getSpatialGroup()->dirtyGeom();
859+
gPipeline.markRebuild(mDrawable->getSpatialGroup());
838860
}
839861
}
840862

0 commit comments

Comments
 (0)