@@ -639,6 +639,15 @@ void LLVOVolume::animateTextures()
639
639
if (!facep->mTextureMatrix )
640
640
{
641
641
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
+ }
642
651
}
643
652
644
653
LLMatrix4& tex_mat = *facep->mTextureMatrix ;
@@ -784,7 +793,24 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
784
793
LLFace* face = mDrawable ->getFace (i);
785
794
if (!face) continue ;
786
795
const LLTextureEntry *te = face->getTextureEntry ();
787
- LLViewerTexture *imagep = face->getTexture ();
796
+ LLViewerTexture *imagep = nullptr ;
797
+ U32 ch_min;
798
+ U32 ch_max;
799
+ if (!te->getGLTFRenderMaterial ())
800
+ {
801
+ ch_min = LLRender::DIFFUSE_MAP;
802
+ ch_max = LLRender::SPECULAR_MAP;
803
+ }
804
+ else
805
+ {
806
+ ch_min = LLRender::BASECOLOR_MAP;
807
+ ch_max = LLRender::EMISSIVE_MAP;
808
+ }
809
+ for (U32 ch = ch_min; (!imagep && ch <= ch_max); ++ch)
810
+ {
811
+ // Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else)
812
+ imagep = face->getTexture (ch);
813
+ }
788
814
if (!imagep || !te ||
789
815
face->mExtents [0 ].equals3 (face->mExtents [1 ]))
790
816
{
@@ -812,12 +838,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
812
838
// if the face has gotten small enough to turn off texture animation and texture
813
839
// animation is running, rebuild the render batch for this face to turn off
814
840
// 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.
815
845
if (face->mTextureMatrix != NULL )
816
846
{
817
- if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
818
- (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
847
+ if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
819
848
{
820
849
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 ());
821
860
}
822
861
}
823
862
0 commit comments