#include <lib_collider.h>
Ray collider engine : evaluates intersections between a ray and a single polygon object. The polygons are split into two triangles each when calculating the intersections, thus affecting the intersection count when the invisible shared edges are hit. The original polygon object remains unmodified.
Public Member Functions | |
Bool | Init (BaseObject *goal, Bool force=false) |
Bool | Intersect (const Vector &ray_p, const Vector &ray_dir, Float ray_length, Bool only_test=false) |
Int32 | GetIntersectionCount () |
Bool | GetIntersection (Int32 number, GeRayColResult *res) |
Bool | GetNearestIntersection (GeRayColResult *res) |
Static Public Member Functions | |
static GeRayCollider * | Alloc () |
static void | Free (GeRayCollider *&data) |
Private Member Functions | |
GeRayCollider () | |
~GeRayCollider () | |
|
private |
|
private |
|
static |
|
static |
Bool Init | ( | BaseObject * | goal, |
Bool | force = false |
||
) |
Initializes the ray collider with the object specified by goal.
[in] | goal | The object to check for intersections. The pointed object is copied. |
[in] | force | If false then Cinema 4D checks if the passed object's GetDirty(DIRTYFLAGS::DATA) is unchanged. If yes, it does nothing and returns true.If true it always rebuilds the cache. |
Bool Intersect | ( | const Vector & | ray_p, |
const Vector & | ray_dir, | ||
Float | ray_length, | ||
Bool | only_test = false |
||
) |
Checks if the line segment specified by ray_p to ray_p + ray_dir*ray_length intersects the object.
If only_test is false the intersections can be evaluated with GetIntersectionCount() and GetIntersection().
[in] | ray_p | The start point of the ray in object coordinates. |
[in] | ray_dir | The ray direction in object coordinates. |
[in] | ray_length | The ray length. |
[in] | only_test | If true no information about the intersections are stored, so only the return value can be used to tell if there were intersections or not. |
Int32 GetIntersectionCount | ( | ) |
Retrieves the number of intersections found by Intersect(), which is in terms of the amount of triangles hit by the ray. Intersecting a shared edge will result in a value greater than one. Intersecting a shared edge point will result in a value that varies depending on how the polygon object is split up into triangles.
Bool GetIntersection | ( | Int32 | number, |
GeRayColResult * | res | ||
) |
Retrieves intersections, found with Intersect(), by index.
[in] | number | The intersection index: 0 <= number < GetIntersectionCount() |
[out] | res | Assigned the intersection information. The caller owns the pointed GeRayColResult. |
Bool GetNearestIntersection | ( | GeRayColResult * | res | ) |
Retrieves the intersection, found with Intersect(), closest to the start of the ray.
[in] | res | Assigned the intersection information. The caller owns the pointed GeRayColResult. |