Skip to content

Commit d5935a7

Browse files
authored
Fix name copy (#907)
limit checks updated benchmarks fix name drawing fixes for dll build updated 7950x benchmarks updated readme updated batch file SSE2/Neon is now default with no compiler defines disable warnings as errors for external libraries (glfw) added dynamic builds to GitHub actions #909 #910
1 parent 3e96863 commit d5935a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+468
-430
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ jobs:
8484
working-directory: ${{github.workspace}}/build
8585
run: ./bin/${{env.BUILD_TYPE}}/test
8686

87-
samples-windows:
88-
name: samples-windows
87+
samples-windows-static:
88+
name: samples-windows-static
8989
runs-on: windows-latest
9090
steps:
9191

@@ -101,9 +101,27 @@ jobs:
101101

102102
- name: Build
103103
run: cmake --build ${{github.workspace}}/build --config Release
104+
105+
samples-windows-dynamic:
106+
name: samples-windows-dynamic
107+
runs-on: windows-latest
108+
steps:
109+
110+
- uses: actions/checkout@v4
111+
112+
- name: Setup MSVC dev command prompt
113+
uses: TheMrMilchmann/setup-msvc-dev@v3
114+
with:
115+
arch: x64
116+
117+
- name: Configure CMake
118+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBOX2D_SAMPLES=ON -DBUILD_SHARED_LIBS=ON -DBOX2D_UNIT_TESTS=OFF
104119

105-
samples-macos:
106-
name: samples-macos
120+
- name: Build
121+
run: cmake --build ${{github.workspace}}/build --config Release
122+
123+
samples-macos-static:
124+
name: samples-macos-static
107125
runs-on: macos-latest
108126

109127
steps:
@@ -114,3 +132,16 @@ jobs:
114132

115133
- name: Build
116134
run: cmake --build ${{github.workspace}}/build --config Release
135+
136+
samples-macos-dynamic:
137+
name: samples-macos-dynamic
138+
runs-on: macos-latest
139+
140+
steps:
141+
- uses: actions/checkout@v4
142+
143+
- name: Configure CMake
144+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBOX2D_SAMPLES=ON -DBUILD_SHARED_LIBS=ON -DBOX2D_UNIT_TESTS=OFF
145+
146+
- name: Build
147+
run: cmake --build ${{github.workspace}}/build --config Release

CMakeLists.txt

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ if (MSVC OR APPLE)
3131
add_compile_options("$<$<CONFIG:Debug>:/fsanitize=address>")
3232
add_link_options("$<$<CONFIG:Debug>:/INCREMENTAL:NO>")
3333
elseif(APPLE)
34-
# more sanitizers on Apple clang
35-
# add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
3634
add_compile_options(-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=undefined)
3735
add_link_options(-fsanitize=address -fsanitize-address-use-after-scope -fsanitize=undefined)
3836
endif()
@@ -47,22 +45,24 @@ endif()
4745

4846
# Deterministic math
4947
# https://box2d.org/posts/2024/08/determinism/
50-
# todo make this apply to ClangCL
5148
if (MINGW OR APPLE OR UNIX)
5249
add_compile_options(-ffp-contract=off)
5350
endif()
5451

55-
option(BOX2D_ENABLE_SIMD "Enable SIMD math (faster)" ON)
52+
option(BOX2D_DISABLE_SIMD "Disable SIMD math (slower)" OFF)
5653

5754
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
58-
cmake_dependent_option(BOX2D_AVX2 "Enable AVX2" OFF "BOX2D_ENABLE_SIMD" OFF)
55+
cmake_dependent_option(BOX2D_AVX2 "Enable AVX2" OFF "NOT BOX2D_DISABLE_SIMD" OFF)
5956
endif()
6057

61-
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
6258
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6359
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
6460
set(CMAKE_VERBOSE_MAKEFILE ON)
6561

62+
# Needed for samples.exe to find box2d.dll
63+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
64+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
65+
6666
add_subdirectory(src)
6767

6868
# This hides samples, test, and doxygen from apps that use box2d via FetchContent
@@ -74,17 +74,6 @@ if(PROJECT_IS_TOP_LEVEL)
7474
option(BOX2D_VALIDATE "Enable heavy validation" ON)
7575
option(BOX2D_UNIT_TESTS "Build the Box2D unit tests" ON)
7676

77-
# Needed for samples.exe to find box2d.dll
78-
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
79-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
80-
81-
include(GNUInstallDirs)
82-
83-
install(
84-
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/box2d"
85-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
86-
)
87-
8877
if(MSVC AND WIN32)
8978
# add_compile_options(/fsanitize=address)
9079
# set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/GS- /Gy /O2 /Oi /Ot")

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ Box2D is a 2D physics engine for games.
1212

1313
### Collision
1414
- Continuous collision detection
15-
- Contact events and sensors
15+
- Contact events
1616
- Convex polygons, capsules, circles, rounded polygons, segments, and chains
1717
- Multiple shapes per body
1818
- Collision filtering
1919
- Ray casts, shape casts, and overlap queries
20+
- Sensor system
2021

2122
### Physics
2223
- Robust _Soft Step_ rigid body solver
@@ -31,19 +32,22 @@ Box2D is a 2D physics engine for games.
3132
- Data-oriented design
3233
- Written in portable C17
3334
- Extensive multithreading and SIMD
35+
- Optimized for large piles of bodies
3436

3537
### Samples
3638
- OpenGL with GLFW and enkiTS
3739
- Graphical user interface with imgui
3840
- Many samples to demonstrate features and performance
3941

40-
## Building
42+
## Building for Visual Studio
4143
- Install [CMake](https://cmake.org/)
4244
- Ensure CMake is in the user `PATH`
43-
- Visual Studio: run `build.bat` from the command prompt
44-
- Otherwise: run `build.sh` from a bash shell
45+
- Run `create_sln.bat`
46+
- Open and build `build/box2d.sln`
47+
48+
## Building for Linux
49+
- Run `build.sh` from a bash shell
4550
- Results are in the build sub-folder
46-
- On Windows you can open box2d.sln
4751

4852
## Building for Xcode
4953
- Install [CMake](https://cmake.org)
@@ -52,15 +56,25 @@ Box2D is a 2D physics engine for games.
5256
- mkdir build
5357
- cd build
5458
- cmake -G Xcode ..
55-
- open box2d.xcodeproj
59+
- Open `box2d.xcodeproj`
5660
- Select the samples scheme
57-
- Edit the scheme to set a custom working directory to the box2d directory
58-
- You can now build and run the samples
61+
- Build and run the samples
62+
63+
## Building and installing
64+
- mkdir build
65+
- cd build
66+
- cmake ..
67+
- cmake --build . --config Release
68+
- cmake --install . (might need sudo)
5969

6070
## Compatibility
6171
The Box2D library and samples build and run on Windows, Linux, and Mac.
6272

63-
Box2D should be built on recent versions of clang and gcc. You will need the latest Visual Studio version for C11 atomics to compile (17.8.3+).
73+
You will need a compiler that supports C17 to build the Box2D library.
74+
75+
You will need a compiler that supports C++20 to build the samples.
76+
77+
Box2D uses SSE2 and Neon SIMD math to improve performance. This can be disabled by defining `BOX2D_DISABLE_SIMD`.
6478

6579
## Documentation
6680
- [Manual](https://box2d.org/documentation/)
@@ -73,7 +87,7 @@ Box2D should be built on recent versions of clang and gcc. You will need the lat
7387
Please do not submit pull requests. Instead, please file an issue for bugs or feature requests. For support, please visit the Discord server.
7488

7589
# Giving Feedback
76-
Please file an issue or start a chat on discord.
90+
Please file an issue or start a chat on discord. You can also use [GitHub Discussions](https://github.com/erincatto/box2d/discussions).
7791

7892
## License
7993
Box2D is developed by Erin Catto and uses the [MIT license](https://en.wikipedia.org/wiki/MIT_License).
@@ -83,7 +97,7 @@ Support development of Box2D through [Github Sponsors](https://github.com/sponso
8397

8498
Please consider starring this repository and subscribing to my [YouTube channel](https://www.youtube.com/@erin_catto).
8599

86-
## Ports, wrappers, and bindings
100+
## External ports, wrappers, and bindings (unsupported)
87101
- Beef bindings - https://github.com/EnokViking/Box2DBeef
88102
- C++ bindings - https://github.com/HolyBlackCat/box2cpp
89103
- WASM - https://github.com/Birch-san/box2d3-wasm

benchmark/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ set(BOX2D_BENCHMARK_FILES
55
)
66
add_executable(benchmark ${BOX2D_BENCHMARK_FILES})
77

8-
set_target_properties(benchmark PROPERTIES C_STANDARD 17)
8+
set_target_properties(benchmark PROPERTIES
9+
C_STANDARD 17
10+
C_STANDARD_REQUIRED YES
11+
C_EXTENSIONS NO
12+
COMPILE_WARNING_AS_ERROR ON
13+
)
914

1015
target_link_libraries(benchmark PRIVATE box2d shared enkiTS)
1116

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
threads,ms
2-
1,2528.51
3-
2,1460.58
4-
3,1004.38
5-
4,822.484
6-
5,712.691
7-
6,638.201
8-
7,583.016
9-
8,540.158
2+
1,3174.52
3+
2,1795.2
4+
3,1217.45
5+
4,996.27
6+
5,857.203
7+
6,763.975
8+
7,696.29
9+
8,648.49
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
threads,ms
2-
1,1579.54
3-
2,849.264
4-
3,591.984
5-
4,466.064
6-
5,393.207
7-
6,347.593
8-
7,305.863
9-
8,305.205
2+
1,1951.88
3+
2,1026.26
4+
3,721.553
5+
4,563.934
6+
5,473.542
7+
6,415.048
8+
7,367.646
9+
8,362.217
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
threads,ms
2-
1,2592.03
3-
2,1412.01
4-
3,953.71
5-
4,731.394
6-
5,601.527
7-
6,511.144
8-
7,441.201
9-
8,393.566
2+
1,3312.37
3+
2,1674.87
4+
3,1116.48
5+
4,859.268
6+
5,691.412
7+
6,594.236
8+
7,513.412
9+
8,462.289

benchmark/amd7950x_avx2/rain.csv

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
threads,ms
2-
1,6462.19
3-
2,3806.63
4-
3,2907
5-
4,2413.23
6-
5,2069.53
7-
6,1852.14
8-
7,1671.47
9-
8,1547.16
2+
1,8415.32
3+
2,4830.51
4+
3,3684.98
5+
4,3008.05
6+
5,2568.19
7+
6,2275.1
8+
7,2054.01
9+
8,1896.27

benchmark/amd7950x_avx2/smash.csv

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
threads,ms
2-
1,1533.42
3-
2,981.749
4-
3,763.27
5-
4,642.928
6-
5,574.053
7-
6,527.394
8-
7,492.883
9-
8,468.971
2+
1,1946.15
3+
2,1212.81
4+
3,937.648
5+
4,786.533
6+
5,699.338
7+
6,636.796
8+
7,597.153
9+
8,564.691
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
threads,ms
2-
1,4126.1
3-
2,2491.09
4-
3,1918.78
5-
4,1543.11
6-
5,1360.84
7-
6,1216.53
8-
7,1110.95
9-
8,1043.96
2+
1,5145.33
3+
2,3090.7
4+
3,2362.34
5+
4,1890.21
6+
5,1643.82
7+
6,1473.02
8+
7,1339.32
9+
8,1256.21

0 commit comments

Comments
 (0)