behdad / box2d

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

Move localAnchor into base class #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Since every joint definition and joint instance contains local anchor
members promoting them to the base b2JointDef and b2Joint classes
respectively would make them easier to handle in a uniform way.  In the
case of b2Joint, member functions GetAnchorA() and GetAnchorB() no longer
need to be virtual either.

The main complication is b2GearJointDef, but that class already ignores its
bodyA and bodyB members so it could just as easily ignore its localAnchorA
and localAnchorB members too.

I've attached updated versions of all the joints with this change applied.
 The only external modification needed is to change references to
b2MouseJointDef::target to b2MouseJointDef::localAnchorA.

Original issue reported on code.google.com by kennethdmiller3 on 20 Mar 2010 at 3:46

Attachments:

GoogleCodeExporter commented 9 years ago
This seems like a lateral change. It doesn't seem like a significant gain and 
might add 
more confusion since some joints might not need anchor points. For example, I 
could 
write a joint that controls the angle between two bodies. Angular control 
requires no 
anchor points.

The GetAnchor functions are just for debug draw and can be anything.

Original comment by erinca...@gmail.com on 23 Mar 2010 at 3:58

GoogleCodeExporter commented 9 years ago
That's pretty much what I expected.  It's mainly helpful when building joint
definitions from external data because common code can set up the anchors 
instead of
each specific type.  However, my usage pattern is unusual since most users just
generate specific joint definitions directly in code.

Original comment by kennethdmiller3 on 23 Mar 2010 at 6:15