backported fixes from rtxon: BSP tree construction and mouse handling
[dosdemo] / src / bsptree.h
1 #ifndef BSPMESH_H_
2 #define BSPMESH_H_
3
4 #include "mesh.h"
5 #include "vmath.h"
6 #include "polyclip.h"
7
8 struct bsppoly {
9         struct cplane plane;
10         int vcount;
11         struct g3d_vertex *verts;
12 };
13
14 struct bspnode {
15         struct bsppoly poly;
16         struct bspnode *front, *back;
17 };
18
19 struct bsptree {
20         struct bspnode *root;
21         struct bsppoly *soup;   /* dynarr: see dynarr.h */
22 };
23
24 int init_bsp(struct bsptree *bsp);
25 void destroy_bsp(struct bsptree *bsp);
26
27 int save_bsp(struct bsptree *bsp, const char *fname);
28 int load_bsp(struct bsptree *bsp, const char *fname);
29
30 int bsp_add_poly(struct bsptree *bsp, struct g3d_vertex *v, int vnum);
31 int bsp_add_mesh(struct bsptree *bsp, struct g3d_mesh *m);
32
33 int bsp_build(struct bsptree *bsp);
34
35 void draw_bsp(struct bsptree *bsp, float view_x, float view_y, float view_z);
36
37 #endif  /* BSPMESH_H_ */