Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,184 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/IO/SystemFile.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/Debug/TraceContext.h>
#include <SceneAPI/SceneCore/Components/LoadingComponent.h>
#include <SceneAPI/SceneCore/Components/SceneSystemComponent.h>
#include <SceneAPI/SceneCore/Components/Utilities/EntityConstructor.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
#include <SceneAPI/SceneCore/Events/SceneSerializationBus.h>
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
//
// Loading Result Combiner
//
LoadingResultCombiner::LoadingResultCombiner()
: m_manifestResult(ProcessingResult::Ignored)
, m_assetResult(ProcessingResult::Ignored)
{
}
void LoadingResultCombiner::operator=(LoadingResult rhs)
{
switch (rhs)
{
case LoadingResult::Ignored:
return;
case LoadingResult::AssetLoaded:
m_assetResult = m_assetResult != ProcessingResult::Failure ? ProcessingResult::Success : ProcessingResult::Failure;
return;
case LoadingResult::ManifestLoaded:
m_manifestResult = m_manifestResult != ProcessingResult::Failure ? ProcessingResult::Success : ProcessingResult::Failure;
return;
case LoadingResult::AssetFailure:
m_assetResult = ProcessingResult::Failure;
return;
case LoadingResult::ManifestFailure:
m_manifestResult = ProcessingResult::Failure;
return;
}
}
ProcessingResult LoadingResultCombiner::GetManifestResult() const
{
return m_manifestResult;
}
ProcessingResult LoadingResultCombiner::GetAssetResult() const
{
return m_assetResult;
}
//
// Asset Importer Request
//
void AssetImportRequest::GetManifestExtension(AZStd::string& /*result*/)
{
}
void AssetImportRequest::GetSupportedFileExtensions(AZStd::unordered_set<AZStd::string>& /*extensions*/)
{
}
ProcessingResult AssetImportRequest::PrepareForAssetLoading(Containers::Scene& /*scene*/, RequestingApplication /*requester*/)
{
return ProcessingResult::Ignored;
}
LoadingResult AssetImportRequest::LoadAsset(Containers::Scene& /*scene*/, const AZStd::string& /*path*/, const Uuid& /*guid*/,
RequestingApplication /*requester*/)
{
return LoadingResult::Ignored;
}
void AssetImportRequest::FinalizeAssetLoading(Containers::Scene& /*scene*/, RequestingApplication /*requester*/)
{
}
ProcessingResult AssetImportRequest::UpdateManifest(Containers::Scene& /*scene*/, ManifestAction /*action*/, RequestingApplication /*requester*/)
{
return ProcessingResult::Ignored;
}
void AssetImportRequest::AreCustomNormalsUsed(bool &value)
{
// Leave the SceneProcessingConfigSystemComponent do the job
AZ_UNUSED(value);
}
AZStd::shared_ptr<Containers::Scene> AssetImportRequest::LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath, const Uuid& sourceGuid,
RequestingApplication requester)
{
AZStd::string sceneName;
AzFramework::StringFunc::Path::GetFileName(assetFilePath.c_str(), sceneName);
AZStd::shared_ptr<Containers::Scene> scene = AZStd::make_shared<Containers::Scene>(AZStd::move(sceneName));
AZ_Assert(scene, "Unable to create new scene for asset importing.");
// Unique pointer, will deactivate and clean up once going out of scope.
SceneCore::EntityConstructor::EntityPointer loaders =
SceneCore::EntityConstructor::BuildEntity("Scene Loading", SceneCore::LoadingComponent::TYPEINFO_Uuid());
ProcessingResultCombiner areAllPrepared;
AssetImportRequestBus::BroadcastResult(areAllPrepared, &AssetImportRequestBus::Events::PrepareForAssetLoading, *scene, requester);
if (areAllPrepared.GetResult() == ProcessingResult::Failure)
{
AZ_TracePrintf(Utilities::ErrorWindow, "Not all asset loaders could initialize.\n");
return nullptr;
}
LoadingResultCombiner filesLoaded;
AssetImportRequestBus::BroadcastResult(filesLoaded, &AssetImportRequestBus::Events::LoadAsset, *scene, assetFilePath, sourceGuid, requester);
AssetImportRequestBus::Broadcast(&AssetImportRequestBus::Events::FinalizeAssetLoading, *scene, requester);
if (filesLoaded.GetAssetResult() != ProcessingResult::Success)
{
AZ_TracePrintf(Utilities::ErrorWindow, "Failed to load requested scene file.\n");
return nullptr;
}
ManifestAction action = ManifestAction::Update;
// If the result for manifest is ignored it means no manifest was found.
if (filesLoaded.GetManifestResult() == ProcessingResult::Failure || filesLoaded.GetManifestResult() == ProcessingResult::Ignored)
{
scene->GetManifest().Clear();
action = ManifestAction::ConstructDefault;
}
ProcessingResultCombiner manifestUpdate;
AssetImportRequestBus::BroadcastResult(manifestUpdate, &AssetImportRequestBus::Events::UpdateManifest, *scene, action, requester);
if (manifestUpdate.GetResult() == ProcessingResult::Failure)
{
AZ_TracePrintf(Utilities::ErrorWindow, "Unable to %s manifest.\n", action == ManifestAction::ConstructDefault ? "create new" : "update");
return nullptr;
}
return scene;
}
bool AssetImportRequest::IsManifestExtension(const char* filePath)
{
AZStd::string manifestExtension;
AssetImportRequestBus::Broadcast(&AssetImportRequestBus::Events::GetManifestExtension, manifestExtension);
AZ_Assert(!manifestExtension.empty(), "Manifest extension was not declared.");
return AzFramework::StringFunc::Path::IsExtension(filePath, manifestExtension.c_str());
}
bool AssetImportRequest::IsSceneFileExtension(const char* filePath)
{
AZStd::unordered_set<AZStd::string> extensions;
AssetImportRequestBus::Broadcast(&AssetImportRequestBus::Events::GetSupportedFileExtensions, extensions);
AZ_Assert(!extensions.empty(), "No extensions found for source files.");
for (const AZStd::string& extension : extensions)
{
if (AzFramework::StringFunc::Path::IsExtension(filePath, extension.c_str()))
{
return true;
}
}
return false;
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,120 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Uuid.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/unordered_set.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/ProcessingResult.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace Events
{
enum class LoadingResult
{
Ignored,
AssetLoaded,
ManifestLoaded,
AssetFailure,
ManifestFailure
};
class SCENE_CORE_API LoadingResultCombiner
{
public:
LoadingResultCombiner();
void operator= (LoadingResult rhs);
ProcessingResult GetManifestResult() const;
ProcessingResult GetAssetResult() const;
private:
ProcessingResult m_manifestResult;
ProcessingResult m_assetResult;
};
class SCENE_CORE_API AssetImportRequest
: public AZ::EBusTraits
{
public:
enum RequestingApplication
{
Generic,
Editor,
AssetProcessor
};
enum ManifestAction
{
Update,
ConstructDefault
};
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
using MutexType = AZStd::recursive_mutex;
virtual ~AssetImportRequest() = 0;
//! Fills the given list with all available file extensions, excluding the extension for the manifest.
virtual void GetSupportedFileExtensions(AZStd::unordered_set<AZStd::string>& extensions);
//! Gets the file extension for the manifest.
virtual void GetManifestExtension(AZStd::string& result);
//! Before asset loading starts this is called to allow for any required initialization.
virtual ProcessingResult PrepareForAssetLoading(Containers::Scene& scene, RequestingApplication requester);
//! Starts the loading of the asset at the given path in the given scene. Loading optimizations can be applied based on
//! the calling application.
virtual LoadingResult LoadAsset(Containers::Scene& scene, const AZStd::string& path, const Uuid& guid, RequestingApplication requester);
//! FinalizeAssetLoading can be used to do any work to complete loading, such as complete asynchronous loading
//! or adjust the loaded content in the the SceneGraph. While manifest changes can be done here as well, it's
//! recommended to wait for the UpdateManifest call.
virtual void FinalizeAssetLoading(Containers::Scene& scene, RequestingApplication requester);
//! After all loading has completed, this call can be used to make adjustments to the manifest. Based on the given
//! action this can mean constructing a new manifest or updating an existing manifest. This call is intended
//! to deal with any default behavior of the manifest.
virtual ProcessingResult UpdateManifest(Containers::Scene& scene, ManifestAction action,
RequestingApplication requester);
// Get scene processing project setting: UseCustomNormal
virtual void AreCustomNormalsUsed(bool & value);
//! Utility function to load an asset and manifest from file by using the EBus functions above.
//! @param assetFilePath The absolute path to the source file (not the manifest).
//! @param sourceGuid The guid assigned to the source file (not the manifest).
//! @param requester The application making the request to load the file. This can be used to optimize the type and amount of data
//! to load.
static AZStd::shared_ptr<Containers::Scene> LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath,
const Uuid&sourceGuid, RequestingApplication requester);
//! Utility function to determine if a given file path points to a scene manifest file (.assetinfo).
//! @param filePath A relative or absolute path to the file to check.
static bool IsManifestExtension(const char* filePath);
//! Utility function to determine if a given file path points to a scene file (for instance .fbx).
//! @param filePath A relative or absolute path to the file to check.
static bool IsSceneFileExtension(const char* filePath);
};
using AssetImportRequestBus = AZ::EBus<AssetImportRequest>;
inline AssetImportRequest::~AssetImportRequest() = default;
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,53 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
CallProcessorBinder::~CallProcessorBinder()
{
BusDisconnect();
}
ProcessingResult CallProcessorBinder::Process(ICallContext* context)
{
ProcessingResultCombiner result;
for (auto& it : m_bindings)
{
result += it->Process(this, context);
}
return result.GetResult();
}
void CallProcessorBinder::ActivateBindings()
{
CallProcessorBus::Handler::BusConnect();
}
void CallProcessorBinder::DeactivateBindings()
{
CallProcessorBus::Handler::BusDisconnect();
}
void CallProcessorBinder::ClearBindings()
{
m_bindings.clear();
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,136 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/ProcessingResult.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
// CallProcessorBinder automatically registers to the CallProcessorBus to
// handle process calls on behave to the parent class by filtering
// and forwarding calls to the appropriate functions.
// To use, derive from CallProcessorBinder and call "BindToCall"
// one or more times to register functions with that accept a
// processor context with the signature "ProcessingResult(X& context) const" or
// "ProcessingResult(X& context)", where X is any class derived from ICallContext.
//
// Example:
// Example inherits from CallProcessorBinder and has the following
// function: ProcessingResult ProcessContext(ExampleContext& context);
// In Example's constructor call:
// BindToCall(&Example::ProcessContext);
// If an processor call with the ExampleContext is send,
// Example::ProcessContext will automatically be called.
class SCENE_CORE_CLASS CallProcessorBinder :
public CallProcessorBus::Handler
{
public:
enum class TypeMatch
{
Exact,
Derived
};
AZ_RTTI(CallProcessorBinder, "{887A50B4-3FC4-4695-A88E-CA7BE931A73E}");
SCENE_CORE_API ProcessingResult Process(ICallContext* context) override final;
CallProcessorBinder() = default;
SCENE_CORE_API virtual ~CallProcessorBinder();
protected:
CallProcessorBinder(const CallProcessorBinder&) = delete;
template<typename Class, typename ContextType>
inline void BindToCall(ProcessingResult(Class::*Func)(ContextType& context) const, TypeMatch typeMatch = TypeMatch::Exact);
template<typename Class, typename ContextType>
inline void BindToCall(ProcessingResult(Class::*Func)(ContextType& context), TypeMatch typeMatch = TypeMatch::Exact);
SCENE_CORE_API void ActivateBindings();
SCENE_CORE_API void DeactivateBindings();
SCENE_CORE_API void ClearBindings();
private:
class FunctionBinding
{
public:
virtual ~FunctionBinding() = default;
virtual ProcessingResult Process(CallProcessorBinder* thisPtr, ICallContext* context) = 0;
protected:
template<typename Class, typename ContextType, typename Function>
ProcessingResult Call(CallProcessorBinder* thisPtr, ICallContext* context, Function function);
};
template<typename Class, typename ContextType>
class ConstFunctionBindingTemplate : public FunctionBinding
{
public:
using Function = ProcessingResult(Class::*)(ContextType&) const;
explicit ConstFunctionBindingTemplate(Function function);
~ConstFunctionBindingTemplate() override = default;
ProcessingResult Process(CallProcessorBinder* thisPtr, ICallContext* context) override;
private:
Function m_function;
};
template<typename Class, typename ContextType>
class FunctionBindingTemplate : public FunctionBinding
{
public:
using Function = ProcessingResult(Class::*)(ContextType&);
explicit FunctionBindingTemplate(Function function);
~FunctionBindingTemplate() override = default;
ProcessingResult Process(CallProcessorBinder* thisPtr, ICallContext* context) override;
private:
Function m_function;
};
template<typename Class, typename ContextType>
class ConstDerivedFunctionBindingTemplate : public FunctionBinding
{
public:
using Function = ProcessingResult(Class::*)(ContextType&) const;
explicit ConstDerivedFunctionBindingTemplate(Function function);
~ConstDerivedFunctionBindingTemplate() override = default;
ProcessingResult Process(CallProcessorBinder* thisPtr, ICallContext* context) override;
private:
Function m_function;
};
template<typename Class, typename ContextType>
class DerivedFunctionBindingTemplate : public FunctionBinding
{
public:
using Function = ProcessingResult(Class::*)(ContextType&);
explicit DerivedFunctionBindingTemplate(Function function);
~DerivedFunctionBindingTemplate() override = default;
ProcessingResult Process(CallProcessorBinder* thisPtr, ICallContext* context) override;
private:
Function m_function;
};
AZStd::vector<AZStd::unique_ptr<FunctionBinding>> m_bindings;
};
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.inl>
@@ -0,0 +1,155 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/typetraits/is_base_of.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
template<typename Class, typename ContextType>
void CallProcessorBinder::BindToCall(ProcessingResult(Class::*Func)(ContextType& context) const, TypeMatch typeMatch)
{
static_assert((AZStd::is_base_of<CallProcessorBinder, Class>::value),
"CallProcessorBinder can only bind to classes derived from it.");
static_assert((AZStd::is_base_of<ICallContext, ContextType>::value),
"Only arguments derived from ICallContext are accepted by CallProcessorBinder");
if (typeMatch == TypeMatch::Exact)
{
using Binder = ConstFunctionBindingTemplate<Class, ContextType>;
m_bindings.emplace_back(AZStd::make_unique<Binder>(Func));
}
else
{
using Binder = ConstDerivedFunctionBindingTemplate<Class, ContextType>;
m_bindings.emplace_back(AZStd::make_unique<Binder>(Func));
}
}
template<typename Class, typename ContextType>
void CallProcessorBinder::BindToCall(ProcessingResult(Class::*Func)(ContextType& context), TypeMatch typeMatch)
{
static_assert((AZStd::is_base_of<CallProcessorBinder, Class>::value),
"CallProcessorBinder can only bind to classes derived from it.");
static_assert((AZStd::is_base_of<ICallContext, ContextType>::value),
"Only arguments derived from ICallContext are accepted by CallProcessorBinder");
if (typeMatch == TypeMatch::Exact)
{
using Binder = FunctionBindingTemplate<Class, ContextType>;
m_bindings.emplace_back(AZStd::make_unique<Binder>(Func));
}
else
{
using Binder = DerivedFunctionBindingTemplate<Class, ContextType>;
m_bindings.emplace_back(AZStd::make_unique<Binder>(Func));
}
}
// FunctionBinding
template<typename Class, typename ContextType, typename Function>
ProcessingResult CallProcessorBinder::FunctionBinding::Call(CallProcessorBinder* thisPtr, ICallContext* context, Function function)
{
ContextType* arg = azrtti_cast<ContextType*>(context);
if (arg)
{
// As the compiler can't "see" the target Class for conversion the safety checks in azrtti_cast
// throw a false positive. Instead of using azrtti_cast directly, so address look up here
// and use a standard reinterpret_cast.
void* address = thisPtr->RTTI_AddressOf(Class::TYPEINFO_Uuid());
AZ_Assert(address, "Unable to case CallProcessorBinder to %s.", Class::TYPEINFO_Name());
return (reinterpret_cast<Class*>(address)->*(function))(*arg);
}
else
{
AZ_Assert(arg, "CallProcessorBinder failed to cast context for unknown reasons.");
return ProcessingResult::Failure;
}
}
// ConstFunctionBindingTemplate
template<typename Class, typename ContextType>
CallProcessorBinder::ConstFunctionBindingTemplate<Class, ContextType>::ConstFunctionBindingTemplate(Function function)
: m_function(function)
{
}
template<typename Class, typename ContextType>
ProcessingResult CallProcessorBinder::ConstFunctionBindingTemplate<Class, ContextType>::Process(
CallProcessorBinder* thisPtr, ICallContext* context)
{
if (context && context->RTTI_GetType() == ContextType::TYPEINFO_Uuid())
{
return Call<Class, ContextType, Function>(thisPtr, context, m_function);
}
return ProcessingResult::Ignored;
}
//FunctionBindingTemplate
template<typename Class, typename ContextType>
CallProcessorBinder::FunctionBindingTemplate<Class, ContextType>::FunctionBindingTemplate(Function function)
: m_function(function)
{
}
template<typename Class, typename ContextType>
ProcessingResult CallProcessorBinder::FunctionBindingTemplate<Class, ContextType>::Process(
CallProcessorBinder* thisPtr, ICallContext* context)
{
if (context && context->RTTI_GetType() == ContextType::TYPEINFO_Uuid())
{
return Call<Class, ContextType, Function>(thisPtr, context, m_function);
}
return ProcessingResult::Ignored;
}
// ConstDerivedFunctionBindingTemplate
template<typename Class, typename ContextType>
CallProcessorBinder::ConstDerivedFunctionBindingTemplate<Class, ContextType>::ConstDerivedFunctionBindingTemplate(Function function)
: m_function(function)
{
}
template<typename Class, typename ContextType>
ProcessingResult CallProcessorBinder::ConstDerivedFunctionBindingTemplate<Class, ContextType>::Process(
CallProcessorBinder* thisPtr, ICallContext* context)
{
if (context && context->RTTI_IsTypeOf(ContextType::TYPEINFO_Uuid()))
{
return Call<Class, ContextType, Function>(thisPtr, context, m_function);
}
return ProcessingResult::Ignored;
}
//DerivedFunctionBindingTemplate
template<typename Class, typename ContextType>
CallProcessorBinder::DerivedFunctionBindingTemplate<Class, ContextType>::DerivedFunctionBindingTemplate(Function function)
: m_function(function)
{
}
template<typename Class, typename ContextType>
ProcessingResult CallProcessorBinder::DerivedFunctionBindingTemplate<Class, ContextType>::Process(
CallProcessorBinder* thisPtr, ICallContext* context)
{
if (context && context->RTTI_IsTypeOf(ContextType::TYPEINFO_Uuid()))
{
return Call<Class, ContextType, Function>(thisPtr, context, m_function);
}
return ProcessingResult::Ignored;
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,40 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
uint8_t CallProcessor::GetPriority() const
{
return CallProcessor::NormalProcessing;
}
bool CallProcessor::Compare(const CallProcessor* rhs) const
{
AZ_Assert(rhs, "Invalid argument for ProcessingEvents::Compare.");
return GetPriority() < rhs->GetPriority();
}
ProcessingResult Process(ICallContext& context)
{
ProcessingResultCombiner result;
CallProcessorBus::BroadcastResult(result, &CallProcessorBus::Events::Process, &context);
return result.GetResult();
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,86 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/std/containers/vector.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/EBus/EBus.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
#include <SceneAPI/SceneCore/Events/ProcessingResult.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
class ICallContext
{
public:
AZ_RTTI(ICallContext, "{525ED64B-9425-4F88-8E6B-D02FF61429B7}");
virtual ~ICallContext() = 0;
};
class SCENE_CORE_CLASS CallProcessor
: public AZ::EBusTraits
{
public:
enum ProcessingPriority : uint8_t
{
EarliestProcessing = 0,
EarlyProcessing = 64,
NormalProcessing = 128,
LateProcessing = 192,
LatestProcessing = 255
};
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::MultipleAndOrdered;
using MutexType = AZStd::recursive_mutex;
virtual ~CallProcessor() = 0;
// Request to process the event for the given context.
virtual ProcessingResult Process(ICallContext* context) = 0;
// The order of the calling processors is undetermined, but sometimes a context needs to be
// processed before another. In these situations the priority of a processor can be
// reduced or increased to make sure it gets called before or after normal processing
// has happened. Note that if two or more processors are raised to the same priority
// there will still not be a guarantee which will gets to do work first.
SCENE_CORE_API virtual uint8_t GetPriority() const;
SCENE_CORE_API bool Compare(const CallProcessor* rhs) const;
};
using CallProcessorBus = AZ::EBus<CallProcessor>;
// Utility function to call the CallProcessor EBus.
SCENE_CORE_API ProcessingResult Process(ICallContext& context);
// Utility function to all the CallProcessor EBus.
// Usage:
// Process<Context>(ContextArg1, ContextArg2, ContextArg3);
template<typename Context, typename... Args>
ProcessingResult Process(Args&&... args);
inline ICallContext::~ICallContext()
{
}
inline CallProcessor::~CallProcessor()
{
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
#include <SceneAPI/SceneCore/Events/CallProcessorBus.inl>
@@ -0,0 +1,29 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/utils.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
template<typename Context, typename... Args>
ProcessingResult Process(Args&&... args)
{
Context context(std::forward<Args>(args)...);
return Process(context);
}
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,150 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/ExportEventContext.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
/////////////
// PreExportEventContext
/////////////
PreExportEventContext::PreExportEventContext(ExportProductList& productList, const AZStd::string& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier)
: m_outputDirectory(outputDirectory)
, m_productList(productList)
, m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
PreExportEventContext::PreExportEventContext(ExportProductList& productList, AZStd::string&& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier)
: m_outputDirectory(AZStd::move(outputDirectory))
, m_productList(productList)
, m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
const AZStd::string& PreExportEventContext::GetOutputDirectory() const
{
return m_outputDirectory;
}
ExportProductList& PreExportEventContext::GetProductList()
{
return m_productList;
}
const ExportProductList& PreExportEventContext::GetProductList() const
{
return m_productList;
}
const Containers::Scene& PreExportEventContext::GetScene() const
{
return m_scene;
}
const char* PreExportEventContext::GetPlatformIdentifier() const
{
return m_platformIdentifier;
}
/////////////
// ExportEventContext
/////////////
ExportEventContext::ExportEventContext(ExportProductList& productList, const AZStd::string& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier)
: m_outputDirectory(outputDirectory)
, m_productList(productList)
, m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
ExportEventContext::ExportEventContext(ExportProductList& productList, AZStd::string&& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier)
: m_outputDirectory(AZStd::move(outputDirectory))
, m_productList(productList)
, m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
const AZStd::string& ExportEventContext::GetOutputDirectory() const
{
return m_outputDirectory;
}
ExportProductList& ExportEventContext::GetProductList()
{
return m_productList;
}
const ExportProductList& ExportEventContext::GetProductList() const
{
return m_productList;
}
const Containers::Scene& ExportEventContext::GetScene() const
{
return m_scene;
}
const char* ExportEventContext::GetPlatformIdentifier() const
{
return m_platformIdentifier;
}
/////////////
// PostExportEventContext
/////////////
PostExportEventContext::PostExportEventContext(ExportProductList& productList, const AZStd::string& outputDirectory, const char* platformIdentifier)
: m_outputDirectory(outputDirectory)
, m_productList(productList)
, m_platformIdentifier(platformIdentifier)
{
}
PostExportEventContext::PostExportEventContext(ExportProductList& productList, AZStd::string&& outputDirectory, const char* platformIdentifier)
: m_outputDirectory(AZStd::move(outputDirectory))
, m_platformIdentifier(platformIdentifier)
, m_productList(productList)
{
}
const AZStd::string PostExportEventContext::GetOutputDirectory() const
{
return m_outputDirectory;
}
ExportProductList& PostExportEventContext::GetProductList()
{
return m_productList;
}
const ExportProductList& PostExportEventContext::GetProductList() const
{
return m_productList;
}
const char* PostExportEventContext::GetPlatformIdentifier() const
{
return m_platformIdentifier;
}
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,126 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace DataTypes
{
class IGroup;
}
namespace Events
{
class ExportProductList;
// Signals an export of the contained scene is about to happen.
class PreExportEventContext
: public ICallContext
{
public:
AZ_RTTI(PreExportEventContext, "{6B303E35-8BF0-43DD-9AD7-7D7F24F18F37}", ICallContext);
~PreExportEventContext() override = default;
SCENE_CORE_API PreExportEventContext(ExportProductList& productList, const AZStd::string& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API PreExportEventContext(ExportProductList& productList, AZStd::string&& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API const AZStd::string& GetOutputDirectory() const;
SCENE_CORE_API ExportProductList& GetProductList();
SCENE_CORE_API const ExportProductList& GetProductList() const;
SCENE_CORE_API const Containers::Scene& GetScene() const;
SCENE_CORE_API const char* GetPlatformIdentifier() const;
private:
AZStd::string m_outputDirectory;
ExportProductList& m_productList;
const Containers::Scene& m_scene;
/**
* The platform identifier is configured in the AssetProcessorPlatformConfig.ini and is data driven
* it is generally a value like "pc" or "ios" or such.
* this const char* points at memory owned by the caller but it will always survive for the duration of the call.
*/
const char* m_platformIdentifier = nullptr;
};
// Signals the scene that the contained scene needs to be exported to the specified directory.
class ExportEventContext
: public ICallContext
{
public:
AZ_RTTI(ExportEventContext, "{ECE4A3BD-CE48-4B17-9609-6D97F8A887D3}", ICallContext);
~ExportEventContext() override = default;
SCENE_CORE_API ExportEventContext(ExportProductList& productList, const AZStd::string& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API ExportEventContext(ExportProductList& productList, AZStd::string&& outputDirectory, const Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API const AZStd::string& GetOutputDirectory() const;
SCENE_CORE_API ExportProductList& GetProductList();
SCENE_CORE_API const ExportProductList& GetProductList() const;
SCENE_CORE_API const Containers::Scene& GetScene() const;
SCENE_CORE_API const char* GetPlatformIdentifier() const;
private:
AZStd::string m_outputDirectory;
ExportProductList& m_productList;
const Containers::Scene& m_scene;
/**
* The platform identifier is configured in the AssetProcessorPlatformConfig.ini and is data driven
* it is generally a value like "pc" or "ios" or such.
* this const char* points at memory owned by the caller but it will always survive for the duration of the call.
*/
const char* m_platformIdentifier = nullptr;
};
// Signals that an export has completed and written (if successful) to the specified directory.
class PostExportEventContext
: public ICallContext
{
public:
AZ_RTTI(PostExportEventContext, "{92E0AD59-62CA-45E3-BB73-5659D10FF0DE}", ICallContext);
~PostExportEventContext() override = default;
SCENE_CORE_API PostExportEventContext(ExportProductList& productList, const AZStd::string& outputDirectory, const char* platformIdentifier);
SCENE_CORE_API PostExportEventContext(ExportProductList& productList, AZStd::string&& outputDirectory, const char* platformIdentifier);
SCENE_CORE_API const AZStd::string GetOutputDirectory() const;
SCENE_CORE_API ExportProductList& GetProductList();
SCENE_CORE_API const ExportProductList& GetProductList() const;
SCENE_CORE_API const char* GetPlatformIdentifier() const;
private:
AZStd::string m_outputDirectory;
/**
* The platform identifier is configured in the AssetProcessorPlatformConfig.ini and is data driven
* it is generally a value like "pc" or "ios" or such.
* this const char* points at memory owned by the caller but it will always survive for the duration of the call.
*/
const char* m_platformIdentifier = nullptr;
ExportProductList& m_productList;
};
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,94 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
ExportProduct::ExportProduct(const AZStd::string& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags)
:ExportProduct(AZStd::string(filename), id, assetType, lod, subId, dependencyFlags)
{
}
ExportProduct::ExportProduct(AZStd::string&& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags)
: m_filename(AZStd::move(filename))
, m_id(id)
, m_assetType(assetType)
, m_lod(lod)
, m_subId(subId)
, m_dependencyFlags(dependencyFlags)
{
}
ExportProduct::ExportProduct(ExportProduct&& rhs)
{
*this = AZStd::move(rhs);
}
ExportProduct& ExportProduct::operator=(ExportProduct&& rhs)
{
m_legacyFileNames = AZStd::move(rhs.m_legacyFileNames);
m_filename = AZStd::move(rhs.m_filename);
m_id = rhs.m_id;
m_assetType = rhs.m_assetType;
m_lod = rhs.m_lod;
m_subId = rhs.m_subId;
m_dependencyFlags = rhs.m_dependencyFlags;
m_legacyPathDependencies = rhs.m_legacyPathDependencies;
m_productDependencies = rhs.m_productDependencies;
return *this;
}
ExportProduct& ExportProductList::AddProduct(const AZStd::string& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags)
{
return AddProduct(AZStd::string(filename), id, assetType, lod, subId, dependencyFlags);
}
ExportProduct& ExportProductList::AddProduct(AZStd::string&& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags)
{
AZ_Assert(!filename.empty(), "A filename is required to register a product.");
AZ_Assert(!id.IsNull(), "Provided guid is not valid");
AZ_Assert(!lod.has_value() || lod < 16, "Lod value has to be between 0 and 15 or disabled.");
size_t index = m_products.size();
m_products.emplace_back(AZStd::move(filename), id, assetType, lod, subId, dependencyFlags);
return m_products[index];
}
const AZStd::vector<ExportProduct>& ExportProductList::GetProducts() const
{
return m_products;
}
void ExportProductList::AddDependencyToProduct(const AZStd::string& productName, ExportProduct& dependency)
{
for (ExportProduct& product : m_products)
{
if (product.m_filename == productName)
{
product.m_productDependencies.push_back(dependency);
break;
}
}
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,76 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/base.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Math/Uuid.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
struct ExportProduct
{
SCENE_CORE_API ExportProduct(const AZStd::string& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags = Data::ProductDependencyInfo::CreateFlags(Data::AssetLoadBehavior::NoLoad));
SCENE_CORE_API ExportProduct(AZStd::string&& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags = Data::ProductDependencyInfo::CreateFlags(Data::AssetLoadBehavior::NoLoad));
ExportProduct(const ExportProduct& rhs) = default;
SCENE_CORE_API ExportProduct(ExportProduct&& rhs);
ExportProduct& operator=(const ExportProduct& rhs) = default;
SCENE_CORE_API ExportProduct& operator=(ExportProduct&& rhs);
//! Other names the product file may be known as in the past. This is only backwards compatibility in ResourceCompilerScene.
AZStd::vector<AZStd::string> m_legacyFileNames;
//! Relative or absolute path of the product file.
AZStd::string m_filename;
//! Unique id for the product file. This is usually based on the group id and is used to generate the
//! the sub id.
Uuid m_id;
//! Type of the product file.
Data::AssetType m_assetType;
AZStd::optional<u32> m_subId;
//! If the product makes use of level of detail, the level is encoded in the sub id. Otherwise the entire sub id number will be used for the product id.
AZStd::optional<u8> m_lod;
//! Save off any product dependency flags that are detected for any serialized dependencies.
Data::ProductDependencyInfo::ProductDependencyFlags m_dependencyFlags;
//! Relative path dependencies for autogenerated FBX materials
AZStd::vector<AZStd::string> m_legacyPathDependencies;
//! In the case of CGFs, we will have LOD export products that are dependencies of the base LOD
AZStd::vector<ExportProduct> m_productDependencies;
};
class ExportProductList
{
public:
SCENE_CORE_API ExportProduct& AddProduct(const AZStd::string& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags = Data::ProductDependencyInfo::CreateFlags(Data::AssetLoadBehavior::NoLoad));
SCENE_CORE_API ExportProduct& AddProduct(AZStd::string&& filename, Uuid id, Data::AssetType assetType, AZStd::optional<u8> lod, AZStd::optional<u32> subId,
Data::ProductDependencyInfo::ProductDependencyFlags dependencyFlags = Data::ProductDependencyInfo::CreateFlags(Data::AssetLoadBehavior::NoLoad));
SCENE_CORE_API const AZStd::vector<ExportProduct>& GetProducts() const;
SCENE_CORE_API void AddDependencyToProduct(const AZStd::string& productName, ExportProduct& dependency);
private:
AZStd::vector<ExportProduct> m_products;
};
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,76 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/GenerateEventContext.h>
namespace AZ::SceneAPI::Events
{
/////////////
// PreGenerateEventContext
/////////////
PreGenerateEventContext::PreGenerateEventContext(Containers::Scene& scene, const char* platformIdentifier)
: m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
Containers::Scene& PreGenerateEventContext::GetScene() const
{
return m_scene;
}
const char* PreGenerateEventContext::GetPlatformIdentifier() const
{
return m_platformIdentifier;
}
/////////////
// GenerateEventContext
/////////////
GenerateEventContext::GenerateEventContext(Containers::Scene& scene, const char* platformIdentifier)
: m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
Containers::Scene& GenerateEventContext::GetScene() const
{
return m_scene;
}
const char* GenerateEventContext::GetPlatformIdentifier() const
{
return m_platformIdentifier;
}
/////////////
// PostGenerateEventContext
/////////////
PostGenerateEventContext::PostGenerateEventContext(Containers::Scene& scene, const char* platformIdentifier)
: m_scene(scene)
, m_platformIdentifier(platformIdentifier)
{
}
Containers::Scene& PostGenerateEventContext::GetScene() const
{
return m_scene;
}
const char* PostGenerateEventContext::GetPlatformIdentifier() const
{
return m_platformIdentifier;
}
} // namespace AZ::SceneAPI::Events
@@ -0,0 +1,94 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ::SceneAPI::Containers { class Scene; }
namespace AZ::SceneAPI::DataTypes { class IGroup; }
namespace AZ::SceneAPI::Events
{
class ExportProductList;
// Signals the scene generation step is about to happen
class PreGenerateEventContext
: public ICallContext
{
public:
AZ_RTTI(PreGenerateEventContext, "{0D1AB113-D35E-4C35-9820-E7B22F37D90C}", ICallContext)
SCENE_CORE_API PreGenerateEventContext(Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API Containers::Scene& GetScene() const;
SCENE_CORE_API const char* GetPlatformIdentifier() const;
private:
Containers::Scene& m_scene;
/**
* The platform identifier is configured in the AssetProcessorPlatformConfig.ini and is data driven
* it is generally a value like "pc" or "ios" or such.
* this const char* points at memory owned by the caller but it will always survive for the duration of the call.
*/
const char* m_platformIdentifier = nullptr;
};
// Signals that all appropriate objects should be generated into the Scene
class GenerateEventContext
: public ICallContext
{
public:
AZ_RTTI(GenerateEventContext, "{B53CCBBF-965A-4709-AD33-AFD5F3AE8580}", ICallContext)
SCENE_CORE_API GenerateEventContext(Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API Containers::Scene& GetScene() const;
SCENE_CORE_API const char* GetPlatformIdentifier() const;
private:
Containers::Scene& m_scene;
/**
* The platform identifier is configured in the AssetProcessorPlatformConfig.ini and is data driven
* it is generally a value like "pc" or "ios" or such.
* this const char* points at memory owned by the caller but it will always survive for the duration of the call.
*/
const char* m_platformIdentifier = nullptr;
};
// Signals that the generation step is complete
class PostGenerateEventContext
: public ICallContext
{
public:
AZ_RTTI(PostGenerateEventContext, "{3EE65CBF-6C0E-425A-9ECC-3CC8FC4372F7}", ICallContext)
SCENE_CORE_API PostGenerateEventContext(Containers::Scene& scene, const char* platformIdentifier);
SCENE_CORE_API Containers::Scene& GetScene() const;
SCENE_CORE_API const char* GetPlatformIdentifier() const;
private:
Containers::Scene& m_scene;
/**
* The platform identifier is configured in the AssetProcessorPlatformConfig.ini and is data driven
* it is generally a value like "pc" or "ios" or such.
* this const char* points at memory owned by the caller but it will always survive for the duration of the call.
*/
const char* m_platformIdentifier = nullptr;
};
} // namespace AZ::SceneAPI::Events
@@ -0,0 +1,79 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Crc.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/set.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace DataTypes
{
class IGraphObject;
}
namespace Events
{
#if defined(AZ_PLATFORM_LINUX)
class SCENE_CORE_API GraphMetaInfo
#else
class GraphMetaInfo
#endif
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
inline static Crc32 GetIgnoreVirtualType()
{
static Crc32 s_ignoreVirtualType = AZ_CRC("Ignore", 0x0d88d6e2);
return s_ignoreVirtualType;
}
SCENE_CORE_API GraphMetaInfo() = default;
virtual ~GraphMetaInfo() = default;
// Gets the path to the icon associated with the given object.
SCENE_CORE_API virtual void GetIconPath([[maybe_unused]] AZStd::string& iconPath, [[maybe_unused]] const DataTypes::IGraphObject* target) {}
// Provides a short description of the type.
SCENE_CORE_API virtual void GetToolTip([[maybe_unused]] AZStd::string& toolTip, [[maybe_unused]] const DataTypes::IGraphObject* target) {}
// Provides a list of string CRCs that indicate the virtual type the given node can act as.
// Virtual types are none custom types that are different interpretations of existing types based on
// their name or attributes.
SCENE_CORE_API virtual void GetVirtualTypes([[maybe_unused]] AZStd::set<Crc32>& types,
[[maybe_unused]] const Containers::Scene& scene,
[[maybe_unused]] Containers::SceneGraph::NodeIndex node) {}
// Provides a list of string CRCs that indicate all available virtual types.
SCENE_CORE_API virtual void GetAllVirtualTypes([[maybe_unused]] AZStd::set<Crc32>& types) {}
// Converts the virtual type hashed name into a readable name.
SCENE_CORE_API virtual void GetVirtualTypeName([[maybe_unused]] AZStd::string& name, [[maybe_unused]] Crc32 type) {}
};
using GraphMetaInfoBus = AZ::EBus<GraphMetaInfo>;
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,93 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/ImportEventContext.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
/////////////
// PreImportEventContext
/////////////
PreImportEventContext::PreImportEventContext(const char* inputDirectory)
: m_inputDirectory(inputDirectory)
{
}
PreImportEventContext::PreImportEventContext(const AZStd::string& inputDirectory)
: m_inputDirectory(inputDirectory)
{
}
PreImportEventContext::PreImportEventContext(AZStd::string&& inputDirectory)
: m_inputDirectory(AZStd::move(inputDirectory))
{
}
const AZStd::string& PreImportEventContext::GetInputDirectory() const
{
return m_inputDirectory;
}
/////////////
// ImportEventContext
/////////////
ImportEventContext::ImportEventContext(const char* inputDirectory, Containers::Scene& scene)
: m_inputDirectory(inputDirectory)
, m_scene(scene)
{
}
ImportEventContext::ImportEventContext(const AZStd::string& inputDirectory, Containers::Scene& scene)
: m_inputDirectory(inputDirectory)
, m_scene(scene)
{
}
ImportEventContext::ImportEventContext(AZStd::string&& inputDirectory, Containers::Scene& scene)
: m_inputDirectory(AZStd::move(inputDirectory))
, m_scene(scene)
{
}
const AZStd::string& ImportEventContext::GetInputDirectory() const
{
return m_inputDirectory;
}
Containers::Scene& ImportEventContext::GetScene()
{
return m_scene;
}
/////////////
// PostImportEventContext
/////////////
PostImportEventContext::PostImportEventContext(const Containers::Scene& scene)
: m_scene(scene)
{
}
const Containers::Scene& PostImportEventContext::GetScene() const
{
return m_scene;
}
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,84 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/std/string/string.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace Events
{
// Signals an import of the scene graph is about to happen.
class PreImportEventContext
: public ICallContext
{
public:
AZ_RTTI(PreImportEventContext, "{89BA9931-E6B5-4096-B5AE-80E80A8B4DB2}", ICallContext);
~PreImportEventContext() override = default;
SCENE_CORE_API PreImportEventContext(const char* inputDirectory);
SCENE_CORE_API PreImportEventContext(const AZStd::string& inputDirectory);
SCENE_CORE_API PreImportEventContext(AZStd::string&& inputDirectory);
SCENE_CORE_API const AZStd::string& GetInputDirectory() const;
private:
const AZStd::string m_inputDirectory;
};
// Signals that the scene is ready to import the scene graph from source data
class ImportEventContext
: public ICallContext
{
public:
AZ_RTTI(ImportEventContext, "{4E0C75C2-564F-4BDF-BFAA-B7E4683B24B9}", ICallContext);
~ImportEventContext() override = default;
SCENE_CORE_API ImportEventContext(const char* inputDirectory, Containers::Scene& scene);
SCENE_CORE_API ImportEventContext(const AZStd::string& inputDirectory, Containers::Scene& scene);
SCENE_CORE_API ImportEventContext(AZStd::string&& inputDirectory, Containers::Scene& scene);
SCENE_CORE_API const AZStd::string& GetInputDirectory() const;
SCENE_CORE_API Containers::Scene& GetScene();
private:
AZStd::string m_inputDirectory;
Containers::Scene& m_scene;
};
// Signals that an import has completed and the data should be ready to use (if there were no errors)
class PostImportEventContext
: public ICallContext
{
public:
AZ_RTTI(PostImportEventContext, "{683D2E3E-0040-4E78-90BF-76FAFFD50767}", ICallContext);
~PostImportEventContext() override = default;
SCENE_CORE_API PostImportEventContext(const Containers::Scene& scene);
SCENE_CORE_API const Containers::Scene& GetScene() const;
private:
const Containers::Scene& m_scene;
};
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,47 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/ManifestMetaInfoBus.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
ManifestMetaInfo::ManifestMetaInfo()
{
}
void ManifestMetaInfo::GetCategoryAssignments(CategoryRegistrationList& /*categories*/, const Containers::Scene& /*scene*/)
{
}
void ManifestMetaInfo::GetIconPath(AZStd::string& /*iconPath*/, const DataTypes::IManifestObject& /*target*/)
{
}
void ManifestMetaInfo::GetAvailableModifiers(ModifiersList& /*modifiers*/,
const Containers::Scene& /*scene*/, const DataTypes::IManifestObject& /*target*/)
{
}
void ManifestMetaInfo::InitializeObject(const Containers::Scene& /*scene*/, DataTypes::IManifestObject& /*target*/)
{
}
void ManifestMetaInfo::ObjectUpdated(const Containers::Scene& /*scene*/, const DataTypes::IManifestObject* /*target*/, void* /*sender*/)
{
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,100 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <limits>
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Uuid.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzCore/std/containers/vector.h>
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace DataTypes
{
class IManifestObject;
}
namespace Events
{
class SCENE_CORE_API ManifestMetaInfo
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
struct CategoryRegistration
{
AZStd::string m_categoryName;
AZ::Uuid m_categoryTargetGroupId;
int m_preferredOrder;
CategoryRegistration(const char* categoryName, const AZ::Uuid& categoryTargetId, int preferredOrder = std::numeric_limits<int>::max())
: m_categoryName(categoryName)
, m_categoryTargetGroupId(categoryTargetId)
, m_preferredOrder(preferredOrder)
{
}
};
using CategoryRegistrationList = AZStd::vector<CategoryRegistration>;
using ModifiersList = AZStd::vector<AZ::Uuid>;
ManifestMetaInfo();
virtual ~ManifestMetaInfo() = 0;
//! Gets a list of all the categories and the class identifiers that are listed for that category.
virtual void GetCategoryAssignments(CategoryRegistrationList& categories, const Containers::Scene& scene);
//! Gets the path to the icon associated with the given object.
virtual void GetIconPath(AZStd::string& iconPath, const DataTypes::IManifestObject& target);
//! Gets a list of a the modifiers (such as rules for groups) that the target accepts.
//! Note that updates to the target may change what modifiers can be accepted. For instance
//! if a group only accepts a single rule of a particular type, calling this function a second time
//! will not include the uuid of that rule.
//! This method is called when the "Add Modifier" button is pressed in the FBX Settings Editor.
virtual void GetAvailableModifiers(ModifiersList& modifiers, const Containers::Scene& scene,
const DataTypes::IManifestObject& target);
//! Initialized the given manifest object based on the scene. Depending on what other entries have been added
//! to the manifest, an implementation of this function may decided that certain values should or shouldn't
//! be added, such as not adding meshes to a group that already belong to another group.
//! This method is always called each time a Group type of object is created in memory (e.g. When the user
//! clicks the "Add another Mesh" or "Add another Actor" in the FBX Settings Editor). Overriders of this method
//! should check the type of the \p target to decide to take action (e.g. add a Modifier) or do nothing.
virtual void InitializeObject(const Containers::Scene& scene, DataTypes::IManifestObject& target);
//! Called when an existing object is updated. This is not called when an object is initialized, which is handled,
//! by InitializeObject, but a parent may still get the update. For instance adding or removing a rule will
//! have this called for the parent group.
//! @param scene The scene the object belongs to.
//! @param target The object that's being updated. If this is null it refers to an update to the entire manifest, for
//! when a group is deleted for instance.
//! @param sender An optional argument to keep track of the object that called this function. This can be used if the
//! same object that sends a message also handles the callback to avoid recursively updating.
virtual void ObjectUpdated(const Containers::Scene& scene, const DataTypes::IManifestObject* target, void* sender = nullptr);
};
inline ManifestMetaInfo::~ManifestMetaInfo() = default;
using ManifestMetaInfoBus = AZ::EBus<ManifestMetaInfo>;
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -0,0 +1,57 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Events/ProcessingResult.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
ProcessingResultCombiner::ProcessingResultCombiner()
: m_value(ProcessingResult::Ignored)
{
}
void ProcessingResultCombiner::operator=(ProcessingResult rhs)
{
Combine(rhs);
}
void ProcessingResultCombiner::operator+=(ProcessingResult rhs)
{
Combine(rhs);
}
void ProcessingResultCombiner::Combine(ProcessingResult rhs)
{
switch (rhs)
{
case ProcessingResult::Ignored:
return;
case ProcessingResult::Success:
m_value = m_value != ProcessingResult::Failure ? rhs : ProcessingResult::Failure;
return;
case ProcessingResult::Failure:
m_value = ProcessingResult::Failure;
return;
}
}
ProcessingResult ProcessingResultCombiner::GetResult() const
{
return m_value;
}
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,48 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/SceneCoreConfiguration.h>
namespace AZ
{
namespace SceneAPI
{
namespace Events
{
enum class ProcessingResult
{
Ignored, // Event didn't apply to the processor or there was no work to do.
Success, // Data was successfully processed.
Failure // Attempts to process data failed.
};
// Combines ProcessingResult together with the stored value such that
// Ignored doesn't change the stored value,
// Failure is always stored,
// Success is only stored if not already set to failure.
class ProcessingResultCombiner
{
public:
SCENE_CORE_API ProcessingResultCombiner();
SCENE_CORE_API void operator=(ProcessingResult rhs); // For use with EBus
SCENE_CORE_API void operator+=(ProcessingResult rhs); // Common use.
SCENE_CORE_API ProcessingResult GetResult() const;
private:
void Combine(ProcessingResult rhs);
ProcessingResult m_value;
};
} // Events
} // SceneAPI
} // AZ
@@ -0,0 +1,58 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Math/Uuid.h>
#include <AzCore/std/parallel/mutex.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzCore/std/string/string.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
}
namespace Events
{
//! EBus to deal with serialization to and from disks of scene and manifest files.
class SceneSerialization
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
// Use a mutex to lock the EBus in case tools are running on different threads.
using MutexType = AZStd::recursive_mutex;
virtual ~SceneSerialization() = 0;
//! Loads a scene and its corresponding manifest if available, otherwise a new manifest
//! is created.
//! @param sceneFilePath The absolute or relative path to the scene file in the source folder.
//! @param sceneSourceGuid The source uuid for the scene file. If a null-uuid is given LoadScene
//! will attempt to query the Asset Processor for the uuid.
//! @return The loaded scene or null if the file couldn't be fully resolved or an error
//! occurred during loading.
virtual AZStd::shared_ptr<Containers::Scene> LoadScene(const AZStd::string& sceneFilePath, Uuid sceneSourceGuid) = 0;
};
using SceneSerializationBus = AZ::EBus<SceneSerialization>;
inline SceneSerialization::~SceneSerialization() = default;
} // namespace Events
} // namespace SceneAPI
} // namespace AZ