Skip to content

Commit 7ef6e8f

Browse files
authored
Merge pull request #3143 from secondlife/v-2768_extrafps
#2768, #2848: Partial cherry pick of "Animated pbr textures don't animate" from develop
2 parents feb6b39 + ff856af commit 7ef6e8f

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

indra/newview/llvovolume.cpp

Lines changed: 42 additions & 3 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;
@@ -784,7 +793,24 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
784793
LLFace* face = mDrawable->getFace(i);
785794
if (!face) continue;
786795
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+
}
788814
if (!imagep || !te ||
789815
face->mExtents[0].equals3(face->mExtents[1]))
790816
{
@@ -812,12 +838,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
812838
// if the face has gotten small enough to turn off texture animation and texture
813839
// animation is running, rebuild the render batch for this face to turn off
814840
// 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.
815845
if (face->mTextureMatrix != NULL)
816846
{
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))
819848
{
820849
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());
821860
}
822861
}
823862

0 commit comments

Comments
 (0)