summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-04-16 15:25:25 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-04-16 15:25:25 -0400
commit78d985c154b0d71064b89891f5b2005e48c300ce (patch)
treec43bc6be58ec9b30f0f4dfaa6c027736fb331582 /indra/llmath
parent6c2a278c3dbd9d0660be5e9f6ec1c756af7cb992 (diff)
parenta3cbd41543258818589dd0e368c68d2dc62b3398 (diff)
Merge branch 'main' into release/luau-scripting
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llvolume.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 6d36daa92a..e694732da2 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5592,9 +5592,9 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
U32 stream_count = data.w.empty() ? 4 : 5;
- U32 vert_count = meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count);
+ size_t vert_count = meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count);
- if (vert_count < 65535)
+ if (vert_count < 65535 && vert_count != 0)
{
std::vector<U32> indices;
indices.resize(mNumIndices);
@@ -5613,6 +5613,13 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
{
U32 src_idx = i;
U32 dst_idx = remap[i];
+ if (dst_idx >= mNumVertices)
+ {
+ dst_idx = mNumVertices - 1;
+ // Shouldn't happen, figure out what gets returned in remap and why.
+ llassert(false);
+ LL_DEBUGS_ONCE("LLVOLUME") << "Invalid destination index, substituting" << LL_ENDL;
+ }
mIndices[i] = dst_idx;
mPositions[dst_idx].load3(data.p[src_idx].mV);
@@ -5646,6 +5653,10 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
}
else
{
+ if (vert_count == 0)
+ {
+ LL_WARNS_ONCE("LLVOLUME") << "meshopt_generateVertexRemapMulti failed to process a model or model was invalid" << LL_ENDL;
+ }
// blew past the max vertex size limit, use legacy tangent generation which never adds verts
createTangents();
}