updating atom mesh component to support non-uniform scale component

This commit is contained in:
greerdv
2021-04-14 14:05:59 +01:00
parent 5de3ff4c61
commit 2fb2813b48
35 changed files with 166 additions and 84 deletions
@@ -164,15 +164,15 @@ namespace AZ
return false;
}
bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor) const
bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor) const
{
AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender);
const AZ::Transform inverseTM = modelTransform.GetInverse();
const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart);
const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / nonUniformScale;
// 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);
const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / nonUniformScale;
const AZ::Vector3 rayDirLocal = rayDestLocal - raySrcLocal;
return LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor);