GeColliderCache Class Reference Library » Collider

#include <lib_collider.h>

详细描述

Collision cache : stores a set of triangles, each with an ID, for use with the other collision classes.

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

The following function fills a GeColliderCache from a BaseObject :

Bool FillColliderCache( GeColliderCache & c, BaseObject & obj) { // Get polygon object ModelingCommandData md1; md1. op = &obj; md1. doc = obj. GetDocument (); if (! SendModelingCommand ( MCOMMAND_CURRENTSTATETOOBJECT , md1)) return false ;

// Triangulate it ModelingCommandData md2; md2. op = static_cast< BaseObject * > (md1. result -> GetIndex (0)); if (! SendModelingCommand ( MCOMMAND_TRIANGULATE , md2)) return false ; AutoAlloc<PolygonObject> poly( static_cast< PolygonObject * > (md2. op )); if (!poly) return false ;

// Get the polygon data CPolygon * tris = poly->GetPolygon(); 向量 * points = poly-> GetPoint ();

// Fill the cache

if (c. BeginInput (poly->GetPolygonCount()) != COL_OK ) return false ;
for ( int i = 0; i < poly->GetPolygonCount(); ++i) { if (c. AddTriangle (points[tris[i].a], points[tris[i].b], points[tris[i].c], i) != COL_OK ) return false ; } if (c. EndInput () != COL_OK ) return false ; return true ; }

公共成员函数

Bool   CopyTo ( GeColliderCache *dest)
Int32   BeginInput ( Int32 cnt_tris)
Int32   AddTriangle (const 向量 &p1, const 向量 &p2, const 向量 &p3, Int32 id)
Int32   EndInput ()

静态公共成员函数

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

私有成员函数

  GeColliderCache ()
  ~GeColliderCache ()

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

◆  GeColliderCache()

GeColliderCache () private

◆  ~GeColliderCache()

~ GeColliderCache () private

成员函数文档编制

◆  Alloc()

static GeColliderCache * Alloc ( )
static

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

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

◆  Free()

static void Free ( GeColliderCache *&  data )
static

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

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

◆  CopyTo()

Bool CopyTo ( GeColliderCache dest )

Copies all triangles to another cache.

参数
[in,out] dest The destination cache. The caller owns the pointed collider cache.
返回
true if successful, otherwise false .

◆  BeginInput()

Int32 BeginInput ( Int32   cnt_tris )

Call this function before storing triangles into the cache. Removes any previous data and allocates space for cnt_tris number of triangles.

参数
[in] cnt_tris The number of triangles to store.
返回
The result: COL

◆  AddTriangle()

Int32 AddTriangle ( const 向量 p1 ,
const 向量 p2 ,
const 向量 p3 ,
Int32   id  
)

Adds a triangle to the cache with the specified corners and id .

参数
[in] p1 The first point.
[in] p2 The second point.
[in] p3 The third point.
[in] id The triangle ID.
返回
The result: COL

◆  EndInput()

Int32 EndInput ( )

Call this function after storing triangles into the cache.

返回
The result: COL
GeColliderCache::EndInput
Int32 EndInput()
ModelingCommandData::result
AtomArray * result
定义: operatingsystem.h:828
SendModelingCommand
Bool SendModelingCommand(Int32 command, ModelingCommandData &data)
BaseObject
定义: c4d_baseobject.h:224
CPolygon
Represents a polygon that can be either a triangle or a quadrangle.
定义: c4d_baseobject.h:43
GeColliderCache::BeginInput
Int32 BeginInput(Int32 cnt_tris)
CPolygon::GetPoint
Int32 & GetPoint(Int32 index) const
定义: c4d_baseobject.h:131
GeColliderCache::AddTriangle
Int32 AddTriangle(const Vector &p1, const Vector &p2, const Vector &p3, Int32 id)
ModelingCommandData
A helper object for SendModelingCommand().
定义: operatingsystem.h:805
maxon::Vec3< maxon::Float64, 1 >
GeColliderCache
定义: lib_collider.h:84
GeListNode::GetDocument
BaseDocument * GetDocument()
定义: c4d_baselist.h:1915
ModelingCommandData::op
BaseObject * op
The input object. Use arr for multiple objects.
定义: operatingsystem.h:819
PolygonObject
定义: c4d_baseobject.h:1597
COL_OK
#define COL_OK
OK.
定义: lib_collider.h:25
MCOMMAND_TRIANGULATE
#define MCOMMAND_TRIANGULATE
Triangulate.
定义: ge_prepass.h:1399
AutoAlloc
定义: ge_autoptr.h:36
MCOMMAND_CURRENTSTATETOOBJECT
#define MCOMMAND_CURRENTSTATETOOBJECT
Current state to object (returns object): MDATA_CURRENTSTATETOOBJECT.
定义: ge_prepass.h:1410
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
ModelingCommandData::doc
BaseDocument * doc
定义: operatingsystem.h:817
AtomArray::GetIndex
C4DAtom * GetIndex(Int32 idx) const
定义: c4d_baselist.h:1634