diff options
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-rw-r--r-- | indra/llmath/llvolume.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 292e8f1ff4..5375e2813b 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -219,7 +219,7 @@ void calc_tangent_from_triangle( // intersect test between triangle vert0, vert1, vert2 and a ray from orig in direction dir. -// returns TRUE if intersecting and returns barycentric coordinates in intersection_a, intersection_b, +// returns true if intersecting and returns barycentric coordinates in intersection_a, intersection_b, // and returns the intersection point along dir in intersection_t. // Moller-Trumbore algorithm @@ -4492,7 +4492,7 @@ void LLVolumeParams::reduceT(F32 begin, F32 end) const F32 MIN_CONCAVE_PROFILE_WEDGE = 0.125f; // 1/8 unity const F32 MIN_CONCAVE_PATH_WEDGE = 0.111111f; // 1/9 unity -// returns TRUE if the shape can be approximated with a convex shape +// returns true if the shape can be approximated with a convex shape // for collison purposes bool LLVolumeParams::isConvex() const { @@ -4656,7 +4656,7 @@ bool LLVolume::isFaceMaskValid(LLFaceID face_mask) bool LLVolume::isConvex() const { - // mParams.isConvex() may return FALSE even though the final + // mParams.isConvex() may return false even though the final // geometry is actually convex due to LOD approximations. // TODO -- provide LLPath and LLProfile with isConvex() methods // that correctly determine convexity. -- Leviathan @@ -5565,9 +5565,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); @@ -5586,6 +5586,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); @@ -5619,6 +5626,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(); } |