Merge branch 'main' into pruiksma/ATOM-15561
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include <SceneAPI/SceneCore/Containers/Views/PairIterator.h>
|
||||
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphDownwardsIterator.h>
|
||||
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
|
||||
namespace AZ::RPI
|
||||
{
|
||||
using namespace AZ::SceneAPI;
|
||||
@@ -114,7 +117,7 @@ namespace AZ::RPI
|
||||
meshNodeName, sourceMesh.m_name.GetCStr());
|
||||
|
||||
const DataTypes::MatrixType globalTransform = Utilities::BuildWorldTransform(sceneGraph, sceneNodeIndex);
|
||||
BuildMorphTargetMesh(vertexOffset, sourceMesh, productMesh, metaAssetCreator, blendShapeName, blendShapeData, globalTransform, coordSysConverter);
|
||||
BuildMorphTargetMesh(vertexOffset, sourceMesh, productMesh, metaAssetCreator, blendShapeName, blendShapeData, globalTransform, coordSysConverter, scene.GetSourceFilename());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +160,8 @@ namespace AZ::RPI
|
||||
const AZStd::string& blendShapeName,
|
||||
const AZStd::shared_ptr<const DataTypes::IBlendShapeData>& blendShapeData,
|
||||
const DataTypes::MatrixType& globalTransform,
|
||||
const AZ::SceneAPI::CoordinateSystemConverter& coordSysConverter)
|
||||
const AZ::SceneAPI::CoordinateSystemConverter& coordSysConverter,
|
||||
const AZStd::string& sourceSceneFilename)
|
||||
{
|
||||
const float tolerance = CalcPositionDeltaTolerance(sourceMesh);
|
||||
AZ::Aabb deltaPositionAabb = AZ::Aabb::CreateNull();
|
||||
@@ -288,6 +292,8 @@ namespace AZ::RPI
|
||||
metaData.m_maxPositionDelta = maxValue;
|
||||
}
|
||||
|
||||
metaData.m_wrinkleMask = GetWrinkleMask(sourceSceneFilename, blendShapeName);
|
||||
|
||||
metaAssetCreator.AddMorphTarget(metaData);
|
||||
|
||||
AZ_Assert(uncompressedPositionDeltas.size() == compressedDeltas.size(), "Number of uncompressed (%d) and compressed position delta components (%d) do not match.",
|
||||
@@ -312,4 +318,47 @@ namespace AZ::RPI
|
||||
AZ_Assert((packedCompressedMorphTargetVertexData.size() - metaData.m_startIndex) == numMorphedVertices, "Vertex index range (%d) in morph target meta data does not match number of morphed vertices (%d).",
|
||||
packedCompressedMorphTargetVertexData.size() - metaData.m_startIndex, numMorphedVertices);
|
||||
}
|
||||
|
||||
Data::Asset<RPI::StreamingImageAsset> MorphTargetExporter::GetWrinkleMask(const AZStd::string& sourceSceneFullFilePath, const AZStd::string& blendShapeName) const
|
||||
{
|
||||
AZ::Data::Asset<AZ::RPI::StreamingImageAsset> imageAsset;
|
||||
|
||||
// See if there is a wrinkle map mask for this mesh
|
||||
AZStd::string sceneRelativeFilePath;
|
||||
bool relativePathFound = true;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(relativePathFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetRelativeProductPathFromFullSourceOrProductPath, sourceSceneFullFilePath, sceneRelativeFilePath);
|
||||
|
||||
if (relativePathFound)
|
||||
{
|
||||
AZ::StringFunc::Path::StripFullName(sceneRelativeFilePath);
|
||||
|
||||
// Get the folder the masks are supposed to be in
|
||||
AZStd::string folderName;
|
||||
AZ::StringFunc::Path::GetFileName(sourceSceneFullFilePath.c_str(), folderName);
|
||||
folderName += "_wrinklemasks";
|
||||
|
||||
// Note: for now, we're assuming the mask is always authored as a .tif
|
||||
AZStd::string blendMaskFileName = blendShapeName + "_wrinklemask.tif.streamingimage";
|
||||
|
||||
AZStd::string maskFolderAndFile;
|
||||
AZ::StringFunc::Path::Join(folderName.c_str(), blendMaskFileName.c_str(), maskFolderAndFile);
|
||||
|
||||
AZStd::string maskRelativePath;
|
||||
AZ::StringFunc::Path::Join(sceneRelativeFilePath.c_str(), maskFolderAndFile.c_str(), maskRelativePath);
|
||||
AZ::StringFunc::Path::Normalize(maskRelativePath);
|
||||
|
||||
// Now see if the file exists
|
||||
AZ::Data::AssetId maskAssetId;
|
||||
Data::AssetCatalogRequestBus::BroadcastResult(maskAssetId, &Data::AssetCatalogRequests::GetAssetIdByPath, maskRelativePath.c_str(), AZ::Data::s_invalidAssetType, false);
|
||||
|
||||
if (maskAssetId.IsValid())
|
||||
{
|
||||
// Flush asset manager events to ensure no asset references are held by closures queued on Ebuses.
|
||||
AZ::Data::AssetManager::Instance().DispatchEvents();
|
||||
|
||||
imageAsset.Create(maskAssetId, AZ::Data::AssetLoadBehavior::PreLoad, false);
|
||||
}
|
||||
}
|
||||
return imageAsset;
|
||||
}
|
||||
} // namespace AZ::RPI
|
||||
|
||||
@@ -64,7 +64,11 @@ namespace AZ
|
||||
const AZStd::string& blendShapeName,
|
||||
const AZStd::shared_ptr<const AZ::SceneAPI::DataTypes::IBlendShapeData>& blendShapeData,
|
||||
const AZ::SceneAPI::DataTypes::MatrixType& globalTransform,
|
||||
const AZ::SceneAPI::CoordinateSystemConverter& coordSysConverter);
|
||||
const AZ::SceneAPI::CoordinateSystemConverter& coordSysConverter,
|
||||
const AZStd::string& sourceSceneFilename);
|
||||
|
||||
// Find a wrinkle mask for this morph target, if it exists
|
||||
Data::Asset<RPI::StreamingImageAsset> GetWrinkleMask(const AZStd::string& sourceSceneFullFilePath, const AZStd::string& blendShapeName) const;
|
||||
};
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace AZ
|
||||
const MaterialPropertyDescriptor* propertyDescriptor = materialTypeAssetCreator.GetMaterialPropertiesLayout()->GetPropertyDescriptor(propertyIndex);
|
||||
|
||||
AZ::Name enumName = AZ::Name(property.m_value.GetValue<AZStd::string>());
|
||||
uint32_t enumValue = propertyDescriptor->GetEnumValue(enumName);
|
||||
uint32_t enumValue = propertyDescriptor ? propertyDescriptor->GetEnumValue(enumName) : MaterialPropertyDescriptor::InvalidEnumValue;
|
||||
if (enumValue == MaterialPropertyDescriptor::InvalidEnumValue)
|
||||
{
|
||||
materialTypeAssetCreator.ReportError("Enum value '%s' couldn't be found in the 'enumValues' list", enumName.GetCStr());
|
||||
|
||||
@@ -93,11 +93,12 @@ namespace AZ
|
||||
void Pass::SetEnabled(bool enabled)
|
||||
{
|
||||
m_flags.m_enabled = enabled;
|
||||
OnHierarchyChange();
|
||||
}
|
||||
|
||||
bool Pass::IsEnabled() const
|
||||
{
|
||||
return m_flags.m_enabled;
|
||||
return m_flags.m_enabled && (m_flags.m_parentEnabled || m_parent == nullptr);
|
||||
}
|
||||
|
||||
// --- Error Logging ---
|
||||
@@ -140,6 +141,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// Set new tree depth and path
|
||||
m_flags.m_parentEnabled = m_parent->m_flags.m_enabled && (m_parent->m_flags.m_parentEnabled || m_parent->m_parent == nullptr);
|
||||
m_treeDepth = m_parent->m_treeDepth + 1;
|
||||
m_path = ConcatPassName(m_parent->m_path, m_name);
|
||||
m_flags.m_partOfHierarchy = m_parent->m_flags.m_partOfHierarchy;
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace AZ::RPI
|
||||
->Field("numVertices", &MorphTargetMetaAsset::MorphTarget::m_numVertices)
|
||||
->Field("minPositionDelta", &MorphTargetMetaAsset::MorphTarget::m_minPositionDelta)
|
||||
->Field("maxPositionDelta", &MorphTargetMetaAsset::MorphTarget::m_maxPositionDelta)
|
||||
->Field("wrinkleMask", &MorphTargetMetaAsset::MorphTarget::m_wrinkleMask)
|
||||
->Field("hasColorDeltas", &MorphTargetMetaAsset::MorphTarget::m_hasColorDeltas)
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user