MCPcopy Create free account
hub / github.com/crownengine/crown / destroy

Method destroy

src/world/render_world.cpp:2099–2138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2097}
2098
2099void RenderWorld::MeshManager::destroy(MeshId mesh)
2100{
2101 const u32 mesh_i = index(mesh);
2102
2103 const u32 last = _data.size - 1;
2104 const UnitId u = _data.unit[mesh_i];
2105
2106 culling_set::fixup(_render_world->_cullable_objects, CullableType::MESH, mesh_i, last);
2107 culling_set::fixup(_render_world->_cullable_shadow_casters, CullableType::MESH, mesh_i, last);
2108
2109 _data.unit[mesh_i] = _data.unit[last];
2110 _data.resource[mesh_i] = _data.resource[last];
2111 _data.geometry[mesh_i] = _data.geometry[last];
2112 _data.mesh[mesh_i].vbh = _data.mesh[last].vbh;
2113 _data.mesh[mesh_i].ibh = _data.mesh[last].ibh;
2114 _data.material[mesh_i] = _data.material[last];
2115 _data.world[mesh_i] = _data.world[last];
2116 _data.obb[mesh_i] = _data.obb[last];
2117 _data.sphere[mesh_i] = _data.sphere[last];
2118 _data.skeleton[mesh_i] = _data.skeleton[last];
2119 _data.flags[mesh_i] = _data.flags[last];
2120 _data.prev_flags[mesh_i] = _data.prev_flags[last];
2121#if CROWN_CAN_RELOAD
2122 _data.material_resource[mesh_i] = _data.material_resource[last];
2123 _data.geometry_name[mesh_i] = _data.geometry_name[last];
2124#endif
2125
2126 if (mesh_i != last) {
2127 const MeshId last_id = hash_map::get(_map, _data.unit[mesh_i], MeshId { UINT32_MAX });
2128 _indices[last_id.i & MESH_INDEX_MASK].index = mesh_i;
2129 }
2130
2131 const u32 slot = mesh.i & MESH_INDEX_MASK;
2132 _indices[slot].index = UINT32_MAX;
2133 _indices[slot].next = _free_list;
2134 _free_list = slot;
2135
2136 hash_map::remove(_map, u);
2137 --_data.size;
2138}
2139
2140void RenderWorld::MeshManager::swap(u32 inst_a, u32 inst_b)
2141{

Callers 6

~RenderWorldMethod · 0.45
mesh_destroyMethod · 0.45
sprite_destroyMethod · 0.45
lod_group_destroyMethod · 0.45
light_destroyMethod · 0.45

Calls 6

fixupFunction · 0.85
getFunction · 0.85
setClass · 0.85
removeFunction · 0.70
deallocateMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected