feedback from PR
This commit is contained in:
@@ -131,6 +131,8 @@ namespace AZ
|
||||
|
||||
void ApplyMatrix3x4(const Matrix3x4& matrix3x4);
|
||||
|
||||
void MultiplyByScale(const Vector3& scale);
|
||||
|
||||
//! Transforms an Aabb and returns the resulting Obb.
|
||||
Obb GetTransformedObb(const Transform& transform) const;
|
||||
|
||||
|
||||
@@ -292,6 +292,13 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE void Aabb::MultiplyByScale(const Vector3& scale)
|
||||
{
|
||||
m_min *= scale;
|
||||
m_max *= scale;
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Transform& transform) const
|
||||
{
|
||||
Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max);
|
||||
|
||||
@@ -145,8 +145,10 @@ namespace AZ
|
||||
const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const override;
|
||||
void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) override;
|
||||
|
||||
void SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) override;
|
||||
Matrix3x4 GetMatrix3x4(const MeshHandle& meshHandle) override;
|
||||
void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override;
|
||||
Transform GetTransform(const MeshHandle& meshHandle) override;
|
||||
Vector3 GetNonUniformScale(const MeshHandle& meshHandle) override;
|
||||
|
||||
void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override;
|
||||
RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override;
|
||||
|
||||
+7
-4
@@ -61,10 +61,13 @@ namespace AZ
|
||||
virtual const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const = 0;
|
||||
//! Connects a handler to any changes to an RPI::Model. Changes include loading and reloading.
|
||||
virtual void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) = 0;
|
||||
//! Sets the Matrix3x4 for a given mesh handle.
|
||||
virtual void SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) = 0;
|
||||
//! Gets the Matrix3x4 for a given mesh handle.
|
||||
virtual Matrix3x4 GetMatrix3x4(const MeshHandle& meshHandle) = 0;
|
||||
//! Sets the transform for a given mesh handle.
|
||||
virtual void SetTransform(const MeshHandle& meshHandle, const Transform& transform,
|
||||
const Vector3& nonUniformScale = Vector3::CreateOne()) = 0;
|
||||
//! Gets the transform for a given mesh handle.
|
||||
virtual Transform GetTransform(const MeshHandle& meshHandle) = 0;
|
||||
//! Gets the non-uniform scale for a given mesh handle.
|
||||
virtual Vector3 GetNonUniformScale(const MeshHandle& meshHandle) = 0;
|
||||
//! Sets the sort key for a given mesh handle.
|
||||
virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0;
|
||||
//! Gets the sort key for a given mesh handle.
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ namespace AZ
|
||||
void SetProbeOuterExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& outerExtents) override;
|
||||
void SetProbeInnerExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& innerExtents) override;
|
||||
void SetProbeCubeMap(const ReflectionProbeHandle& probe, Data::Instance<RPI::Image>& cubeMapImage) override;
|
||||
void SetProbeMatrix3x4(const ReflectionProbeHandle& probe, const AZ::Matrix3x4& matrix3x4) override;
|
||||
void SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform) override;
|
||||
void BakeProbe(const ReflectionProbeHandle& probe, BuildCubeMapCallback callback) override;
|
||||
void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) override;
|
||||
bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const override { return (probe.get() != nullptr); }
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ namespace AZ
|
||||
virtual void SetProbeOuterExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& outerExtents) = 0;
|
||||
virtual void SetProbeInnerExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& innerExtents) = 0;
|
||||
virtual void SetProbeCubeMap(const ReflectionProbeHandle& handle, Data::Instance<RPI::Image>& cubeMapImage) = 0;
|
||||
virtual void SetProbeMatrix3x4(const ReflectionProbeHandle& handle, const AZ::Matrix3x4& matrix3x4) = 0;
|
||||
virtual void SetProbeTransform(const ReflectionProbeHandle& handle, const AZ::Transform& transform) = 0;
|
||||
virtual void BakeProbe(const ReflectionProbeHandle& handle, BuildCubeMapCallback callback) = 0;
|
||||
virtual void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) = 0;
|
||||
virtual bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const = 0;
|
||||
|
||||
+4
-2
@@ -50,8 +50,10 @@ namespace AZ
|
||||
// TransformServiceFeatureProcessorInterface overrides ...
|
||||
ObjectId ReserveObjectId() override;
|
||||
void ReleaseObjectId(ObjectId& id) override;
|
||||
void SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& matrix3x4) override;
|
||||
AZ::Matrix3x4 GetMatrix3x4ForId(ObjectId id) const override;
|
||||
void SetTransformForId(ObjectId id, const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override;
|
||||
AZ::Transform GetTransformForId(ObjectId id) const override;
|
||||
AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
+8
-5
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Transform.h>
|
||||
#include <AzCore/Math/Vector3.h>
|
||||
#include <Atom/RPI.Public/FeatureProcessor.h>
|
||||
|
||||
namespace AZ
|
||||
@@ -34,11 +35,13 @@ namespace AZ
|
||||
//! Releases an object ID to be used by others. The passed in handle is invalidated.
|
||||
virtual void ReleaseObjectId(ObjectId& id) = 0;
|
||||
|
||||
//! Sets the Matrix3x4 for a given id. Id must be one reserved earlier.
|
||||
virtual void SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& transform) = 0;
|
||||
//! Gets the Matrix3x4 for a given id. Id must be one reserved earlier.
|
||||
virtual AZ::Matrix3x4 GetMatrix3x4ForId(ObjectId) const = 0;
|
||||
|
||||
//! Sets the transform (and optionally non-uniform scale) for a given id. Id must be one reserved earlier.
|
||||
virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform,
|
||||
const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) = 0;
|
||||
//! Gets the transform for a given id. Id must be one reserved earlier.
|
||||
virtual AZ::Transform GetTransformForId(ObjectId) const = 0;
|
||||
//! Gets the non-uniform scale for a given id. Id must be one reserved earlier.
|
||||
virtual AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@ namespace UnitTest
|
||||
MOCK_CONST_METHOD1(GetModel, AZStd::intrusive_ptr<AZ::RPI::Model>(const MeshHandle&));
|
||||
MOCK_CONST_METHOD1(GetMaterialAssignmentMap, const AZ::Render::MaterialAssignmentMap&(const MeshHandle&));
|
||||
MOCK_METHOD2(ConnectModelChangeEventHandler, void(const MeshHandle&, ModelChangedEvent::Handler&));
|
||||
MOCK_METHOD2(SetMatrix3x4, void(const MeshHandle&, const AZ::Matrix3x4&));
|
||||
MOCK_METHOD3(SetTransform, void(const MeshHandle&, const AZ::Transform&, const AZ::Vector3&));
|
||||
MOCK_METHOD2(SetExcludeFromReflectionCubeMaps, void(const MeshHandle&, bool));
|
||||
MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Data::Instance<AZ::RPI::Material>&));
|
||||
MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Render::MaterialAssignmentMap&));
|
||||
MOCK_METHOD1(GetMatrix3x4, AZ::Matrix3x4 (const MeshHandle&));
|
||||
MOCK_METHOD1(GetTransform, AZ::Transform(const MeshHandle&));
|
||||
MOCK_METHOD1(GetNonUniformScale, AZ::Vector3(const MeshHandle&));
|
||||
MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey));
|
||||
MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&));
|
||||
MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride));
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void MeshFeatureProcessor::SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4)
|
||||
void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
{
|
||||
@@ -264,26 +264,39 @@ namespace AZ
|
||||
meshData.m_cullBoundsNeedsUpdate = true;
|
||||
meshData.m_objectSrgNeedsUpdate = true;
|
||||
|
||||
m_transformService->SetMatrix3x4ForId(meshHandle->m_objectId, matrix3x4);
|
||||
m_transformService->SetTransformForId(meshHandle->m_objectId, transform, nonUniformScale);
|
||||
|
||||
// ray tracing data needs to be updated with the new transform
|
||||
if (m_rayTracingFeatureProcessor)
|
||||
{
|
||||
m_rayTracingFeatureProcessor->SetMeshMatrix3x4(meshHandle->m_objectId, matrix3x4);
|
||||
m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform, nonUniformScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Matrix3x4 MeshFeatureProcessor::GetMatrix3x4(const MeshHandle& meshHandle)
|
||||
Transform MeshFeatureProcessor::GetTransform(const MeshHandle& meshHandle)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
{
|
||||
return m_transformService->GetMatrix3x4ForId(meshHandle->m_objectId);
|
||||
return m_transformService->GetTransformForId(meshHandle->m_objectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Invalid mesh handle");
|
||||
return Matrix3x4::CreateIdentity();
|
||||
return Transform::CreateIdentity();
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 MeshFeatureProcessor::GetNonUniformScale(const MeshHandle& meshHandle)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
{
|
||||
return m_transformService->GetNonUniformScaleForId(meshHandle->m_objectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Invalid mesh handle");
|
||||
return Vector3::CreateOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,11 +857,14 @@ namespace AZ
|
||||
AZ_Assert(m_cullBoundsNeedsUpdate, "This function only needs to be called if the culling bounds need to be rebuilt");
|
||||
AZ_Assert(m_model, "The model has not finished loading yet");
|
||||
|
||||
Matrix3x4 localToWorld = transformService->GetMatrix3x4ForId(m_objectId);
|
||||
Transform localToWorld = transformService->GetTransformForId(m_objectId);
|
||||
Vector3 nonUniformScale = transformService->GetNonUniformScaleForId(m_objectId);
|
||||
|
||||
Vector3 center;
|
||||
float radius;
|
||||
Aabb localAabb = m_model->GetAabb();
|
||||
localAabb.MultiplyByScale(nonUniformScale);
|
||||
|
||||
localAabb.GetTransformedAabb(localToWorld).GetAsSphere(center, radius);
|
||||
|
||||
m_cullable.m_cullData.m_boundingSphere = Sphere(center, radius);
|
||||
@@ -922,11 +938,11 @@ namespace AZ
|
||||
|
||||
// retrieve the list of probes that contain the centerpoint of the mesh
|
||||
TransformServiceFeatureProcessor* transformServiceFeatureProcessor = m_scene->GetFeatureProcessor<TransformServiceFeatureProcessor>();
|
||||
Matrix3x4 matrix3x4 = transformServiceFeatureProcessor->GetMatrix3x4ForId(m_objectId);
|
||||
Transform transform = transformServiceFeatureProcessor->GetTransformForId(m_objectId);
|
||||
|
||||
ReflectionProbeFeatureProcessor* reflectionProbeFeatureProcessor = m_scene->GetFeatureProcessor<ReflectionProbeFeatureProcessor>();
|
||||
ReflectionProbeFeatureProcessor::ReflectionProbeVector reflectionProbes;
|
||||
reflectionProbeFeatureProcessor->FindReflectionProbes(matrix3x4.GetTranslation(), reflectionProbes);
|
||||
reflectionProbeFeatureProcessor->FindReflectionProbes(transform.GetTranslation(), reflectionProbes);
|
||||
|
||||
if (!reflectionProbes.empty() && reflectionProbes[0])
|
||||
{
|
||||
|
||||
+2
-1
@@ -80,7 +80,8 @@ namespace AZ
|
||||
->InstanceID(blasIndex)
|
||||
->HitGroupIndex(blasIndex)
|
||||
->Blas(rayTracingSubMesh.m_blas)
|
||||
->Matrix3x4(rayTracingMesh.second.m_matrix3x4)
|
||||
->Transform(rayTracingMesh.second.m_transform)
|
||||
->NonUniformScale(rayTracingMesh.second.m_nonUniformScale)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
// set initial transform
|
||||
mesh.m_matrix3x4 = m_transformServiceFeatureProcessor->GetMatrix3x4ForId(objectId);
|
||||
mesh.m_transform = m_transformServiceFeatureProcessor->GetTransformForId(objectId);
|
||||
|
||||
m_revision++;
|
||||
m_subMeshCount += aznumeric_cast<uint32_t>(subMeshes.size());
|
||||
@@ -141,7 +141,7 @@ namespace AZ
|
||||
m_meshInfoBufferNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void RayTracingFeatureProcessor::SetMeshMatrix3x4(const ObjectId objectId, const AZ::Matrix3x4 matrix3x4)
|
||||
void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, const AZ::Transform transform, const AZ::Vector3 nonUniformScale)
|
||||
{
|
||||
if (!m_rayTracingEnabled)
|
||||
{
|
||||
@@ -151,7 +151,8 @@ namespace AZ
|
||||
MeshMap::iterator itMesh = m_meshes.find(objectId.GetIndex());
|
||||
if (itMesh != m_meshes.end())
|
||||
{
|
||||
itMesh->second.m_matrix3x4 = matrix3x4;
|
||||
itMesh->second.m_transform = transform;
|
||||
itMesh->second.m_nonUniformScale = nonUniformScale;
|
||||
m_revision++;
|
||||
}
|
||||
|
||||
@@ -296,10 +297,10 @@ namespace AZ
|
||||
|
||||
for (const auto& mesh : m_meshes)
|
||||
{
|
||||
AZ::Matrix3x4 meshMatrix3x4 = transformFeatureProcessor->GetMatrix3x4ForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first));
|
||||
AZ::Matrix3x4 noScaleMatrix3x4 = meshMatrix3x4;
|
||||
noScaleMatrix3x4.ExtractScale();
|
||||
AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromMatrix3x4(noScaleMatrix3x4);
|
||||
AZ::Transform meshTransform = transformFeatureProcessor->GetTransformForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first));
|
||||
AZ::Transform noScaleTransform = meshTransform;
|
||||
noScaleTransform.ExtractScale();
|
||||
AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromTransform(noScaleTransform);
|
||||
rotationMatrix = rotationMatrix.GetInverseFull().GetTranspose();
|
||||
|
||||
const RayTracingFeatureProcessor::SubMeshVector& subMeshes = mesh.second.m_subMeshes;
|
||||
|
||||
@@ -66,7 +66,10 @@ namespace AZ
|
||||
SubMeshVector m_subMeshes;
|
||||
|
||||
// mesh transform
|
||||
AZ::Matrix3x4 m_matrix3x4 = AZ::Matrix3x4::CreateIdentity();
|
||||
AZ::Transform m_transform = AZ::Transform::CreateIdentity();
|
||||
|
||||
// mesh non-uniform scale
|
||||
AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne();
|
||||
|
||||
// flag indicating if the Blas objects in the sub-meshes are built
|
||||
bool m_blasBuilt = false;
|
||||
@@ -85,7 +88,8 @@ namespace AZ
|
||||
|
||||
//! Sets the ray tracing mesh transform
|
||||
//! This will cause an update to the RayTracing acceleration structure on the next frame
|
||||
void SetMeshMatrix3x4(const ObjectId objectId, const AZ::Matrix3x4 matrix3x4);
|
||||
void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform,
|
||||
const AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne());
|
||||
|
||||
//! Retrieves ray tracing data for all meshes in the scene
|
||||
const MeshMap& GetMeshes() const { return m_meshes; }
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace AZ
|
||||
m_visualizationMeshHandle = m_meshFeatureProcessor->AcquireMesh(m_visualizationModelAsset);
|
||||
m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_visualizationMeshHandle, true);
|
||||
m_meshFeatureProcessor->SetRayTracingEnabled(m_visualizationMeshHandle, false);
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_visualizationMeshHandle, AZ::Matrix3x4::CreateIdentity());
|
||||
m_meshFeatureProcessor->SetTransform(m_visualizationMeshHandle, AZ::Transform::CreateIdentity());
|
||||
|
||||
// We have to pre-load this asset before creating a Material instance because the InstanceDatabase will attempt a blocking load which could deadlock,
|
||||
// particularly when slices are involved.
|
||||
@@ -206,10 +206,10 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
void ReflectionProbe::SetMatrix3x4(const AZ::Matrix3x4& matrix3x4)
|
||||
void ReflectionProbe::SetTransform(const AZ::Transform& transform)
|
||||
{
|
||||
m_position = matrix3x4.GetTranslation();
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_visualizationMeshHandle, matrix3x4);
|
||||
m_position = transform.GetTranslation();
|
||||
m_meshFeatureProcessor->SetTransform(m_visualizationMeshHandle, transform);
|
||||
m_outerAabbWs = Aabb::CreateCenterHalfExtents(m_position, m_outerExtents / 2.0f);
|
||||
m_innerAabbWs = Aabb::CreateCenterHalfExtents(m_position, m_innerExtents / 2.0f);
|
||||
m_updateSrg = true;
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace AZ
|
||||
void Simulate(uint32_t probeIndex);
|
||||
|
||||
const Vector3& GetPosition() const { return m_position; }
|
||||
void SetMatrix3x4(const AZ::Matrix3x4& matrix3x4);
|
||||
void SetTransform(const AZ::Transform& transform);
|
||||
|
||||
const AZ::Vector3& GetOuterExtents() const { return m_outerExtents; }
|
||||
void SetOuterExtents(const AZ::Vector3& outerExtents);
|
||||
|
||||
+4
-4
@@ -222,7 +222,7 @@ namespace AZ
|
||||
{
|
||||
AZStd::shared_ptr<ReflectionProbe> reflectionProbe = AZStd::make_shared<ReflectionProbe>();
|
||||
reflectionProbe->Init(GetParentScene(), &m_reflectionRenderData);
|
||||
reflectionProbe->SetMatrix3x4(AZ::Matrix3x4::CreateFromTransform(transform));
|
||||
reflectionProbe->SetTransform(transform);
|
||||
reflectionProbe->SetUseParallaxCorrection(useParallaxCorrection);
|
||||
m_reflectionProbes.push_back(reflectionProbe);
|
||||
m_probeSortRequired = true;
|
||||
@@ -263,10 +263,10 @@ namespace AZ
|
||||
probe->SetCubeMapImage(cubeMapImage);
|
||||
}
|
||||
|
||||
void ReflectionProbeFeatureProcessor::SetProbeMatrix3x4(const ReflectionProbeHandle& probe, const AZ::Matrix3x4& matrix3x4)
|
||||
void ReflectionProbeFeatureProcessor::SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform)
|
||||
{
|
||||
AZ_Assert(probe.get(), "SetProbeMatrix3x4 called with an invalid handle");
|
||||
probe->SetMatrix3x4(matrix3x4);
|
||||
AZ_Assert(probe.get(), "SetProbeTransform called with an invalid handle");
|
||||
probe->SetTransform(transform);
|
||||
m_probeSortRequired = true;
|
||||
}
|
||||
|
||||
|
||||
+16
-4
@@ -210,12 +210,14 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void TransformServiceFeatureProcessor::SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& matrix3x4)
|
||||
void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale)
|
||||
{
|
||||
AZ_Error("TransformServiceFeatureProcessor", m_isWriteable, "Transform data cannot be written to during this phase");
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle.");
|
||||
if (id.IsValid())
|
||||
{
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(transform);
|
||||
matrix3x4.MultiplyByScale(nonUniformScale);
|
||||
matrix3x4.StoreToRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
|
||||
// Inverse transpose to take the non-uniform scale out of the transform for usage with normals.
|
||||
@@ -224,10 +226,20 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Matrix3x4 TransformServiceFeatureProcessor::GetMatrix3x4ForId(ObjectId id) const
|
||||
AZ::Transform TransformServiceFeatureProcessor::GetTransformForId(ObjectId id) const
|
||||
{
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle.");
|
||||
return AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the transform for an invalid handle.");
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
AZ::Transform transform = AZ::Transform::CreateFromMatrix3x4(matrix3x4);
|
||||
transform.ExtractScale();
|
||||
return transform;
|
||||
}
|
||||
|
||||
AZ::Vector3 TransformServiceFeatureProcessor::GetNonUniformScaleForId(ObjectId id) const
|
||||
{
|
||||
AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the non-uniform scale for an invalid handle.");
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform);
|
||||
return matrix3x4.RetrieveScale();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,8 @@ namespace AZ
|
||||
{
|
||||
uint32_t m_instanceID = 0;
|
||||
uint32_t m_hitGroupIndex = 0;
|
||||
AZ::Matrix3x4 m_matrix3x4 = AZ::Matrix3x4::CreateIdentity();
|
||||
AZ::Transform m_transform = AZ::Transform::CreateIdentity();
|
||||
AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne();
|
||||
RHI::Ptr<RHI::RayTracingBlas> m_blas;
|
||||
};
|
||||
using RayTracingTlasInstanceVector = AZStd::vector<RayTracingTlasInstance>;
|
||||
@@ -153,7 +154,8 @@ namespace AZ
|
||||
RayTracingTlasDescriptor* Instance();
|
||||
RayTracingTlasDescriptor* InstanceID(uint32_t instanceID);
|
||||
RayTracingTlasDescriptor* HitGroupIndex(uint32_t hitGroupIndex);
|
||||
RayTracingTlasDescriptor* Matrix3x4(const AZ::Matrix3x4& matrix3x4);
|
||||
RayTracingTlasDescriptor* Transform(const AZ::Transform& transform);
|
||||
RayTracingTlasDescriptor* NonUniformScale(const AZ::Vector3& nonUniformScale);
|
||||
RayTracingTlasDescriptor* Blas(RHI::Ptr<RHI::RayTracingBlas>& blas);
|
||||
RayTracingTlasDescriptor* InstancesBuffer(RHI::Ptr<RHI::Buffer>& tlasInstances);
|
||||
RayTracingTlasDescriptor* NumInstances(uint32_t numInstancesInBuffer);
|
||||
|
||||
@@ -78,13 +78,20 @@ namespace AZ
|
||||
return this;
|
||||
}
|
||||
|
||||
RayTracingTlasDescriptor* RayTracingTlasDescriptor::Matrix3x4(const AZ::Matrix3x4& matrix3x4)
|
||||
RayTracingTlasDescriptor* RayTracingTlasDescriptor::Transform(const AZ::Transform& transform)
|
||||
{
|
||||
AZ_Assert(m_buildContext, "Matrix3x4 property can only be added to an Instance entry");
|
||||
m_buildContext->m_matrix3x4 = matrix3x4;
|
||||
AZ_Assert(m_buildContext, "Transform property can only be added to an Instance entry");
|
||||
m_buildContext->m_transform = transform;
|
||||
return this;
|
||||
}
|
||||
|
||||
RayTracingTlasDescriptor* RayTracingTlasDescriptor::NonUniformScale(const AZ::Vector3& nonUniformScale)
|
||||
{
|
||||
AZ_Assert(m_buildContext, "NonUniformSCale property can only be added to an Instance entry");
|
||||
m_buildContext->m_nonUniformScale = nonUniformScale;
|
||||
return this;
|
||||
}
|
||||
|
||||
RayTracingTlasDescriptor* RayTracingTlasDescriptor::Blas(RHI::Ptr<RHI::RayTracingBlas>& blas)
|
||||
{
|
||||
AZ_Assert(m_buildContext, "Blas property can only be added to an Instance entry");
|
||||
|
||||
@@ -89,7 +89,9 @@ namespace AZ
|
||||
mappedData[i].InstanceID = instance.m_instanceID;
|
||||
mappedData[i].InstanceContributionToHitGroupIndex = instance.m_hitGroupIndex;
|
||||
// convert transform to row-major 3x4
|
||||
instance.m_matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]);
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform);
|
||||
matrix3x4.MultiplyByScale(instance.m_nonUniformScale);
|
||||
matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]);
|
||||
mappedData[i].AccelerationStructure = static_cast<DX12::Buffer*>(blas->GetBuffers().m_blasBuffer.get())->GetMemoryView().GetGpuAddress();
|
||||
// [GFX TODO][ATOM-5270] Add ray tracing TLAS instance mask support
|
||||
mappedData[i].InstanceMask = 0x1;
|
||||
|
||||
@@ -92,7 +92,9 @@ namespace AZ
|
||||
|
||||
mappedData[i].instanceCustomIndex = instance.m_instanceID;
|
||||
mappedData[i].instanceShaderBindingTableRecordOffset = instance.m_hitGroupIndex;
|
||||
instance.m_matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]);
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform);
|
||||
matrix3x4.MultiplyByScale(instance.m_nonUniformScale);
|
||||
matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]);
|
||||
|
||||
RayTracingBlas* blas = static_cast<RayTracingBlas*>(instance.m_blas.get());
|
||||
VkAccelerationStructureDeviceAddressInfoKHR addressInfo = {};
|
||||
|
||||
+10
-13
@@ -214,6 +214,8 @@ namespace AZ
|
||||
MaterialReceiverRequestBus::Handler::BusDisconnect();
|
||||
MaterialComponentNotificationBus::Handler::BusDisconnect();
|
||||
|
||||
m_nonUniformScaleChangedHandler.Disconnect();
|
||||
|
||||
m_meshFeatureProcessor = nullptr;
|
||||
m_transformInterface = nullptr;
|
||||
m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId);
|
||||
@@ -232,22 +234,18 @@ namespace AZ
|
||||
|
||||
void MeshComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, [[maybe_unused]] const AZ::Transform& world)
|
||||
{
|
||||
UpdateOverallMatrix();
|
||||
if (m_meshFeatureProcessor)
|
||||
{
|
||||
m_meshFeatureProcessor->SetTransform(m_meshHandle, world, m_cachedNonUniformScale);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3 & nonUniformScale)
|
||||
{
|
||||
m_cachedNonUniformScale = nonUniformScale;
|
||||
UpdateOverallMatrix();
|
||||
}
|
||||
|
||||
void MeshComponentController::UpdateOverallMatrix()
|
||||
{
|
||||
if (m_meshFeatureProcessor)
|
||||
{
|
||||
Matrix3x4 world = Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM());
|
||||
world.MultiplyByScale(m_cachedNonUniformScale);
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, world);
|
||||
m_meshFeatureProcessor->SetTransform(m_meshHandle, m_transformInterface->GetWorldTM(), m_cachedNonUniformScale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,10 +291,9 @@ namespace AZ
|
||||
m_meshHandle = m_meshFeatureProcessor->AcquireMesh(m_configuration.m_modelAsset, materials);
|
||||
m_meshFeatureProcessor->ConnectModelChangeEventHandler(m_meshHandle, m_changeEventHandler);
|
||||
|
||||
const AZ::Matrix3x4& matrix3x4 = m_transformInterface
|
||||
? Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()) * Matrix3x4::CreateScale(m_cachedNonUniformScale)
|
||||
: Matrix3x4::Identity();
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, matrix3x4);
|
||||
const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : AZ::Transform::CreateIdentity();
|
||||
|
||||
m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale);
|
||||
m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey);
|
||||
m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride);
|
||||
m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps);
|
||||
|
||||
@@ -124,7 +124,6 @@ namespace AZ
|
||||
void RefreshModelRegistration();
|
||||
|
||||
void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale);
|
||||
void UpdateOverallMatrix();
|
||||
|
||||
Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr;
|
||||
Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
|
||||
m_featureProcessor->SetProbeMatrix3x4(m_handle, Matrix3x4::CreateFromTransform(world));
|
||||
m_featureProcessor->SetProbeTransform(m_handle, world);
|
||||
}
|
||||
|
||||
void ReflectionProbeComponentController::OnShapeChanged(ShapeChangeReasons changeReason)
|
||||
|
||||
@@ -192,9 +192,8 @@ namespace AZ
|
||||
|
||||
void AtomActorInstance::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world)
|
||||
{
|
||||
// The mesh Matrix3x4 is used to determine where the actor instance is actually rendered
|
||||
AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(world);
|
||||
m_meshFeatureProcessor->SetMatrix3x4(*m_meshHandle, matrix3x4); // handle validity is checked internally.
|
||||
// The mesh transform is used to determine where the actor instance is actually rendered
|
||||
m_meshFeatureProcessor->SetTransform(*m_meshHandle, world); // handle validity is checked internally.
|
||||
|
||||
if (m_skinnedMeshRenderProxy.IsValid())
|
||||
{
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Blast
|
||||
|
||||
AZ::Transform transform = AZ::Transform::Identity();
|
||||
AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformInterface::GetWorldTM);
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(transform));
|
||||
m_meshFeatureProcessor->SetTransform(m_meshHandle, transform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Blast
|
||||
{
|
||||
if (m_meshFeatureProcessor)
|
||||
{
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(world));
|
||||
m_meshFeatureProcessor->SetTransform(m_meshHandle, world);
|
||||
}
|
||||
}
|
||||
} // namespace Blast
|
||||
|
||||
@@ -74,10 +74,7 @@ namespace Blast
|
||||
{
|
||||
if (m_chunkActors[chunkId])
|
||||
{
|
||||
auto matrix3x4 = AZ::Matrix3x4::CreateFromTransform(m_chunkActors[chunkId]->GetWorldBody()->GetTransform());
|
||||
// Multiply by scale because the transform on the world body does not store scale
|
||||
matrix3x4.MultiplyByScale(m_scale);
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_chunkMeshHandles[chunkId], matrix3x4);
|
||||
m_meshFeatureProcessor->SetTransform(m_chunkMeshHandles[chunkId], m_chunkActors[chunkId]->GetWorldBody()->GetTransform(), m_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace Blast
|
||||
|
||||
// ActorRenderManager::SyncMeshes
|
||||
{
|
||||
EXPECT_CALL(*m_mockMeshFeatureProcessor, SetMatrix3x4(_, _))
|
||||
EXPECT_CALL(*m_mockMeshFeatureProcessor, SetTransform(_, _, _))
|
||||
.Times(aznumeric_cast<int>(m_actorFactory->m_mockActors[0]->GetChunkIndices().size()));
|
||||
actorRenderManager->SyncMeshes();
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace WhiteBox
|
||||
|
||||
void AtomRenderMesh::UpdateTransform(const AZ::Transform& worldFromLocal)
|
||||
{
|
||||
m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(worldFromLocal));
|
||||
m_meshFeatureProcessor->SetTransform(m_meshHandle, worldFromLocal);
|
||||
}
|
||||
|
||||
void AtomRenderMesh::UpdateMaterial([[maybe_unused]] const WhiteBoxMaterial& material)
|
||||
|
||||
Reference in New Issue
Block a user