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

Function fixup

src/world/render_world.cpp:127–142  ·  view source on GitHub ↗

Fix culling set indices when an instance at index inst is destroyed and the last instance is moved into its slot.

Source from the content-addressed store, hash-verified

125 // Fix culling set indices when an instance at index inst is destroyed and the last instance is
126 // moved into its slot.
127 static void fixup(CullingSet &set, CullableType::Enum type, u32 inst, u32 last)
128 {
129 // Remove any entry that still points at the destroyed index.
130 culling_set::remove(set, type, inst);
131
132 // If we destroyed the last element, there is nothing else to fix.
133 if (inst == last)
134 return;
135
136 // Any entry that referred to the former last index must now point to inst.
137 const u32 num = array::size(set.id);
138 for (u32 i = 0; i < num; ++i) {
139 if (set.id[i] == last && set.type[i] == type)
140 set.id[i] = inst;
141 }
142 }
143
144 static void update(CullingSet &set, CullableType::Enum type, u32 object_id, const Sphere &sphere, const Matrix4x4 &world)
145 {

Callers 1

destroyMethod · 0.85

Calls 2

removeFunction · 0.70
sizeFunction · 0.50

Tested by

no test coverage detected