Replies: 7 comments 7 replies
-
physicsSystem.RemoveStepListener(this.constraintListener);
physicsSystem.RemoveConstraint(this.constraint);
bodyInterface.RemoveBody(this.body.GetID()); |
Beta Was this translation helpful? Give feedback.
-
Will this release memory inside Wasm? I think this would require a subsequent Edit: thinking about it, the physics system will not be able to know about allocated vectors, me thinks, so some bookkeeping would still be required, I suppose. |
Beta Was this translation helpful? Give feedback.
-
looking at this example https://github.com/jrouwe/JoltPhysics.js/blob/main/Examples/add_remove_bodies.html and this is how bodies destroyed JoltPhysics.js/Examples/js/example.js Lines 180 to 189 in 7c22d4b |
Beta Was this translation helpful? Give feedback.
-
Perhaps, examples could be improved, by showing what can be destroyed immediately (e.g. temp vectors), and what should wait until the object is no longer needed. For example, when we create a mesh shape, it is not immediately clear if we can reuse an allocated material list, should we wait with destroying it until the shape is destroyed first, or will it auto-destroy when the associated shape is destroyed. If implemented as in example, most probably it will keep floating in Wasm space even after shape is destroyed, until we close the webpage. const shape = new Jolt.MeshShapeSettings(triangles, new Jolt.PhysicsMaterialList()).Create().Get(); Edit: const materials = new Jolt.PhysicsMaterialList();
const settings = new Jolt.MeshShapeSettings(triangles, materials);
const shape = settings.Create().Get();
Jolt.destroy(materials);
Jolt.destroy(settings); However, I am not very familiar with Jolt yet, so not sure what materials are for or how to use them, and given it is optional parameter, I'd then shorten it to: const settings = new Jolt.MeshShapeSettings(triangles);
const shape = settings.Create().Get();
Jolt.destroy(settings); |
Beta Was this translation helpful? Give feedback.
-
Hello, I tried documenting how this works a bit better and also created an example. Can you take a look at this and tell me if I missed something important? |
Beta Was this translation helpful? Give feedback.
-
I see the
|
Beta Was this translation helpful? Give feedback.
-
This is unfortunately another peculiarity of the
So you don't have to free these objects. Unfortunately it also means that if you do something like:
so in the end you calculate:
What will work is this:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am looking for a proper way to clean the physics system from any user objects. Perhaps even destroying it, and creating a fresh one. I've looked into the physics system interface, but it doesn't seem to have one. What would be a recommendation?
Beta Was this translation helpful? Give feedback.
All reactions