[r17] GetDensity?

Erin,

It appears you've removed GetDensity from the fixtures. I realize you're doing all the mass stuff as soon as the fixture gets created now, but I still need access to the density info (get and set). Can you add that back in? Or where did you move it to?

Thanks 🙂
I could add density back in at a cost of memory and without any use inside the engine. Why not store that in the user data?
Well I could keep a copy of it sure, that's not really a problem, but then I still can't update it after the body has been created... is it really that costly to have a SetDensity function?
Is this for an editor where you are trying to change the density in real-time? For an editor you should not be using Box2D as your database, because Box2D is not designed to be a client database and it will probably never be designed to be a client database.

The reason is that Box2D needs to cook some data to be efficient. It also loses some data during the cooking process so you cannot recover the original data.
Yes, it is for an editor. I'm not really trying to use Box2D as a database though; I've already wrapped all of Box2D's functionality with my own classes so that I can store any additional information in there that Box2D has cooked away. Storing the density in there would not be a problem. There has to be a game scenario though where changing the density would be beneficial though, no? Like when Kirby turns into a statue or a rock, his density should be increased. I'm not asking for the density to be saved somewhere, just for the ability to change it somehow 🙂
We have the ability to make something static or revert back to dynamic using b2World::SetMassData and b2World::ResetMass. In principle, you can set the mass properties to anything you want. You can view the fixture definition as the easy way to set the mass properties.

Do you actually have a case where you need to change the density from one positive value to another positive value at run-time? If so, please file a change request at Google and provide a code sample of how you need this to work.
Okay... I filed an issue.

http://code.google.com/p/box2d/issues/detail?id=20

Original thread: https://box2d.org/forum/viewtopic.php?t=3719