src/scene.c

changeset 43
5a8c31904e44
parent 41
df81d493716e
child 44
b3da4096c607
equal deleted inserted replaced
42:cc912686f663 43:5a8c31904e44
47 offsetof(AscSceneNode, children), 47 offsetof(AscSceneNode, children),
48 offsetof(AscSceneNode, next) 48 offsetof(AscSceneNode, next)
49 ); 49 );
50 } 50 }
51 51
52 static CxTreeVisitor asc_scene_node_visitor(AscSceneNode *node) {
53 return cx_tree_visitor(node,
54 offsetof(AscSceneNode, children),
55 offsetof(AscSceneNode, next)
56 );
57 }
58
52 void asc_scene_init(AscScene *scene) { 59 void asc_scene_init(AscScene *scene) {
53 if (scene->root != NULL) { 60 if (scene->root != NULL) {
54 asc_error("Scene is already initialized."); 61 asc_error("Scene is already initialized.");
55 return; 62 return;
56 } 63 }
93 // TODO: avoid recalculating the groups, if possible 100 // TODO: avoid recalculating the groups, if possible
94 scene->rg_sprites_opaque_size = 0; 101 scene->rg_sprites_opaque_size = 0;
95 scene->rg_sprites_blended_size = 0; 102 scene->rg_sprites_blended_size = 0;
96 103
97 // skip the root node deliberately, we know it's just the container 104 // skip the root node deliberately, we know it's just the container
98 CxTreeIterator iter = asc_scene_node_iterator(scene->root, false); 105 CxTreeVisitor iter = asc_scene_node_visitor(scene->root);
99 cxIteratorNext(iter); 106 cxIteratorNext(iter);
100 107
101 // update the children and add them to the render groups 108 // update the children and add them to the render groups
102 cx_foreach(AscSceneNode*, node, iter) { 109 cx_foreach(AscSceneNode*, node, iter) {
103 node->depth = iter.depth; 110 node->depth = iter.depth;

mercurial