From 496891b4c05686879a883619a8ccf54a49d5b275 Mon Sep 17 00:00:00 2001 From: greerdv Date: Wed, 21 Apr 2021 10:55:05 +0100 Subject: [PATCH] feedback from PR --- .../Include/Atom/RHI/RayTracingAccelerationStructure.h | 2 +- Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp | 8 +++++--- .../Code/Source/Mesh/MeshComponentController.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h index 317094e24c..5fde518cb2 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h @@ -12,7 +12,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 46059a3132..15c8aaf528 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -167,16 +167,18 @@ namespace AZ bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const { AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender); + const AZ::Vector3 clampedScale = nonUniformScale.GetMax(AZ::Vector3(AZ::MinTransformScale)); + const AZ::Transform inverseTM = modelTransform.GetInverse(); - const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / nonUniformScale; + const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / clampedScale; // Instead of just rotating 'dir' we need it to be scaled too, so that 'distanceFactor' will be in the target units rather than object local units. const AZ::Vector3 rayDest = rayStart + dir; - const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / nonUniformScale; + const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / clampedScale; const AZ::Vector3 rayDirLocal = rayDestLocal - raySrcLocal; bool result = LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor, normal); - normal = (normal * nonUniformScale).GetNormalized(); + normal = (normal * clampedScale).GetNormalized(); return result; } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index c99ca7b848..b0315fdf9c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -232,7 +232,7 @@ namespace AZ return m_configuration; } - void MeshComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, [[maybe_unused]] const AZ::Transform& world) + void MeshComponentController::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world) { if (m_meshFeatureProcessor) {