From 18b0e69848b988731446f9420b3c292ac9a64afe Mon Sep 17 00:00:00 2001 From: Antonio Pisano Date: Thu, 28 Dec 2023 11:25:19 +0100 Subject: [PATCH] Revert previous fixes from #47 #52 and #54, as the previous commit should make them not necessary anymore --- src/components/body/ammo-body.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/body/ammo-body.js b/src/components/body/ammo-body.js index 264cce1..2c0e733 100644 --- a/src/components/body/ammo-body.js +++ b/src/components/body/ammo-body.js @@ -364,24 +364,15 @@ let AmmoBody = { 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); + delete this.body; + } Ammo.destroy(this.rbInfo); Ammo.destroy(this.msTransform); Ammo.destroy(this.motionState); Ammo.destroy(this.localInertia); Ammo.destroy(this.rotation); - if (this.body) { - if (!this.data.emitCollisionEvents) { - // As per issue 47 / PR 48 there is a strange bug - // not yet understood, where destroying an Ammo body - // leads to subsequent issues reporting collision events. - // - // So if we are reporting collision events, preferable to - // tolerate a small memory leak, by not destroying the - // Ammo body, rather than missing collision events. - Ammo.destroy(this.body); - } - delete this.body; - } }, beforeStep: function() {