Merge remote-tracking branch 'upstream/development' into Atom/santorac/OptionalSceneApiMaterialConversion3
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/RTTI/RTTI.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/Rules/IRule.h>
|
||||
#include <AzCore/std/string/fixed_string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -18,7 +19,8 @@ namespace AZ
|
||||
{
|
||||
namespace DataTypes
|
||||
{
|
||||
const static AZStd::string s_advancedDisabledString = "Disabled";
|
||||
static const char* s_advancedDisabledString = "Disabled";
|
||||
|
||||
class IMeshAdvancedRule
|
||||
: public IRule
|
||||
{
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> AssetImportRequest::LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath, const Uuid& sourceGuid,
|
||||
RequestingApplication requester)
|
||||
RequestingApplication requester, const Uuid& loadingComponentUuid)
|
||||
{
|
||||
AZStd::string sceneName;
|
||||
AzFramework::StringFunc::Path::GetFileName(assetFilePath.c_str(), sceneName);
|
||||
@@ -113,7 +113,7 @@ namespace AZ
|
||||
|
||||
// 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());
|
||||
SceneCore::EntityConstructor::BuildEntity("Scene Loading", loadingComponentUuid);
|
||||
|
||||
ProcessingResultCombiner areAllPrepared;
|
||||
AssetImportRequestBus::BroadcastResult(areAllPrepared, &AssetImportRequestBus::Events::PrepareForAssetLoading, *scene, requester);
|
||||
|
||||
@@ -102,8 +102,9 @@ namespace AZ
|
||||
//! @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.
|
||||
//! @param loadingComponentUuid The UUID assigned to the loading component.
|
||||
static AZStd::shared_ptr<Containers::Scene> LoadSceneFromVerifiedPath(const AZStd::string& assetFilePath,
|
||||
const Uuid&sourceGuid, RequestingApplication requester);
|
||||
const Uuid& sourceGuid, RequestingApplication requester, const Uuid& loadingComponentUuid);
|
||||
|
||||
//! 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.
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/Math/Guid.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Scene.h>
|
||||
#include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
|
||||
#include <SceneAPI/SceneCore/Components/LoadingComponent.h>
|
||||
#include <SceneAPI/SceneCore/Mocks/Events/MockAssetImportRequest.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -184,7 +185,7 @@ namespace AZ
|
||||
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> result =
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
|
||||
EXPECT_EQ(nullptr, result);
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ namespace AZ
|
||||
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> result =
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
|
||||
EXPECT_EQ(nullptr, result);
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ namespace AZ
|
||||
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> result =
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
|
||||
EXPECT_EQ(nullptr, result);
|
||||
}
|
||||
|
||||
@@ -253,7 +254,7 @@ namespace AZ
|
||||
EXPECT_CALL(handler, UpdateManifest(_, _, _)).Times(0);
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> result =
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
|
||||
EXPECT_EQ(nullptr, result);
|
||||
}
|
||||
|
||||
@@ -285,7 +286,7 @@ namespace AZ
|
||||
EXPECT_CALL(manifestHandler, UpdateManifest(_, _, _)).Times(1);
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> result =
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
|
||||
EXPECT_EQ(nullptr, result);
|
||||
}
|
||||
|
||||
@@ -313,7 +314,7 @@ namespace AZ
|
||||
EXPECT_CALL(manifestHandler, UpdateManifest(_, _, _)).Times(1);
|
||||
|
||||
AZStd::shared_ptr<Containers::Scene> result =
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic);
|
||||
AssetImportRequest::LoadSceneFromVerifiedPath("test.asset", m_testId, Events::AssetImportRequest::RequestingApplication::Generic, SceneCore::LoadingComponent::TYPEINFO_Uuid());
|
||||
EXPECT_NE(nullptr, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,15 @@
|
||||
#include "DebugOutput.h"
|
||||
#include <AzCore/std/optional.h>
|
||||
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Scene.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphDownwardsIterator.h>
|
||||
#include <SceneAPI/SceneCore/DataTypes/IGraphObject.h>
|
||||
#include <SceneAPI/SceneCore/Events/ExportProductList.h>
|
||||
#include <SceneAPI/SceneCore/Utilities/Reporting.h>
|
||||
|
||||
namespace AZ::SceneAPI::Utilities
|
||||
{
|
||||
void DebugOutput::Write(const char* name, const char* data)
|
||||
@@ -118,4 +127,63 @@ namespace AZ::SceneAPI::Utilities
|
||||
{
|
||||
return m_output;
|
||||
}
|
||||
|
||||
void WriteAndLog(AZ::IO::SystemFile& dbgFile, const char* strToWrite)
|
||||
{
|
||||
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "%s", strToWrite);
|
||||
dbgFile.Write(strToWrite, strlen(strToWrite));
|
||||
dbgFile.Write("\n", strlen("\n"));
|
||||
}
|
||||
|
||||
void DebugOutput::BuildDebugSceneGraph(const char* outputFolder, AZ::SceneAPI::Events::ExportProductList& productList, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene, AZStd::string productName)
|
||||
{
|
||||
const int debugSceneGraphVersion = 1;
|
||||
AZStd::string debugSceneFile;
|
||||
|
||||
AzFramework::StringFunc::Path::ConstructFull(outputFolder, productName.c_str(), debugSceneFile);
|
||||
AZ_TracePrintf(AZ::SceneAPI::Utilities::LogWindow, "outputFolder %s, name %s.\n", outputFolder, productName.c_str());
|
||||
|
||||
AZ::IO::SystemFile dbgFile;
|
||||
if (dbgFile.Open(debugSceneFile.c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY))
|
||||
{
|
||||
WriteAndLog(dbgFile, AZStd::string::format("ProductName: %s", productName.c_str()).c_str());
|
||||
WriteAndLog(dbgFile, AZStd::string::format("debugSceneGraphVersion: %d", debugSceneGraphVersion).c_str());
|
||||
WriteAndLog(dbgFile, scene->GetName().c_str());
|
||||
|
||||
const AZ::SceneAPI::Containers::SceneGraph& sceneGraph = scene->GetGraph();
|
||||
auto names = sceneGraph.GetNameStorage();
|
||||
auto content = sceneGraph.GetContentStorage();
|
||||
auto pairView = AZ::SceneAPI::Containers::Views::MakePairView(names, content);
|
||||
auto view = AZ::SceneAPI::Containers::Views::MakeSceneGraphDownwardsView<
|
||||
AZ::SceneAPI::Containers::Views::BreadthFirst>(
|
||||
sceneGraph, sceneGraph.GetRoot(), pairView.cbegin(), true);
|
||||
|
||||
for (auto&& viewIt : view)
|
||||
{
|
||||
if (viewIt.second == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AZ::SceneAPI::DataTypes::IGraphObject* graphObject = const_cast<AZ::SceneAPI::DataTypes::IGraphObject*>(viewIt.second.get());
|
||||
|
||||
WriteAndLog(dbgFile, AZStd::string::format("Node Name: %s", viewIt.first.GetName()).c_str());
|
||||
WriteAndLog(dbgFile, AZStd::string::format("Node Path: %s", viewIt.first.GetPath()).c_str());
|
||||
WriteAndLog(dbgFile, AZStd::string::format("Node Type: %s", graphObject->RTTI_GetTypeName()).c_str());
|
||||
|
||||
AZ::SceneAPI::Utilities::DebugOutput debugOutput;
|
||||
viewIt.second->GetDebugOutput(debugOutput);
|
||||
|
||||
if (!debugOutput.GetOutput().empty())
|
||||
{
|
||||
WriteAndLog(dbgFile, debugOutput.GetOutput().c_str());
|
||||
}
|
||||
}
|
||||
dbgFile.Close();
|
||||
|
||||
static const AZ::Data::AssetType dbgSceneGraphAssetType("{07F289D1-4DC7-4C40-94B4-0A53BBCB9F0B}");
|
||||
productList.AddProduct(productName, AZ::Uuid::CreateName(productName.c_str()), dbgSceneGraphAssetType,
|
||||
AZStd::nullopt, AZStd::nullopt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,25 @@
|
||||
#include <SceneAPI/SceneCore/Utilities/HashHelper.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/optional.h>
|
||||
#include <cinttypes>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace SceneAPI
|
||||
{
|
||||
namespace Containers
|
||||
{
|
||||
class Scene;
|
||||
}
|
||||
namespace Events
|
||||
{
|
||||
struct ExportProduct;
|
||||
class ExportProductList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZ::SceneAPI::Utilities
|
||||
{
|
||||
class DebugOutput
|
||||
@@ -41,6 +58,8 @@ namespace AZ::SceneAPI::Utilities
|
||||
|
||||
SCENE_CORE_API const AZStd::string& GetOutput() const;
|
||||
|
||||
SCENE_CORE_API static void BuildDebugSceneGraph(const char* outputFolder, AZ::SceneAPI::Events::ExportProductList& productList, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene, AZStd::string productName);
|
||||
|
||||
protected:
|
||||
AZStd::string m_output;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user