57 |
57 |
58 asc_dprintf("Destroyed scene %"PRIxPTR, (uintptr_t) scene); |
58 asc_dprintf("Destroyed scene %"PRIxPTR, (uintptr_t) scene); |
59 asc_scene_node_free(scene->root); |
59 asc_scene_node_free(scene->root); |
60 } |
60 } |
61 |
61 |
|
62 void asc_scene_execute_behaviors(AscScene *scene) { |
|
63 CxTreeVisitor iter = cx_tree_visitor(scene->root, |
|
64 offsetof(AscSceneNode, children), |
|
65 offsetof(AscSceneNode, next) |
|
66 ); |
|
67 cx_foreach(AscSceneNode*, node, iter) { |
|
68 CxIterator behavior_iter = cxListIterator(node->behaviors); |
|
69 cx_foreach(AscBehavior*, behavior, behavior_iter) { |
|
70 if (behavior->enabled) { |
|
71 behavior->func(behavior); |
|
72 } |
|
73 } |
|
74 } |
|
75 } |
|
76 |
62 void asc_scene_draw(AscScene *scene) { |
77 void asc_scene_draw(AscScene *scene) { |
63 if (scene->root == NULL) return; |
78 if (scene->root == NULL) return; |
64 |
79 |
65 // if the window resized, we must update the viewport |
80 // if the window resized, we must update the viewport |
66 if (asc_active_window->resized) { |
81 if (asc_active_window->resized) { |
89 ); |
104 ); |
90 cx_foreach(AscSceneNode*, node, iter) { |
105 cx_foreach(AscSceneNode*, node, iter) { |
91 // skip hidden nodes (and all their children) |
106 // skip hidden nodes (and all their children) |
92 if (asc_test_flag(node->flags, ASC_SCENE_NODE_HIDDEN)) { |
107 if (asc_test_flag(node->flags, ASC_SCENE_NODE_HIDDEN)) { |
93 cxTreeVisitorContinue(iter); |
108 cxTreeVisitorContinue(iter); |
94 } |
|
95 |
|
96 // execute behaviors, first |
|
97 // TODO: move to a separate iteration that is decoupled from drawing - issue #646 |
|
98 CxIterator behavior_iter = cxListIterator(node->behaviors); |
|
99 cx_foreach(AscBehavior*, behavior, behavior_iter) { |
|
100 behavior->func(behavior); |
|
101 } |
109 } |
102 |
110 |
103 // TODO: implement culling |
111 // TODO: implement culling |
104 |
112 |
105 // check if geometry needs update |
113 // check if geometry needs update |