LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
lg_landscape.h
1 /*
2  * LibGame - Copyright (C) Emmanuel Thomas-Maurin 2011-2024
3  * All rights reserved
4  */
5 
6 #ifndef LG_LANDSCAPE_H
7 #define LG_LANDSCAPE_H
8 
9 #define QUADTREE_NAME_MAX_LEN (64 - 1)
10 
11 #define QUADTREE_MAX_DEPTH 32
12 #define QUADTREE_PRINTOUT_MAX_DEPTH 8
13 
14 #define QUADTREE_TO_SCENENODE_ID_SHIFT 1000
15 
16 /* QuadTree quadrants */
17 typedef enum {
18  LG_QUADRANTS_MINUS_ONE = -1,
19  LG_NW,
20  LG_NE,
21  LG_SW,
22  LG_SE,
23  LG_QUADRANTS_PLUS_ONE
24 } lg_quadrant;
25 
26 /* LG_QTNode = LG QuadTree Node */
27 typedef struct LG_QTNode LG_QTNode;
28 
29 struct LG_QTNode {
30  int id; /* User-defined */
31  char name[QUADTREE_NAME_MAX_LEN + 1];
32  LG_QTNode *parent;
33  LG_QTNode *child[4]; /* NW, NE, SW, SE */
34  Rec2Df bounds; /* Actually a bounding square, ie w = h */
35  zboolean is_leaf;
36  void *data; /* Usually a mesh */
37 };
38 
39 LG_QTNode lg_qtnode(int, const char *, Rec2Df *, void *);
40 
42 
44 
46 
47 void lg_traverse_landscape(LG_QTNode *, int (*)(LG_QTNode *));
48 
50 
52 
54 
55 #endif /* LG_LANDSCAPE_H */
Rec2Df
Definition: lg_gr_func.h:54
lg_qtnode
LG_QTNode lg_qtnode(int id, const char *name, Rec2Df *bounds, void *data)
Definition: lg_landscape.c:48
lg_qtnode_get_root
LG_QTNode * lg_qtnode_get_root(LG_QTNode *node)
Definition: lg_landscape.c:125
lg_traverse_printout_landscape
void lg_traverse_printout_landscape(LG_QTNode *node, zboolean extra_info)
Definition: lg_landscape.c:288
LG_SceneNode
Definition: lg_scene_graph.h:29
lg_qtnode_add_child
void lg_qtnode_add_child(LG_QTNode *node, LG_QTNode *child, int quadrant)
Definition: lg_landscape.c:90
LG_QTNode
Definition: lg_landscape.h:29
lg_qtnode_info
void lg_qtnode_info(LG_QTNode *node)
Definition: lg_landscape.c:299
lg_qtnode_info2
int lg_qtnode_info2(LG_QTNode *node)
Definition: lg_landscape.c:345
lg_traverse_landscape
void lg_traverse_landscape(LG_QTNode *node, int(*func)(LG_QTNode *))
Definition: lg_landscape.c:223
lg_add_scenenode_from_qtnode
void lg_add_scenenode_from_qtnode(LG_SceneNode *top_scene_node, LG_QTNode *qt_node)
Definition: lg_landscape.c:179