Problem with joints [solved]

Hi, I'm trying to use joints in my class so I tried to make a function but it seems not to work…

Code:
void Level::link(int b1, int b2)
{
   b2Body* body1 = m_Ball[b1]->getBody();
   b2Body* body2 = m_Ball[b2]->getBody();
   
   b2DistanceJointDef jointDef;
   jointDef.Initialize(body1, body2, body1->GetPosition(), body2->GetPosition());
   jointDef.collideConnected = true;
   jointDef.frequencyHz = 4.0f;
   jointDef.dampingRatio = 0.5f;
   
   m_Joint.push_back(m_world->CreateJoint(&jointDef));
}


It should create a distance joint between the two bodies from another class Ball stored in a std::vector.
This part of code makes my game freezing so I wonder what's the problem in it.

Do you have any idea ?

Thanks.
Can you narrow things down a bit through debugging? Here are some things to try (if you haven't already):

- Make sure you're testing the app in debug mode (specifically, make sure asserts are enabled, and that iterator debugging/range checking is enabled if your compiler supports it).
- Step through the code in the debugger and try to determine exactly where the app is locking up. Is it in Box2D's 'step' function? In the code that you posted? Somewhere else?

I don't see any obvious errors in your code, but there are a lot of *potential* errors there (bad indices, invalid body pointers, etc.). Doing some debugging should help narrow things down though.
Thanks, in fact, I was seeking in the wrong place.
This code is correct but the manner I drawn the Joints on the screen was wrong. So it created bugs only if there were joints, which explain why it was working when commented it.

Sorry…

So thanks, this is solved !

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