summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rw-r--r--indra/newview/llvovolume.cpp101
1 files changed, 69 insertions, 32 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 9b63875ffe..7740376d5c 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -639,6 +639,15 @@ void LLVOVolume::animateTextures()
if (!facep->mTextureMatrix)
{
facep->mTextureMatrix = new LLMatrix4();
+ if (facep->getVirtualSize() > MIN_TEX_ANIM_SIZE)
+ {
+ // Fix the one edge case missed in
+ // LLVOVolume::updateTextureVirtualSize when the
+ // mTextureMatrix is not yet present
+ gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
+ mDrawable->getSpatialGroup()->dirtyGeom();
+ gPipeline.markRebuild(mDrawable->getSpatialGroup());
+ }
}
LLMatrix4& tex_mat = *facep->mTextureMatrix;
@@ -782,11 +791,29 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
for (S32 i = 0; i < num_faces; i++)
{
LLFace* face = mDrawable->getFace(i);
- if (!face) continue;
+ if (!face || face->mExtents[0].equals3(face->mExtents[1])) continue;
const LLTextureEntry *te = face->getTextureEntry();
- LLViewerTexture *imagep = face->getTexture();
- if (!imagep || !te ||
- face->mExtents[0].equals3(face->mExtents[1]))
+ if (!te) continue;
+
+ LLViewerTexture *imagep = nullptr;
+ U32 ch_min;
+ U32 ch_max;
+ if (!te->getGLTFRenderMaterial())
+ {
+ ch_min = LLRender::DIFFUSE_MAP;
+ ch_max = LLRender::SPECULAR_MAP;
+ }
+ else
+ {
+ ch_min = LLRender::BASECOLOR_MAP;
+ ch_max = LLRender::EMISSIVE_MAP;
+ }
+ for (U32 ch = ch_min; (!imagep && ch <= ch_max); ++ch)
+ {
+ // Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else)
+ imagep = face->getTexture(ch);
+ }
+ if (!imagep)
{
continue;
}
@@ -812,12 +839,25 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
// if the face has gotten small enough to turn off texture animation and texture
// animation is running, rebuild the render batch for this face to turn off
// texture animation
+ // Do the opposite when the face gets big enough.
+ // If a face is animatable, it will always have non-null mTextureMatrix
+ // pointer defined after the first call to LLVOVolume::animateTextures,
+ // although the animation is not always turned on.
if (face->mTextureMatrix != NULL)
{
- if ((vsize < MIN_TEX_ANIM_SIZE && old_size > MIN_TEX_ANIM_SIZE) ||
- (vsize > MIN_TEX_ANIM_SIZE && old_size < MIN_TEX_ANIM_SIZE))
+ if ((vsize > MIN_TEX_ANIM_SIZE) != (old_size > MIN_TEX_ANIM_SIZE))
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_TCOORD);
+ // dirtyGeom+markRebuild tells the engine to call
+ // LLVolumeGeometryManager::rebuildGeom, which rebuilds the
+ // LLDrawInfo for the spatial group containing this LLFace,
+ // safely copying the mTextureMatrix from the LLFace the the
+ // LLDrawInfo. While it's not ideal to call it here, prims with
+ // animated faces get moved to a smaller partition to reduce
+ // side-effects of their updates (see shrinkWrap in
+ // LLVOVolume::animateTextures).
+ mDrawable->getSpatialGroup()->dirtyGeom();
+ gPipeline.markRebuild(mDrawable->getSpatialGroup());
}
}
@@ -3210,6 +3250,7 @@ void LLVOVolume::updateSpotLightPriority()
{
return;
}
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
F32 r = getLightRadius();
LLVector3 pos = mDrawable->getPositionAgent();
@@ -3656,7 +3697,7 @@ const LLMeshSkinInfo* LLVOVolume::getSkinInfo() const
// virtual
bool LLVOVolume::isRiggedMesh() const
{
- return isMesh() && getSkinInfo();
+ return getSkinInfo() != nullptr;
}
//----------------------------------------------------------------------------
@@ -3817,7 +3858,6 @@ void LLVOVolume::updateRiggingInfo()
LLVolume *volume = getVolume();
if (skin && avatar && volume)
{
- LL_DEBUGS("RigSpammish") << "starting, vovol " << this << " lod " << getLOD() << " last " << mLastRiggingInfoLOD << LL_ENDL;
if (getLOD()>mLastRiggingInfoLOD || getLOD()==3)
{
// Rigging info may need update
@@ -3833,9 +3873,6 @@ void LLVOVolume::updateRiggingInfo()
}
// Keep the highest LOD info available.
mLastRiggingInfoLOD = getLOD();
- LL_DEBUGS("RigSpammish") << "updated rigging info for LLVOVolume "
- << this << " lod " << mLastRiggingInfoLOD
- << LL_ENDL;
}
}
}
@@ -5864,7 +5901,23 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{
if (gltf_mat != nullptr)
{
- add_face(sPbrFaces, pbr_count, facep);
+ // In theory, we should never actually get here with alpha blending.
+ // How this is supposed to work is we check if the surface is alpha blended, and we assign it to the
+ // alpha draw pool. For rigged meshes, this apparently may not happen consistently. For now, just
+ // discard it here if the alpha is 0 (fully transparent) to achieve parity with blinn-phong materials in
+ // function.
+ bool should_render = true;
+ if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)
+ {
+ if (gltf_mat->mBaseColor.mV[3] == 0.0f)
+ {
+ should_render = false;
+ }
+ }
+ if (should_render)
+ {
+ add_face(sPbrFaces, pbr_count, facep);
+ }
}
else
{
@@ -6026,8 +6079,8 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
group->mBuilt = 1.f;
- const U32 MAX_BUFFER_COUNT = 4096;
- LLVertexBuffer* locked_buffer[MAX_BUFFER_COUNT];
+ static std::vector<LLVertexBuffer*> locked_buffer;
+ locked_buffer.resize(0);
U32 buffer_count = 0;
@@ -6072,8 +6125,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
group->dirtyGeom();
gPipeline.markRebuild(group);
}
-
- buff->unmapBuffer();
}
}
}
@@ -6089,17 +6140,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
{
LL_PROFILE_ZONE_NAMED("rebuildMesh - flush");
- for (LLVertexBuffer** iter = locked_buffer, ** end_iter = locked_buffer+buffer_count; iter != end_iter; ++iter)
- {
- (*iter)->unmapBuffer();
- }
-
- // don't forget alpha
- if(group != NULL &&
- !group->mVertexBuffer.isNull())
- {
- group->mVertexBuffer->unmapBuffer();
- }
+ LLVertexBuffer::flushBuffers();
}
group->clearState(LLSpatialGroup::MESH_DIRTY | LLSpatialGroup::NEW_DRAWINFO);
@@ -6498,6 +6539,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND)
{
registerFace(group, facep, LLRenderPass::PASS_ALPHA);
+ is_alpha = true;
}
else if (gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK)
{
@@ -6781,11 +6823,6 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
++face_iter;
}
-
- if (buffer)
- {
- buffer->unmapBuffer();
- }
}
group->mBufferMap[mask].clear();