Cutting down on suprious lines

The 2.1 API is becoming a bit burdensome. My main metric for quality of an API is number of calls required to do anything.

My two main complaints are: b2BodyDef::type and b2World::ResetForces.
These are now more or less mandatory, but they've only been added to support extra features. I would much prefer to see reasonable defaults, and a way to opt in to more advanced behaviour. Not only does it neaten up code, but it lowers the bar to entry, as there's less stuff to understand to get a working game.

In the case of ResetForces, this is clear - b2World should have a flag AutoResetForces or something, on by default. As most users don't want to use, or even know, about this feature.

Body types is harder, but I'd still like to see it infer something from the density of fixtures. Because the majority of users will be satisfied with the positive mass == dynamic scheme. Again, a flag to turn this off seems the simplest solution (with SetType automatically disabling the flag).
BorisTheBrave wrote:
In the case of ResetForces, this is clear - b2World should have a flag AutoResetForces or something, on by default. As most users don't want to use, or even know, about this feature.


I like this idea. Please file an issue.

BorisTheBrave wrote:
Body types is harder, but I'd still like to see it infer something from the density of fixtures. Because the majority of users will be satisfied with the positive mass == dynamic scheme. Again, a flag to turn this off seems the simplest solution (with SetType automatically disabling the flag).


This seems a bit complex to do correctly. I'd rather not add lots of branching in the code to eliminate one line of code.

In my opinion, setting the body type makes the user's intentions clear. I felt that in the old system the body type was a bit fuzzy. Currently the body type specifies an algorithm for computing the mass. Densities are just data.
Erin Catto wrote:
In my opinion, setting the body type makes the user's intentions clear. I felt that in the old system the body type was a bit fuzzy. Currently the body type specifies an algorithm for computing the mass. Densities are just data.

Yes, I agree. I wanted to open the floor in case there is a nice way to it.

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