I made a simple motorcycle/vehicle and it pointed out some odd behaviour, I'm not sure if it's me or a bug in the engine, but here goes anyway.
Just paste that into any of the tests, start the testbed and when the vehicle spawns try to grab the spinning wheel with the mouse, preferably closer to the outer edge, after a few seconds the whole system explodes and the two wheels become nulled, not reacting to anything.
Any clues?
Code:
{
b2CircleDef sd1;
sd1.radius = 0.5f;
sd1.density = 2.0f;
sd1.friction = 5.0f;
b2BodyDef w1;
w1.AddShape(&sd1);
w1.position.Set(-0.75f, 20.0f);
b2Body *b1 = m_world->CreateBody(&w1);
w1.position.Set(0.75f, 20.0f);
b2Body *b2 = m_world->CreateBody(&w1);
w1.position.Set(0.0f, 20.6f);
b2Body *b3 = m_world->CreateBody(&w1);
b2DistanceJointDef jointDef;
jointDef.collideConnected = true;
jointDef.body1 = b1;
jointDef.body2 = b2;
jointDef.anchorPoint1 = b1->GetCenterPosition();
jointDef.anchorPoint2 = b2->GetCenterPosition();
m_world->CreateJoint(&jointDef);
b2RevoluteJointDef revoluteDef;
revoluteDef.collideConnected = false;
revoluteDef.body1 = b3;
revoluteDef.body2 = b2;
revoluteDef.anchorPoint = b2->GetCenterPosition();
m_world->CreateJoint(&revoluteDef);
revoluteDef.body2 = b1;
revoluteDef.enableMotor = true;
revoluteDef.motorSpeed = 50.0f;
revoluteDef.motorTorque = 1000.0f;
revoluteDef.anchorPoint = b1->GetCenterPosition();
m_world->CreateJoint(&revoluteDef);
}
b2CircleDef sd1;
sd1.radius = 0.5f;
sd1.density = 2.0f;
sd1.friction = 5.0f;
b2BodyDef w1;
w1.AddShape(&sd1);
w1.position.Set(-0.75f, 20.0f);
b2Body *b1 = m_world->CreateBody(&w1);
w1.position.Set(0.75f, 20.0f);
b2Body *b2 = m_world->CreateBody(&w1);
w1.position.Set(0.0f, 20.6f);
b2Body *b3 = m_world->CreateBody(&w1);
b2DistanceJointDef jointDef;
jointDef.collideConnected = true;
jointDef.body1 = b1;
jointDef.body2 = b2;
jointDef.anchorPoint1 = b1->GetCenterPosition();
jointDef.anchorPoint2 = b2->GetCenterPosition();
m_world->CreateJoint(&jointDef);
b2RevoluteJointDef revoluteDef;
revoluteDef.collideConnected = false;
revoluteDef.body1 = b3;
revoluteDef.body2 = b2;
revoluteDef.anchorPoint = b2->GetCenterPosition();
m_world->CreateJoint(&revoluteDef);
revoluteDef.body2 = b1;
revoluteDef.enableMotor = true;
revoluteDef.motorSpeed = 50.0f;
revoluteDef.motorTorque = 1000.0f;
revoluteDef.anchorPoint = b1->GetCenterPosition();
m_world->CreateJoint(&revoluteDef);
}
Just paste that into any of the tests, start the testbed and when the vehicle spawns try to grab the spinning wheel with the mouse, preferably closer to the outer edge, after a few seconds the whole system explodes and the two wheels become nulled, not reacting to anything.
Any clues?