summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-03-01 13:21:16 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2022-03-01 13:41:42 +0200
commit97a103255e433629f13e2156aa307ca329cdcfc6 (patch)
treebf5de1cef5930647c4ab87a0cff7f88f0007832d /indra/llmath/llvolume.cpp
parent92c302d6fba687f0921544b278e22b698d058646 (diff)
parent6ca09a94554ec01f5c94ec60fffd01d7e33f3546 (diff)
Merge branch 'master' (DRTVWR-557) into DRTVWR-546
# Conflicts: # autobuild.xml # doc/contributions.txt # indra/cmake/GLOD.cmake # indra/llcommon/tests/llprocess_test.cpp # indra/newview/VIEWER_VERSION.txt # indra/newview/lldrawpoolavatar.cpp # indra/newview/llfloatermodelpreview.cpp # indra/newview/llmodelpreview.cpp # indra/newview/llviewertexturelist.cpp # indra/newview/llvovolume.cpp # indra/newview/viewer_manifest.py
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-rw-r--r--indra/llmath/llvolume.cpp76
1 files changed, 58 insertions, 18 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index d91a973153..efa1a4076b 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2425,7 +2425,14 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
//copy out indices
- face.resizeIndices(idx.size()/2);
+ S32 num_indices = idx.size() / 2;
+ face.resizeIndices(num_indices);
+
+ if (num_indices > 2 && !face.mIndices)
+ {
+ LL_WARNS() << "Failed to allocate " << num_indices << " indices for face index: " << i << " Total: " << face_count << LL_ENDL;
+ continue;
+ }
if (idx.empty() || face.mNumIndices < 3)
{ //why is there an empty index list?
@@ -2444,6 +2451,13 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
U32 num_verts = pos.size()/(3*2);
face.resizeVertices(num_verts);
+ if (num_verts > 0 && !face.mPositions)
+ {
+ LL_WARNS() << "Failed to allocate " << num_verts << " vertices for face index: " << i << " Total: " << face_count << LL_ENDL;
+ face.resizeIndices(0);
+ continue;
+ }
+
LLVector3 minp;
LLVector3 maxp;
LLVector2 min_tc;
@@ -2545,6 +2559,13 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
if (mdl[i].has("Weights"))
{
face.allocateWeights(num_verts);
+ if (!face.mWeights && num_verts)
+ {
+ LL_WARNS() << "Failed to allocate " << num_verts << " weights for face index: " << i << " Total: " << face_count << LL_ENDL;
+ face.resizeIndices(0);
+ face.resizeVertices(0);
+ continue;
+ }
LLSD::Binary weights = mdl[i]["Weights"];
@@ -5312,22 +5333,23 @@ bool LLVolumeFace::cacheOptimize()
{
triangle_data.resize(mNumIndices / 3);
vertex_data.resize(mNumVertices);
- }
- catch (std::bad_alloc&)
- {
- LL_WARNS("LLVOLUME") << "Resize failed" << LL_ENDL;
- return false;
- }
- for (U32 i = 0; i < mNumIndices; i++)
- { //populate vertex data and triangle data arrays
- U16 idx = mIndices[i];
- U32 tri_idx = i/3;
+ for (U32 i = 0; i < mNumIndices; i++)
+ { //populate vertex data and triangle data arrays
+ U16 idx = mIndices[i];
+ U32 tri_idx = i / 3;
- vertex_data[idx].mTriangles.push_back(&(triangle_data[tri_idx]));
- vertex_data[idx].mIdx = idx;
- triangle_data[tri_idx].mVertex[i%3] = &(vertex_data[idx]);
- }
+ vertex_data[idx].mTriangles.push_back(&(triangle_data[tri_idx]));
+ vertex_data[idx].mIdx = idx;
+ triangle_data[tri_idx].mVertex[i % 3] = &(vertex_data[idx]);
+ }
+ }
+ catch (std::bad_alloc&)
+ {
+ // resize or push_back failed
+ LL_WARNS("LLVOLUME") << "Resize for " << mNumVertices << " vertices failed" << LL_ENDL;
+ return false;
+ }
/*F32 pre_acmr = 1.f;
//measure cache misses from before rebuild
@@ -6363,8 +6385,18 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
mTexCoords = NULL;
}
- mNumVertices = num_verts;
- mNumAllocatedVertices = num_verts;
+
+ if (mPositions)
+ {
+ mNumVertices = num_verts;
+ mNumAllocatedVertices = num_verts;
+ }
+ else
+ {
+ // Either num_verts is zero or allocation failure
+ mNumVertices = 0;
+ mNumAllocatedVertices = 0;
+ }
// Force update
mJointRiggingInfoTab.clear();
@@ -6465,7 +6497,15 @@ void LLVolumeFace::resizeIndices(S32 num_indices)
mIndices = NULL;
}
- mNumIndices = num_indices;
+ if (mIndices)
+ {
+ mNumIndices = num_indices;
+ }
+ else
+ {
+ // Either num_indices is zero or allocation failure
+ mNumIndices = 0;
+ }
}
void LLVolumeFace::pushIndex(const U16& idx)