Phase 1: Safety & performance foundation for Grid/Entity overhaul
- Fix Entity3D self-reference cycle: replace raw `self` pointer with `pyobject` strong-ref pattern matching UIEntity (closes #266) - TileLayer inherits Grid texture when none set, in all three attachment paths: constructor, add_layer(), and .grid property (closes #254) - Add SpatialHash::queryCell() for O(1) entity-at-cell lookup; fix missing spatial_hash.insert() in Entity.__init__ grid= kwarg path; use queryCell in GridPoint.entities (closes #253) - Add FOV dirty flag and parameter cache to skip redundant computeFOV calls when map unchanged and params match (closes #292) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
836a0584df
commit
94f5f5a3fd
13 changed files with 436 additions and 47 deletions
|
|
@ -59,8 +59,8 @@ Entity3D::Entity3D(int grid_x, int grid_z)
|
|||
|
||||
Entity3D::~Entity3D()
|
||||
{
|
||||
// Cleanup cube geometry when last entity is destroyed?
|
||||
// For now, leave it - it's shared static data
|
||||
// Release Python identity reference (handles viewport destruction edge case)
|
||||
releasePyIdentity();
|
||||
|
||||
// Clean up Python animation callback
|
||||
Py_XDECREF(py_anim_callback_);
|
||||
|
|
@ -468,7 +468,7 @@ void Entity3D::updateAnimation(float dt)
|
|||
// Fire Python callback
|
||||
if (py_anim_callback_) {
|
||||
PyObject* result = PyObject_CallFunction(py_anim_callback_, "(Os)",
|
||||
self, anim_clip_.c_str());
|
||||
pyobject, anim_clip_.c_str());
|
||||
if (result) {
|
||||
Py_DECREF(result);
|
||||
} else {
|
||||
|
|
@ -722,7 +722,9 @@ int Entity3D::init(PyEntity3DObject* self, PyObject* args, PyObject* kwds)
|
|||
|
||||
// Register in object cache
|
||||
self->data->serial_number = PythonObjectCache::getInstance().assignSerial();
|
||||
self->data->self = (PyObject*)self;
|
||||
// Set strong ref for Python subclass identity preservation
|
||||
self->data->pyobject = (PyObject*)self;
|
||||
Py_INCREF((PyObject*)self);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue