New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Entity#destroy
#5414
Fix Entity#destroy
#5414
Conversation
Just to confirm, that scene basically has:
|
@yaustar yep exactly, testable like: const isEntityChildOfGraphNode = _ => _ instanceof pc.Entity && _.parent?.constructor === pc.GraphNode;
const entitiesInGraphNodes = pc.app.root.find(isEntityChildOfGraphNode);
entitiesInGraphNodes.map(ent => {
const {name, path, parent} = ent;
return {name, path, ent, parent};
}); Output in Seemore: More ideas for (possible?) solutions:
Probably everything has pros/cons, but so far I tend to (1) or (2) |
personally I would find the |
I just thought about performance, lets say having 20 skeletons with ~70
So I pretty much agree, I would also like to see Or other tricks are Would it be okay to implement |
Absolutely, I'd like that. If possible, create two separate PRs please. |
Debugging and debugging 🤓 Found another reason why it fails... Called from: Simply said, the "component removal code" is snatching away our entities (which we want to delete recursively) before our recursion ever has a chance to get to them (they just "disappear" 🤯👻💥). This is easily fixed though, simply first disabled all component, then do the recursion, and then to component deletion. Or 2nd possible solution: mark the entire hierarchy we want to delete (something like But I like the 1st solution, simply destroying the components after the recursion, so I will research that route a bit more... I realize that historically this stuff was a mine field, a change here breaks a project there etc... please just link me all scenes I shall test this with 🔍 (after all, we want to fix bugs, not introduce new ones). |
Add assertion to make sure it worked
Ready for review... pretty happy about the result. I'm testing with Seemore and besides the event bug I also found a room-loading bug in |
Co-authored-by: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com>
Revert order in Entity#destroy
Context for latest commit: Output of this code in this.removeModelFromLayers();
const ents = this._model.getGraph().find(_ => _ instanceof Entity);
if (ents.length) {
console.log(ents);
}
this._model.getGraph().destroy(); Edit: This looks like a potential other entity orphan trap: engine/src/framework/components/sprite/component.js Lines 599 to 603 in 039da2e
(but I have no test scene right now to validate quickly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, looks great to me, I don't see any problems now. Thanks!
Co-authored-by: Will Eastcott <will@playcanvas.com>
Co-authored-by: Will Eastcott <will@playcanvas.com>
Fixes #4649
The main issue is simply that
GraphNode
has nodestroy
method and if aEntity
is inside aGraphNode
... it will never be deleted.I can imagine many solutions, but simply to get the conversations going I propose this one...
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.