Skip to content

Commit c21b66d

Browse files
committed
clean up
1 parent b1d1b77 commit c21b66d

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

samples/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ static void CreateUI( GLFWwindow* window, const char* glslVersion )
148148
assert( false );
149149
}
150150

151-
ImGui::GetFontSize();
152151
ImGui::GetStyle().ScaleAllSizes( s_context.uiScale );
153152

154153
const char* fontPath = "samples/data/droid_sans.ttf";

samples/sample_issues.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,9 @@ class UnstableWindmill : public Sample
707707

708708
// rotors
709709
b2WeldJointDef wjdef = b2DefaultWeldJointDef();
710-
// wjdef.base.constraintHertz = 30.0f;
710+
711+
// This simulation can be stabilized by using a lower constraint stiffness
712+
wjdef.base.constraintHertz = 30.0f;
711713
wjdef.base.bodyIdA = center;
712714

713715
b2Polygon polygon;

samples/sample_joints.cpp

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)