matter icon indicating copy to clipboard operation
matter copied to clipboard

Fixes QueryChanged for Multiple Worlds

Open TheyCallMeRyan opened this issue 11 months ago • 1 comments

Proposed changes

Has queryChanged create a proxy for each component, allowing each world to get its own unique hookState from useHookState

Related issues

Primarily intended to solve: https://github.com/matter-ecs/matter/issues/155 Has a side-effect of solving: https://github.com/matter-ecs/matter/issues/147 since clearing the proxies will clear the queryChanged storage.

Additional comments

I had an alternate solution initially where I created the local world storage based on the hookState, but I think that resulted in a far messier solution. https://github.com/TheyCallMeRyan/matter/commit/cb39966f0bba9dee1ffa893ad79e2662c916413b Both solutions fix both issues though.

TheyCallMeRyan avatar Jan 11 '25 12:01 TheyCallMeRyan

Might be worth noting for issue 147 - the warning in the docs that removing entities with world:clear() won't be reported by queryChanged is still valid; this just makes it so the world can still be used afterwards and perform as expected.

TheyCallMeRyan avatar Jan 11 '25 13:01 TheyCallMeRyan