Crash in b2MulT when initializing a b2RevoluteJoint

Crash in b2MulT when initializing a b2RevoluteJoint
0.0 0



Not too sure how to look into this more. I have 2 ‘planets’ - a wrecking ball and a pivot (going for a space council worker theme - similar to the aliens at start of hitchhikers guide). I am trying to make the ball revolve around the pivot using a catapult style movement (pull it back around the orbit, then release it and it will aim to return to its original position).

Anyway, none of this matters because when I try to initialize the b2RevoluteJoint controlling this movement, I get a crash in the app:

PlanetPotters.win32.exe!b2MulT(const b2Transform & T, const b2Vec2 & v) Line 605 + 0x8 bytes
PlanetPotters.win32.exe!b2Body::GetLocalPoint(const b2Vec2 & worldPoint) Line 562 + 0x14 bytes
PlanetPotters.win32.exe!b2RevoluteJointDef::Initialize(b2Body * bA, b2Body * bB, const b2Vec2 & anchor) Line 40 + 0x16 bytes
PlanetPotters.win32.exe!WreckingBall::addPivot(b2World * world, double x, double y) Line 27
PlanetPotters.win32.exe!HelloWorld::init() Line 94
PlanetPotters.win32.exe!HelloWorld::create() Line 27 + 0xb1 bytes
PlanetPotters.win32.exe!HelloWorld::scene() Line 15 + 0x5 bytes
PlanetPotters.win32.exe!AppDelegate::applicationDidFinishLaunching() Line 36 + 0x5 bytes
libcocos2d.dll!cocos2d::CCApplication::run() Line 46 + 0xf bytes
PlanetPotters.win32.exe!wWinMain(HINSTANCE*_ * hInstance, HINSTANCE*_ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 30 + 0x19 bytes
PlanetPotters.win32.exe!__tmainCRTStartup() Line 547 + 0x2c bytes
PlanetPotters.win32.exe!wWinMainCRTStartup() Line 371

My line of code that triggers this is:
jointDef.Initialize(getBody(), pivot.getBody(), getBody()->GetWorldCenter());

getBody should be just returning a reference to the bodies of the pivot and wrecking ball (this line is called from within the wrecking ball - trying to initialise the pivot with it). I thought it would be a problem with the anchor getBody()->GetWorldCenter(), but even when I replace this with b2Vec2(1,1) I get the same error.

What could be wrong here?


Got it,

I think my problem was that the body of the ball wasn’t defined before I called Initialize on the joint.

Is working now (Though in unexpected ways)