ByteArena / box2d

Box2D.go - Go port of Box2D - a 2D Physics Engine for Games.
Other
295 stars 48 forks source link

DynamicsB2JointFriction Dump method has a Pointer Reciever #32

Open scirelli opened 3 years ago

scirelli commented 3 years ago

I'm a noob to box2d (and Go), I was following a C++ example on creating joints. In the example:

b2xxxJoint* joint = (b2xxxJoint*)world->CreateJoint( &jointDef );

They cast the returned joint to the one they wanted created. Doing the same in Go gives a compilation error

impossible type assertion: box2d.B2FrictionJoint does not implement box2d.B2JointInterface (Dump method has pointer receiver)

var jointDef box2d.B2FrictionJointDef = box2d.MakeB2FrictionJointDef()
jointDef.BodyA = ball1
jointDef.BodyB = ball2
joint := world.CreateJoint(&jointDef).(box2d.B2FrictionJoint)

Looking at the source and you can see it's a pointer receiver B2JointFrictio Line 282

Some of the other joints are not B2JointDistance Line 337