Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of easy way to change mass during run-time #20

Closed
GoogleCodeExporter opened this issue Apr 10, 2015 · 3 comments
Closed

Lack of easy way to change mass during run-time #20

GoogleCodeExporter opened this issue Apr 10, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

What version of the product are you using? On what operating system?
r17, I don't think this has changed since.

Please provide any additional information below.
Would like a `SetDensity` or `SetMassFromDensity` function on either b2Body
or b2Fixture. Setting the mass manually with `SetMassData` is okay, but it
requires us to know how to compute the mass and inertia from only a density
value, which can be confusing.

A case where it would be nice to be able to do this is when a body changes
from one material into another, like in Kirby Super Star, where Kirby
changes into stone, or perhaps when water turns into ice; a user may want
to change its density during run-time.

A code example:
b2BodyDef bd;
b2Body *kirby = world->CreateBody(&bd);
// ... add some fixture data, set density to 0.3 so that kirby is nice and
fluffy
body->SetMassFromDensity(10); // omg, kirby just turned to stone and
suddenly got really heavy so now he can crush his opponents!

Original issue reported on code.google.com by mnbaya...@gmail.com on 22 Sep 2009 at 12:28

@GoogleCodeExporter
Copy link
Author

i Need this to, by now, i can't get the density and even change this over the 
Box2D
version on iPhone.

Original comment by bad...@gmail.com on 5 Nov 2009 at 2:36

@GoogleCodeExporter
Copy link
Author

Original comment by erinca...@gmail.com on 20 Nov 2009 at 6:43

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

This has been fixed. You can now call b2Fixture::SetDensity then 
b2Body::ResetMass.

Original comment by erinca...@gmail.com on 20 Nov 2009 at 6:44

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant