Update spatial hash in animation setProperty for entity position, closes #256
UIEntity::setProperty() now calls spatial_hash.update() when draw_x/draw_y change, matching the Python property setter behavior. Added enable_shared_from_this<UIEntity> to support shared_from_this() in the setProperty path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2f4928cfa3
commit
5173eaf7f5
3 changed files with 84 additions and 5 deletions
|
|
@ -1640,15 +1640,23 @@ PyObject* UIEntity::repr(PyUIEntityObject* self) {
|
|||
// "x" and "y" are kept as aliases for backwards compatibility
|
||||
bool UIEntity::setProperty(const std::string& name, float value) {
|
||||
if (name == "draw_x" || name == "x") { // #176 - draw_x is preferred, x is alias
|
||||
float old_x = position.x;
|
||||
float old_y = position.y;
|
||||
position.x = value;
|
||||
// Don't update sprite position here - UIGrid::render() handles the pixel positioning
|
||||
if (grid) grid->markCompositeDirty(); // #144 - Propagate to parent grid for texture caching
|
||||
if (grid) {
|
||||
grid->markCompositeDirty();
|
||||
grid->spatial_hash.update(shared_from_this(), old_x, old_y); // #256
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (name == "draw_y" || name == "y") { // #176 - draw_y is preferred, y is alias
|
||||
float old_x = position.x;
|
||||
float old_y = position.y;
|
||||
position.y = value;
|
||||
// Don't update sprite position here - UIGrid::render() handles the pixel positioning
|
||||
if (grid) grid->markCompositeDirty(); // #144 - Propagate to parent grid for texture caching
|
||||
if (grid) {
|
||||
grid->markCompositeDirty();
|
||||
grid->spatial_hash.update(shared_from_this(), old_x, old_y); // #256
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (name == "sprite_scale") {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ sf::Vector2f PyObject_to_sfVector2f(PyObject* obj);
|
|||
PyObject* UIGridPointState_to_PyObject(const UIGridPointState& state);
|
||||
PyObject* UIGridPointStateVector_to_PyList(const std::vector<UIGridPointState>& vec);
|
||||
|
||||
class UIEntity
|
||||
class UIEntity : public std::enable_shared_from_this<UIEntity>
|
||||
{
|
||||
public:
|
||||
uint64_t serial_number = 0; // For Python object cache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue