summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gfx/src/scene/scene_graph.h78
1 files changed, 39 insertions, 39 deletions
diff --git a/gfx/src/scene/scene_graph.h b/gfx/src/scene/scene_graph.h
index 93d2e38..a26f828 100644
--- a/gfx/src/scene/scene_graph.h
+++ b/gfx/src/scene/scene_graph.h
@@ -44,50 +44,50 @@
44/// - The node's parent cannot be the node's child or sibling, unless it's 0. 44/// - The node's parent cannot be the node's child or sibling, unless it's 0.
45/// - If the node has a parent and the node is the leftmost sibling, then the 45/// - If the node has a parent and the node is the leftmost sibling, then the
46/// parent's child is the node. 46/// parent's child is the node.
47#define ASSERT_TREE_NODE_INVARIANT(ITEM) \ 47#define ASSERT_TREE_NODE_INVARIANT(ITEM) \
48 { \ 48 { \
49 const gfx_idx item_idx = MEM_GET_INDEX(ITEM).val; \ 49 const gfx_idx item_idx = MEM_GET_INDEX(ITEM).val; \
50 assert((ITEM)->prev.val != item_idx); \ 50 assert((ITEM)->prev.val != item_idx); \
51 assert((ITEM)->next.val != item_idx); \ 51 assert((ITEM)->next.val != item_idx); \
52 if ((ITEM)->prev.val) { \ 52 if ((ITEM)->prev.val) { \
53 assert((ITEM)->prev.val != (ITEM)->next.val); \ 53 assert((ITEM)->prev.val != (ITEM)->next.val); \
54 } \ 54 } \
55 if ((ITEM)->child.val) { \ 55 if ((ITEM)->child.val) { \
56 assert((ITEM)->child.val != (ITEM)->prev.val); \ 56 assert((ITEM)->child.val != (ITEM)->prev.val); \
57 assert((ITEM)->child.val != (ITEM)->next.val); \ 57 assert((ITEM)->child.val != (ITEM)->next.val); \
58 } \ 58 } \
59 assert((ITEM)->parent.val != item_idx); \ 59 assert((ITEM)->parent.val != item_idx); \
60 if ((ITEM)->parent.val && !(ITEM)->prev.val) { \ 60 if ((ITEM)->parent.val && !(ITEM)->prev.val) { \
61 assert((ITEM)->parent.val != (ITEM)->prev.val); \ 61 assert((ITEM)->parent.val != (ITEM)->prev.val); \
62 assert((ITEM)->parent.val != (ITEM)->next.val); \ 62 assert((ITEM)->parent.val != (ITEM)->next.val); \
63 const typeof(ITEM) item_parent = MEM_GET((ITEM)->parent); \ 63 const __typeof__(ITEM) item_parent = MEM_GET((ITEM)->parent); \
64 assert(item_parent->child.val == item_idx); \ 64 assert(item_parent->child.val == item_idx); \
65 } \ 65 } \
66 } 66 }
67 67
68/// Prepend an item to a list. 68/// Prepend an item to a list.
69/// Modify HEAD_INDEX to equal the index of the new head. 69/// Modify HEAD_INDEX to equal the index of the new head.
70#define LIST_PREPEND(HEAD_INDEX, ITEM) \ 70#define LIST_PREPEND(HEAD_INDEX, ITEM) \
71 (ITEM)->next = HEAD_INDEX; \ 71 (ITEM)->next = HEAD_INDEX; \
72 if (HEAD_INDEX.val) { \ 72 if (HEAD_INDEX.val) { \
73 typeof(ITEM) old_head = MEM_GET(HEAD_INDEX); \ 73 __typeof__(ITEM) old_head = MEM_GET(HEAD_INDEX); \
74 old_head->prev = MEM_GET_INDEX(ITEM); \ 74 old_head->prev = MEM_GET_INDEX(ITEM); \
75 } \ 75 } \
76 HEAD_INDEX = MEM_GET_INDEX(ITEM); \ 76 HEAD_INDEX = MEM_GET_INDEX(ITEM); \
77 ASSERT_LIST_NODE_INVARIANT(ITEM); 77 ASSERT_LIST_NODE_INVARIANT(ITEM);
78 78
79/// Disconnect an item from its siblings. 79/// Disconnect an item from its siblings.
80#define LIST_REMOVE(ITEM) \ 80#define LIST_REMOVE(ITEM) \
81 if ((ITEM)->prev.val) { \ 81 if ((ITEM)->prev.val) { \
82 typeof(ITEM) prev_sibling = MEM_GET((ITEM)->prev); \ 82 __typeof__(ITEM) prev_sibling = MEM_GET((ITEM)->prev); \
83 prev_sibling->next = (ITEM)->next; \ 83 prev_sibling->next = (ITEM)->next; \
84 } \ 84 } \
85 if ((ITEM)->next.val) { \ 85 if ((ITEM)->next.val) { \
86 typeof(ITEM) next_sibling = MEM_GET((ITEM)->next); \ 86 __typeof__(ITEM) next_sibling = MEM_GET((ITEM)->next); \
87 next_sibling->prev = (ITEM)->prev; \ 87 next_sibling->prev = (ITEM)->prev; \
88 } \ 88 } \
89 (ITEM)->prev.val = 0; \ 89 (ITEM)->prev.val = 0; \
90 (ITEM)->next.val = 0; \ 90 (ITEM)->next.val = 0; \
91 ASSERT_LIST_NODE_INVARIANT(ITEM); 91 ASSERT_LIST_NODE_INVARIANT(ITEM);
92 92
93/// Set the child's parent. 93/// Set the child's parent.
@@ -126,8 +126,8 @@
126 /* The parent points only to its first/leftmost child. If this item is */ \ 126 /* The parent points only to its first/leftmost child. If this item is */ \
127 /* the leftmost sibling, then we need to rewire the parent to point to */ \ 127 /* the leftmost sibling, then we need to rewire the parent to point to */ \
128 /* the next sibling to keep the parent connected to its children. */ \ 128 /* the next sibling to keep the parent connected to its children. */ \
129 typeof(ITEM) parent = MEM_GET((ITEM)->parent); \ 129 __typeof__(ITEM) parent = MEM_GET((ITEM)->parent); \
130 const typeof(ITEM) parent_child = MEM_GET(parent->child); \ 130 const __typeof__(ITEM) parent_child = MEM_GET(parent->child); \
131 if (parent_child == ITEM) { \ 131 if (parent_child == ITEM) { \
132 assert((ITEM)->prev.val == 0); \ 132 assert((ITEM)->prev.val == 0); \
133 parent->child = (ITEM)->next; \ 133 parent->child = (ITEM)->next; \