IIntersect Class Reference

#include <lib_intersect.h>

Detailed Description

Intersect interface.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 IIntersect ()
 
 ~IIntersect ()
 

Alloc/Free

static IIntersectAlloc (INTERSECTTYPE type)
 
static void Free (IIntersect *&isect)
 

Miscellaneous

Bool Init (PolygonObject *pObject)
 
Bool AddObject (PolygonObject *pObject)
 
void Clear ()
 

Hit

Bool Hit (BaseDraw *bd, Float mx, Float my, Bool backfaces, IntersectHitData &hitData)
 
Bool Hit (const Vector &rayp, const Vector &rayv, Bool backfaces, IntersectHitData &hitData)
 

Constructor & Destructor Documentation

◆ IIntersect()

IIntersect ( )
private

◆ ~IIntersect()

~IIntersect ( )
private

Member Function Documentation

◆ Alloc()

static IIntersect* Alloc ( INTERSECTTYPE  type)
static

Allocates an intersect interface. Destroy the allocated intersect interface with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]typeThe intersect type: INTERSECTTYPE
Returns
The allocated intersect interface, or nullptr if the allocation failed.

◆ Free()

static void Free ( IIntersect *&  isect)
static

Destructs intersect interfaces allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]isectThe intersect interface to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ Init()

Bool Init ( PolygonObject pObject)

Adds the PolygonObject pObject to the data structure for intersection testing against the triangles.

Note
Internally this calls Clear() before.
Parameters
[in]pObjectThe polygon object to set. The caller owns the pointed object.
Returns
true if successful, otherwise false. (Due to not enough memory.)

◆ AddObject()

Bool AddObject ( PolygonObject pObject)

Adds another polygon object object.

Parameters
[in]pObjectThe polygon object to set. The caller owns the pointed object.
Returns
true if successful, otherwise false. (Due to not enough memory.)

◆ Clear()

void Clear ( )

Clears all the data.

◆ Hit() [1/2]

Bool Hit ( BaseDraw bd,
Float  mx,
Float  my,
Bool  backfaces,
IntersectHitData hitData 
)

From a viewport cast a ray, in screen space, onto the object(s) and return any data if there was a hit.
Returns the closest hit point if multiple intersections are found.

Parameters
[in]bdThe view that the user is casting the ray from. The caller owns the pointed view.
[in]mxThe X coordinate (mouse coordinate) in screen space.
[in]myThe Y coordinate (mouse coordinate) in screen space.
[in]backfacestrue to allow back facing polygons to be hit tested.
If enabled and the back facing hit point is closer than the front hit point, then it is returned.
[out]hitDataFilled with the intersection data if there was a hit.
Returns
true if there was a hit, otherwise false.

◆ Hit() [2/2]

Bool Hit ( const Vector rayp,
const Vector rayv,
Bool  backfaces,
IntersectHitData hitData 
)

Given a ray in object space do a hit intersection against the object(s) and return any data if there was a hit.
Return the closest hit point if multiple intersections are found.

Parameters
[in]raypThe starting position of the ray in object space.
[in]rayvThe direction the ray is pointing.
[in]backfacestrue to allow back facing polygons to be hit tested.
If enabled and the back facing hit point is closer than the front hit point, then it is returned.
[out]hitDataFilled with the intersection data if there was a hit.
Returns
true if there was a hit, otherwise false.