GeRayCollider Class Reference Library » Collider

#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.

注意
Has to be created with Alloc() and destroyed with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

公共成员函数

Bool   Init ( BaseObject *goal, Bool force=false)
Bool   Intersect (const 向量 &ray_p, const 向量 &ray_dir, Float ray_length, Bool only_test=false)
Int32   GetIntersectionCount ()
Bool   GetIntersection ( Int32 number, GeRayColResult *res)
Bool   GetNearestIntersection ( GeRayColResult *res)

静态公共成员函数

static GeRayCollider Alloc ()
static void  Free ( GeRayCollider *&data)

私有成员函数

  GeRayCollider ()
  ~GeRayCollider ()

构造函数 & 析构函数文档编制

◆  GeRayCollider()

GeRayCollider () private

◆  ~GeRayCollider()

~ GeRayCollider () private

成员函数文档编制

◆  Alloc()

static GeRayCollider * Alloc ( )
static

Allocates a ray collider engine. Destroy the allocated ray collider engine with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

返回
The allocated ray collider engine, or nullptr if the allocation failed.

◆  Free()

static void Free ( GeRayCollider *&  data )
static

Destructs ray collider engines allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in,out] data The ray collider engine to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  Init()

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 false then Cinema 4D checks if the passed object's GetDirty(DIRTYFLAGS::DATA) is unchanged. If yes, it does nothing and returns true .
true it always rebuilds the cache.
返回
true if successful, otherwise false .

◆  Intersect()

Bool Intersect ( const 向量 ray_p ,
const 向量 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.
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 true no information about the intersections are stored, so only the return value can be used to tell if there were intersections or not.
返回
true if there was an intersection, otherwise false .

◆  GetIntersectionCount()

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.

返回
The number of intersections.

◆  GetIntersection()

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 .
返回
true if successful, otherwise false .

◆  GetNearestIntersection()

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 .
返回
true if successful, otherwise false .