Skip to content

Commit

Permalink
Fix sensor event order (#840)
Browse files Browse the repository at this point in the history
Continuous collision now invokes the pre-solve callback.
Contact events are no longer enabled by default.
  • Loading branch information
erincatto authored Nov 19, 2024
1 parent a9f2c92 commit 41e067c
Show file tree
Hide file tree
Showing 18 changed files with 612 additions and 188 deletions.
5 changes: 4 additions & 1 deletion include/box2d/box2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ B2_API void* b2World_GetUserData( b2WorldId worldId );
/// Dump memory stats to box2d_memory.txt
B2_API void b2World_DumpMemoryStats( b2WorldId worldId );

/// todo testing
/// This is for internal testing
B2_API void b2World_RebuildStaticTree( b2WorldId worldId );

/// This is for internal testing
B2_API void b2World_EnableSpeculative( b2WorldId worldId, bool flag );

/** @} */

/**
Expand Down
3 changes: 3 additions & 0 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ FetchContent_Populate(imgui
set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/build/imgui)

add_library(imgui STATIC
${IMGUI_DIR}/imconfig.h
${IMGUI_DIR}/imgui.h

${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_demo.cpp
Expand Down
2 changes: 1 addition & 1 deletion samples/data/background.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main()
float noise = random(uv + time * 0.1);

// Adjust these values to control the intensity and color of the grain
float grainIntensity = 0.03;
float grainIntensity = 0.01;

// Mix the base color with the noise
vec3 color = baseColor + vec3(noise * grainIntensity);
Expand Down
3 changes: 3 additions & 0 deletions samples/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,9 @@ Draw::Draw()
m_solidCapsules = nullptr;
m_solidPolygons = nullptr;
m_debugDraw = {};
m_smallFont = nullptr;
m_mediumFont = nullptr;
m_largeFont = nullptr;
}

Draw::~Draw()
Expand Down
7 changes: 6 additions & 1 deletion samples/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

#include "box2d/types.h"

//
struct ImFont;

struct Camera
{
Camera();
Expand Down Expand Up @@ -65,6 +66,10 @@ class Draw
struct GLSolidCapsules* m_solidCapsules;
struct GLSolidPolygons* m_solidPolygons;
b2DebugDraw m_debugDraw;

ImFont* m_smallFont;
ImFont* m_mediumFont;
ImFont* m_largeFont;
};

extern Draw g_draw;
Expand Down
7 changes: 4 additions & 3 deletions samples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ static void CreateUI( GLFWwindow* window, const char* glslVersion )
{
ImFontConfig fontConfig;
fontConfig.RasterizerMultiply = s_windowScale * s_framebufferScale;
ImGui::GetIO().Fonts->AddFontFromFileTTF( fontPath, 14.0f, &fontConfig );
ImGui::GetIO().Fonts->AddFontFromFileTTF( fontPath, 48.0f, &fontConfig );
g_draw.m_smallFont = ImGui::GetIO().Fonts->AddFontFromFileTTF( fontPath, 14.0f, &fontConfig );
g_draw.m_mediumFont = ImGui::GetIO().Fonts->AddFontFromFileTTF( fontPath, 40.0f, &fontConfig );
g_draw.m_largeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF( fontPath, 64.0f, &fontConfig );
}
else
{
Expand Down Expand Up @@ -706,7 +707,7 @@ int main( int, char** )

// ImGui::ShowDemoWindow();

// if (g_draw.m_showUI)
if (g_draw.m_showUI)
{
snprintf( buffer, 128, "%.1f ms - step %d - camera (%g, %g, %g)", 1000.0f * frameTime, s_sample->m_stepCount,
g_camera.m_center.x, g_camera.m_center.y, g_camera.m_zoom );
Expand Down
7 changes: 5 additions & 2 deletions samples/sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,11 @@ void Sample::Step( Settings& settings )
timeStep = 0.0f;
}

g_draw.DrawString( 5, m_textLine, "****PAUSED****" );
m_textLine += m_textIncrement;
if (g_draw.m_showUI)
{
g_draw.DrawString( 5, m_textLine, "****PAUSED****" );
m_textLine += m_textIncrement;
}
}

g_draw.m_debugDraw.drawingBounds = g_camera.GetViewBounds();
Expand Down
Loading

0 comments on commit 41e067c

Please sign in to comment.