Hi, I’m having issues with this solution. When I manually delete cached collision data in
for (const instance of otherEntity.collision.model.meshInstances) {
delete this.app.systems.collision._triMeshCache[instance.mesh.id];
}
Ammo.destroy(otherEntity.collision.shape);
Ammo will randomly (!) throw errors, like this:
Uncaught TypeError: ha[L[((L[(e >> 2)] + 8) >> 2)]] is not a function
at lh (ammo.js:32:24329)
at Array.HA (ammo.js:36:38107)
at Array.EA (ammo.js:32:119491)
at Uj (ammo.js:34:38987)
at x.addRigidBody (ammo.js:611:426)
at RigidBodyComponentSystem.addBody (playcanvas.js:56507:27)
at RigidBodyComponent.enableSimulation (playcanvas.js:56148:22)
at set mask (playcanvas.js:56020:15)
at template.js:117:24
at Array.forEach (<anonymous>)
I believe what’s happening is other pieces of my game rely on the entity in question, and when its mesh cache is destroyed, sometimes those other pieces ask Ammo for information that I destroyed using this manual call. However, this should not happen if the Ammo deletion and re-creation of the mesh happens instantly — yet it does happen sometimes which leads me to believe that Playcanvas<>Ammo is calculating physics asynchronously (and non-deterministically) to save on performance.
The result is that this manual solution is a non-starter for my use case. I would need to disconnect each reference to that collider and pause the expectation for it to exist while this operation completes during an unknown time.
Is there any other way to scale a mesh collider without directly accessing Ammo mesh caches?
UPDATE: I’ve started a new thread here, and came up with an alternative solution which does not rely on calling Ammo.destroy (which was causing my bug) - https://forum.playcanvas.com/t/setlocalscale-collision-mesh-ammo-js-errors/40022/2