Advertisement
Guest User

Untitled

a guest
Jan 21st, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1.  
  2. // Copy the b2j(b2Joint*) function to make your own, and change
  3. // the first part where the bodies are stored
  4.  
  5. Json::Value b2dJson::myCustom_b2j(b2Joint* joint)
  6. {
  7. Json::Value jointValue;
  8.  
  9. //old code
  10. //int bodyIndexA = lookupBodyIndex( joint->GetBodyA() );
  11. //int bodyIndexB = lookupBodyIndex( joint->GetBodyB() );
  12. //jointValue["bodyA"] = bodyIndexA;
  13. //jointValue["bodyB"] = bodyIndexB;
  14.  
  15. //new code -> nothing, just comment out the 4 lines above
  16.  
  17.  
  18.  
  19.  
  20.  
  21. // Copy the j2b2Joint(b2World* world, Json::Value jointValue) function to
  22. // make your own, comment out the first part that checks for the bodies,
  23. // change the last part where the bodies are set in the
  24. // jointDef, and change the function signature to pass your desired bodies
  25.  
  26. b2Joint* b2dJson::myCustom_j2b2Joint(b2World* world, Json::Value jointValue, b2Body* bodyA, b2Body* bodyB)
  27. {
  28. //comment out
  29. //int bodyIndexA = jointValue["bodyA"].asInt();
  30. //int bodyIndexB = jointValue["bodyB"].asInt();
  31. //if ( bodyIndexA >= (int)m_bodies.size() || bodyIndexB >= (int)m_bodies.size() )
  32. // return NULL;
  33.  
  34. ...
  35.  
  36. //near the end of the function
  37. if ( jointDef ) {
  38. //set features common to all joints
  39. //old code
  40. jointDef->bodyA = m_bodies[bodyIndexA];
  41. jointDef->bodyB = m_bodies[bodyIndexB];
  42.  
  43. //new code
  44. jointDef->bodyA = bodyA;
  45. jointDef->bodyB = bodyB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement