-
Notifications
You must be signed in to change notification settings - Fork 16
/
octree.h
57 lines (42 loc) · 1.52 KB
/
octree.h
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
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _OCTREE_H_
#define _OCTREE_H_
#define LEFT 0
#define RIGHT 4
#define BOTTOM 0
#define TOP 2
#define BACK 0
#define FRONT 1
#include "mesh.h"
#include "vec3.h"
typedef struct octree_node octree_node;
typedef enum {
STATUS_ACTIVE,
STATUS_INACTIVE,
STATUS_BOUNDARY
} octree_status;
struct octree_node {
octree_status status; /* active, inactive, boundary */
unsigned char depth; /* depth in tree (root has 0 depth) */
char leaf; /* whether or not node is leaf */
int testid;
int rep_vindex; /* representative vertex index */
vec3 rep_vnormal; /* representative vertex normal */
vec3 sp_center; /* bounding sphere center .. */
float sp_radius; /* .. and radius */
vec3 bb_midpt; /* bounding box center .. */
vec3 bb_extent; /* .. and extents */
vec3 cone_normal; /* normal cone direction .. */
double cone_angle; /* .. and angle */
int *activated; /* activated[0]=# tris, */
octree_node *parent; /* pointer to parent node */
octree_node *subtree[8]; /* pointers to children (x,y,z) */
};
typedef struct {
mesh *mesh; /* pointer to mesh */
octree_node *root; /* root of vertex octree */
octree_node **vertex_nodes; /* per-vertex leaf node */
octree_node **activators; /* per-triangle "activating" node */
} octree;
octree *octree_create(mesh *m);
void octree_free(octree *o);
#endif // !_OCTREE_H_