-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Current behavior:
I think the methods defined in the WorldBody
, WorldJoint
, WorldShape
... and so on, are the best ones to use when updating the state (unless you are modifying multiple values at once and care a lot about performance). A couple examples:
void SetAcceleration(World& world, BodyID id, const LinearAcceleration2& linear,
AngularAcceleration angular)
{
auto body = GetBody(world, id);
SetAcceleration(body, linear, angular);
SetBody(world, id, body);
}
void SetFriction(World& world, ShapeID id, NonNegative<Real> value)
{
auto object = GetShape(world, id);
SetFriction(object, value);
SetShape(world, id, object);
}
Partly because they turn three lines of code into one, but mostly because it's so easy to otherwise forget to call SetBody(world, id, body)
or SetShape(world, id, object)
or whatever when you're done modifying the object. I believe it's especially easy for programmers new to C++ to forget that GetBody
for example returns the body by value, and not by reference.
These "helper" methods does however not cover all the different setters of the objects which makes it a bit inconsistent.
Desired improvement:
All Set
-methods to bodies, contacts, joints, shapes and what not, should have a corresponding "world" method equivalent that provides the functionality to modify the value directly in the World
state.