Add a new implementation for cone/ray intersect to simplify code and fix issue with current implementation (#3902)
* add a new implementation for cone/ray intersect to simplify and fix existing issue Signed-off-by: hultonha <hultonha@amazon.co.uk> * move new ray/cone intersection function to AzToolsFramework - repond to PR comments Signed-off-by: hultonha <hultonha@amazon.co.uk> * updates following PR feedback Signed-off-by: hultonha <hultonha@amazon.co.uk> * add additional comment to give more context to the intersection function Signed-off-by: hultonha <hultonha@amazon.co.uk> * update google test expect usage Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
@@ -628,7 +628,7 @@ int AZ::Intersect::IntersectRayCappedCylinder(
|
||||
int AZ::Intersect::IntersectRayCone(
|
||||
const Vector3& rayOrigin, const Vector3& rayDir,
|
||||
const Vector3& coneApex, const Vector3& coneDir, float coneHeight,
|
||||
float coneBaseRaidus, float& t1, float& t2)
|
||||
float coneBaseRadius, float& t1, float& t2)
|
||||
{
|
||||
// Q = rayOrgin, A = coneApex
|
||||
Vector3 AQ = rayOrigin - coneApex;
|
||||
@@ -646,7 +646,7 @@ int AZ::Intersect::IntersectRayCone(
|
||||
return 0;
|
||||
}
|
||||
|
||||
float r2 = coneBaseRaidus * coneBaseRaidus;
|
||||
float r2 = coneBaseRadius * coneBaseRadius;
|
||||
float h2 = coneHeight * coneHeight;
|
||||
|
||||
float m2 = m * m;
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace AZ
|
||||
//! @return The number of intersecting points.
|
||||
int IntersectRayCone(
|
||||
const Vector3& rayOrigin, const Vector3& rayDir,
|
||||
const Vector3& coneApex, const Vector3& coneDir, float coneHeight, float coneBaseRaidus,
|
||||
const Vector3& coneApex, const Vector3& coneDir, float coneHeight, float coneBaseRadius,
|
||||
float& t1, float& t2);
|
||||
|
||||
//! Test intersection between a ray and a plane in 3D.
|
||||
|
||||
@@ -609,6 +609,21 @@ namespace UnitTest
|
||||
EXPECT_EQ(hits, 0);
|
||||
}
|
||||
|
||||
// replicates a scenario in the Editor using a cone and a pick ray which should have failed but passed
|
||||
// note: To replicate this, select an entity so the default translation manipulator appears, move very close to the
|
||||
// entity, hover the mouse over one of the manipulator linear manipulator arrows (cone part) and move the mouse away
|
||||
// notice the manipulator will remain highlighted as a successful intersection is still reported
|
||||
TEST(MATH_IntersectRayConeTestEditor, DISABLED_RayConeEditorScenarioTest)
|
||||
{
|
||||
auto rayOrigin = Vector3(0.0f, -0.808944702f, 0.0f);
|
||||
auto rayDir = Vector3(0.301363617f, 0.939044654f, 0.165454566f);
|
||||
float t1 = 0.0f;
|
||||
float t2 = 0.0f;
|
||||
int hits = Intersect::IntersectRayCone(
|
||||
rayOrigin, rayDir, AZ::Vector3(0.0f, 0.0f, 0.161788940f), AZ::Vector3(0.0f, 0.0f, -1.0f), 0.0453009047, 0.0113252262, t1, t2);
|
||||
EXPECT_EQ(hits, 0);
|
||||
}
|
||||
|
||||
class MATH_IntersectRayQuadTest
|
||||
: public AllocatorsFixture
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user