fix(ecs): some replacement issues

This commit is contained in:
lisk77 2025-11-25 13:24:59 +01:00
parent a01a52766d
commit eced6ddf3f
8 changed files with 176 additions and 112 deletions

View file

@ -28,6 +28,12 @@ impl SparseSet {
}
if let Some(page_vec) = &mut self.sparse[page] {
// If there is already a mapping, overwrite the existing dense value instead of pushing.
if let Some(sparse_index) = page_vec[index % self.page_size] {
let _ = self.dense.set::<T>(sparse_index, value);
return;
}
page_vec[index % self.page_size] = Some(self.dense.data.len());
}