Skip to content

Commit

Permalink
Miscellaneous fixes (erincatto#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
erincatto authored Dec 25, 2022
1 parent d8e153b commit 87c98c6
Show file tree
Hide file tree
Showing 11 changed files with 4,841 additions and 4,624 deletions.
2 changes: 1 addition & 1 deletion docs/dynamics.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ too strong.

### Joint Definition
Each joint type has a definition that derives from b2JointDef. All
joints are connected between two different bodies. One body may static.
joints are connected between two different bodies. One body may be static.
Joints between static and/or kinematic bodies are allowed, but have no
effect and use some processing time.

Expand Down
2 changes: 1 addition & 1 deletion include/box2d/b2_collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ B2_API void b2CollideEdgeAndCircle(b2Manifold* manifold,
/// Compute the collision manifold between an edge and a polygon.
B2_API void b2CollideEdgeAndPolygon(b2Manifold* manifold,
const b2EdgeShape* edgeA, const b2Transform& xfA,
const b2PolygonShape* circleB, const b2Transform& xfB);
const b2PolygonShape* polygonB, const b2Transform& xfB);

/// Clipping for contact manifolds.
B2_API int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2],
Expand Down
3 changes: 3 additions & 0 deletions include/box2d/b2_world.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ class B2_API b2World
friend class b2ContactManager;
friend class b2Controller;

b2World(const b2World&) = delete;
void operator=(const b2World&) = delete;

void Solve(const b2TimeStep& step);
void SolveTOI(const b2TimeStep& step);

Expand Down
2 changes: 1 addition & 1 deletion src/dynamics/b2_contact_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ bool b2ContactSolver::SolveTOIPositionConstraints(int32 toiIndexA, int32 toiInde
}

float mB = 0.0f;
float iB = 0.;
float iB = 0.0f;
if (indexB == toiIndexA || indexB == toiIndexB)
{
mB = pc->invMassB;
Expand Down
2 changes: 1 addition & 1 deletion src/rope/b2_rope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void b2Rope::SetTuning(const b2RopeTuning& tuning)

void b2Rope::Step(float dt, int32 iterations, const b2Vec2& position)
{
if (dt == 0.0)
if (dt == 0.0f)
{
return;
}
Expand Down
11 changes: 7 additions & 4 deletions testbed/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static Test* s_test = nullptr;
static Settings s_settings;
static bool s_rightMouseDown = false;
static b2Vec2 s_clickPointWS = b2Vec2_zero;
static float s_displayScale = 1.0f;

void glfwErrorCallback(int error, const char* description)
{
Expand Down Expand Up @@ -113,7 +114,7 @@ static void CreateUI(GLFWwindow* window, const char* glslVersion = NULL)

if (fontPath)
{
ImGui::GetIO().Fonts->AddFontFromFileTTF(fontPath, 16.0f);
ImGui::GetIO().Fonts->AddFontFromFileTTF(fontPath, 14.0f * s_displayScale);
}
}

Expand Down Expand Up @@ -350,11 +351,11 @@ static void ScrollCallback(GLFWwindow* window, double dx, double dy)

static void UpdateUI()
{
int menuWidth = 180;
float menuWidth = 180.0f * s_displayScale;
if (g_debugDraw.m_showUI)
{
ImGui::SetNextWindowPos(ImVec2((float)g_camera.m_width - menuWidth - 10, 10));
ImGui::SetNextWindowSize(ImVec2((float)menuWidth, (float)g_camera.m_height - 20));
ImGui::SetNextWindowPos({g_camera.m_width - menuWidth - 10.0f, 10.0f});
ImGui::SetNextWindowSize({menuWidth, g_camera.m_height - 20.0f});

ImGui::Begin("Tools", &g_debugDraw.m_showUI, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);

Expand Down Expand Up @@ -523,6 +524,8 @@ int main(int, char**)
return -1;
}

glfwGetWindowContentScale(g_mainWindow, &s_displayScale, &s_displayScale);

glfwMakeContextCurrent(g_mainWindow);

// Load OpenGL functions using glad
Expand Down
2 changes: 1 addition & 1 deletion testbed/tests/collision_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CollisionProcessing : public Test
shape.SetTwoSided(b2Vec2(-50.0f, 0.0f), b2Vec2(50.0f, 0.0f));

b2FixtureDef sd;
sd.shape = &shape;;
sd.shape = &shape;

b2BodyDef bd;
b2Body* ground = m_world->CreateBody(&bd);
Expand Down
2 changes: 1 addition & 1 deletion testbed/tests/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Web : public Test
jd.bodyA = m_bodies[0];
jd.bodyB = m_bodies[1];
jd.localAnchorA.Set(0.5f, 0.0f);
jd.localAnchorB.Set(-0.5f, 0.0f);;
jd.localAnchorB.Set(-0.5f, 0.0f);
p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
d = p2 - p1;
Expand Down
9,435 changes: 4,823 additions & 4,612 deletions unit-test/doctest.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion unit-test/joint_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
DOCTEST_TEST_CASE("joint reactions")
{
b2Vec2 gravity(0, -10.0f);
b2World world = b2World(gravity);
b2World world(gravity);

b2BodyDef bodyDef;
b2Body* ground = world.CreateBody(&bodyDef);
Expand Down
2 changes: 1 addition & 1 deletion unit-test/world_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MyContactListener : public b2ContactListener

DOCTEST_TEST_CASE("begin contact")
{
b2World world = b2World(b2Vec2(0.0f, -10.0f));
b2World world({ 0.0f, -10.0f });
MyContactListener listener;
world.SetContactListener(&listener);

Expand Down

0 comments on commit 87c98c6

Please sign in to comment.