@@ -641,6 +641,15 @@ void LLVOVolume::animateTextures()
641
641
if (!facep->mTextureMatrix )
642
642
{
643
643
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
+ }
644
653
}
645
654
646
655
LLMatrix4& tex_mat = *facep->mTextureMatrix ;
@@ -832,12 +841,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
832
841
// if the face has gotten small enough to turn off texture animation and texture
833
842
// animation is running, rebuild the render batch for this face to turn off
834
843
// 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.
835
848
if (face->mTextureMatrix != NULL )
836
849
{
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))
839
851
{
840
852
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 ());
841
863
}
842
864
}
843
865
@@ -5409,7 +5431,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
5409
5431
info->mEnd - draw_vec[idx]->mStart + facep->getGeomCount () <= (U32) gGLManager .mGLMaxVertexRange &&
5410
5432
info->mCount + facep->getIndicesCount () <= (U32) gGLManager .mGLMaxIndexRange &&
5411
5433
#endif
5412
- info->mMaterialID == mat_id &&
5434
+ info->mMaterialHash == mat_id &&
5413
5435
info->mFullbright == fullbright &&
5414
5436
info->mBump == bump &&
5415
5437
(!mat || (info->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different
@@ -5468,11 +5490,11 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
5468
5490
if (gltf_mat)
5469
5491
{
5470
5492
// just remember the material ID, render pools will reference the GLTF material
5471
- draw_info->mMaterialID = mat_id;
5493
+ draw_info->mMaterialHash = mat_id;
5472
5494
}
5473
5495
else if (mat)
5474
5496
{
5475
- draw_info->mMaterialID = mat_id;
5497
+ draw_info->mMaterialHash = mat_id;
5476
5498
5477
5499
// We have a material. Update our draw info accordingly.
5478
5500
@@ -5504,10 +5526,10 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
5504
5526
}
5505
5527
}
5506
5528
5507
- // if (type == LLRenderPass::PASS_ALPHA) // always populate the draw_info ptr
5508
- { // for alpha sorting
5509
- facep-> setDrawInfo ( draw_info);
5510
- }
5529
+ // This backpointer is used by alpha sorting and avatar attachment
5530
+ // accounting.
5531
+ // To be safe, always populate the draw_info ptr.
5532
+ facep-> setDrawInfo (draw_info);
5511
5533
5512
5534
if (index < FACE_DO_NOT_BATCH_TEXTURES)
5513
5535
{ // initialize texture list for texture batching
@@ -6129,7 +6151,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
6129
6151
LLVertexBuffer::flushBuffers ();
6130
6152
}
6131
6153
6132
- group->clearState (LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO );
6154
+ group->clearState (LLSpatialGroup::MESH_DIRTY);
6133
6155
}
6134
6156
}
6135
6157
}
0 commit comments