Fix culling set indices when an instance at index inst is destroyed and the last instance is moved into its slot.
| 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 | { |