Updates to kd-tree ray intersection - ATOM-15673 (#1026)

* updates to kd-tree ray intersection

* update tests for kd-tree

* add one more test for kd-tree intersection

* updates to ModelKdTree following review feedback

* improve api doc comment for RayIntersection in ModelKdTree

* updates following review feedback

* update .clang-format to stack parameters if they do not all fit on one line
This commit is contained in:
Tom Hulton-Harrop
2021-06-02 09:20:45 +01:00
committed by GitHub
parent 0f699cfd47
commit 4a5b7edbfe
7 changed files with 143 additions and 44 deletions
@@ -485,16 +485,12 @@ namespace AZ
m_transformInterface->GetWorldTM(), m_cachedNonUniformScale, ray.m_startWorldPosition,
ray.m_endWorldPosition - ray.m_startWorldPosition, t, normal))
{
// note: this is a temporary workaround to handle cases where model->RayIntersection
// returns negative distances, follow-up ATOM-15673
const auto absT = AZStd::abs(t);
// fill in ray result structure after successful intersection
const auto intersectionLine = (ray.m_endWorldPosition - ray.m_startWorldPosition);
result.m_uv = AZ::Vector2::CreateZero();
result.m_worldPosition = ray.m_startWorldPosition + intersectionLine * absT;
result.m_worldPosition = ray.m_startWorldPosition + intersectionLine * t;
result.m_worldNormal = normal;
result.m_distance = intersectionLine.GetLength() * absT;
result.m_distance = intersectionLine.GetLength() * t;
result.m_entityAndComponent = m_entityComponentIdPair;
}
}