Add missing spatial_hash.insert() in set_grid() grid transfer, closes #274

When transferring an entity to a new grid via entity.grid = new_grid,
the entity was removed from the old grid's spatial hash but never
inserted into the new one. This made it invisible to spatial queries
on the destination grid.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-04-10 01:45:18 -04:00
commit 8780f287bd
2 changed files with 75 additions and 0 deletions

View file

@ -795,6 +795,7 @@ int UIEntity::set_grid(PyUIEntityObject* self, PyObject* value, void* closure)
if (self->data->grid != new_grid) {
new_grid->entities->push_back(self->data);
self->data->grid = new_grid;
new_grid->spatial_hash.insert(self->data); // #274
// Resize gridstate to match new grid dimensions
self->data->ensureGridstate();