|
@@ -28,6 +28,7 @@
|
|
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
|
|
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
|
|
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
|
|
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
|
|
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
|
|
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
|
|
|
|
+#include <SceneAPI/SceneCore/Events/ImportEventContext.h>
|
|
|
|
|
|
namespace AZ::SceneAPI::Behaviors
|
|
namespace AZ::SceneAPI::Behaviors
|
|
{
|
|
{
|
|
@@ -180,20 +181,21 @@ namespace AZ::SceneAPI::Behaviors
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
- struct ScriptProcessorRuleBehavior::ExportEventHandler final
|
|
|
|
|
|
+ struct ScriptProcessorRuleBehavior::EventHandler final
|
|
: public AZ::SceneAPI::SceneCore::ExportingComponent
|
|
: public AZ::SceneAPI::SceneCore::ExportingComponent
|
|
{
|
|
{
|
|
using PreExportEventContextFunction = AZStd::function<bool(Events::PreExportEventContext&)>;
|
|
using PreExportEventContextFunction = AZStd::function<bool(Events::PreExportEventContext&)>;
|
|
PreExportEventContextFunction m_preExportEventContextFunction;
|
|
PreExportEventContextFunction m_preExportEventContextFunction;
|
|
|
|
|
|
- ExportEventHandler(PreExportEventContextFunction preExportEventContextFunction)
|
|
|
|
|
|
+ EventHandler(PreExportEventContextFunction preExportEventContextFunction)
|
|
: m_preExportEventContextFunction(preExportEventContextFunction)
|
|
: m_preExportEventContextFunction(preExportEventContextFunction)
|
|
{
|
|
{
|
|
- BindToCall(&ExportEventHandler::PrepareForExport);
|
|
|
|
|
|
+ BindToCall(&EventHandler::PrepareForExport);
|
|
|
|
+ BindToCall(&EventHandler::PreImportEventContext);
|
|
AZ::SceneAPI::SceneCore::ExportingComponent::Activate();
|
|
AZ::SceneAPI::SceneCore::ExportingComponent::Activate();
|
|
}
|
|
}
|
|
|
|
|
|
- ~ExportEventHandler()
|
|
|
|
|
|
+ ~EventHandler()
|
|
{
|
|
{
|
|
AZ::SceneAPI::SceneCore::ExportingComponent::Deactivate();
|
|
AZ::SceneAPI::SceneCore::ExportingComponent::Deactivate();
|
|
}
|
|
}
|
|
@@ -203,12 +205,21 @@ namespace AZ::SceneAPI::Behaviors
|
|
{
|
|
{
|
|
return m_preExportEventContextFunction(context) ? Events::ProcessingResult::Success : Events::ProcessingResult::Failure;
|
|
return m_preExportEventContextFunction(context) ? Events::ProcessingResult::Success : Events::ProcessingResult::Failure;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // used to detect that the "next" source scene is starting to be processed
|
|
|
|
+ Events::ProcessingResult PreImportEventContext([[maybe_unused]] Events::PreImportEventContext& context)
|
|
|
|
+ {
|
|
|
|
+ m_pythonScriptStack.clear();
|
|
|
|
+ return Events::ProcessingResult::Success;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AZStd::vector<AZStd::string> m_pythonScriptStack;
|
|
};
|
|
};
|
|
|
|
|
|
void ScriptProcessorRuleBehavior::Activate()
|
|
void ScriptProcessorRuleBehavior::Activate()
|
|
{
|
|
{
|
|
Events::AssetImportRequestBus::Handler::BusConnect();
|
|
Events::AssetImportRequestBus::Handler::BusConnect();
|
|
- m_exportEventHandler = AZStd::make_shared<ExportEventHandler>([this](Events::PreExportEventContext& context)
|
|
|
|
|
|
+ m_eventHandler = AZStd::make_shared<EventHandler>([this](Events::PreExportEventContext& context)
|
|
{
|
|
{
|
|
return this->DoPrepareForExport(context);
|
|
return this->DoPrepareForExport(context);
|
|
});
|
|
});
|
|
@@ -216,7 +227,7 @@ namespace AZ::SceneAPI::Behaviors
|
|
|
|
|
|
void ScriptProcessorRuleBehavior::Deactivate()
|
|
void ScriptProcessorRuleBehavior::Deactivate()
|
|
{
|
|
{
|
|
- m_exportEventHandler.reset();
|
|
|
|
|
|
+ m_eventHandler.reset();
|
|
Events::AssetImportRequestBus::Handler::BusDisconnect();
|
|
Events::AssetImportRequestBus::Handler::BusDisconnect();
|
|
UnloadPython();
|
|
UnloadPython();
|
|
}
|
|
}
|
|
@@ -271,6 +282,14 @@ namespace AZ::SceneAPI::Behaviors
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (scriptDiscoveryAttempts == 0)
|
|
|
|
+ {
|
|
|
|
+ if (!m_eventHandler->m_pythonScriptStack.empty())
|
|
|
|
+ {
|
|
|
|
+ scriptPath = m_eventHandler->m_pythonScriptStack.back();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (scriptPath.empty())
|
|
if (scriptPath.empty())
|
|
{
|
|
{
|
|
AZ_Warning("scene", scriptDiscoveryAttempts == 0,
|
|
AZ_Warning("scene", scriptDiscoveryAttempts == 0,
|
|
@@ -278,6 +297,10 @@ namespace AZ::SceneAPI::Behaviors
|
|
scene.GetManifestFilename().c_str());
|
|
scene.GetManifestFilename().c_str());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ m_eventHandler->m_pythonScriptStack.push_back(scriptPath);
|
|
|
|
+ }
|
|
|
|
|
|
// already prepared the Python VM?
|
|
// already prepared the Python VM?
|
|
if (m_editorPythonEventsInterface)
|
|
if (m_editorPythonEventsInterface)
|