]> git.bts.cx Git - benzene.git/blob - src/bz/collision/collision.h
Sprites
[benzene.git] / src / bz / collision / collision.h
1 #ifndef BZ_COLLISION_COLLISION_H
2 #define BZ_COLLISION_COLLISION_H
3
4 #include <bz/math/vector.h>
5 #include <bz/memory/arena.h>
6 #include <bz/types/common.h>
7 #include <bz/types/identifier.h>
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 enum BZCollisionBodyType {
14 BZCollisionBodyTypeSolid,
15 };
16 typedef enum BZCollisionBodyType BZCollisionBodyType;
17
18 enum BZCollisionShapeType {
19 BZCollisionShapeTypeUnknown,
20 BZCollisionShapeTypeCircle,
21 BZCollisionShapeTypeCirclePerimeter,
22 BZCollisionShapeTypeLine,
23 BZCollisionShapeTypeTriangle,
24 };
25 typedef enum BZCollisionShapeType BZCollisionShapeType;
26
27 struct BZCollisionShape {
28 BZCollisionShapeType type;
29 union {
30 struct {
31 BZVector circleOrigin;
32 float circleRadius;
33 };
34 struct {
35 BZVector lineOrigin;
36 BZVector lineDirection;
37 float lineMagnitude;
38 };
39 struct {
40 BZVector trianglePoint1;
41 BZVector trianglePoint2;
42 BZVector trianglePoint3;
43 };
44 };
45 };
46 typedef struct BZCollisionShape BZCollisionShape;
47
48 //typedef uint32_t BZCollisionTag;
49 typedef uint32_t BZCollisionTagMask;
50
51 typedef struct BZCollisionSpace BZCollisionSpace;
52 typedef BZCollisionSpace * BZCollisionSpaceID;
53
54 typedef struct BZCollisionBody BZCollisionBody;
55 typedef BZCollisionBody * BZCollisionBodyID;
56
57 extern BZCollisionSpaceID bzCollisionMakeSpace(BZMemoryArenaID arena, size_t maxBodies, const char *identifierFmt, ...);
58
59
60
61 extern void bzCollisionResetSpace(BZCollisionSpaceID space);
62
63 extern BZCollisionBodyID bzCollisionAddBody(BZCollisionSpaceID space, BZCollisionBodyType bodyType, const BZCollisionShape *shape, BZIdentifierHash tagHash, void *userParameter);
64
65 /////zones
66
67 extern bool bzCollisionResolve(BZVector *positionOut, void **userParameterOut, BZCollisionSpaceID space, const BZCollisionShape *shape, BZIdentifierHash tagHash);
68
69 extern void bzCollisionDrawDebug(BZCollisionSpaceID space);
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif