Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Intersect::SegmentTriangleHitTester Class Reference

#include <IntersectSegment.h>

Public Member Functions

 SegmentTriangleHitTester (const AZ::Vector3 &p, const AZ::Vector3 &q)
 
bool IntersectSegmentTriangleCCW (const AZ::Vector3 &a, const AZ::Vector3 &b, const AZ::Vector3 &c, AZ::Vector3 &normal, float &t) const
 
bool IntersectSegmentTriangle (const AZ::Vector3 &a, const AZ::Vector3 &b, const AZ::Vector3 &c, AZ::Vector3 &normal, float &t) const
 
AZ::Vector3 GetIntersectionPoint (float t) const
 

Detailed Description

SegmentTriangleHitTester is an optimized form of "watertight" segment/triangle collisions that is designed to compare a single segment against multiple triangles. Construction of the class pre-computes information about the segment itself so that each triangle intersection API call can perform less setup work. Usage: SegmentTriangleHitTester hitTester(rayStart, rayEnd); for (auto& tri : triangles) if (hitTester.IntersectSegmentTriangle(tri.a, tri.b, tri.c, outNormal, outT)) hitPoint = rayStart + (rayEnd - rayStart) * outT;

Constructor & Destructor Documentation

◆ SegmentTriangleHitTester()

AZ::Intersect::SegmentTriangleHitTester::SegmentTriangleHitTester ( const AZ::Vector3 p,
const AZ::Vector3 q 
)

Construct a hit tester for segment pq that can be used to compare against multiple triangles.

Parameters
pSegment start point.
qSegment end point.

Member Function Documentation

◆ GetIntersectionPoint()

AZ::Vector3 AZ::Intersect::SegmentTriangleHitTester::GetIntersectionPoint ( float  t) const
inline

Gets the segment intersection point for a given Time of intersection 't'.

Parameters
tTime of intersection along the segment [0.0 (p), 1.0 (q)].
Returns
The point on the segment where the intersection occurred.

◆ IntersectSegmentTriangle()

bool AZ::Intersect::SegmentTriangleHitTester::IntersectSegmentTriangle ( const AZ::Vector3 a,
const AZ::Vector3 b,
const AZ::Vector3 c,
AZ::Vector3 normal,
float &  t 
) const
inline

Same as IntersectSegmentTriangleCCW without respecting the triangle (a,b,c) vertex order (i.e. double sided).

Parameters
aTriangle vertex 1.
bTriangle vertex 2.
cTriangle vertex 3.
normalTriangle normal at the intersection point if segment intersects triangle.
tTime of intersection along the segment [0.0 (p), 1.0 (q)] if segment intersects triangle.
Returns
true if the segment intersects the triangle otherwise false.

◆ IntersectSegmentTriangleCCW()

bool AZ::Intersect::SegmentTriangleHitTester::IntersectSegmentTriangleCCW ( const AZ::Vector3 a,
const AZ::Vector3 b,
const AZ::Vector3 c,
AZ::Vector3 normal,
float &  t 
) const
inline

For the given segment pq and a triangle abc (CCW), returns whether the segment intersects the triangle and if so, also returns the time of intersection along the segment and the triangle normal.

Parameters
aTriangle vertex 1.
bTriangle vertex 2.
cTriangle vertex 3.
normalTriangle normal at the intersection point if segment intersects triangle.
tTime of intersection along the segment [0.0 (p), 1.0 (q)] if segment intersects triangle.
Returns
true if the segment intersects the triangle otherwise false.

The documentation for this class was generated from the following file: