|
@@ -17,6 +17,13 @@
|
|
|
#include <assimp/scene.h>
|
|
|
#include <assimp/postprocess.h>
|
|
|
|
|
|
+#if AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+#include <csignal>
|
|
|
+#include <cstdlib>
|
|
|
+#include <iostream>
|
|
|
+#include <stdlib.h>
|
|
|
+#endif // AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+
|
|
|
namespace AZ
|
|
|
{
|
|
|
namespace AssImpSDKWrapper
|
|
@@ -34,10 +41,31 @@ namespace AZ
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+#if AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+ void signal_handler(int signal)
|
|
|
+ {
|
|
|
+ AZ_TracePrintf(
|
|
|
+ SceneAPI::Utilities::ErrorWindow,
|
|
|
+ "Failed to import scene with Asset Importer library. An %s has occured in the library, this scene file cannot be parsed by the library.",
|
|
|
+ signal == SIGABRT ? "assert" : "unknown error");
|
|
|
+ }
|
|
|
+#endif // AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+
|
|
|
bool AssImpSceneWrapper::LoadSceneFromFile(const char* fileName)
|
|
|
{
|
|
|
AZ_TracePrintf(SceneAPI::Utilities::LogWindow, "AssImpSceneWrapper::LoadSceneFromFile %s", fileName);
|
|
|
AZ_TraceContext("Filename", fileName);
|
|
|
+
|
|
|
+#if AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+ // Turn off the abort popup because it can disrupt automation.
|
|
|
+ // AssImp calls abort when asserts are enabled, and an assert is encountered.
|
|
|
+#ifdef _WRITE_ABORT_MSG
|
|
|
+ _set_abort_behavior(0, _WRITE_ABORT_MSG);
|
|
|
+#endif // #ifdef _WRITE_ABORT_MSG
|
|
|
+ // Instead, capture any calls to abort with a signal handler, and report them.
|
|
|
+ auto previous_handler = std::signal(SIGABRT, signal_handler);
|
|
|
+#endif // AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+
|
|
|
// aiProcess_JoinIdenticalVertices is not enabled because O3DE has a mesh optimizer that also does this,
|
|
|
// this flag is disabled to keep AssImp output similar to FBX SDK to reduce downstream bugs for the initial AssImp release.
|
|
|
// There's currently a minimum of properties and flags set to maximize compatibility with the existing node graph.
|
|
@@ -49,6 +77,15 @@ namespace AZ
|
|
|
| aiProcess_LimitBoneWeights //Limits the number of bones that can affect a vertex to a maximum value
|
|
|
//dropping the least important and re-normalizing
|
|
|
| aiProcess_GenNormals); //Generate normals for meshes
|
|
|
+
|
|
|
+#if AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+ // Reset abort behavior for anything else that may call abort.
|
|
|
+ std::signal(SIGABRT, previous_handler);
|
|
|
+#ifdef _WRITE_ABORT_MSG
|
|
|
+ _set_abort_behavior(1, _WRITE_ABORT_MSG);
|
|
|
+#endif // #ifdef _WRITE_ABORT_MSG
|
|
|
+#endif // AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL
|
|
|
+
|
|
|
if (!m_assImpScene)
|
|
|
{
|
|
|
AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "Failed to import Asset Importer Scene. Error returned: %s", m_importer.GetErrorString());
|