147 cxTreeVisitorContinue(iter); |
147 cxTreeVisitorContinue(iter); |
148 } |
148 } |
149 |
149 |
150 // TODO: implement culling |
150 // TODO: implement culling |
151 |
151 |
152 // check if geometry needs update |
152 // clear information flags from the previous frame |
153 asc_clear_flag(node->flags, |
153 asc_clear_flag(node->flags, |
154 ASC_SCENE_NODE_GRAPHICS_UPDATED |
154 ASC_SCENE_NODE_GRAPHICS_UPDATED |
155 | ASC_SCENE_NODE_TRANSFORM_UPDATED); |
155 | ASC_SCENE_NODE_TRANSFORM_UPDATED); |
|
156 // check if geometry needs an update |
156 if (asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS)) { |
157 if (asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS)) { |
157 asc_set_flag(node->flags, ASC_SCENE_NODE_GRAPHICS_UPDATED); |
158 asc_set_flag(node->flags, ASC_SCENE_NODE_GRAPHICS_UPDATED); |
158 asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS); |
159 asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_GRAPHICS); |
159 assert(node->update_func != NULL); |
160 assert(node->update_func != NULL); |
160 node->update_func(node); |
161 node->update_func(node); |
161 } |
162 } |
|
163 // check if transform needs an update |
162 if (asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM)) { |
164 if (asc_test_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM)) { |
163 asc_set_flag(node->flags, ASC_SCENE_NODE_TRANSFORM_UPDATED); |
165 asc_set_flag(node->flags, ASC_SCENE_NODE_TRANSFORM_UPDATED); |
164 asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM); |
166 asc_clear_flag(node->flags, ASC_SCENE_NODE_UPDATE_TRANSFORM); |
165 |
167 if (node->parent == scene->root) { |
166 // Only recalculate from components if not using custom transform |
168 // skip unnecessary multiplication with unity matrix |
167 if (!asc_test_flag(node->flags, ASC_SCENE_NODE_CUSTOM_TRANSFORM)) { |
169 asc_transform_copy(node->world_transform, node->transform); |
168 asc_transform_from_vec3f( |
170 } else { |
|
171 asc_mat4f_mulst( |
|
172 node->world_transform, |
169 node->transform, |
173 node->transform, |
170 node->position, |
174 node->parent->world_transform |
171 node->scale, |
|
172 node->rotation |
|
173 ); |
175 ); |
174 } |
176 } |
175 |
|
176 asc_mat4f_mulst( |
|
177 node->world_transform, |
|
178 node->transform, |
|
179 node->parent->world_transform |
|
180 ); |
|
181 } |
177 } |
182 |
178 |
183 // add to render group |
179 // add to render group |
184 if (node->render_group >= 0) { |
180 if (node->render_group >= 0) { |
185 cxListAdd(render_group[node->render_group], node); |
181 cxListAdd(render_group[node->render_group], node); |