summaryrefslogtreecommitdiff
path: root/indra/llmath/llvolume.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-09-22 14:55:07 +0800
committerErik Kundiman <erik@megapahit.org>2026-09-22 14:55:07 +0800
commit66877554dbdec33d28171420a2b4fde65e309e7c (patch)
treebe44385b4713d920bad4f77a4905b87f0eb5254a /indra/llmath/llvolume.cpp
parent9391fa2734ae74e9d49d74f7b2df181b526c6605 (diff)
parent8fb3801667bf5f8fadfe191d8628b2b3cf443273 (diff)
Merge tag 'Second_Life_Develop#8fb38016-2026-09-12' into 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 c49d5ff7d3..df1df32265 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -58,6 +58,10 @@
#include <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
@@ -5963,6 +5967,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;
@@ -6008,9 +6034,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&)
{
@@ -6020,6 +6056,10 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents)
catch (...)
{
LL_WARNS_ONCE("LLVolume") << "Mikktspace::genTangSpace() failed" << LL_ENDL;
+ }
+
+ if (!tangent_ok)
+ {
return false;
}