Skip to content

fix: Recompute bounds of a re-added ShapeHitbox; stop growing its ancestor list - #4142

Open
adario wants to merge 1 commit into
flame-engine:mainfrom
adario:fix/shape-hitbox-remount
Open

adario wants to merge 1 commit into
flame-engine:mainfrom
adario:fix/shape-hitbox-remount

Conversation

@adario

@adario adario commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes two bugs in ShapeHitbox when a hitbox is removed and re-added:

  • Stale bounds: _validAabb is only reset by the transform listeners, which onRemove
    detaches. If an ancestor moves while the hitbox is removed, the re-added hitbox keeps its old
    aabb, so the broadphase, raycast, containsPoint and the collision callbacks use the old
    position. This also happens when the hitbox is removed and added again together with its
    parent. onMount now marks the bounds as invalid.
  • Growing ancestor list: onMount appends to _transformAncestors and never clears it, so
    each re-mount adds the ancestors again and onRemove walks the whole list. onRemove now
    clears it.

A hitbox that fills its parent (no explicit size) hid the first bug, since filling the parent
recomputes the bounds on mount.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • [-] I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [-] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #4141

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ShapeHitbox keeps stale bounds if re-added after its ancestors moved; it also grows its ancestors list on every mount

1 participant