updating atom mesh component to support non-uniform scale component
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user