![]() |
LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
Functions | |
| LG_QTNode | lg_qtnode (int id, const char *name, Rec2Df *bounds, void *data) |
| void | lg_qtnode_set_altitude (LG_QTNode *node, float altitude) |
| void | lg_qtnode_add_child (LG_QTNode *node, LG_QTNode *child, int quadrant, float altitude) |
| LG_QTNode * | lg_qtnode_get_root (LG_QTNode *node) |
| void | lg_add_scenenode_from_qtnode (LG_SceneNode *top_scene_node, LG_QTNode *qt_node) |
| void | lg_traverse_landscape (LG_QTNode *node, int(*func)(LG_QTNode *)) |
| void | lg_traverse_printout_landscape (LG_QTNode *node, zboolean extra_info) |
| void | lg_qtnode_info (LG_QTNode *node) |
| int | lg_qtnode_info2 (LG_QTNode *node) |
=== QuadTree implementation ===
LG_QTNode = LG QuadTree Node
QuadTree quadrants: LG_NW (0), LG_NE (1), LG_SW (2), LG_SE (3)
Create a new landscape node (LG_QTNode)
If no bounding rectangle is provided (bounds == NULL), default one is {-1.0, -1.0, 2.0, 2.0}
No need to free anything when done (no dynamically allocated memory)
| id | Node's id |
| name | Node's name |
| bounds | A pointer to a bounding rectangle (actually must be a square), may be NULL |
| data | A pointer to data (terrain tile, mesh, whatever ...), may be NULL |
| void lg_qtnode_set_altitude | ( | LG_QTNode * | node, |
| float | altitude | ||
| ) |
Set specifically landscape node's altitude
| altitude |
Add child node to landscape node
WARNING: node == child, or adding twice the same node, will lead to undefined behaviour (because adding a node changes that node's bounds)
-> NEVER REUSE NODES, CREATE NEW ONES INSTEAD (they're cheap)
| void lg_add_scenenode_from_qtnode | ( | LG_SceneNode * | top_scene_node, |
| LG_QTNode * | qt_node | ||
| ) |
Parse a quad tree and create/add a scene node for each leaf (to the top scene node)
| top_scene_node | A pointer to a LG_SceneNode |
| qt_node | A pointer to a LG_QTNode |
Go from top to bottom, starting at node (may be different from the top node)
Call (*func)(node) for each leaf
| node | A pointer to a LG_QTNode |
| func | A func pointer |
| void lg_traverse_printout_landscape | ( | LG_QTNode * | node, |
| zboolean | extra_info | ||
| ) |
Go from top to bottom
Print out quad tree structure (quite nicely) -> node->name (node->id/quadrant/altitude)
| node | A pointer to a LG_QTNode |
| extra_info | If TRUE, print out extra info |
| void lg_qtnode_info | ( | LG_QTNode * | node | ) |
| int lg_qtnode_info2 | ( | LG_QTNode * | node | ) |
Print out LG_QTNode info
Same as above func but returns (int)0, so suitable to use with lg_traverse_landscape()
| node | A pointer to a LG_QTNode |