#include <math.h>
Classes | |
struct | AABB2D |
A data structure describing a 2D box. More... | |
struct | AABB3D |
A data structure describing a 3D box. More... | |
Typedefs | |
typedef void(* | MGCDHandlePair2D )(Int el1, Int el2, struct AABB2D *els, void *context) |
2DBox pair handler function type definition | |
typedef void(* | MGCDHandlePair3D )(Int el1, Int el2, struct AABB3D *els, void *context) |
3DBox pair handler function type definition | |
Functions | |
Int | mgcdContactDetect2D (Float *grids, Int gridCount, struct AABB2D *elem, Int elemCount, const char *mstr, MGCDHandlePair2D func, void *context) |
Perform 2D multi grid contact dection. | |
Int | mgcdContactDetect3D (Float *grids, Int gridCount, struct AABB3D *elem, Int elemCount, const char *mstr, MGCDHandlePair3D func, void *context) |
Perform 3D multi grid contact dection. |
MGCD stands for Multi Grid Contact Detection. It implements two well known algorithms for 2D and 3D contact detection, NBS and Screening.
void(* MGCDHandlePair2D)(Int el1, Int el2, struct AABB2D *els, void *context) |
2DBox pair handler function type definition
User can define a function of this type and provide the function pointer to MGCD 2D detection api to handle the contecting 2D box pairs when a contacting pair is detected
el1 | the index of the first box in els | |
el2 | the index of the second box in els | |
els | a pointer to a struct AABB2D array containing all box infomation | |
context | custom data struct used inside the function |
void(* MGCDHandlePair3D)(Int el1, Int el2, struct AABB3D *els, void *context) |
3DBox pair handler function type definition
User can define a function of this type and provide the function pointer to MGCD 3D detection api to handle the contecting 3D box pairs when a contacting pair is detected.
el1 | The index of the first box of the contacting pair in els | |
el2 | The index of the second box of the contacting pair in els | |
els | A pointer to a struct AABB3D array containing all box infomation | |
context | Custom data struct used inside the function |
Int mgcdContactDetect2D | ( | Float * | grids, | |
Int | gridCount, | |||
struct AABB2D * | elem, | |||
Int | elemCount, | |||
const char * | mstr, | |||
MGCDHandlePair2D | func, | |||
void * | context | |||
) |
Perform 2D multi grid contact dection.
This function take the basic informations of grid configuration, information of all AABB2Ds the detection perform on and a custom contacting box pair handler as input parameter. It then perform the 2D Multi Grid Contact detection algorithm automatically and return the contacting pair count if no error occur, or error code otherwise.
grids | A Float array indecating the cell size of each grid | |
gridCount | An integer indecation the number of grids | |
elem | A AABB2D array, describing the position and size of all objects | |
elemCount | Number of AABB2Ds | |
mstr | A string describing what detection algorithm each grid should use -"NBS" : Use NBS algorithm for each grid. -"SCR" : Use Screening algorithm for each grid. -"AUTO" : Default configuration, in this implementation, NBS will be used. -custom : User can provide a method configuration string to customize what algorithm each grid should use. The length of method cofiguration string should equals to gridCount, and each character should be 'a', 'n' or 's', for each representing a selection of algorithm:
| |
func | A custom contacting box pair handler, can be NULL | |
context | Custom data structure used by handler |
Int mgcdContactDetect3D | ( | Float * | grids, | |
Int | gridCount, | |||
struct AABB3D * | elem, | |||
Int | elemCount, | |||
const char * | mstr, | |||
MGCDHandlePair3D | func, | |||
void * | context | |||
) |
Perform 3D multi grid contact dection.
This function take the basic informations of grid configuration, information of all AABB3Ds the detection perform on and a custom contacting box pair handler as input parameter. It perform the 3D Multi Grid Contact detection algorithm automatically and return the contacting pair count if no error occur, or error code other wise.
grids | A Float array indecating the cell size of each grid | |
gridCount | An integer indecation the number of grids | |
elem | A AABB3D array, describing the position and size of all objects | |
elemCount | Number of AABB3Ds | |
mstr | A string describing what detection algorithm each grid should use -"NBS" : Use NBS algorithm for each grid. -"SCR" : Use Screening algorithm for each grid. -"AUTO" : Default configuration, in this implementation, NBS will be used. -custom : User can provide a method configuration string to customize what algorithm each grid should use. The length of method cofiguration string should equals to gridCount, and each character should be 'a', 'n' or 's', for each representing a selection of algorithm:
| |
func | A custom contacting box pair handler, can be NULL | |
context | Custom data structure used by handler |