#include <lib_intersect.h>
Intersect interface.
- Note
- Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
◆ IIntersect()
◆ ~IIntersect()
◆ Alloc()
Allocates an intersect interface. Destroy the allocated intersect interface with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Parameters
-
- Returns
- The allocated intersect interface, or nullptr if the allocation failed.
◆ Free()
Destructs intersect interfaces allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.
- Parameters
-
[in,out] | isect | The intersect interface to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards. |
◆ Init()
Adds the PolygonObject pObject to the data structure for intersection testing against the triangles.
- Note
- Internally this calls Clear() before.
- Parameters
-
[in] | pObject | The polygon object to set. The caller owns the pointed object. |
- Returns
- true if successful, otherwise false. (Due to not enough memory.)
◆ AddObject()
Adds another polygon object object.
- Parameters
-
[in] | pObject | The polygon object to set. The caller owns the pointed object. |
- Returns
- true if successful, otherwise false. (Due to not enough memory.)
◆ Clear()
◆ Hit() [1/2]
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] | bd | The view that the user is casting the ray from. The caller owns the pointed view. |
[in] | mx | The X coordinate (mouse coordinate) in screen space. |
[in] | my | The Y coordinate (mouse coordinate) in screen space. |
[in] | backfaces | true 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] | hitData | Filled with the intersection data if there was a hit. |
- Returns
- true if there was a hit, otherwise false.
◆ Hit() [2/2]
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] | rayp | The starting position of the ray in object space. |
[in] | rayv | The direction the ray is pointing. |
[in] | backfaces | true 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] | hitData | Filled with the intersection data if there was a hit. |
- Returns
- true if there was a hit, otherwise false.