Fix ecs bug when finalizing removal of detached entity in the last row of the old table

This commit is contained in:
Nikita Lisitsa 2024-05-31 19:07:51 +03:00
parent 0bfedccc7b
commit fc18c75557

View file

@ -89,10 +89,14 @@ namespace psemek::ecs
{
// Swap with the last row in that table
auto table_entity_handles = table.entity_handles();
table.swap_rows(row, table_entity_handles.size() - 1);
auto last_row = table_entity_handles.size() - 1;
if (row != last_row)
{
table.swap_rows(row, last_row);
auto swap_handle = table_entity_handles[row];
entities[swap_handle.id].row = row;
}
table.pop_row();
auto swap_handle = table_entity_handles[row];
entities[swap_handle.id].row = row;
}
void container::finalize_iteration(detail::table & table)