Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copy the b2j(b2Joint*) function to make your own, and change
- // the first part where the bodies are stored
- Json::Value b2dJson::myCustom_b2j(b2Joint* joint)
- {
- Json::Value jointValue;
- //old code
- //int bodyIndexA = lookupBodyIndex( joint->GetBodyA() );
- //int bodyIndexB = lookupBodyIndex( joint->GetBodyB() );
- //jointValue["bodyA"] = bodyIndexA;
- //jointValue["bodyB"] = bodyIndexB;
- //new code -> nothing, just comment out the 4 lines above
- // Copy the j2b2Joint(b2World* world, Json::Value jointValue) function to
- // make your own, comment out the first part that checks for the bodies,
- // change the last part where the bodies are set in the
- // jointDef, and change the function signature to pass your desired bodies
- b2Joint* b2dJson::myCustom_j2b2Joint(b2World* world, Json::Value jointValue, b2Body* bodyA, b2Body* bodyB)
- {
- //comment out
- //int bodyIndexA = jointValue["bodyA"].asInt();
- //int bodyIndexB = jointValue["bodyB"].asInt();
- //if ( bodyIndexA >= (int)m_bodies.size() || bodyIndexB >= (int)m_bodies.size() )
- // return NULL;
- ...
- //near the end of the function
- if ( jointDef ) {
- //set features common to all joints
- //old code
- jointDef->bodyA = m_bodies[bodyIndexA];
- jointDef->bodyB = m_bodies[bodyIndexB];
- //new code
- jointDef->bodyA = bodyA;
- jointDef->bodyB = bodyB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement