Skip to content
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

[Ammo] Not all collision event fireing (issue with remove entities) #47

Closed
smeybi opened this issue Oct 10, 2023 · 4 comments
Closed

[Ammo] Not all collision event fireing (issue with remove entities) #47

smeybi opened this issue Oct 10, 2023 · 4 comments

Comments

@smeybi
Copy link

smeybi commented Oct 10, 2023

When using ammo, and physics objects are removed, the collision event does not work properly anymore. There are dropouts in between.

If Ammo.destroy(this.body); is replaced by this.system.driver.removeBody(this.body); it works. with remove: element in line 16560

here is the whole element from line 16560:
remove: function() {
if (this.triMesh) Ammo.destroy(this.triMesh);
if (this.localScaling) Ammo.destroy(this.localScaling);
if (this.compoundShape) Ammo.destroy(this.compoundShape);
if (this.body) {
// Ammo.destroy(this.body);
this.system.driver.removeBody(this.body)
delete this.body;
}
Ammo.destroy(this.rbInfo);
Ammo.destroy(this.msTransform);
Ammo.destroy(this.motionState);
Ammo.destroy(this.localInertia);
Ammo.destroy(this.rotation);
},

For example it works, remove the ammo body and the object3D separate, not problem

document.querySelector('a-scene').systems.physics.driver.removeBody(e.target.body)
e.target.object3D.parent.remove(e.target.object3D)

i have reported this before here:
n5ro#137 (comment)

here is a new glitch to see the error:
(Comment out the new script 'aframe-physic-system-fix.js'
aframe-physic-system.js is the original.
perhaps increase the number and speed of boxes on powerful computers to see the error)
https://aframe-physics-system-remove-bug.glitch.me

@diarmidmackenzie
Copy link
Member

Thanks for (re) reporting this.

There seem to be a whole load of things that are set up on ammo-body initialization that aren't cleared up on removal.

Here's an attempt at a fix:
#48

Do you have an established way of testing this? Any feedback would be welcome.

@diarmidmackenzie
Copy link
Member

Have a glitch for testing this: https://aframe-physics-system-issue-47.glitch.me/ - see #48 for details. Fix seems to not be working yet.

diarmidmackenzie added a commit to diarmidmackenzie/aframe-physics-system that referenced this issue Oct 11, 2023
diarmidmackenzie added a commit to diarmidmackenzie/aframe-physics-system that referenced this issue Oct 11, 2023
diarmidmackenzie added a commit to diarmidmackenzie/aframe-physics-system that referenced this issue Oct 11, 2023
@diarmidmackenzie
Copy link
Member

I think we should close this on the basis that we have an adequate fix here:
#52

OK?

Elettrotecnica pushed a commit to Elettrotecnica/aframe-physics-system that referenced this issue Dec 28, 2023
…he previous commit should make them not necessary anymore
diarmidmackenzie added a commit that referenced this issue Jan 3, 2024
@diarmidmackenzie
Copy link
Member

Updated test here to point to a build with fix #57 in place, and it seems to be working correctly.

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

No branches or pull requests

2 participants