summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2026-10-13 14:34:41 -0400
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2026-10-13 14:34:41 -0400
commit181fd93f799e15a6ff924362c4a05be8db3639af (patch)
treef3a3a530b80b1b17e71c7b6d7fa8b981b52c61f9 /indra/llmath/llvolume.cpp
parent8ba5d1a8adc47c21b23d9482e72de9517f9a98fc (diff)
parent083db782e29434ab17963fcac76b0ec3cd93b9d0 (diff)
Merge remote-tracking branch 'origin/release/26.5' into geenz/main-26.5
Diffstat (limited to 'indra/llmath/llvolume.cpp')
-rw-r--r--indra/llmath/llvolume.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index d4f3d1ac25..33ec074029 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -58,6 +58,10 @@
#include "meshoptimizer/meshoptimizer.h"
+#if LL_WINDOWS
+#include <llexception.h> //SEH
+#endif
+
#define DEBUG_SILHOUETTE_BINORMALS 0
#define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette
#define DEBUG_SILHOUETTE_EDGE_MAP 0 // DaveP: Use this to display edge map using the silhouette
@@ -5812,6 +5816,28 @@ struct MikktData
}
};
+#if LL_WINDOWS
+static void genTangSpaceCPP(mikk::Mikktspace<MikktData>& ctx)
+{
+ ctx.genTangSpace();
+}
+static bool genTangSpaceSEH(mikk::Mikktspace<MikktData>& ctx)
+{
+ __try
+ {
+ genTangSpaceCPP(ctx);
+ return true;
+ }
+ __except (msc_exception_filter(GetExceptionCode(), GetExceptionInformation()))
+ {
+ // Likely low memory or bad input; abort tangent generation for this
+ // mesh and let the caller decide how to proceed.
+ // (C++ exceptions like std::bad_alloc are not handled here)
+ return false;
+ }
+}
+#endif
+
bool LLVolumeFace::cacheOptimize(bool gen_tangents)
{ //optimize for vertex cache according to Forsyth method:
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME;
@@ -5857,9 +5883,19 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
// and is executed on a background thread
MikktData data(this);
mikk::Mikktspace ctx(data);
+ bool tangent_ok = false;
try
{
+#if LL_WINDOWS
+ tangent_ok = genTangSpaceSEH(ctx);
+ if (!tangent_ok)
+ {
+ LL_WARNS_ONCE("LLVolume") << "SEH exception in Mikktspace::genTangSpace()" << LL_ENDL;
+ }
+#else
ctx.genTangSpace();
+ tangent_ok = true;
+#endif
}
catch (std::bad_alloc&)
{
@@ -5869,6 +5905,10 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
catch (...)
{
LL_WARNS_ONCE("LLVolume") << "Mikktspace::genTangSpace() failed" << LL_ENDL;
+ }
+
+ if (!tangent_ok)
+ {
return false;
}