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

Fix memory leak on mesh collider destroy #5106

Merged
merged 28 commits into from
May 12, 2023
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8f7277c
Added `destroyShape` function to global system
MushAsterion Feb 27, 2023
316a86b
Use of `destroyShape`
MushAsterion Feb 27, 2023
4ea6669
Fixed shape destruction on `recreatePhysicalShapes`
MushAsterion Feb 27, 2023
319db04
Reverted extra line deleted
MushAsterion Feb 27, 2023
f44ba06
Made shape null in `destroyShape`
MushAsterion Feb 27, 2023
bd9e9c3
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 1, 2023
3c218f5
Added Ammo for testing modules requiring Ammo to work
MushAsterion Mar 1, 2023
2852b57
Added test for shape colliders destruction on collision component des…
MushAsterion Mar 1, 2023
201702e
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 4, 2023
568092a
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 10, 2023
7214116
Remove not relevant anymore comment
MushAsterion Mar 11, 2023
26bab08
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 11, 2023
fc96352
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 17, 2023
d3c3fa3
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 18, 2023
c49c6d4
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 22, 2023
69c76fa
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Mar 25, 2023
f600f9c
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 2, 2023
d98bbf0
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 8, 2023
aaaf03e
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 13, 2023
7b3b582
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 17, 2023
1a3b862
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 18, 2023
609ecd8
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 26, 2023
9f8e0ac
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion Apr 29, 2023
8988b26
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion May 10, 2023
fb1eeaf
Shortened shape destroying
MushAsterion May 12, 2023
3deec39
Merge branch 'playcanvas:main' into fix-mesh-collider
MushAsterion May 12, 2023
3f6767f
Remove Ammo tests
MushAsterion May 12, 2023
83f7992
Remove Ammo tests
MushAsterion May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/framework/components/collision/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class CollisionSystemImpl {
component._compoundParent.entity.rigidbody.activate();
}

Ammo.destroy(data.shape);
data.shape = null;
this.destroyShape(data);
}

data.shape = this.createPhysicalShape(component.entity, data);
Expand Down Expand Up @@ -156,6 +155,13 @@ class CollisionSystemImpl {
}
}

destroyShape(data) {
if (data.shape) {
Ammo.destroy(data.shape);
data.shape = null;
}
}

beforeRemove(entity, component) {
if (component.data.shape) {
if (component._compoundParent && !component._compoundParent.entity._destroying) {
Expand All @@ -167,8 +173,7 @@ class CollisionSystemImpl {

component._compoundParent = null;

Ammo.destroy(component.data.shape);
component.data.shape = null;
this.destroyShape(component.data);
}
}

Expand Down Expand Up @@ -514,11 +519,6 @@ class CollisionMeshSystemImpl extends CollisionSystemImpl {
Ammo.destroy(data.shape);
data.shape = null;
}

remove(entity, data) {
this.destroyShape(data);
super.remove(entity, data);
}
}

// Compound Collision System
Expand Down