free-language / box2d

Automatically exported from code.google.com/p/box2d
0 stars 0 forks source link

Cache mass data on shapes #138

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Fixture::GetMassData() recalculates the mass data on each call. The method gets 
called a lot inside the engine (by several methods in body such as 
Body::ResetMassData())

I suggest that since the mass, inertia and center of the shapes are unlikely to 
change, they should be cached and only recalculated if the properties change.

Original issue reported on code.google.com by gentoo...@hotmail.com on 24 Jun 2010 at 1:00

GoogleCodeExporter commented 9 years ago
Initially I did cache the mass data, but some users want to be able to change 
the density and other things on the fly, making caching error-prone.

Currently there is a function b2Fixture::GetShape that returns a non-const 
pointer to the shape. The fixture will not know if the shape was modified. So 
any mass cache may become invalid.

Original comment by erinca...@gmail.com on 29 Aug 2010 at 7:37