summaryrefslogtreecommitdiff
path: root/src/transform_hierarchy.h
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-17 17:04:28 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-17 17:04:28 +1100
commite4a74976574a7d89906cfbf605ef095ca90dba61 (patch)
tree2358c0e1b926d9d51eafd326194f5aa21d6f20fc /src/transform_hierarchy.h
parent116a44dff58b0175736f4188204c60490e558a9f (diff)
chore: format
Diffstat (limited to 'src/transform_hierarchy.h')
-rw-r--r--src/transform_hierarchy.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/transform_hierarchy.h b/src/transform_hierarchy.h
index 9598fe9..af77ee1 100644
--- a/src/transform_hierarchy.h
+++ b/src/transform_hierarchy.h
@@ -1,17 +1,18 @@
/**
* @file transform_hierarchy.h
-*/
+ */
#pragma once
#include "maths_types.h"
#include "render_types.h"
-#define MAX_TF_NODE_CHILDREN 32 /** TEMP: Make it simpler to manage children in `transform_node`s */
+#define MAX_TF_NODE_CHILDREN \
+ 32 /** TEMP: Make it simpler to manage children in `transform_node`s */
typedef struct transform_hierarchy transform_hierarchy;
struct transform_node {
- model_handle model; /** A handle back to what model this node represents */
+ model_handle model; /** A handle back to what model this node represents */
transform tf;
mat4 local_matrix_tf; /** cached local affine transform */
mat4 world_matrix_tf; /** cached world-space affine transform */
@@ -36,7 +37,8 @@ void transform_hierarchy_free(transform_hierarchy* tfh);
// --- Main usecase
-/** @brief Updates matrices of any invalidated nodes based on the `is_dirty` flag inside `transform` */
+/** @brief Updates matrices of any invalidated nodes based on the `is_dirty` flag inside `transform`
+ */
void transform_hierarchy_propagate_transforms(transform_hierarchy* tfh);
// --- Queries
@@ -45,7 +47,8 @@ void transform_hierarchy_propagate_transforms(transform_hierarchy* tfh);
transform_node* transform_hierarchy_root_node(transform_hierarchy* tfh);
// --- Mutations
-transform_node* transform_hierarchy_add_node(transform_node* parent, model_handle model, transform tf);
+transform_node* transform_hierarchy_add_node(transform_node* parent, model_handle model,
+ transform tf);
void transform_hierarchy_delete_node(transform_node* node);
// --- Traversal
@@ -53,16 +56,21 @@ void transform_hierarchy_delete_node(transform_node* node);
/**
* @brief Perform a depth-first search traversal starting from `start_node`.
* @param start_node The starting node of the traversal.
- * @param visit_node The function to call for each node visited. The callback should return false to stop the traversal early.
- * @param is_pre_order Indicates whether to do pre-order or post-order traversal i.e. when to call the `visit_node` function.
- * @param ctx_data An optional pointer to data that is be passed on each call to `visit_node`. Can be used to carry additional information or context.
+ * @param visit_node The function to call for each node visited. The callback should return false to
+ stop the traversal early.
+ * @param is_pre_order Indicates whether to do pre-order or post-order traversal i.e. when to call
+ the `visit_node` function.
+ * @param ctx_data An optional pointer to data that is be passed on each call to `visit_node`. Can
+ be used to carry additional information or context.
*
* @note The main use-cases are:
1. traversing the whole tree to update cached 4x4 affine transform matrices (post-order)
2. freeing child nodes after deleting a node in the tree (post-order)
3. debug pretty printing the whole tree (post-order)
*/
-void transform_hierarchy_dfs(transform_node* start_node, bool (*visit_node)(transform_node* node, void* ctx_data), bool is_pre_order, void* ctx_data);
+void transform_hierarchy_dfs(transform_node* start_node,
+ bool (*visit_node)(transform_node* node, void* ctx_data),
+ bool is_pre_order, void* ctx_data);
struct core;
void transform_hierarchy_debug_print(transform_node* start_node, struct core* core); \ No newline at end of file