summaryrefslogtreecommitdiff
path: root/libphysics/dat.h
blob: 452aee6a67b99677552e0cc1d50fe7947cb4ad1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#define BLOCK_SIZE 16

typedef struct Body {
	BodyType type;
	int active;
	int generation;
	vec2 pos;
	vec2 size;
	vec2 vel;
	vec2 accel;
} Body;

typedef struct BlockmapNode BlockmapNode;
struct BlockmapNode {
	BodyID id;
	BlockmapNode *next;
};

typedef struct TestCollision TestCollision;
struct TestCollision {
	BodyID a, b;
};

void phxmapcollision(Body *);
void phxbodycollision(Body *, Body *);

int phxaabbcheck(Body *a, Body *b);
void phxcollisionmap(Body *a);
void phxaabbresolv(Body *a, Body *b, vec2 p, vec2 n);

int phxenqevent(CollisionEvent *ev);
int phxdeqevent(CollisionEvent *ev);

void __phxbroadphasereset(void);
void __phxbroadphase(int n, BodyID bid[n]);
void __phxnarrowphase(int n, TestCollision coll[n]);

Body   *__getbodydata(BodyID id);
BodyID  __getbodyid(Body *);

extern int  phxmapwidth, phxmapheight;
extern int *phxmapbuffer;

extern Body phxbodypool[];
extern int  phxbodypoolsize;