This is from another thread:
I keep running into situations where this would be very handy. I have to call SetMassFromShapes after every single added shape, since my framework has no idea whether each added shape is the last one. I imagine that each time it is called, the mass is calculated for each shape. So there's a bit of redundancy going on there for many-shape bodies.
Perhaps instead SetMassFromShapes could be a boolean, and each time a shape is added or removed, the mass could be incremented or decremented, and the center of mass could be offset appropriately. Or perhaps shapes could cache their mass/center of mass to avoid recalculating it every time SetMassFromShapes is called.
shaktool wrote:
While we're making the API user-friendly, any reason why we would still need to explicitly call "setMassFromShapes()"? Maybe that should just be the default thing to do. And in order to avoid recalculating the mass every time a new shape is added, just recalculate it the next time the mass is requested.
I keep running into situations where this would be very handy. I have to call SetMassFromShapes after every single added shape, since my framework has no idea whether each added shape is the last one. I imagine that each time it is called, the mass is calculated for each shape. So there's a bit of redundancy going on there for many-shape bodies.
Perhaps instead SetMassFromShapes could be a boolean, and each time a shape is added or removed, the mass could be incremented or decremented, and the center of mass could be offset appropriately. Or perhaps shapes could cache their mass/center of mass to avoid recalculating it every time SetMassFromShapes is called.