@@ -988,44 +988,41 @@ class WheelJoint : public Sample
988988 m_hertz = 1 .0f ;
989989 m_dampingRatio = 0 .7f ;
990990
991- for ( int i = 0 ; i < 2 ; ++i )
992- {
993- b2BodyDef bodyDef = b2DefaultBodyDef ();
994- bodyDef.position = { 0 .0f , 10 .25f };
995- bodyDef.type = b2_dynamicBody;
996- b2BodyId bodyId = b2CreateBody ( m_worldId, &bodyDef );
991+ b2BodyDef bodyDef = b2DefaultBodyDef ();
992+ bodyDef.position = { 0 .0f , 10 .25f };
993+ bodyDef.type = b2_dynamicBody;
994+ b2BodyId bodyId = b2CreateBody ( m_worldId, &bodyDef );
997995
998- b2ShapeDef shapeDef = b2DefaultShapeDef ();
999- b2Capsule capsule = { { 0 .0f , -0 .5f }, { 0 .0f , 0 .5f }, 0 .5f };
1000- b2CreateCapsuleShape ( bodyId, &shapeDef, &capsule );
996+ b2ShapeDef shapeDef = b2DefaultShapeDef ();
997+ b2Capsule capsule = { { 0 .0f , -0 .5f }, { 0 .0f , 0 .5f }, 0 .5f };
998+ b2CreateCapsuleShape ( bodyId, &shapeDef, &capsule );
1001999
1002- b2Vec2 pivot = { 0 .0f , 10 .0f };
1003- b2Vec2 axis = b2Normalize ( { 1 .0f , 1 .0f } );
1004- b2WheelJointDef jointDef = b2DefaultWheelJointDef ();
1005- jointDef.base .bodyIdA = groundId;
1006- jointDef.base .bodyIdB = bodyId;
1007- jointDef.base .localFrameA .q = b2MakeRotFromUnitVector ( axis );
1008- jointDef.base .localFrameA .p = b2Body_GetLocalPoint ( jointDef.base .bodyIdA , pivot );
1009- jointDef.base .localFrameB .p = b2Body_GetLocalPoint ( jointDef.base .bodyIdB , pivot );
1010- jointDef.motorSpeed = m_motorSpeed;
1011- jointDef.maxMotorTorque = m_motorTorque;
1012- jointDef.enableMotor = m_enableMotor;
1013- jointDef.lowerTranslation = -3 .0f ;
1014- jointDef.upperTranslation = 3 .0f ;
1015- jointDef.enableLimit = m_enableLimit;
1016- jointDef.hertz = m_hertz;
1017- jointDef.dampingRatio = m_dampingRatio;
1000+ b2Vec2 pivot = { 0 .0f , 10 .0f };
1001+ b2Vec2 axis = b2Normalize ( { 1 .0f , 1 .0f } );
1002+ b2WheelJointDef jointDef = b2DefaultWheelJointDef ();
1003+ jointDef.base .bodyIdA = groundId;
1004+ jointDef.base .bodyIdB = bodyId;
1005+ jointDef.base .localFrameA .q = b2MakeRotFromUnitVector ( axis );
1006+ jointDef.base .localFrameA .p = b2Body_GetLocalPoint ( jointDef.base .bodyIdA , pivot );
1007+ jointDef.base .localFrameB .p = b2Body_GetLocalPoint ( jointDef.base .bodyIdB , pivot );
1008+ jointDef.motorSpeed = m_motorSpeed;
1009+ jointDef.maxMotorTorque = m_motorTorque;
1010+ jointDef.enableMotor = m_enableMotor;
1011+ jointDef.lowerTranslation = -3 .0f ;
1012+ jointDef.upperTranslation = 3 .0f ;
1013+ jointDef.enableLimit = m_enableLimit;
1014+ jointDef.hertz = m_hertz;
1015+ jointDef.dampingRatio = m_dampingRatio;
10181016
1019- m_jointId = b2CreateWheelJoint ( m_worldId, &jointDef );
1020- }
1017+ m_jointId = b2CreateWheelJoint ( m_worldId, &jointDef );
10211018 }
10221019
10231020 void UpdateGui () override
10241021 {
10251022 float fontSize = ImGui::GetFontSize ();
1026- float height = 220 .0f ;
1023+ float height = 15 .0f * fontSize ;
10271024 ImGui::SetNextWindowPos ( ImVec2 ( 0 .5f * fontSize, m_camera->height - height - 2 .0f * fontSize ), ImGuiCond_Once );
1028- ImGui::SetNextWindowSize ( ImVec2 ( 240 .0f , height ) );
1025+ ImGui::SetNextWindowSize ( ImVec2 ( 18 .0f * fontSize , height ) );
10291026
10301027 ImGui::Begin ( " Wheel Joint" , nullptr , ImGuiWindowFlags_NoResize );
10311028
0 commit comments