1 #ifndef BZ_COLLISION_COLLISION_H
2 #define BZ_COLLISION_COLLISION_H
4 #include <bz/math/vector.h>
5 #include <bz/memory/arena.h>
6 #include <bz/types/common.h>
7 #include <bz/types/identifier.h>
13 enum BZCollisionBodyType
{
14 BZCollisionBodyTypeSolid
,
16 typedef enum BZCollisionBodyType BZCollisionBodyType
;
18 enum BZCollisionShapeType
{
19 BZCollisionShapeTypeUnknown
,
20 BZCollisionShapeTypeCircle
,
21 BZCollisionShapeTypeCirclePerimeter
,
22 BZCollisionShapeTypeLine
,
23 BZCollisionShapeTypeTriangle
,
25 typedef enum BZCollisionShapeType BZCollisionShapeType
;
27 struct BZCollisionShape
{
28 BZCollisionShapeType type
;
31 BZVector circleOrigin
;
36 BZVector lineDirection
;
40 BZVector trianglePoint1
;
41 BZVector trianglePoint2
;
42 BZVector trianglePoint3
;
46 typedef struct BZCollisionShape BZCollisionShape
;
48 //typedef uint32_t BZCollisionTag;
49 typedef uint32_t BZCollisionTagMask
;
51 typedef struct BZCollisionSpace BZCollisionSpace
;
52 typedef BZCollisionSpace
* BZCollisionSpaceID
;
54 typedef struct BZCollisionBody BZCollisionBody
;
55 typedef BZCollisionBody
* BZCollisionBodyID
;
57 extern BZCollisionSpaceID
bzCollisionMakeSpace(BZMemoryArenaID arena
, size_t maxBodies
, const char *identifierFmt
, ...);
61 extern void bzCollisionResetSpace(BZCollisionSpaceID space
);
63 extern BZCollisionBodyID
bzCollisionAddBody(BZCollisionSpaceID space
, BZCollisionBodyType bodyType
, const BZCollisionShape
*shape
, BZIdentifierHash tagHash
, void *userParameter
);
67 extern bool bzCollisionResolve(BZVector
*positionOut
, void **userParameterOut
, BZCollisionSpaceID space
, const BZCollisionShape
*shape
, BZIdentifierHash tagHash
);
69 extern void bzCollisionDrawDebug(BZCollisionSpaceID space
);