Yo @Cedric and @sebavan i was thing about setting up BABYLON.PhysicsImpostor.HeightmapImpostor support for Ammo.js but i am not quite sure what the deal behind the clean of physics impostors.
To support heightmaps from meshes, i need to store the Ammo._malloc result on the impostor.object or basically the ground mesh. I do that like this:
What is the best place to place clean up code for Ammo.js heap memory we allocated at runtime and what do we use to free that memory. I dont see a Ammo._free … But i do think i could add the to the Ammo.js exported functions just like _malloc
I am just not sure because i dont see any Ammo.js example where they FREE the memory they allocated for the heightmap… Like once you created that memory on the heap… it stays on the heap until a new page is loaded
How should i handle clean up if i went ahead and added heightmap impostor support like we have for cannon.js
Yes, it makes sense to reinitialize the heap once in a while. For example when no physics objects are being active. With fixed memory size, it 's possible to not be able to allocate memory because of fragmentation. I guess, it’s possible to mitigate this effect with dynamic allocation… with the price of less performance and more memory allocated.