| 218 | } |
| 219 | |
| 220 | void SceneGraph::destroy(TransformId transform) |
| 221 | { |
| 222 | CE_ASSERT(transform.i < _data.size, "Index out of bounds"); |
| 223 | |
| 224 | // Unlink all children. |
| 225 | TransformId cur = _data.first_child[transform.i]; |
| 226 | while (is_valid(cur)) { |
| 227 | TransformId next_sibling = _data.next_sibling[cur.i]; |
| 228 | unlink(cur); |
| 229 | cur = next_sibling; |
| 230 | } |
| 231 | unlink(transform); |
| 232 | |
| 233 | const u32 last = _data.size - 1; |
| 234 | const UnitId u = _data.unit[transform.i]; |
| 235 | const UnitId last_u = _data.unit[last]; |
| 236 | |
| 237 | if (last != transform.i) { |
| 238 | scene_graph_swap(*this, transform, make_instance(last)); |
| 239 | hash_map::set(_map, last_u, transform.i); |
| 240 | } |
| 241 | hash_map::remove(_map, u); |
| 242 | |
| 243 | --_data.size; |
| 244 | } |
| 245 | |
| 246 | TransformId SceneGraph::instance(UnitId unit) |
| 247 | { |
no test coverage detected