├── core ├── events.cpp ├── input.cpp ├── input.h ├── core.cpp ├── materials │ └── bakedTexture.mat ├── console_server.h └── snowflake.h ├── scalable-game ├── main.js ├── game.cpp ├── CMakeLists.txt └── renderer_filament.h ├── assets ├── fonts │ ├── Roboto-License.txt │ └── Roboto-Medium.ttf ├── textures │ ├── link.png │ ├── elf_m_idle.png │ ├── elf_m_idle.png~ │ ├── knight │ │ └── idle │ │ │ └── base-color.png │ └── weapons │ │ ├── bow │ │ ├── bow-0-base.png │ │ ├── bow-1-base.png │ │ ├── bow-2-base.png │ │ └── bow-3-base.png │ │ └── sword │ │ ├── iron-base.png │ │ ├── stone-base.png │ │ ├── wood-base.png │ │ └── diamond-base.png └── models │ ├── quad.mtl │ ├── quad.obj │ └── cube.obj ├── deps ├── box2d │ ├── .gitignore │ ├── extern │ │ ├── sajson │ │ │ ├── sajson.cpp │ │ │ └── CMakeLists.txt │ │ ├── glad │ │ │ └── CMakeLists.txt │ │ ├── imgui │ │ │ └── CMakeLists.txt │ │ └── glfw │ │ │ └── src │ │ │ ├── xkb_unicode.h │ │ │ ├── null_joystick.h │ │ │ ├── posix_time.h │ │ │ ├── null_joystick.c │ │ │ ├── posix_thread.h │ │ │ ├── null_init.c │ │ │ ├── cocoa_joystick.h │ │ │ ├── nsgl_context.h │ │ │ ├── glfw_config.h │ │ │ ├── win32_joystick.h │ │ │ ├── cocoa_time.c │ │ │ ├── linux_joystick.h │ │ │ ├── null_platform.h │ │ │ ├── null_monitor.c │ │ │ ├── win32_time.c │ │ │ └── posix_time.c │ ├── testbed │ │ ├── data │ │ │ └── droid_sans.ttf │ │ ├── MacOSXBundleInfo.plist.in │ │ ├── tests │ │ │ ├── heavy1.cpp │ │ │ ├── add_pair.cpp │ │ │ ├── restitution.cpp │ │ │ ├── circle_stack.cpp │ │ │ ├── pyramid.cpp │ │ │ ├── chain.cpp │ │ │ ├── heavy2.cpp │ │ │ ├── conveyor_belt.cpp │ │ │ ├── pulley_joint.cpp │ │ │ ├── dump_loader.cpp │ │ │ ├── tumbler.cpp │ │ │ ├── convex_hull.cpp │ │ │ ├── mobile_unbalanced.cpp │ │ │ └── shape_editing.cpp │ │ ├── imgui_impl_glfw.h │ │ ├── CMakeLists.txt │ │ ├── settings.h │ │ ├── imgui_impl_opengl3.h │ │ └── draw.h │ ├── deploy_docs.sh │ ├── build.bat │ ├── build_docs.sh │ ├── build.sh │ ├── .github │ │ ├── pull_request_template.md │ │ ├── issue_template.md │ │ └── FUNDING.yml │ ├── .travis.yml │ ├── unit-test │ │ ├── CMakeLists.txt │ │ ├── math_test.cpp │ │ └── world_test.cpp │ ├── LICENSE │ ├── include │ │ └── box2d │ │ │ ├── b2_types.h │ │ │ ├── b2_timer.h │ │ │ ├── b2_api.h │ │ │ ├── b2_contact_manager.h │ │ │ ├── box2d.h │ │ │ ├── b2_stack_allocator.h │ │ │ ├── b2_block_allocator.h │ │ │ ├── b2_time_step.h │ │ │ ├── b2_time_of_impact.h │ │ │ ├── b2_circle_shape.h │ │ │ ├── b2_growable_stack.h │ │ │ └── b2_edge_shape.h │ ├── src │ │ ├── common │ │ │ ├── b2_draw.cpp │ │ │ ├── b2_settings.cpp │ │ │ ├── b2_stack_allocator.cpp │ │ │ └── b2_math.cpp │ │ └── dynamics │ │ │ ├── b2_circle_contact.h │ │ │ ├── b2_polygon_contact.h │ │ │ ├── b2_edge_circle_contact.h │ │ │ ├── b2_polygon_circle_contact.h │ │ │ ├── b2_edge_polygon_contact.h │ │ │ ├── b2_chain_circle_contact.h │ │ │ ├── b2_chain_polygon_contact.h │ │ │ ├── b2_world_callbacks.cpp │ │ │ ├── b2_edge_circle_contact.cpp │ │ │ ├── b2_edge_polygon_contact.cpp │ │ │ ├── b2_circle_contact.cpp │ │ │ ├── b2_polygon_circle_contact.cpp │ │ │ ├── b2_polygon_contact.cpp │ │ │ ├── b2_chain_circle_contact.cpp │ │ │ ├── b2_chain_polygon_contact.cpp │ │ │ ├── b2_island.h │ │ │ └── b2_contact_solver.h │ ├── CMakeLists.txt │ └── CHANGELOG.md └── imgui_sdl │ ├── imgui_sdl.h │ ├── LICENSE │ ├── example.cpp │ └── README.md ├── .gitignore ├── client ├── default-settings.json ├── video_windows.cpp ├── IO_file.h ├── main_windows.h ├── CMakeLists.txt └── window_process_windows.cpp ├── .gitmodules ├── README.md ├── CMakeLists.txt ├── CMakeSettings.json ├── server └── CMakeLists.txt └── web-client └── style.css /core/events.cpp: -------------------------------------------------------------------------------- 1 | #include "core.h" -------------------------------------------------------------------------------- /core/input.cpp: -------------------------------------------------------------------------------- 1 | #include "input.h" -------------------------------------------------------------------------------- /core/input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /scalable-game/main.js: -------------------------------------------------------------------------------- 1 | setUpdate(() => { }); -------------------------------------------------------------------------------- /assets/fonts/Roboto-License.txt: -------------------------------------------------------------------------------- 1 | Apache License, Version 2.0 2 | -------------------------------------------------------------------------------- /scalable-game/game.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | //used to make configuring more simple -------------------------------------------------------------------------------- /assets/textures/link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/link.png -------------------------------------------------------------------------------- /deps/box2d/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | imgui.ini 3 | settings.ini 4 | .vscode/ 5 | CMakeSettings.json 6 | out/ 7 | .vs/ 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | out/ 3 | *build/ 4 | 5 | *.vs/ 6 | 7 | docs/ 8 | \.vscode/ 9 | 10 | deps/protobuf/cmake_build/ -------------------------------------------------------------------------------- /assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /assets/textures/elf_m_idle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/elf_m_idle.png -------------------------------------------------------------------------------- /assets/textures/elf_m_idle.png~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/elf_m_idle.png~ -------------------------------------------------------------------------------- /deps/box2d/extern/sajson/sajson.cpp: -------------------------------------------------------------------------------- 1 | // This cpp is here to force cmake to make a project file for sajson. 2 | int sajson_dummy; 3 | -------------------------------------------------------------------------------- /deps/box2d/testbed/data/droid_sans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/deps/box2d/testbed/data/droid_sans.ttf -------------------------------------------------------------------------------- /assets/textures/knight/idle/base-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/knight/idle/base-color.png -------------------------------------------------------------------------------- /assets/textures/weapons/bow/bow-0-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/bow/bow-0-base.png -------------------------------------------------------------------------------- /assets/textures/weapons/bow/bow-1-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/bow/bow-1-base.png -------------------------------------------------------------------------------- /assets/textures/weapons/bow/bow-2-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/bow/bow-2-base.png -------------------------------------------------------------------------------- /assets/textures/weapons/bow/bow-3-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/bow/bow-3-base.png -------------------------------------------------------------------------------- /deps/box2d/deploy_docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copies documentation to blog 4 | cp -R build/docs/html/. ../blog/public/documentation/ 5 | -------------------------------------------------------------------------------- /assets/textures/weapons/sword/iron-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/sword/iron-base.png -------------------------------------------------------------------------------- /assets/textures/weapons/sword/stone-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/sword/stone-base.png -------------------------------------------------------------------------------- /assets/textures/weapons/sword/wood-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/sword/wood-base.png -------------------------------------------------------------------------------- /assets/textures/weapons/sword/diamond-base.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yourWaifu/the-bespoke-game/master/assets/textures/weapons/sword/diamond-base.png -------------------------------------------------------------------------------- /deps/box2d/build.bat: -------------------------------------------------------------------------------- 1 | rem Use this batch file to build box2d for Visual Studio 2 | rmdir /s /q build 3 | mkdir build 4 | cd build 5 | cmake .. 6 | cmake --build . 7 | start box2d.sln 8 | -------------------------------------------------------------------------------- /deps/box2d/build_docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Builds Box2D along with documentation 4 | rm -rf build 5 | mkdir build 6 | cd build 7 | cmake -DBOX2D_BUILD_DOCS=ON .. 8 | cmake --build . 9 | -------------------------------------------------------------------------------- /core/core.cpp: -------------------------------------------------------------------------------- 1 | #include "core.h" 2 | 3 | /* 4 | const Vertex QUAD_VERTICES[4] = { 5 | {{-1, -1}, {0, 0}}, 6 | {{ 1, -1}, {1, 0}}, 7 | {{-1, 1}, {0, 1}}, 8 | {{ 1, 1}, {1, 1}}, 9 | }; 10 | */ -------------------------------------------------------------------------------- /deps/box2d/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Use this to build box2d on any system with a bash shell 4 | rm -rf build 5 | mkdir build 6 | cd build 7 | cmake -DBOX2D_BUILD_DOCS=OFF .. 8 | cmake --build . 9 | -------------------------------------------------------------------------------- /deps/box2d/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Pull requests for core Box2D code are generally not accepted. Please consider filing an issue instead. 2 | 3 | However, pull requests for build system improvements are often accepted. 4 | -------------------------------------------------------------------------------- /deps/box2d/.github/issue_template.md: -------------------------------------------------------------------------------- 1 | Make sure these boxes are checked before submitting your issue - thank you! 2 | 3 | - [ ] Ask for help on [discord](https://discord.gg/NKYgCBP) and/or [reddit](https://www.reddit.com/r/box2d) 4 | - [ ] Consider providing a dump file using b2World::Dump 5 | -------------------------------------------------------------------------------- /assets/models/quad.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'None' 2 | # Material Count: 1 3 | 4 | newmtl Material.001 5 | Ns 323.999994 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.800000 0.800000 0.800000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | -------------------------------------------------------------------------------- /scalable-game/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(game STATIC "game.cpp" "renderer_filament.h") 2 | target_include_directories(game 3 | PUBLIC 4 | ${PROJECT_SOURCE_DIR}/scalable-game 5 | #"${PROJECT_SOURCE_DIR}/deps/string-view-lite/include" 6 | ) 7 | target_compile_features(game PUBLIC cxx_std_20) 8 | target_link_libraries(game core box2d) 9 | -------------------------------------------------------------------------------- /deps/box2d/extern/sajson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(sajson STATIC sajson.cpp sajson.h) 2 | target_include_directories(sajson PUBLIC ..) 3 | 4 | set_target_properties(sajson PROPERTIES 5 | CXX_STANDARD 11 6 | CXX_STANDARD_REQUIRED YES 7 | CXX_EXTENSIONS NO 8 | ) 9 | 10 | source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES sajson.cpp sajson.h) 11 | -------------------------------------------------------------------------------- /deps/box2d/extern/glad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(GLAD_SOURCE_FILES 2 | src/gl.c) 3 | 4 | set(GLAD_HEADER_FILES 5 | include/glad/gl.h 6 | include/KHR/khrplatform.h) 7 | 8 | add_library(glad STATIC ${GLAD_SOURCE_FILES} ${GLAD_HEADER_FILES}) 9 | target_include_directories(glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) 10 | 11 | source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${GLAD_SOURCE_FILES} ${GLAD_HEADER_FILES}) 12 | -------------------------------------------------------------------------------- /assets/models/quad.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.82 (sub 7) OBJ File: '' 2 | # www.blender.org 3 | mtllib quad.mtl 4 | o Quad 5 | v -0.500000 -0.500000 0.000000 6 | v 0.500000 -0.500000 0.000000 7 | v -0.500000 0.500000 0.000000 8 | v 0.500000 0.500000 0.000000 9 | vt 0.000000 0.000000 10 | vt 1.000000 0.000000 11 | vt 0.000000 1.000000 12 | vt 1.000000 1.000000 13 | vn 0.0000 0.0000 1.0000 14 | usemtl Material 15 | s off 16 | f 1/1/1 2/2/1 3/3/1 17 | f 4/4/1 3/3/1 2/2/1 18 | -------------------------------------------------------------------------------- /client/default-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ip": "::1", 3 | "controls": { 4 | "moveUp": "W", 5 | "moveLeft": "A", 6 | "moveDown": "S", 7 | "moveRight": "D", 8 | "useSlot0": "1", 9 | "useSlot1": "2", 10 | "useSlot2": "3", 11 | "useSlot3": "4", 12 | "useSlot4": "5", 13 | "useSlot5": "6", 14 | "useSlot6": "7", 15 | "useSlot7": "8", 16 | "toggleInventoryMenu": "E", 17 | "toggleShopMenu": "Q", 18 | "openMainMenu": "Escape" 19 | } 20 | } -------------------------------------------------------------------------------- /core/materials/bakedTexture.mat: -------------------------------------------------------------------------------- 1 | material { 2 | name : BakedTexture, 3 | parameters : [ 4 | { 5 | type : sampler2d, 6 | name : albedo 7 | } 8 | ], 9 | requires : [ 10 | uv0 11 | ], 12 | shadingModel : lit, 13 | blending : masked, 14 | } 15 | 16 | fragment { 17 | void material(inout MaterialInputs material) { 18 | prepareMaterial(material); 19 | material.baseColor.rgba = texture(materialParams_albedo, getUV0()).rgba; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /scalable-game/renderer_filament.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "console_imgui.h" 5 | 6 | class GenericRenderer { 7 | public: 8 | GenericRenderer(SDL_Window* window, void* windowHandle, Console& _console) {} 9 | ~GenericRenderer() {} 10 | 11 | template 12 | static GenericRenderer create(const WindowT& window, Console& console) { 13 | return GenericRenderer{ window.window, window.getWindow(), console }; 14 | } 15 | }; 16 | 17 | using Renderer = GenericRenderer; -------------------------------------------------------------------------------- /client/video_windows.cpp: -------------------------------------------------------------------------------- 1 | #include "main_windows.h" 2 | 3 | namespace sys { 4 | 5 | VideoSystem::VideoSystem(GameSystem& parentClass) 6 | { 7 | // 8 | //make frame buffer 9 | // 10 | RECT windowRect = parentClass.getWindowRect(); 11 | resolution = { 12 | static_cast(windowRect.right - windowRect.left), 13 | static_cast(windowRect.bottom - windowRect.top) 14 | }; 15 | } 16 | 17 | void VideoSystem::updateWindowFramebuffer() { 18 | } 19 | 20 | void VideoSystem::makeWindow() { 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /deps/box2d/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | dist: bionic 4 | 5 | # This is clang on macOS 6 | compiler: gcc 7 | 8 | branches: 9 | only: 10 | - master 11 | 12 | addons: 13 | apt: 14 | packages: 15 | - libxrandr-dev 16 | - libxinerama-dev 17 | - libxcursor-dev 18 | - libxi-dev 19 | 20 | jobs: 21 | include: 22 | - os: linux 23 | env: 24 | - os: osx 25 | env: 26 | 27 | script: 28 | - mkdir build 29 | - cd build 30 | - cmake .. 31 | - cmake --build . 32 | - ./bin/unit_test 33 | -------------------------------------------------------------------------------- /deps/box2d/extern/imgui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # dear imgui 2 | set(IMGUI_SOURCE_FILES 3 | imgui.cpp 4 | imgui_demo.cpp 5 | imgui_draw.cpp 6 | imgui_widgets.cpp) 7 | 8 | set(IMGUI_HEADER_FILES 9 | imconfig.h 10 | imgui.h 11 | imgui_internal.h 12 | imstb_rectpack.h 13 | imstb_textedit.h 14 | imstb_truetype.h) 15 | 16 | add_library(imgui STATIC ${IMGUI_SOURCE_FILES} ${IMGUI_HEADER_FILES}) 17 | target_include_directories(imgui PUBLIC ..) 18 | 19 | source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${IMGUI_SOURCE_FILES} ${IMGUI_HEADER_FILES}) 20 | -------------------------------------------------------------------------------- /deps/box2d/unit-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(unit_test 2 | doctest.h 3 | hello_world.cpp 4 | collision_test.cpp 5 | joint_test.cpp 6 | math_test.cpp 7 | world_test.cpp 8 | ) 9 | 10 | set_target_properties(unit_test PROPERTIES 11 | CXX_STANDARD 11 12 | CXX_STANDARD_REQUIRED YES 13 | CXX_EXTENSIONS NO 14 | ) 15 | target_link_libraries(unit_test PUBLIC box2d) 16 | 17 | source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES doctest.h 18 | hello_world.cpp collision_test.cpp joint_test.cpp math_test.cpp world_test.cpp ) 19 | -------------------------------------------------------------------------------- /deps/box2d/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | 14 | github: [erincatto] 15 | -------------------------------------------------------------------------------- /deps/imgui_sdl/imgui_sdl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ImDrawData; 4 | struct SDL_Renderer; 5 | 6 | namespace ImGuiSDL 7 | { 8 | // Call this to initialize the SDL renderer device that is internally used by the renderer. 9 | void Initialize(SDL_Renderer* renderer, int windowWidth, int windowHeight); 10 | // Call this before destroying your SDL renderer or ImGui to ensure that proper cleanup is done. This doesn't do anything critically important though, 11 | // so if you're fine with small memory leaks at the end of your application, you can even omit this. 12 | void Deinitialize(); 13 | 14 | // Call this every frame after ImGui::Render with ImGui::GetDrawData(). This will use the SDL_Renderer provided to the interfrace with Initialize 15 | // to draw the contents of the draw data to the screen. 16 | void Render(ImDrawData* drawData); 17 | } 18 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/GameNetworkingSockets"] 2 | path = deps/GameNetworkingSockets 3 | url = https://github.com/ValveSoftware/GameNetworkingSockets.git 4 | [submodule "deps/filament"] 5 | path = deps/filament 6 | url = https://github.com/google/filament.git 7 | [submodule "deps/protobuf"] 8 | path = deps/protobuf 9 | url = https://github.com/protocolbuffers/protobuf.git 10 | [submodule "deps/string-view-lite"] 11 | path = deps/string-view-lite 12 | url = https://github.com/martinmoene/string-view-lite.git 13 | [submodule "deps/v8-cmake"] 14 | path = deps/v8-cmake 15 | url = https://github.com/yourWaifu/v8-cmake.git 16 | [submodule "deps/asio"] 17 | path = deps/asio 18 | url = https://github.com/chriskohlhoff/asio.git 19 | [submodule "deps/box2d"] 20 | path = deps/box2d 21 | url = https://github.com/erincatto/box2d.git 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cool-renderer 2 | 3 | ### Linux build 4 | ```shell 5 | sudo apt install clang-7 libglu1-mesa-dev libc++-7-dev libc++abi-7-dev ninja-build libxi-dev 6 | 7 | cd deps/protobuf 8 | ./autogen.sh 9 | CC=clang CXX=clang++ ./configure CXX_FOR_BUILD=clang++ --prefix=/usr/local/ --with-pic 10 | make 11 | sudo make install 12 | 13 | mkdir build 14 | cd build 15 | CC=clang-7 CXX=clang++-7 cmake .. -G Ninja -DCMAKE_CXX_COMPILER="clang++-7" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -stdlib=libc++ -lc++abi -Wno-unused-command-line-argument" -DCMAKE_POSITION_INDEPENDENT_CODE=1 16 | ninja 17 | ``` 18 | if you get a ``builtins-generated/bytecodes not found`` error do 19 | ``` 20 | cd build/deps/v8-cmake 21 | ./bytecode_builtins_list_generator generated/builtins-generated/bytecodes-builtins-list.h 22 | ``` 23 | 24 | ## deps versions 25 | filament 1.7 26 | protobuf 3.11.0.1 27 | 28 | ### web 29 | emscripten f5e21de -------------------------------------------------------------------------------- /assets/models/cube.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.82 (sub 7) OBJ File: '' 2 | # www.blender.org 3 | mtllib cube.mtl 4 | o Cube 5 | v 0.500000 0.500000 -0.500000 6 | v 0.500000 -0.500000 -0.500000 7 | v 0.500000 0.500000 0.500000 8 | v 0.500000 -0.500000 0.500000 9 | v -0.500000 0.500000 -0.500000 10 | v -0.500000 -0.500000 -0.500000 11 | v -0.500000 0.500000 0.500000 12 | v -0.500000 -0.500000 0.500000 13 | vt 0.625000 0.500000 14 | vt 0.875000 0.500000 15 | vt 0.875000 0.750000 16 | vt 0.625000 0.750000 17 | vt 0.375000 0.750000 18 | vt 0.625000 1.000000 19 | vt 0.375000 1.000000 20 | vt 0.375000 0.000000 21 | vt 0.625000 0.000000 22 | vt 0.625000 0.250000 23 | vt 0.375000 0.250000 24 | vt 0.125000 0.500000 25 | vt 0.375000 0.500000 26 | vt 0.125000 0.750000 27 | vn 0.0000 1.0000 0.0000 28 | vn 0.0000 0.0000 1.0000 29 | vn -1.0000 0.0000 0.0000 30 | vn 0.0000 -1.0000 0.0000 31 | vn 1.0000 0.0000 0.0000 32 | vn 0.0000 0.0000 -1.0000 33 | usemtl Material 34 | s off 35 | f 1/1/1 5/2/1 7/3/1 3/4/1 36 | f 4/5/2 3/4/2 7/6/2 8/7/2 37 | f 8/8/3 7/9/3 5/10/3 6/11/3 38 | f 6/12/4 2/13/4 4/5/4 8/14/4 39 | f 2/13/5 1/1/5 3/4/5 4/5/5 40 | f 6/11/6 5/10/6 1/1/6 2/13/6 41 | -------------------------------------------------------------------------------- /deps/box2d/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Erin Catto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /deps/imgui_sdl/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /client/IO_file.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | //This is c++11 code, so there's no std filesystem 7 | 8 | class File { 9 | public: 10 | File(const char* path) : file(path, std::ios::binary | std::ios::ate) { 11 | /*std::ios::ate seeks to the end 12 | This tells us where the input position indicator is 13 | giving us the size */ 14 | size = file.tellg(); 15 | /*sets the input position indicator to the begining 16 | when the input position indicator reaches the end, a 17 | eof flag is set and so clear() fixes that. */ 18 | file.clear(); 19 | file.seekg(0, std::ios::beg); 20 | } 21 | 22 | File(std::string& path) : File(path.c_str()) {} 23 | 24 | ~File() = default; 25 | 26 | template 27 | const void get(std::vector& vector) { 28 | const std::size_t numOfElements = size / sizeof(Type); 29 | vector.resize(numOfElements); 30 | file.read(reinterpret_cast(vector.data()), size); 31 | } 32 | 33 | template 34 | const void get(Type* buffer) { 35 | file.read(reinterpret_cast(buffer), size); 36 | } 37 | 38 | const std::size_t getSize() { 39 | return size; 40 | } 41 | 42 | private: 43 | std::ifstream file; 44 | std::size_t size; 45 | }; -------------------------------------------------------------------------------- /core/console_server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "snowflake.h" 3 | //Since the Game Engine's netcode is about predictions, it's common that 4 | //inputs will predicted to be simalar but console commands don't really 5 | //work like that. to prevent the server from retrying the same request 6 | //over and over again the server needs to store some idempotency values 7 | //that the netcode can predict 8 | 9 | struct ConsoleCommand { 10 | struct IdempotencyKey { 11 | int tick; 12 | Snowflake::RawSnowflake userID; 13 | //should be empty when sent from the client 14 | //but can be filled as such, the server should 15 | //overwrite it 16 | bool operator==(IdempotencyKey& key) { 17 | key.tick == tick && key.userID == userID; 18 | } 19 | } key; 20 | char command[256]; 21 | 22 | bool operator==(ConsoleCommand& command) { 23 | return command.key == key; 24 | } 25 | }; 26 | 27 | template 28 | struct ConsoleState { 29 | //to do store more then one key 30 | using Inputs = decltype(GameState::Input::getConsoleCommands()); 31 | ConsoleCommand::IdempotencyKey lastKeyProcessed; 32 | void update(GameState& gameState) { 33 | auto& commands = gameState.inputs.getConsoleCommands(); 34 | auto& command = commands[0]; 35 | if (command == lastKeyProcessed || !command.command[0]) 36 | return; 37 | 38 | 39 | } 40 | }; -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeList.txt : Top-level CMake project file, do global configuration 2 | # and include sub-projects here. 3 | # 4 | cmake_minimum_required (VERSION 3.8) 5 | 6 | project ("scalable-game" CXX C ASM) 7 | 8 | set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -fno-builtin") 9 | set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -fno-builtin") 10 | set (CXX_STANDARD 17) 11 | 12 | # Include sub-projects. 13 | add_subdirectory("deps/filament") 14 | 15 | if (WIN32) 16 | 17 | endif() 18 | 19 | add_subdirectory("deps/GameNetworkingSockets") 20 | 21 | add_subdirectory("deps/v8-cmake") 22 | get_target_property(V8_BYTECODE_SOURCES v8-bytecodes-builtin-list INTERFACE_SOURCES) 23 | if(NOT EXISTS ${V8_BYTECODE_SOURCES}) 24 | get_target_property(V8_BYTECODE_DIR v8-bytecodes-builtin-list INTERFACE_INCLUDE_DIRECTORIES) 25 | file(MAKE_DIRECTORY ${V8_BYTECODE_DIR}) 26 | file(WRITE ${V8_BYTECODE_SOURCES} "temperatory file to stop error") 27 | endif() 28 | 29 | set(BOX2D_BUILD_UNIT_TESTS OFF CACHE BOOL "Box2D unit test") 30 | set(BOX2D_BUILD_TESTBED OFF CACHE BOOL "Box2D test bed") 31 | add_subdirectory("deps/box2d") 32 | 33 | add_subdirectory("core") 34 | add_subdirectory("scalable-game") 35 | add_subdirectory("server") 36 | add_subdirectory ("client") 37 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_types.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2020 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_TYPES_H 24 | #define B2_TYPES_H 25 | 26 | typedef signed char int8; 27 | typedef signed short int16; 28 | typedef signed int int32; 29 | typedef unsigned char uint8; 30 | typedef unsigned short uint16; 31 | typedef unsigned int uint32; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /deps/box2d/testbed/MacOSXBundleInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | ${MACOSX_BUNDLE_INFO_STRING} 11 | CFBundleIconFile 12 | ${MACOSX_BUNDLE_ICON_FILE} 13 | CFBundleIdentifier 14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleLongVersionString 18 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 19 | CFBundleName 20 | ${MACOSX_BUNDLE_BUNDLE_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 29 | CSResourcesFileMapped 30 | 31 | LSRequiresCarbon 32 | 33 | NSHumanReadableCopyright 34 | ${MACOSX_BUNDLE_COPYRIGHT} 35 | NSSupportsAutomaticGraphicsSwitching 36 | 37 | NSHighResolutionCapable 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x64_x64" ], 8 | "buildRoot": "${projectDir}\\out\\build\\${name}", 9 | "installRoot": "${projectDir}\\out\\install\\${name}", 10 | "cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows ", 11 | "buildCommandArgs": "-v", 12 | "ctestCommandArgs": "", 13 | "cmakeToolchain": "C:\\Users\\steve\\Documents\\GitHub\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" 14 | }, 15 | { 16 | "name": "x64-Release", 17 | "generator": "Ninja", 18 | "configurationType": "RelWithDebInfo", 19 | "buildRoot": "${projectDir}\\out\\build\\${name}", 20 | "installRoot": "${projectDir}\\out\\install\\${name}", 21 | "cmakeCommandArgs": "", 22 | "buildCommandArgs": "-v", 23 | "ctestCommandArgs": "", 24 | "cmakeToolchain": "C:\\Users\\steve\\Documents\\GitHub\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake", 25 | "inheritEnvironments": [ "msvc_x64_x64" ], 26 | "variables": [ 27 | { 28 | "name": "USE_STATIC_CRT", 29 | "value": "true", 30 | "type": "BOOL" 31 | }, 32 | { 33 | "name": "Protobuf_SRC_ROOT_FOLDER", 34 | "value": "C:\\sdk\\protobuf-amd64", 35 | "type": "PATH" 36 | }, 37 | { 38 | "name": "BOX2D_BUILD_TESTBED", 39 | "value": "False", 40 | "type": "BOOL" 41 | } 42 | ] 43 | } 44 | ] 45 | } -------------------------------------------------------------------------------- /deps/box2d/src/common/b2_draw.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | #include "box2d/b2_draw.h" 23 | 24 | b2Draw::b2Draw() 25 | { 26 | m_drawFlags = 0; 27 | } 28 | 29 | void b2Draw::SetFlags(uint32 flags) 30 | { 31 | m_drawFlags = flags; 32 | } 33 | 34 | uint32 b2Draw::GetFlags() const 35 | { 36 | return m_drawFlags; 37 | } 38 | 39 | void b2Draw::AppendFlags(uint32 flags) 40 | { 41 | m_drawFlags |= flags; 42 | } 43 | 44 | void b2Draw::ClearFlags(uint32 flags) 45 | { 46 | m_drawFlags &= ~flags; 47 | } 48 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | 30 | ////////////////////////////////////////////////////////////////////////// 31 | ////// GLFW platform API ////// 32 | ////////////////////////////////////////////////////////////////////////// 33 | 34 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 35 | { 36 | return GLFW_FALSE; 37 | } 38 | 39 | void _glfwPlatformUpdateGamepadGUID(char* guid) 40 | { 41 | } 42 | 43 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CIRCLE_CONTACT_H 24 | #define B2_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2CircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2CircleContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /client/main_windows.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include "game.h" 9 | 10 | namespace sys { 11 | class GameSystem; 12 | 13 | class Window { 14 | public: 15 | typedef LRESULT CALLBACK WindowProcess(HWND, UINT, WPARAM, LPARAM); 16 | Window(GameSystem& system, HINSTANCE & hInstance); 17 | HWND mainWindow; 18 | RECT windowRect; 19 | private: 20 | static LRESULT CALLBACK mainWindowProcess( 21 | HWND windowHandle, 22 | UINT message, 23 | WPARAM wParameter, 24 | LPARAM lParameter 25 | ); 26 | }; 27 | 28 | struct ScreenResolution { 29 | unsigned int width; 30 | unsigned int height; 31 | }; 32 | 33 | class VideoSystem { 34 | public: 35 | VideoSystem(GameSystem& parentClass); 36 | void updateWindowFramebuffer(); 37 | HBITMAP windowBitmap; //I think this should be private 38 | ScreenResolution resolution; 39 | void *bitmapMemory; 40 | private: 41 | HDC windowDeviceContext; 42 | HDC mDeviceContext; 43 | void makeWindow(); //you should make this public later 44 | }; 45 | 46 | class GameSystem { 47 | //order matters here 48 | private: 49 | Window window; 50 | public: 51 | bool isRunning; 52 | GameSystem(HINSTANCE& hInstance); 53 | double time(); 54 | void sendEvents(); 55 | VideoSystem video; 56 | GameCoreSystem gameCore; 57 | Game game; 58 | Event getEvent(); 59 | void addEventToQueue(EventType type, int value, int value2, int deviceNumber); 60 | HWND& getWindowHandle() { return window.mainWindow; } 61 | RECT getWindowRect() { return window.windowRect; } 62 | ScreenResolution getScreenResolution() { return video.resolution; } 63 | inline void* getWindow() { return (void*)window.mainWindow; } 64 | private: 65 | const double secondsPerTick; 66 | const double initializeTime(); 67 | }; 68 | } -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_polygon_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_POLYGON_CONTACT_H 24 | #define B2_POLYGON_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2PolygonContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2PolygonContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_edge_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_EDGE_AND_CIRCLE_CONTACT_H 24 | #define B2_EDGE_AND_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2EdgeAndCircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2EdgeAndCircleContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_polygon_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H 24 | #define B2_POLYGON_AND_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2PolygonAndCircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 34 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 35 | 36 | b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 37 | ~b2PolygonAndCircleContact() {} 38 | 39 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_edge_polygon_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_EDGE_AND_POLYGON_CONTACT_H 24 | #define B2_EDGE_AND_POLYGON_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2EdgeAndPolygonContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); 38 | ~b2EdgeAndPolygonContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_timer.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_TIMER_H 24 | #define B2_TIMER_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_settings.h" 28 | 29 | /// Timer for profiling. This has platform specific code and may 30 | /// not work on every platform. 31 | class B2_API b2Timer 32 | { 33 | public: 34 | 35 | /// Constructor 36 | b2Timer(); 37 | 38 | /// Reset the timer. 39 | void Reset(); 40 | 41 | /// Get the time since construction or the last reset. 42 | float GetMilliseconds() const; 43 | 44 | private: 45 | 46 | #if defined(_WIN32) 47 | double m_start; 48 | static double s_invFrequency; 49 | #elif defined(__linux__) || defined (__APPLE__) 50 | unsigned long long m_start_sec; 51 | unsigned long long m_start_usec; 52 | #endif 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW platform API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | int _glfwPlatformInit(void) 36 | { 37 | _glfwInitTimerPOSIX(); 38 | return GLFW_TRUE; 39 | } 40 | 41 | void _glfwPlatformTerminate(void) 42 | { 43 | _glfwTerminateOSMesa(); 44 | } 45 | 46 | const char* _glfwPlatformGetVersionString(void) 47 | { 48 | return _GLFW_VERSION_NUMBER " null OSMesa"; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_chain_circle_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CHAIN_AND_CIRCLE_CONTACT_H 24 | #define B2_CHAIN_AND_CIRCLE_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2ChainAndCircleContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 38 | ~b2ChainAndCircleContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_api.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_API_H 24 | #define B2_API_H 25 | 26 | #ifdef B2_SHARED 27 | #if defined _WIN32 || defined __CYGWIN__ 28 | #ifdef box2d_EXPORTS 29 | #ifdef __GNUC__ 30 | #define B2_API __attribute__ ((dllexport)) 31 | #else 32 | #define B2_API __declspec(dllexport) 33 | #endif 34 | #else 35 | #ifdef __GNUC__ 36 | #define B2_API __attribute__ ((dllimport)) 37 | #else 38 | #define B2_API __declspec(dllimport) 39 | #endif 40 | #endif 41 | #else 42 | #if __GNUC__ >= 4 43 | #define B2_API __attribute__ ((visibility ("default"))) 44 | #else 45 | #define B2_API 46 | #endif 47 | #endif 48 | #else 49 | #define B2_API 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_chain_polygon_contact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CHAIN_AND_POLYGON_CONTACT_H 24 | #define B2_CHAIN_AND_POLYGON_CONTACT_H 25 | 26 | #include "box2d/b2_contact.h" 27 | 28 | class b2BlockAllocator; 29 | 30 | class b2ChainAndPolygonContact : public b2Contact 31 | { 32 | public: 33 | static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, 34 | b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); 35 | static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); 36 | 37 | b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); 38 | ~b2ChainAndPolygonContact() {} 39 | 40 | void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_world_callbacks.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/b2_fixture.h" 24 | #include "box2d/b2_world_callbacks.h" 25 | 26 | // Return true if contact calculations should be performed between these two shapes. 27 | // If you implement your own collision filter you may want to build from this implementation. 28 | bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB) 29 | { 30 | const b2Filter& filterA = fixtureA->GetFilterData(); 31 | const b2Filter& filterB = fixtureB->GetFilterData(); 32 | 33 | if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) 34 | { 35 | return filterA.groupIndex > 0; 36 | } 37 | 38 | bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0; 39 | return collide; 40 | } 41 | -------------------------------------------------------------------------------- /server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(scaleable-game-server server.cpp) 2 | target_link_directories(scaleable-game-server PUBLIC "${uwebsockets_INCLUDE_DIR}/../lib") 3 | target_link_libraries(scaleable-game-server GameNetworkingSockets game) 4 | target_include_directories( 5 | scaleable-game-server 6 | PRIVATE 7 | #"${PROJECT_SOURCE_DIR}/deps/string-view-lite/include" 8 | ) 9 | add_sanitizers(scaleable-game-server) 10 | 11 | #copy dlls 12 | if(WIN32) 13 | add_custom_command(TARGET scaleable-game-server POST_BUILD 14 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 15 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/GameNetworkingSockets.dll ${CMAKE_CURRENT_BINARY_DIR}) 16 | add_custom_command(TARGET scaleable-game-server POST_BUILD 17 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 18 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/GameNetworkingSockets.pdb ${CMAKE_CURRENT_BINARY_DIR}) 19 | if(CMAKE_BUILD_TYPE STREQUAL "Release" OR EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobuf.dll) 20 | add_custom_command(TARGET scaleable-game-server POST_BUILD 21 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 22 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobuf.dll ${CMAKE_CURRENT_BINARY_DIR}) 23 | endif() 24 | if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobufd.dll) 25 | add_custom_command(TARGET scaleable-game-server POST_BUILD 26 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 27 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobufd.dll ${CMAKE_CURRENT_BINARY_DIR}) 28 | endif() 29 | endif() 30 | 31 | #copy JS files 32 | set(GAME_JS_FILES ${PROJECT_SOURCE_DIR}/scalable-game/main.js) 33 | add_custom_command(TARGET scaleable-game-server POST_BUILD 34 | COMMAND ${CMAKE_COMMAND} -E copy 35 | ${GAME_JS_FILES} ${CMAKE_CURRENT_BINARY_DIR}) -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | 48 | void _glfwInitJoysticksNS(void); 49 | void _glfwTerminateJoysticksNS(void); 50 | 51 | -------------------------------------------------------------------------------- /core/snowflake.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Snowflake { 5 | //snowflake generator 6 | //structure left to right 7 | //Timestamp in ms : 42 bits 8 | //isUnoffical : 1 bit : tells the server if this needs to be replaced 9 | //zero bit : 1 bit : unused, for later perpose 10 | //increment : 20 bits 11 | using RawSnowflake = uint64_t; 12 | //note: this is a c++14 feature 13 | constexpr RawSnowflake timestampMask = 14 | 0b1111111111111111111111111111111111111111110000000000000000000000; 15 | constexpr RawSnowflake isOfficalMask = 16 | 0b0000000000000000000000000000000000000000001000000000000000000000; 17 | constexpr RawSnowflake theZeroBitMask = 18 | 0b0000000000000000000000000000000000000000000100000000000000000000; 19 | constexpr RawSnowflake incrementMask = 20 | 0b0000000000000000000000000000000000000000000011111111111111111111; 21 | 22 | constexpr int getStart(RawSnowflake mask, int i = 0) { 23 | return (mask & 0b1) == 0b0 ? getStart(mask >> 1, i + 1) : i; 24 | } 25 | 26 | constexpr RawSnowflake timestampStart = getStart(timestampMask ); 27 | constexpr RawSnowflake isOfficalStart = getStart(isOfficalMask ); 28 | constexpr RawSnowflake theZeroBitStart = getStart(theZeroBitMask); 29 | constexpr RawSnowflake incrementStart = getStart(incrementMask ); 30 | 31 | const bool isAvaiable(const RawSnowflake snowflake) { 32 | return snowflake != 0; 33 | } 34 | 35 | template 36 | RawSnowflake generate(uint64_t timestampMS) { 37 | //start at 1 so that 0 can be used for unavailable 38 | static int increment = 1; 39 | RawSnowflake target = 0; 40 | target = target | ((timestampMS << timestampStart ) & timestampMask ); 41 | target = target | ((isServer << isOfficalStart ) & isOfficalMask ); 42 | target = target | ((0 << theZeroBitStart) & theZeroBitMask); 43 | target = target | ((increment << incrementStart ) & incrementMask ); 44 | //always increment at the end or else 45 | increment += 1; 46 | return target; 47 | } 48 | } -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_contact_manager.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CONTACT_MANAGER_H 24 | #define B2_CONTACT_MANAGER_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_broad_phase.h" 28 | 29 | class b2Contact; 30 | class b2ContactFilter; 31 | class b2ContactListener; 32 | class b2BlockAllocator; 33 | 34 | // Delegate of b2World. 35 | class B2_API b2ContactManager 36 | { 37 | public: 38 | b2ContactManager(); 39 | 40 | // Broad-phase callback. 41 | void AddPair(void* proxyUserDataA, void* proxyUserDataB); 42 | 43 | void FindNewContacts(); 44 | 45 | void Destroy(b2Contact* c); 46 | 47 | void Collide(); 48 | 49 | b2BroadPhase m_broadPhase; 50 | b2Contact* m_contactList; 51 | int32 m_contactCount; 52 | b2ContactFilter* m_contactFilter; 53 | b2ContactListener* m_contactListener; 54 | b2BlockAllocator* m_allocator; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /deps/box2d/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | 3 | # https://cmake.org/cmake/help/latest/command/project.html 4 | project(box2d VERSION 2.4.1) 5 | 6 | # set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo" CACHE STRING "" FORCE) 7 | 8 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 9 | set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) 10 | 11 | option(BOX2D_BUILD_UNIT_TESTS "Build the Box2D unit tests" ON) 12 | option(BOX2D_BUILD_TESTBED "Build the Box2D testbed" ON) 13 | option(BOX2D_BUILD_DOCS "Build the Box2D documentation" OFF) 14 | option(BOX2D_USER_SETTINGS "Override Box2D settings with b2UserSettings.h" OFF) 15 | 16 | option(BUILD_SHARED_LIBS "Build Box2D as a shared library" OFF) 17 | 18 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 19 | set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) 20 | 21 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") 22 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") 23 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") 24 | 25 | include(GNUInstallDirs) 26 | 27 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 28 | 29 | if (BOX2D_USER_SETTINGS) 30 | add_compile_definitions(B2_USER_SETTINGS) 31 | endif() 32 | 33 | add_subdirectory(src) 34 | 35 | if (BOX2D_BUILD_DOCS) 36 | set(DOXYGEN_SKIP_DOT TRUE) 37 | find_package(Doxygen) 38 | endif() 39 | 40 | if (DOXYGEN_FOUND AND BOX2D_BUILD_DOCS) 41 | add_subdirectory(docs) 42 | endif() 43 | 44 | if (BOX2D_BUILD_UNIT_TESTS) 45 | add_subdirectory(unit-test) 46 | endif() 47 | 48 | if (BOX2D_BUILD_TESTBED) 49 | add_subdirectory(extern/glad) 50 | add_subdirectory(extern/glfw) 51 | add_subdirectory(extern/imgui) 52 | add_subdirectory(extern/sajson) 53 | add_subdirectory(testbed) 54 | 55 | # default startup project for Visual Studio 56 | if (MSVC) 57 | set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT testbed) 58 | set_property(TARGET testbed PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/testbed") 59 | endif() 60 | endif() 61 | 62 | install( 63 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/box2d" 64 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 65 | ) 66 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/box2d.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef BOX2D_H 24 | #define BOX2D_H 25 | 26 | // These include files constitute the main Box2D API 27 | 28 | #include "b2_settings.h" 29 | #include "b2_draw.h" 30 | #include "b2_timer.h" 31 | 32 | #include "b2_chain_shape.h" 33 | #include "b2_circle_shape.h" 34 | #include "b2_edge_shape.h" 35 | #include "b2_polygon_shape.h" 36 | 37 | #include "b2_broad_phase.h" 38 | #include "b2_dynamic_tree.h" 39 | 40 | #include "b2_body.h" 41 | #include "b2_contact.h" 42 | #include "b2_fixture.h" 43 | #include "b2_time_step.h" 44 | #include "b2_world.h" 45 | #include "b2_world_callbacks.h" 46 | 47 | #include "b2_distance_joint.h" 48 | #include "b2_friction_joint.h" 49 | #include "b2_gear_joint.h" 50 | #include "b2_motor_joint.h" 51 | #include "b2_mouse_joint.h" 52 | #include "b2_prismatic_joint.h" 53 | #include "b2_pulley_joint.h" 54 | #include "b2_revolute_joint.h" 55 | #include "b2_weld_joint.h" 56 | #include "b2_wheel_joint.h" 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /deps/box2d/unit-test/math_test.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2020 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/box2d.h" 24 | #include "doctest.h" 25 | #include 26 | 27 | DOCTEST_TEST_CASE("math test") 28 | { 29 | SUBCASE("sweep") 30 | { 31 | // From issue #447 32 | b2Sweep sweep; 33 | sweep.localCenter.SetZero(); 34 | sweep.c0.Set(-2.0f, 4.0f); 35 | sweep.c.Set(3.0f, 8.0f); 36 | sweep.a0 = 0.5f; 37 | sweep.a = 5.0f; 38 | sweep.alpha0 = 0.0f; 39 | 40 | b2Transform transform; 41 | 42 | sweep.GetTransform(&transform, 0.0f); 43 | DOCTEST_REQUIRE_EQ(transform.p.x, sweep.c0.x); 44 | DOCTEST_REQUIRE_EQ(transform.p.y, sweep.c0.y); 45 | DOCTEST_REQUIRE_EQ(transform.q.c, cosf(sweep.a0)); 46 | DOCTEST_REQUIRE_EQ(transform.q.s, sinf(sweep.a0)); 47 | 48 | sweep.GetTransform(&transform, 1.0f); 49 | DOCTEST_REQUIRE_EQ(transform.p.x, sweep.c.x); 50 | DOCTEST_REQUIRE_EQ(transform.p.y, sweep.c.y); 51 | DOCTEST_REQUIRE_EQ(transform.q.c, cosf(sweep.a)); 52 | DOCTEST_REQUIRE_EQ(transform.q.s, sinf(sweep.a)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/heavy1.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class Heavy1 : public Test 26 | { 27 | public: 28 | 29 | Heavy1() 30 | { 31 | { 32 | b2BodyDef bd; 33 | b2Body* ground = m_world->CreateBody(&bd); 34 | 35 | b2EdgeShape shape; 36 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 37 | ground->CreateFixture(&shape, 0.0f); 38 | } 39 | 40 | b2BodyDef bd; 41 | bd.type = b2_dynamicBody; 42 | bd.position.Set(0.0f, 0.5f); 43 | b2Body* body = m_world->CreateBody(&bd); 44 | 45 | b2CircleShape shape; 46 | shape.m_radius = 0.5f; 47 | body->CreateFixture(&shape, 10.0f); 48 | 49 | bd.position.Set(0.0f, 6.0f); 50 | body = m_world->CreateBody(&bd); 51 | shape.m_radius = 5.0f; 52 | body->CreateFixture(&shape, 10.0f); 53 | } 54 | 55 | static Test* Create() 56 | { 57 | return new Heavy1; 58 | } 59 | }; 60 | 61 | static int testIndex = RegisterTest("Solver", "Heavy 1", Heavy1::Create); 62 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_stack_allocator.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_STACK_ALLOCATOR_H 24 | #define B2_STACK_ALLOCATOR_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_settings.h" 28 | 29 | const int32 b2_stackSize = 100 * 1024; // 100k 30 | const int32 b2_maxStackEntries = 32; 31 | 32 | struct B2_API b2StackEntry 33 | { 34 | char* data; 35 | int32 size; 36 | bool usedMalloc; 37 | }; 38 | 39 | // This is a stack allocator used for fast per step allocations. 40 | // You must nest allocate/free pairs. The code will assert 41 | // if you try to interleave multiple allocate/free pairs. 42 | class B2_API b2StackAllocator 43 | { 44 | public: 45 | b2StackAllocator(); 46 | ~b2StackAllocator(); 47 | 48 | void* Allocate(int32 size); 49 | void Free(void* p); 50 | 51 | int32 GetMaxAllocation() const; 52 | 53 | private: 54 | 55 | char m_data[b2_stackSize]; 56 | int32 m_index; 57 | 58 | int32 m_allocation; 59 | int32 m_maxAllocation; 60 | 61 | b2StackEntry m_entries[b2_maxStackEntries]; 62 | int32 m_entryCount; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/nsgl_context.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 28 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl 29 | 30 | 31 | // NSGL-specific per-context data 32 | // 33 | typedef struct _GLFWcontextNSGL 34 | { 35 | id pixelFormat; 36 | id object; 37 | 38 | } _GLFWcontextNSGL; 39 | 40 | // NSGL-specific global data 41 | // 42 | typedef struct _GLFWlibraryNSGL 43 | { 44 | // dlopen handle for OpenGL.framework (for glfwGetProcAddress) 45 | CFBundleRef framework; 46 | 47 | } _GLFWlibraryNSGL; 48 | 49 | 50 | GLFWbool _glfwInitNSGL(void); 51 | void _glfwTerminateNSGL(void); 52 | GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, 53 | const _GLFWctxconfig* ctxconfig, 54 | const _GLFWfbconfig* fbconfig); 55 | void _glfwDestroyContextNSGL(_GLFWwindow* window); 56 | 57 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_block_allocator.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_BLOCK_ALLOCATOR_H 24 | #define B2_BLOCK_ALLOCATOR_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_settings.h" 28 | 29 | const int32 b2_blockSizeCount = 14; 30 | 31 | struct b2Block; 32 | struct b2Chunk; 33 | 34 | /// This is a small object allocator used for allocating small 35 | /// objects that persist for more than one time step. 36 | /// See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp 37 | class B2_API b2BlockAllocator 38 | { 39 | public: 40 | b2BlockAllocator(); 41 | ~b2BlockAllocator(); 42 | 43 | /// Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize. 44 | void* Allocate(int32 size); 45 | 46 | /// Free memory. This will use b2Free if the size is larger than b2_maxBlockSize. 47 | void Free(void* p, int32 size); 48 | 49 | void Clear(); 50 | 51 | private: 52 | 53 | b2Chunk* m_chunks; 54 | int32 m_chunkCount; 55 | int32 m_chunkSpace; 56 | 57 | b2Block* m_freeLists[b2_blockSizeCount]; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/glfw_config.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // MODIFIED_ERIN 38 | #ifdef _WIN32 39 | #define _GLFW_WIN32 40 | #define _CRT_SECURE_NO_WARNINGS 41 | #elif __APPLE__ 42 | #define _GLFW_COCOA 43 | #else 44 | #define _GLFW_X11 45 | #endif 46 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | 52 | void _glfwInitJoysticksWin32(void); 53 | void _glfwTerminateJoysticksWin32(void); 54 | void _glfwDetectJoystickConnectionWin32(void); 55 | void _glfwDetectJoystickDisconnectionWin32(void); 56 | 57 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_time_step.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | #ifndef B2_TIME_STEP_H 23 | #define B2_TIME_STEP_H 24 | 25 | #include "b2_api.h" 26 | #include "b2_math.h" 27 | 28 | /// Profiling data. Times are in milliseconds. 29 | struct B2_API b2Profile 30 | { 31 | float step; 32 | float collide; 33 | float solve; 34 | float solveInit; 35 | float solveVelocity; 36 | float solvePosition; 37 | float broadphase; 38 | float solveTOI; 39 | }; 40 | 41 | /// This is an internal structure. 42 | struct B2_API b2TimeStep 43 | { 44 | float dt; // time step 45 | float inv_dt; // inverse time step (0 if dt == 0). 46 | float dtRatio; // dt * inv_dt0 47 | int32 velocityIterations; 48 | int32 positionIterations; 49 | bool warmStarting; 50 | }; 51 | 52 | /// This is an internal structure. 53 | struct B2_API b2Position 54 | { 55 | b2Vec2 c; 56 | float a; 57 | }; 58 | 59 | /// This is an internal structure. 60 | struct B2_API b2Velocity 61 | { 62 | b2Vec2 v; 63 | float w; 64 | }; 65 | 66 | /// Solver Data 67 | struct B2_API b2SolverData 68 | { 69 | b2TimeStep step; 70 | b2Position* positions; 71 | b2Velocity* velocities; 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /deps/box2d/src/common/b2_settings.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #define _CRT_SECURE_NO_WARNINGS 24 | 25 | #include "box2d/b2_settings.h" 26 | #include 27 | #include 28 | #include 29 | 30 | b2Version b2_version = {2, 4, 0}; 31 | 32 | // Memory allocators. Modify these to use your own allocator. 33 | void* b2Alloc_Default(int32 size) 34 | { 35 | return malloc(size); 36 | } 37 | 38 | void b2Free_Default(void* mem) 39 | { 40 | free(mem); 41 | } 42 | 43 | // You can modify this to use your logging facility. 44 | void b2Log_Default(const char* string, va_list args) 45 | { 46 | vprintf(string, args); 47 | } 48 | 49 | FILE* b2_dumpFile = nullptr; 50 | 51 | void b2OpenDump(const char* fileName) 52 | { 53 | b2Assert(b2_dumpFile == nullptr); 54 | b2_dumpFile = fopen(fileName, "w"); 55 | } 56 | 57 | void b2Dump(const char* string, ...) 58 | { 59 | if (b2_dumpFile == nullptr) 60 | { 61 | return; 62 | } 63 | 64 | va_list args; 65 | va_start(args, string); 66 | vfprintf(b2_dumpFile, string, args); 67 | va_end(args); 68 | } 69 | 70 | void b2CloseDump() 71 | { 72 | fclose(b2_dumpFile); 73 | b2_dumpFile = nullptr; 74 | } 75 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW internal API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | // Initialise timer 37 | // 38 | void _glfwInitTimerNS(void) 39 | { 40 | mach_timebase_info_data_t info; 41 | mach_timebase_info(&info); 42 | 43 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 44 | } 45 | 46 | 47 | ////////////////////////////////////////////////////////////////////////// 48 | ////// GLFW platform API ////// 49 | ////////////////////////////////////////////////////////////////////////// 50 | 51 | uint64_t _glfwPlatformGetTimerValue(void) 52 | { 53 | return mach_absolute_time(); 54 | } 55 | 56 | uint64_t _glfwPlatformGetTimerFrequency(void) 57 | { 58 | return _glfw.timer.ns.frequency; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /deps/box2d/testbed/imgui_impl_glfw.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for GLFW 2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) 3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 8 | // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. 9 | // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 12 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 13 | // https://github.com/ocornut/imgui 14 | 15 | // About GLSL version: 16 | // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. 17 | // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! 18 | 19 | #pragma once 20 | 21 | struct GLFWwindow; 22 | 23 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); 24 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); 25 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); 27 | 28 | // InitXXX function with 'install_callbacks=true': install GLFW callbacks. They will call user's previously installed callbacks, if any. 29 | // InitXXX function with 'install_callbacks=false': do not install GLFW callbacks. You will need to call them yourself from your own GLFW callbacks. 30 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 31 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 32 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 33 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); 34 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_time_of_impact.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_TIME_OF_IMPACT_H 24 | #define B2_TIME_OF_IMPACT_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_math.h" 28 | #include "b2_distance.h" 29 | 30 | /// Input parameters for b2TimeOfImpact 31 | struct B2_API b2TOIInput 32 | { 33 | b2DistanceProxy proxyA; 34 | b2DistanceProxy proxyB; 35 | b2Sweep sweepA; 36 | b2Sweep sweepB; 37 | float tMax; // defines sweep interval [0, tMax] 38 | }; 39 | 40 | /// Output parameters for b2TimeOfImpact. 41 | struct B2_API b2TOIOutput 42 | { 43 | enum State 44 | { 45 | e_unknown, 46 | e_failed, 47 | e_overlapped, 48 | e_touching, 49 | e_separated 50 | }; 51 | 52 | State state; 53 | float t; 54 | }; 55 | 56 | /// Compute the upper bound on time before two shapes penetrate. Time is represented as 57 | /// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, 58 | /// non-tunneling collisions. If you change the time interval, you should call this function 59 | /// again. 60 | /// Note: use b2Distance to compute the contact point and normal at the time of impact. 61 | B2_API void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/add_pair.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class AddPair : public Test 26 | { 27 | public: 28 | 29 | AddPair() 30 | { 31 | m_world->SetGravity(b2Vec2(0.0f,0.0f)); 32 | { 33 | b2CircleShape shape; 34 | shape.m_p.SetZero(); 35 | shape.m_radius = 0.1f; 36 | 37 | float minX = -6.0f; 38 | float maxX = 0.0f; 39 | float minY = 4.0f; 40 | float maxY = 6.0f; 41 | 42 | for (int32 i = 0; i < 400; ++i) 43 | { 44 | b2BodyDef bd; 45 | bd.type = b2_dynamicBody; 46 | bd.position = b2Vec2(RandomFloat(minX,maxX),RandomFloat(minY,maxY)); 47 | b2Body* body = m_world->CreateBody(&bd); 48 | body->CreateFixture(&shape, 0.01f); 49 | } 50 | } 51 | 52 | { 53 | b2PolygonShape shape; 54 | shape.SetAsBox(1.5f, 1.5f); 55 | b2BodyDef bd; 56 | bd.type = b2_dynamicBody; 57 | bd.position.Set(-40.0f,5.0f); 58 | bd.bullet = true; 59 | b2Body* body = m_world->CreateBody(&bd); 60 | body->CreateFixture(&shape, 1.0f); 61 | body->SetLinearVelocity(b2Vec2(10.0f, 0.0f)); 62 | } 63 | } 64 | 65 | static Test* Create() 66 | { 67 | return new AddPair; 68 | } 69 | }; 70 | 71 | static int testIndex = RegisterTest("Benchmark", "Add Pair", AddPair::Create); 72 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_edge_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_edge_circle_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_fixture.h" 27 | 28 | #include 29 | 30 | b2Contact* b2EdgeAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 31 | { 32 | void* mem = allocator->Allocate(sizeof(b2EdgeAndCircleContact)); 33 | return new (mem) b2EdgeAndCircleContact(fixtureA, fixtureB); 34 | } 35 | 36 | void b2EdgeAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 37 | { 38 | ((b2EdgeAndCircleContact*)contact)->~b2EdgeAndCircleContact(); 39 | allocator->Free(contact, sizeof(b2EdgeAndCircleContact)); 40 | } 41 | 42 | b2EdgeAndCircleContact::b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 43 | : b2Contact(fixtureA, 0, fixtureB, 0) 44 | { 45 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 46 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 47 | } 48 | 49 | void b2EdgeAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 50 | { 51 | b2CollideEdgeAndCircle( manifold, 52 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 53 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 54 | } 55 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | 59 | GLFWbool _glfwInitJoysticksLinux(void); 60 | void _glfwTerminateJoysticksLinux(void); 61 | void _glfwDetectJoystickConnectionLinux(void); 62 | 63 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_edge_polygon_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_edge_polygon_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_fixture.h" 27 | 28 | #include 29 | 30 | b2Contact* b2EdgeAndPolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 31 | { 32 | void* mem = allocator->Allocate(sizeof(b2EdgeAndPolygonContact)); 33 | return new (mem) b2EdgeAndPolygonContact(fixtureA, fixtureB); 34 | } 35 | 36 | void b2EdgeAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 37 | { 38 | ((b2EdgeAndPolygonContact*)contact)->~b2EdgeAndPolygonContact(); 39 | allocator->Free(contact, sizeof(b2EdgeAndPolygonContact)); 40 | } 41 | 42 | b2EdgeAndPolygonContact::b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 43 | : b2Contact(fixtureA, 0, fixtureB, 0) 44 | { 45 | b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); 46 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 47 | } 48 | 49 | void b2EdgeAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 50 | { 51 | b2CollideEdgeAndPolygon( manifold, 52 | (b2EdgeShape*)m_fixtureA->GetShape(), xfA, 53 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 54 | } 55 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/null_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null 31 | 32 | #define _GLFW_PLATFORM_CONTEXT_STATE 33 | #define _GLFW_PLATFORM_MONITOR_STATE 34 | #define _GLFW_PLATFORM_CURSOR_STATE 35 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE 36 | #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE 37 | #define _GLFW_EGL_CONTEXT_STATE 38 | #define _GLFW_EGL_LIBRARY_CONTEXT_STATE 39 | 40 | #include "osmesa_context.h" 41 | #include "posix_time.h" 42 | #include "posix_thread.h" 43 | #include "null_joystick.h" 44 | 45 | #if defined(_GLFW_WIN32) 46 | #define _glfw_dlopen(name) LoadLibraryA(name) 47 | #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) 48 | #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) 49 | #else 50 | #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) 51 | #define _glfw_dlclose(handle) dlclose(handle) 52 | #define _glfw_dlsym(handle, name) dlsym(handle, name) 53 | #endif 54 | 55 | // Null-specific per-window data 56 | // 57 | typedef struct _GLFWwindowNull 58 | { 59 | int width; 60 | int height; 61 | } _GLFWwindowNull; 62 | 63 | -------------------------------------------------------------------------------- /deps/box2d/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changes for version 2.4.1 2 | 3 | ## API Changes 4 | - Extended distance joint to have a minimum and maximum limit. 5 | - Removed rope joint. Use the distance joint instead. 6 | - B2_USER_SETTINGS and b2_user_settings.h can control user data, length units, and maximum polygon vertices. 7 | - Default user data is now uintptr_t instead of void* 8 | - b2FixtureDef::restitutionThreshold lets you set the restitution velocity threshold per fixture. 9 | 10 | ## BREAKING Changes 11 | - BREAKING: distance joint 0 stiffness now means the spring is turned off rather than making the joint rigid. 12 | - BREAKING: distance joint minimum and maximum must be set correctly to get old behavior. 13 | 14 | ## Infrastructure 15 | - Library installation function available in CMake. 16 | - Shared library (DLL) option available. 17 | - Bug fixes 18 | 19 | # Changes for version 2.4.0 20 | 21 | ## Infrastructure 22 | - Documentation in Doxygen format 23 | - CMake build system 24 | - Unit test support 25 | - Continuous integration testing using Travis CI 26 | - Limited use of C++11 (nullptr and override) 27 | - Restructured folders and renamed files to better match open-source standards 28 | - MIT License 29 | - Removed float32 and float64 30 | - Linked the Box2D project to GitHub Sponsors 31 | 32 | ## Collision 33 | - Chain and edge shape must now be one-sided to eliminate ghost collisions 34 | - Broad-phase optimizations 35 | - Added b2ShapeCast for linear shape casting 36 | 37 | ## Dynamics 38 | - Joint limits are now predictive and not stateful 39 | - Experimental 2D cloth (rope) 40 | - b2Body::SetActive -> b2Body::SetEnabled 41 | - Better support for running multiple worlds 42 | - Handle zero density better 43 | - The body behaves like a static body 44 | - The body is drawn with a red color 45 | - Added translation limit to wheel joint 46 | - World dump now writes to box2d_dump.inl 47 | - Static bodies are never awake 48 | - All joints with spring-dampers now use stiffness and damping 49 | - Added utility functions to convert frequency and damping ratio to stiffness and damping 50 | 51 | ## Testbed 52 | - Testbed uses dear imgui 53 | - glad OpenGL loader 54 | - OpenGL 3.3 required 55 | 56 | # Changes for version 2.3.0 57 | - Polygon creation now computes the convex hull. Vertices no longer need to be ordered. 58 | - The convex hull code will merge vertices closer than dm_linearSlop. This may lead to failure on very small polygons. 59 | - Added b2MotorJoint. 60 | - Bug fixes. 61 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_circle_contact.h" 24 | #include "box2d/b2_block_allocator.h" 25 | #include "box2d/b2_body.h" 26 | #include "box2d/b2_fixture.h" 27 | #include "box2d/b2_time_of_impact.h" 28 | #include "box2d/b2_world_callbacks.h" 29 | 30 | #include 31 | 32 | b2Contact* b2CircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 33 | { 34 | void* mem = allocator->Allocate(sizeof(b2CircleContact)); 35 | return new (mem) b2CircleContact(fixtureA, fixtureB); 36 | } 37 | 38 | void b2CircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 39 | { 40 | ((b2CircleContact*)contact)->~b2CircleContact(); 41 | allocator->Free(contact, sizeof(b2CircleContact)); 42 | } 43 | 44 | b2CircleContact::b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 45 | : b2Contact(fixtureA, 0, fixtureB, 0) 46 | { 47 | b2Assert(m_fixtureA->GetType() == b2Shape::e_circle); 48 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 49 | } 50 | 51 | void b2CircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 52 | { 53 | b2CollideCircles(manifold, 54 | (b2CircleShape*)m_fixtureA->GetShape(), xfA, 55 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 56 | } 57 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_polygon_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_polygon_circle_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_fixture.h" 27 | 28 | #include 29 | 30 | b2Contact* b2PolygonAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 31 | { 32 | void* mem = allocator->Allocate(sizeof(b2PolygonAndCircleContact)); 33 | return new (mem) b2PolygonAndCircleContact(fixtureA, fixtureB); 34 | } 35 | 36 | void b2PolygonAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 37 | { 38 | ((b2PolygonAndCircleContact*)contact)->~b2PolygonAndCircleContact(); 39 | allocator->Free(contact, sizeof(b2PolygonAndCircleContact)); 40 | } 41 | 42 | b2PolygonAndCircleContact::b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 43 | : b2Contact(fixtureA, 0, fixtureB, 0) 44 | { 45 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 46 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 47 | } 48 | 49 | void b2PolygonAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 50 | { 51 | b2CollidePolygonAndCircle( manifold, 52 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 53 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 54 | } 55 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_polygon_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_polygon_contact.h" 24 | 25 | #include "box2d/b2_block_allocator.h" 26 | #include "box2d/b2_body.h" 27 | #include "box2d/b2_fixture.h" 28 | #include "box2d/b2_time_of_impact.h" 29 | #include "box2d/b2_world_callbacks.h" 30 | 31 | #include 32 | 33 | b2Contact* b2PolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) 34 | { 35 | void* mem = allocator->Allocate(sizeof(b2PolygonContact)); 36 | return new (mem) b2PolygonContact(fixtureA, fixtureB); 37 | } 38 | 39 | void b2PolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 40 | { 41 | ((b2PolygonContact*)contact)->~b2PolygonContact(); 42 | allocator->Free(contact, sizeof(b2PolygonContact)); 43 | } 44 | 45 | b2PolygonContact::b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) 46 | : b2Contact(fixtureA, 0, fixtureB, 0) 47 | { 48 | b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); 49 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 50 | } 51 | 52 | void b2PolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 53 | { 54 | b2CollidePolygons( manifold, 55 | (b2PolygonShape*)m_fixtureA->GetShape(), xfA, 56 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 57 | } 58 | -------------------------------------------------------------------------------- /deps/imgui_sdl/example.cpp: -------------------------------------------------------------------------------- 1 | #include "SDL.h" 2 | #undef main 3 | 4 | #include "imgui.h" 5 | #include "imgui_sdl.h" 6 | 7 | int main() 8 | { 9 | SDL_Init(SDL_INIT_EVERYTHING); 10 | 11 | SDL_Window* window = SDL_CreateWindow("SDL2 ImGui Renderer", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_RESIZABLE); 12 | SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); 13 | 14 | ImGui::CreateContext(); 15 | ImGuiSDL::Initialize(renderer, 800, 600); 16 | 17 | SDL_Texture* texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, 100, 100); 18 | { 19 | SDL_SetRenderTarget(renderer, texture); 20 | SDL_SetRenderDrawColor(renderer, 255, 0, 255, 255); 21 | SDL_RenderClear(renderer); 22 | SDL_SetRenderTarget(renderer, nullptr); 23 | } 24 | 25 | bool run = true; 26 | while (run) 27 | { 28 | ImGuiIO& io = ImGui::GetIO(); 29 | 30 | int wheel = 0; 31 | 32 | SDL_Event e; 33 | while (SDL_PollEvent(&e)) 34 | { 35 | if (e.type == SDL_QUIT) run = false; 36 | else if (e.type == SDL_WINDOWEVENT) 37 | { 38 | if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) 39 | { 40 | io.DisplaySize.x = static_cast(e.window.data1); 41 | io.DisplaySize.y = static_cast(e.window.data2); 42 | } 43 | } 44 | else if (e.type == SDL_MOUSEWHEEL) 45 | { 46 | wheel = e.wheel.y; 47 | } 48 | } 49 | 50 | int mouseX, mouseY; 51 | const int buttons = SDL_GetMouseState(&mouseX, &mouseY); 52 | 53 | // Setup low-level inputs (e.g. on Win32, GetKeyboardState(), or write to those fields from your Windows message loop handlers, etc.) 54 | 55 | io.DeltaTime = 1.0f / 60.0f; 56 | io.MousePos = ImVec2(static_cast(mouseX), static_cast(mouseY)); 57 | io.MouseDown[0] = buttons & SDL_BUTTON(SDL_BUTTON_LEFT); 58 | io.MouseDown[1] = buttons & SDL_BUTTON(SDL_BUTTON_RIGHT); 59 | io.MouseWheel = static_cast(wheel); 60 | 61 | ImGui::NewFrame(); 62 | 63 | ImGui::ShowDemoWindow(); 64 | 65 | ImGui::Begin("Image"); 66 | ImGui::Image(texture, ImVec2(100, 100)); 67 | ImGui::End(); 68 | 69 | SDL_SetRenderDrawColor(renderer, 114, 144, 154, 255); 70 | SDL_RenderClear(renderer); 71 | 72 | ImGui::Render(); 73 | ImGuiSDL::Render(ImGui::GetDrawData()); 74 | 75 | SDL_RenderPresent(renderer); 76 | } 77 | 78 | ImGuiSDL::Deinitialize(); 79 | 80 | SDL_DestroyRenderer(renderer); 81 | SDL_DestroyWindow(window); 82 | 83 | ImGui::DestroyContext(); 84 | 85 | return 0; 86 | } -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/null_monitor.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW platform API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) 36 | { 37 | } 38 | 39 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) 40 | { 41 | } 42 | 43 | void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, 44 | float* xscale, float* yscale) 45 | { 46 | if (xscale) 47 | *xscale = 1.f; 48 | if (yscale) 49 | *yscale = 1.f; 50 | } 51 | 52 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) 53 | { 54 | return NULL; 55 | } 56 | 57 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) 58 | { 59 | } 60 | 61 | GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 62 | { 63 | return GLFW_FALSE; 64 | } 65 | 66 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 67 | { 68 | } 69 | 70 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_circle_shape.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CIRCLE_SHAPE_H 24 | #define B2_CIRCLE_SHAPE_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_shape.h" 28 | 29 | /// A solid circle shape 30 | class B2_API b2CircleShape : public b2Shape 31 | { 32 | public: 33 | b2CircleShape(); 34 | 35 | /// Implement b2Shape. 36 | b2Shape* Clone(b2BlockAllocator* allocator) const override; 37 | 38 | /// @see b2Shape::GetChildCount 39 | int32 GetChildCount() const override; 40 | 41 | /// Implement b2Shape. 42 | bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override; 43 | 44 | /// Implement b2Shape. 45 | /// @note because the circle is solid, rays that start inside do not hit because the normal is 46 | /// not defined. 47 | bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, 48 | const b2Transform& transform, int32 childIndex) const override; 49 | 50 | /// @see b2Shape::ComputeAABB 51 | void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override; 52 | 53 | /// @see b2Shape::ComputeMass 54 | void ComputeMass(b2MassData* massData, float density) const override; 55 | 56 | /// Position 57 | b2Vec2 m_p; 58 | }; 59 | 60 | inline b2CircleShape::b2CircleShape() 61 | { 62 | m_type = e_circle; 63 | m_radius = 0.0f; 64 | m_p.SetZero(); 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_growable_stack.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_GROWABLE_STACK_H 24 | #define B2_GROWABLE_STACK_H 25 | 26 | #include 27 | 28 | #include "b2_settings.h" 29 | 30 | /// This is a growable LIFO stack with an initial capacity of N. 31 | /// If the stack size exceeds the initial capacity, the heap is used 32 | /// to increase the size of the stack. 33 | template 34 | class b2GrowableStack 35 | { 36 | public: 37 | b2GrowableStack() 38 | { 39 | m_stack = m_array; 40 | m_count = 0; 41 | m_capacity = N; 42 | } 43 | 44 | ~b2GrowableStack() 45 | { 46 | if (m_stack != m_array) 47 | { 48 | b2Free(m_stack); 49 | m_stack = nullptr; 50 | } 51 | } 52 | 53 | void Push(const T& element) 54 | { 55 | if (m_count == m_capacity) 56 | { 57 | T* old = m_stack; 58 | m_capacity *= 2; 59 | m_stack = (T*)b2Alloc(m_capacity * sizeof(T)); 60 | memcpy(m_stack, old, m_count * sizeof(T)); 61 | if (old != m_array) 62 | { 63 | b2Free(old); 64 | } 65 | } 66 | 67 | m_stack[m_count] = element; 68 | ++m_count; 69 | } 70 | 71 | T Pop() 72 | { 73 | b2Assert(m_count > 0); 74 | --m_count; 75 | return m_stack[m_count]; 76 | } 77 | 78 | int32 GetCount() 79 | { 80 | return m_count; 81 | } 82 | 83 | private: 84 | T* m_stack; 85 | T m_array[N]; 86 | int32 m_count; 87 | int32 m_capacity; 88 | }; 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/restitution.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | // Note: even with a restitution of 1.0, there is some energy change 26 | // due to position correction. 27 | class Restitution : public Test 28 | { 29 | public: 30 | 31 | Restitution() 32 | { 33 | const float threshold = 10.0f; 34 | 35 | { 36 | b2BodyDef bd; 37 | b2Body* ground = m_world->CreateBody(&bd); 38 | 39 | b2EdgeShape shape; 40 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 41 | 42 | b2FixtureDef fd; 43 | fd.shape = &shape; 44 | fd.restitutionThreshold = threshold; 45 | ground->CreateFixture(&fd); 46 | } 47 | 48 | { 49 | b2CircleShape shape; 50 | shape.m_radius = 1.0f; 51 | 52 | b2FixtureDef fd; 53 | fd.shape = &shape; 54 | fd.density = 1.0f; 55 | 56 | float restitution[7] = { 0.0f, 0.1f, 0.3f, 0.5f, 0.75f, 0.9f, 1.0f }; 57 | 58 | for (int32 i = 0; i < 7; ++i) 59 | { 60 | b2BodyDef bd; 61 | bd.type = b2_dynamicBody; 62 | bd.position.Set(-10.0f + 3.0f * i, 20.0f); 63 | 64 | b2Body* body = m_world->CreateBody(&bd); 65 | 66 | fd.restitution = restitution[i]; 67 | fd.restitutionThreshold = threshold; 68 | body->CreateFixture(&fd); 69 | } 70 | } 71 | } 72 | 73 | static Test* Create() 74 | { 75 | return new Restitution; 76 | } 77 | }; 78 | 79 | static int testIndex = RegisterTest("Forces", "Restitution", Restitution::Create); 80 | -------------------------------------------------------------------------------- /deps/box2d/unit-test/world_test.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/box2d.h" 24 | #include "doctest.h" 25 | #include 26 | 27 | static bool begin_contact = false; 28 | 29 | class MyContactListener : public b2ContactListener 30 | { 31 | public: 32 | void BeginContact(b2Contact* contact) 33 | { 34 | begin_contact = true; 35 | } 36 | }; 37 | 38 | DOCTEST_TEST_CASE("begin contact") 39 | { 40 | b2World world = b2World(b2Vec2(0.0f, -10.0f)); 41 | MyContactListener listener; 42 | world.SetContactListener(&listener); 43 | 44 | b2CircleShape circle; 45 | circle.m_radius = 5.f; 46 | 47 | b2BodyDef bodyDef; 48 | bodyDef.type = b2_dynamicBody; 49 | 50 | b2Body* bodyA = world.CreateBody(&bodyDef); 51 | b2Body* bodyB = world.CreateBody(&bodyDef); 52 | bodyA->CreateFixture(&circle, 0.0f); 53 | bodyB->CreateFixture(&circle, 0.0f); 54 | 55 | bodyA->SetTransform(b2Vec2(0.f, 0.f), 0.f); 56 | bodyB->SetTransform(b2Vec2(100.f, 0.f), 0.f); 57 | 58 | const float timeStep = 1.f / 60.f; 59 | const int32 velocityIterations = 6; 60 | const int32 positionIterations = 2; 61 | 62 | world.Step(timeStep, velocityIterations, positionIterations); 63 | 64 | CHECK(world.GetContactList() == nullptr); 65 | CHECK(begin_contact == false); 66 | 67 | bodyB->SetTransform(b2Vec2(1.f, 0.f), 0.f); 68 | 69 | world.Step(timeStep, velocityIterations, positionIterations); 70 | 71 | CHECK(world.GetContactList() != nullptr); 72 | CHECK(begin_contact == true); 73 | } 74 | -------------------------------------------------------------------------------- /client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.8) 2 | 3 | set(LIBS core GameNetworkingSockets imgui filamentapp our-resources cube-resources quad-resources filameshio filagui) 4 | 5 | add_executable(scalable-game-client ${CMAKE_CURRENT_SOURCE_DIR}/main_sdl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../deps/imgui_sdl/imgui_sdl.cpp) 6 | list(APPEND LIBS sdl2 game) 7 | target_include_directories(scalable-game-client PRIVATE "../deps/filament/third_party/libsdl2/include" "../deps") 8 | 9 | if(WIN32) 10 | list(APPEND LIBS sdl2main) 11 | 12 | 13 | endif() 14 | 15 | target_link_libraries(scalable-game-client PRIVATE ${LIBS}) 16 | 17 | file(COPY ../assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 18 | 19 | #copy dlls 20 | if(WIN32) 21 | add_custom_command(TARGET scalable-game-client POST_BUILD 22 | COMMAND ${CMAKE_COMMAND} -E copy 23 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/GameNetworkingSockets.dll ${CMAKE_CURRENT_BINARY_DIR}) 24 | add_custom_command(TARGET scalable-game-client POST_BUILD 25 | COMMAND ${CMAKE_COMMAND} -E copy 26 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/GameNetworkingSockets.pdb ${CMAKE_CURRENT_BINARY_DIR}) 27 | if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobuf.dll) 28 | add_custom_command(TARGET scalable-game-client POST_BUILD 29 | COMMAND ${CMAKE_COMMAND} -E copy 30 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobuf.dll ${CMAKE_CURRENT_BINARY_DIR}) 31 | endif() 32 | if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobufd.dll) 33 | add_custom_command(TARGET scalable-game-client POST_BUILD 34 | COMMAND ${CMAKE_COMMAND} -E copy 35 | ${CMAKE_CURRENT_BINARY_DIR}/../deps/GameNetworkingSockets/src/libprotobufd.dll ${CMAKE_CURRENT_BINARY_DIR}) 36 | endif() 37 | endif() 38 | 39 | #copy settings files 40 | add_custom_command(TARGET scalable-game-client POST_BUILD 41 | COMMAND ${CMAKE_COMMAND} -E copy 42 | ${CMAKE_CURRENT_SOURCE_DIR}/default-settings.json ${CMAKE_CURRENT_BINARY_DIR}) 43 | add_custom_command(TARGET scalable-game-client POST_BUILD 44 | COMMAND ${CMAKE_COMMAND} -E copy 45 | ${CMAKE_CURRENT_SOURCE_DIR}/default-settings.json ${CMAKE_CURRENT_BINARY_DIR}/settings.json) 46 | 47 | #copy JS files 48 | set(GAME_JS_FILES ${PROJECT_SOURCE_DIR}/scalable-game/main.js) 49 | add_custom_command(TARGET scalable-game-client POST_BUILD 50 | COMMAND ${CMAKE_COMMAND} -E copy 51 | ${GAME_JS_FILES} ${CMAKE_CURRENT_BINARY_DIR}) -------------------------------------------------------------------------------- /deps/box2d/testbed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set (TESTBED_SOURCE_FILES 2 | draw.cpp 3 | draw.h 4 | imgui_impl_glfw.cpp 5 | imgui_impl_glfw.h 6 | imgui_impl_opengl3.cpp 7 | imgui_impl_opengl3.h 8 | main.cpp 9 | settings.h 10 | settings.cpp 11 | test.cpp 12 | test.h 13 | tests/add_pair.cpp 14 | tests/apply_force.cpp 15 | tests/body_types.cpp 16 | tests/box_stack.cpp 17 | tests/breakable.cpp 18 | tests/bridge.cpp 19 | tests/bullet_test.cpp 20 | tests/cantilever.cpp 21 | tests/car.cpp 22 | tests/chain.cpp 23 | tests/chain_problem.cpp 24 | tests/character_collision.cpp 25 | tests/circle_stack.cpp 26 | tests/collision_filtering.cpp 27 | tests/collision_processing.cpp 28 | tests/compound_shapes.cpp 29 | tests/confined.cpp 30 | tests/continuous_test.cpp 31 | tests/convex_hull.cpp 32 | tests/conveyor_belt.cpp 33 | tests/distance_joint.cpp 34 | tests/distance_test.cpp 35 | tests/dominos.cpp 36 | tests/dump_loader.cpp 37 | tests/dynamic_tree.cpp 38 | tests/edge_shapes.cpp 39 | tests/edge_test.cpp 40 | tests/friction.cpp 41 | tests/gear_joint.cpp 42 | tests/heavy1.cpp 43 | tests/heavy2.cpp 44 | tests/mobile_balanced.cpp 45 | tests/mobile_unbalanced.cpp 46 | tests/motor_joint.cpp 47 | tests/pinball.cpp 48 | tests/platformer.cpp 49 | tests/polygon_collision.cpp 50 | tests/polygon_shapes.cpp 51 | tests/prismatic_joint.cpp 52 | tests/pulley_joint.cpp 53 | tests/pyramid.cpp 54 | tests/ray_cast.cpp 55 | tests/restitution.cpp 56 | tests/revolute_joint.cpp 57 | tests/rope.cpp 58 | tests/sensor.cpp 59 | tests/shape_cast.cpp 60 | tests/shape_editing.cpp 61 | tests/skier.cpp 62 | tests/slider_crank_1.cpp 63 | tests/slider_crank_2.cpp 64 | tests/theo_jansen.cpp 65 | tests/tiles.cpp 66 | tests/time_of_impact.cpp 67 | tests/tumbler.cpp 68 | tests/web.cpp 69 | tests/wheel_joint.cpp 70 | tests/wrecking_ball.cpp 71 | ) 72 | 73 | add_executable(testbed ${TESTBED_SOURCE_FILES}) 74 | target_include_directories(testbed PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) 75 | target_link_libraries(testbed PUBLIC box2d glfw imgui sajson glad) 76 | set_target_properties(testbed PROPERTIES 77 | CXX_STANDARD 11 78 | CXX_STANDARD_REQUIRED YES 79 | CXX_EXTENSIONS NO 80 | ) 81 | 82 | # message(STATUS "runtime = ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") 83 | # message(STATUS "binary = ${CMAKE_CURRENT_BINARY_DIR}") 84 | 85 | # Copy font files, etc 86 | add_custom_command( 87 | TARGET testbed POST_BUILD 88 | COMMAND ${CMAKE_COMMAND} -E copy_directory 89 | ${CMAKE_CURRENT_SOURCE_DIR}/data/ 90 | ${CMAKE_CURRENT_BINARY_DIR}/data/) 91 | 92 | source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${TESTBED_SOURCE_FILES}) 93 | -------------------------------------------------------------------------------- /deps/box2d/src/common/b2_stack_allocator.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/b2_stack_allocator.h" 24 | #include "box2d/b2_math.h" 25 | 26 | b2StackAllocator::b2StackAllocator() 27 | { 28 | m_index = 0; 29 | m_allocation = 0; 30 | m_maxAllocation = 0; 31 | m_entryCount = 0; 32 | } 33 | 34 | b2StackAllocator::~b2StackAllocator() 35 | { 36 | b2Assert(m_index == 0); 37 | b2Assert(m_entryCount == 0); 38 | } 39 | 40 | void* b2StackAllocator::Allocate(int32 size) 41 | { 42 | b2Assert(m_entryCount < b2_maxStackEntries); 43 | 44 | b2StackEntry* entry = m_entries + m_entryCount; 45 | entry->size = size; 46 | if (m_index + size > b2_stackSize) 47 | { 48 | entry->data = (char*)b2Alloc(size); 49 | entry->usedMalloc = true; 50 | } 51 | else 52 | { 53 | entry->data = m_data + m_index; 54 | entry->usedMalloc = false; 55 | m_index += size; 56 | } 57 | 58 | m_allocation += size; 59 | m_maxAllocation = b2Max(m_maxAllocation, m_allocation); 60 | ++m_entryCount; 61 | 62 | return entry->data; 63 | } 64 | 65 | void b2StackAllocator::Free(void* p) 66 | { 67 | b2Assert(m_entryCount > 0); 68 | b2StackEntry* entry = m_entries + m_entryCount - 1; 69 | b2Assert(p == entry->data); 70 | if (entry->usedMalloc) 71 | { 72 | b2Free(p); 73 | } 74 | else 75 | { 76 | m_index -= entry->size; 77 | } 78 | m_allocation -= entry->size; 79 | --m_entryCount; 80 | 81 | p = nullptr; 82 | } 83 | 84 | int32 b2StackAllocator::GetMaxAllocation() const 85 | { 86 | return m_maxAllocation; 87 | } 88 | -------------------------------------------------------------------------------- /deps/box2d/testbed/settings.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #pragma once 24 | 25 | struct Settings 26 | { 27 | Settings() 28 | { 29 | Reset(); 30 | } 31 | 32 | void Reset() 33 | { 34 | m_testIndex = 0; 35 | m_windowWidth = 1600; 36 | m_windowHeight = 900; 37 | m_hertz = 60.0f; 38 | m_velocityIterations = 8; 39 | m_positionIterations = 3; 40 | m_drawShapes = true; 41 | m_drawJoints = true; 42 | m_drawAABBs = false; 43 | m_drawContactPoints = false; 44 | m_drawContactNormals = false; 45 | m_drawContactImpulse = false; 46 | m_drawFrictionImpulse = false; 47 | m_drawCOMs = false; 48 | m_drawStats = false; 49 | m_drawProfile = false; 50 | m_enableWarmStarting = true; 51 | m_enableContinuous = true; 52 | m_enableSubStepping = false; 53 | m_enableSleep = true; 54 | m_pause = false; 55 | m_singleStep = false; 56 | } 57 | 58 | void Save(); 59 | void Load(); 60 | 61 | int m_testIndex; 62 | int m_windowWidth; 63 | int m_windowHeight; 64 | float m_hertz; 65 | int m_velocityIterations; 66 | int m_positionIterations; 67 | bool m_drawShapes; 68 | bool m_drawJoints; 69 | bool m_drawAABBs; 70 | bool m_drawContactPoints; 71 | bool m_drawContactNormals; 72 | bool m_drawContactImpulse; 73 | bool m_drawFrictionImpulse; 74 | bool m_drawCOMs; 75 | bool m_drawStats; 76 | bool m_drawProfile; 77 | bool m_enableWarmStarting; 78 | bool m_enableContinuous; 79 | bool m_enableSubStepping; 80 | bool m_enableSleep; 81 | bool m_pause; 82 | bool m_singleStep; 83 | }; 84 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/circle_stack.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class CircleStack : public Test 26 | { 27 | public: 28 | 29 | enum 30 | { 31 | e_count = 10 32 | }; 33 | 34 | CircleStack() 35 | { 36 | { 37 | b2BodyDef bd; 38 | b2Body* ground = m_world->CreateBody(&bd); 39 | 40 | b2EdgeShape shape; 41 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 42 | ground->CreateFixture(&shape, 0.0f); 43 | } 44 | 45 | { 46 | b2CircleShape shape; 47 | shape.m_radius = 1.0f; 48 | 49 | for (int32 i = 0; i < e_count; ++i) 50 | { 51 | b2BodyDef bd; 52 | bd.type = b2_dynamicBody; 53 | bd.position.Set(0.0, 4.0f + 3.0f * i); 54 | 55 | m_bodies[i] = m_world->CreateBody(&bd); 56 | 57 | m_bodies[i]->CreateFixture(&shape, 1.0f); 58 | 59 | m_bodies[i]->SetLinearVelocity(b2Vec2(0.0f, -50.0f)); 60 | } 61 | } 62 | } 63 | 64 | void Step(Settings& settings) override 65 | { 66 | Test::Step(settings); 67 | 68 | //for (int32 i = 0; i < e_count; ++i) 69 | //{ 70 | // printf("%g ", m_bodies[i]->GetWorldCenter().y); 71 | //} 72 | 73 | //for (int32 i = 0; i < e_count; ++i) 74 | //{ 75 | // printf("%g ", m_bodies[i]->GetLinearVelocity().y); 76 | //} 77 | 78 | //printf("\n"); 79 | } 80 | 81 | static Test* Create() 82 | { 83 | return new CircleStack; 84 | } 85 | 86 | b2Body* m_bodies[e_count]; 87 | }; 88 | 89 | static int testIndex = RegisterTest("Stacking", "Circles", CircleStack::Create); 90 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/pyramid.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class Pyramid : public Test 26 | { 27 | public: 28 | enum 29 | { 30 | e_count = 20 31 | }; 32 | 33 | Pyramid() 34 | { 35 | { 36 | b2BodyDef bd; 37 | b2Body* ground = m_world->CreateBody(&bd); 38 | 39 | b2EdgeShape shape; 40 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 41 | ground->CreateFixture(&shape, 0.0f); 42 | } 43 | 44 | { 45 | float a = 0.5f; 46 | b2PolygonShape shape; 47 | shape.SetAsBox(a, a); 48 | 49 | b2Vec2 x(-7.0f, 0.75f); 50 | b2Vec2 y; 51 | b2Vec2 deltaX(0.5625f, 1.25f); 52 | b2Vec2 deltaY(1.125f, 0.0f); 53 | 54 | for (int32 i = 0; i < e_count; ++i) 55 | { 56 | y = x; 57 | 58 | for (int32 j = i; j < e_count; ++j) 59 | { 60 | b2BodyDef bd; 61 | bd.type = b2_dynamicBody; 62 | bd.position = y; 63 | b2Body* body = m_world->CreateBody(&bd); 64 | body->CreateFixture(&shape, 5.0f); 65 | 66 | y += deltaY; 67 | } 68 | 69 | x += deltaX; 70 | } 71 | } 72 | } 73 | 74 | void Step(Settings& settings) override 75 | { 76 | Test::Step(settings); 77 | 78 | //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; 79 | 80 | //if (m_stepCount == 400) 81 | //{ 82 | // tree->RebuildBottomUp(); 83 | //} 84 | } 85 | 86 | static Test* Create() 87 | { 88 | return new Pyramid; 89 | } 90 | }; 91 | 92 | static int testIndex = RegisterTest("Stacking", "Pyramid", Pyramid::Create); 93 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_chain_circle_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_chain_circle_contact.h" 24 | #include "box2d/b2_block_allocator.h" 25 | #include "box2d/b2_fixture.h" 26 | #include "box2d/b2_chain_shape.h" 27 | #include "box2d/b2_edge_shape.h" 28 | 29 | #include 30 | 31 | b2Contact* b2ChainAndCircleContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) 32 | { 33 | void* mem = allocator->Allocate(sizeof(b2ChainAndCircleContact)); 34 | return new (mem) b2ChainAndCircleContact(fixtureA, indexA, fixtureB, indexB); 35 | } 36 | 37 | void b2ChainAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 38 | { 39 | ((b2ChainAndCircleContact*)contact)->~b2ChainAndCircleContact(); 40 | allocator->Free(contact, sizeof(b2ChainAndCircleContact)); 41 | } 42 | 43 | b2ChainAndCircleContact::b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB) 44 | : b2Contact(fixtureA, indexA, fixtureB, indexB) 45 | { 46 | b2Assert(m_fixtureA->GetType() == b2Shape::e_chain); 47 | b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); 48 | } 49 | 50 | void b2ChainAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 51 | { 52 | b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape(); 53 | b2EdgeShape edge; 54 | chain->GetChildEdge(&edge, m_indexA); 55 | b2CollideEdgeAndCircle( manifold, &edge, xfA, 56 | (b2CircleShape*)m_fixtureB->GetShape(), xfB); 57 | } 58 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_chain_polygon_contact.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "b2_chain_polygon_contact.h" 24 | #include "box2d/b2_block_allocator.h" 25 | #include "box2d/b2_fixture.h" 26 | #include "box2d/b2_chain_shape.h" 27 | #include "box2d/b2_edge_shape.h" 28 | 29 | #include 30 | 31 | b2Contact* b2ChainAndPolygonContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) 32 | { 33 | void* mem = allocator->Allocate(sizeof(b2ChainAndPolygonContact)); 34 | return new (mem) b2ChainAndPolygonContact(fixtureA, indexA, fixtureB, indexB); 35 | } 36 | 37 | void b2ChainAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) 38 | { 39 | ((b2ChainAndPolygonContact*)contact)->~b2ChainAndPolygonContact(); 40 | allocator->Free(contact, sizeof(b2ChainAndPolygonContact)); 41 | } 42 | 43 | b2ChainAndPolygonContact::b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB) 44 | : b2Contact(fixtureA, indexA, fixtureB, indexB) 45 | { 46 | b2Assert(m_fixtureA->GetType() == b2Shape::e_chain); 47 | b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); 48 | } 49 | 50 | void b2ChainAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) 51 | { 52 | b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape(); 53 | b2EdgeShape edge; 54 | chain->GetChildEdge(&edge, m_indexA); 55 | b2CollideEdgeAndPolygon( manifold, &edge, xfA, 56 | (b2PolygonShape*)m_fixtureB->GetShape(), xfB); 57 | } 58 | -------------------------------------------------------------------------------- /deps/box2d/testbed/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) 2 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 3 | // (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..) 4 | 5 | // Implemented features: 6 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. 7 | 8 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 9 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 10 | // https://github.com/ocornut/imgui 11 | 12 | // About OpenGL function loaders: 13 | // About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually. 14 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad. 15 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. 16 | 17 | // About GLSL version: 18 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 19 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 20 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 21 | 22 | #pragma once 23 | 24 | // MOD_ERIN 25 | #define IMGUI_IMPL_OPENGL_LOADER_GLAD 26 | 27 | // Set default OpenGL loader to be gl3w 28 | #if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \ 29 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \ 30 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \ 31 | && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) 32 | #define IMGUI_IMPL_OPENGL_LOADER_GL3W 33 | #endif 34 | 35 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 36 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 37 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 38 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 39 | 40 | // Called by Init/NewFrame/Shutdown 41 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 42 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 43 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 44 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 45 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/chain.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | #define TEST_BAD_BODY 0 26 | 27 | class Chain : public Test 28 | { 29 | public: 30 | Chain() 31 | { 32 | b2Body* ground = NULL; 33 | { 34 | b2BodyDef bd; 35 | ground = m_world->CreateBody(&bd); 36 | 37 | b2EdgeShape shape; 38 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 39 | ground->CreateFixture(&shape, 0.0f); 40 | } 41 | 42 | { 43 | b2PolygonShape shape; 44 | shape.SetAsBox(0.6f, 0.125f); 45 | 46 | b2FixtureDef fd; 47 | fd.shape = &shape; 48 | fd.density = 20.0f; 49 | fd.friction = 0.2f; 50 | 51 | b2RevoluteJointDef jd; 52 | jd.collideConnected = false; 53 | 54 | const float y = 25.0f; 55 | b2Body* prevBody = ground; 56 | for (int32 i = 0; i < 30; ++i) 57 | { 58 | b2BodyDef bd; 59 | bd.type = b2_dynamicBody; 60 | bd.position.Set(0.5f + i, y); 61 | b2Body* body = m_world->CreateBody(&bd); 62 | 63 | #if TEST_BAD_BODY == 1 64 | if (i == 10) 65 | { 66 | // Test zero density dynamic body 67 | fd.density = 0.0f; 68 | } 69 | else 70 | { 71 | fd.density = 20.0f; 72 | } 73 | #endif 74 | 75 | body->CreateFixture(&fd); 76 | 77 | b2Vec2 anchor(float(i), y); 78 | jd.Initialize(prevBody, body, anchor); 79 | m_world->CreateJoint(&jd); 80 | 81 | prevBody = body; 82 | } 83 | } 84 | } 85 | 86 | static Test* Create() 87 | { 88 | return new Chain; 89 | } 90 | }; 91 | 92 | static int testIndex = RegisterTest("Joints", "Chain", Chain::Create); 93 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW internal API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | // Initialise timer 36 | // 37 | void _glfwInitTimerWin32(void) 38 | { 39 | uint64_t frequency; 40 | 41 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 42 | { 43 | _glfw.timer.win32.hasPC = GLFW_TRUE; 44 | _glfw.timer.win32.frequency = frequency; 45 | } 46 | else 47 | { 48 | _glfw.timer.win32.hasPC = GLFW_FALSE; 49 | _glfw.timer.win32.frequency = 1000; 50 | } 51 | } 52 | 53 | 54 | ////////////////////////////////////////////////////////////////////////// 55 | ////// GLFW platform API ////// 56 | ////////////////////////////////////////////////////////////////////////// 57 | 58 | uint64_t _glfwPlatformGetTimerValue(void) 59 | { 60 | if (_glfw.timer.win32.hasPC) 61 | { 62 | uint64_t value; 63 | QueryPerformanceCounter((LARGE_INTEGER*) &value); 64 | return value; 65 | } 66 | else 67 | return (uint64_t) timeGetTime(); 68 | } 69 | 70 | uint64_t _glfwPlatformGetTimerFrequency(void) 71 | { 72 | return _glfw.timer.win32.frequency; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /client/window_process_windows.cpp: -------------------------------------------------------------------------------- 1 | #include "main_windows.h" 2 | #include 3 | #include 4 | 5 | namespace sys { 6 | Window::Window(GameSystem& system, HINSTANCE & hInstance) { 7 | WNDCLASS window = { 0 }; 8 | window.lpfnWndProc = mainWindowProcess; 9 | window.hInstance = hInstance; 10 | window.hCursor = LoadCursor(NULL, IDC_ARROW); //load loading cursor 11 | window.lpszMenuName = "Scalable Game"; 12 | window.lpszClassName = "Scalable Game"; 13 | 14 | if (!RegisterClass(&window)) 15 | throw std::exception("Couldn't make window when initializing the video system"); 16 | 17 | DWORD mainWindowStyle = WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX; 18 | windowRect.left = 0; //x 19 | windowRect.right = 1080; //w 20 | windowRect.top = 0; //y 21 | windowRect.bottom = 720; //h 22 | AdjustWindowRectEx(&windowRect, mainWindowStyle, FALSE, 0); 23 | 24 | AdjustWindowRect(&windowRect, mainWindowStyle, FALSE); 25 | mainWindow = CreateWindow( 26 | "Scalable Game", 27 | "Scalable Game", 28 | mainWindowStyle, //the style 29 | CW_USEDEFAULT, //default x 30 | CW_USEDEFAULT, //default y 31 | windowRect.right, //w 32 | windowRect.bottom, //h 33 | NULL, //parent 34 | NULL, //menu 35 | hInstance, //instance 36 | &system //param 37 | ); 38 | UpdateWindow(mainWindow); 39 | } 40 | 41 | //this is where windows send events to 42 | LRESULT CALLBACK Window::mainWindowProcess(HWND windowHandle, UINT message, WPARAM wParameter, LPARAM lParameter) { 43 | //code copied from https://docs.microsoft.com/en-us/windows/win32/opengl/the-program-ported-to-win32 44 | LONG lRet = 1; 45 | PAINTSTRUCT ps; 46 | RECT rect; 47 | 48 | if (message == WM_CREATE) { 49 | LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParameter; 50 | GameSystem * pGameSystem = (GameSystem*)pcs->lpCreateParams; 51 | SetWindowLongPtrW(windowHandle, GWLP_USERDATA, reinterpret_cast(pGameSystem)); 52 | return 1; 53 | } 54 | 55 | GameSystem * pGameSystem = reinterpret_cast(static_cast(GetWindowLongPtrW(windowHandle, GWLP_USERDATA))); 56 | 57 | switch (message) { 58 | case WM_DESTROY: 59 | pGameSystem->isRunning = false; 60 | return 1; 61 | case WM_KEYDOWN: pGameSystem->addEventToQueue(Key, static_cast(wParameter), sys::DOWN, 0); break; 62 | case WM_KEYUP: pGameSystem->addEventToQueue(Key, static_cast(wParameter), sys::UP , 0); break; 63 | 64 | case WM_PAINT: 65 | BeginPaint(pGameSystem->getWindowHandle(), &ps); 66 | EndPaint(pGameSystem->getWindowHandle(), &ps); 67 | break; 68 | } 69 | 70 | return DefWindowProc(windowHandle, message, wParameter, lParameter); //default behavior 71 | } 72 | } -------------------------------------------------------------------------------- /deps/imgui_sdl/README.md: -------------------------------------------------------------------------------- 1 | # imgui_sdl 2 | 3 | ImGuiSDL is a lightweight SDL2 based renderer for [Dear ImGui](https://github.com/ocornut/imgui). Dear ImGui is designed to be easily rendered using modern 3D renderers like OpenGL or DirectX, but while SDL2's renderer does use hardware acceleration (the beforementioned APIs) behind the scenes, it does not provide an interface to pass generic vertex data to OpenGL. ImGuiSDL implements the rendering using a combination of a software based triangle rasterizer and a simple textured/filled rectangle drawer from SDL2. To improve the performance, the slower triangle blits are cached into render textures. 4 | 5 | ImGuiSDL consists of two files that you can simply add to your project to use ImGuiSDL: 6 | 7 | * imgui_sdl.h 8 | * imgui_sdl.cpp 9 | 10 | ## Usage 11 | 12 | There is a full usage example provided in example.cpp, and the public API is exposed and documented in imgui_sdl.h. 13 | 14 | Here's how you initialize ImGuiSDL: 15 | ```cpp 16 | // Create your SDL renderer or use an existing one. 17 | SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); 18 | // Initialize ImGuiSDL by calling Initialize with your SDL_Renderer, and with window size. This will also take care of setting up the ImGui viewport. 19 | ImGuiSDL::Initialize(renderer, 800, 600); 20 | ``` 21 | 22 | Then to render ImGui, call `ImGuiSDL::Render` after calling `ImGui::Render`. You probably want to do this after all other rendering that happens in your project: 23 | 24 | ```cpp 25 | ImGuiSDL::Render(ImGui::GetDrawData()); 26 | ``` 27 | 28 | To cleanup at exit, you can call `ImGuiSDL::Deinitialize`, but that doesn't do anything critical, so if you don't care about cleaning up memory at application exit, you don't need to call this. 29 | 30 | ## Render Result 31 | 32 | ![Render Result](https://i.imgur.com/UzUsUO2.png) 33 | 34 | As you can see the results are not perfect, but this display is definitely good enough to be used as a debug UI which is the main use case for Dear ImGui anyways. The rendering is also done in a little bit simpler style than what Dear ImGui uses by default, mainly to increase the amount of rendering that can be done using rectangles. 35 | 36 | ## Requirements 37 | 38 | The implementation doesn't rely on any non-standard SDL functionality, imgui_sdl.cpp simply includes SDL.h and imgui.h. You can easily change these two includes to point to the correct locations if you use some sort of other include file scheme. 39 | 40 | ## Notes 41 | 42 | Do note that this is just a renderer for SDL2. For input handling, you shoud use the [great SDL2 implementation](https://github.com/ocornut/imgui/blob/master/examples/imgui_impl_sdl.cpp) provided in the Dear ImGui repository, or you could of course roll your own event provider. 43 | 44 | ## Links 45 | 46 | * [SDL2](https://www.libsdl.org/) 47 | * [Dear Imgui](https://github.com/ocornut/imgui) -------------------------------------------------------------------------------- /web-client/style.css: -------------------------------------------------------------------------------- 1 | .js-loading *, 2 | .js-loading *:before, 3 | .js-loading *:after { 4 | animation-play-state: paused !important; 5 | } 6 | 7 | @keyframes cool-spin-in-left { 8 | 0% { 9 | transform: translate(0, 20rem) perspective(1000px) rotateY(90deg); 10 | opacity: 0.0; 11 | } 12 | 100% { 13 | transform: translate(0, 0) perspective(1000px) rotateY(0deg); 14 | opacity: 1; 15 | } 16 | } 17 | 18 | @keyframes cool-spin-in-right { 19 | 0% { 20 | transform: translate(0, 10rem) perspective(1000px) rotateY(-90deg); 21 | opacity: 0.0; 22 | } 23 | 100% { 24 | transform: translate(0, 0) perspective(1000px) rotateY(0deg); 25 | opacity: 1; 26 | } 27 | } 28 | 29 | .white-to-red { 30 | animation: selector 25s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95); 31 | filter: brightness(0.5) sepia(1) saturate(10000%); 32 | } 33 | 34 | .show-on-hover { 35 | opacity: 0.0; 36 | animation-fill-mode: none; 37 | transition: 0.2s linear; 38 | visibility: hidden; 39 | } 40 | .show-on-hover-hovering { /*javascript will set this*/ 41 | opacity: 1; 42 | transition: 0.s linear; 43 | visibility: visible; 44 | } 45 | 46 | .selectable { 47 | transition: 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); 48 | transform: translateZ(0); 49 | } 50 | .selectable:hover, .selectable:focus { 51 | transform: perspective(1000px) translateZ(10ch); 52 | cursor: pointer; 53 | } 54 | .selectable:focus { outline: none; } 55 | .selectable:active, .selectable.js-active { 56 | transform: perspective(1000px) translateZ(-1ch); 57 | transition-duration: 0.1s; 58 | } 59 | 60 | body { 61 | font-family: 'Open Sans', sans-serif; 62 | color: white; 63 | } 64 | 65 | h1, h2, h3, h4, h5, h6 { 66 | font-family: 'Finger Paint', cursive; 67 | } 68 | 69 | h1 { 70 | font-size: 2.5em; 71 | transform: perspective(500px) rotateY(10deg); 72 | text-align: center; 73 | transform-origin: center; 74 | } 75 | 76 | h1:nth-child(even) { 77 | transform: perspective(500px) rotateY(-10deg); 78 | } 79 | 80 | .header-bar { 81 | display: flex; 82 | max-height: 5em; 83 | width: calc(100% - 2em); 84 | height: 100%; 85 | margin: 0 auto; 86 | margin-top: 0.5em; 87 | } 88 | 89 | .header-bar h1 { 90 | font-size: calc(2.5em * 0.61803); 91 | margin: 1em; 92 | transform: perspective(100px) rotateY(0deg); 93 | } 94 | 95 | main { 96 | max-width: 37em; 97 | margin: 0 auto; 98 | padding-left: 1em; 99 | padding-right: 1em; 100 | } 101 | 102 | .loading-bar { 103 | width: 0%; 104 | max-width: 100%; 105 | background-color: white; 106 | text-align: center; 107 | color: black; 108 | margin: 0 auto; 109 | z-index: 100; 110 | } -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/heavy2.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class Heavy2 : public Test 26 | { 27 | public: 28 | 29 | Heavy2() 30 | { 31 | { 32 | b2BodyDef bd; 33 | b2Body* ground = m_world->CreateBody(&bd); 34 | 35 | b2EdgeShape shape; 36 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 37 | ground->CreateFixture(&shape, 0.0f); 38 | } 39 | 40 | b2BodyDef bd; 41 | bd.type = b2_dynamicBody; 42 | bd.position.Set(0.0f, 2.5f); 43 | b2Body* body = m_world->CreateBody(&bd); 44 | 45 | b2CircleShape shape; 46 | shape.m_radius = 0.5f; 47 | body->CreateFixture(&shape, 10.0f); 48 | 49 | bd.position.Set(0.0f, 3.5f); 50 | body = m_world->CreateBody(&bd); 51 | body->CreateFixture(&shape, 10.0f); 52 | 53 | m_heavy = NULL; 54 | } 55 | 56 | void ToggleHeavy() 57 | { 58 | if (m_heavy) 59 | { 60 | m_world->DestroyBody(m_heavy); 61 | m_heavy = NULL; 62 | } 63 | else 64 | { 65 | b2BodyDef bd; 66 | bd.type = b2_dynamicBody; 67 | bd.position.Set(0.0f, 9.0f); 68 | m_heavy = m_world->CreateBody(&bd); 69 | 70 | b2CircleShape shape; 71 | shape.m_radius = 5.0f; 72 | m_heavy->CreateFixture(&shape, 10.0f); 73 | } 74 | } 75 | 76 | void Keyboard(int key) override 77 | { 78 | switch (key) 79 | { 80 | case GLFW_KEY_H: 81 | ToggleHeavy(); 82 | break; 83 | } 84 | } 85 | 86 | static Test* Create() 87 | { 88 | return new Heavy2; 89 | } 90 | 91 | b2Body* m_heavy; 92 | }; 93 | 94 | static int testIndex = RegisterTest("Solver", "Heavy 2", Heavy2::Create); 95 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_island.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_ISLAND_H 24 | #define B2_ISLAND_H 25 | 26 | #include "box2d/b2_body.h" 27 | #include "box2d/b2_math.h" 28 | #include "box2d/b2_time_step.h" 29 | 30 | class b2Contact; 31 | class b2Joint; 32 | class b2StackAllocator; 33 | class b2ContactListener; 34 | struct b2ContactVelocityConstraint; 35 | struct b2Profile; 36 | 37 | /// This is an internal class. 38 | class b2Island 39 | { 40 | public: 41 | b2Island(int32 bodyCapacity, int32 contactCapacity, int32 jointCapacity, 42 | b2StackAllocator* allocator, b2ContactListener* listener); 43 | ~b2Island(); 44 | 45 | void Clear() 46 | { 47 | m_bodyCount = 0; 48 | m_contactCount = 0; 49 | m_jointCount = 0; 50 | } 51 | 52 | void Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep); 53 | 54 | void SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB); 55 | 56 | void Add(b2Body* body) 57 | { 58 | b2Assert(m_bodyCount < m_bodyCapacity); 59 | body->m_islandIndex = m_bodyCount; 60 | m_bodies[m_bodyCount] = body; 61 | ++m_bodyCount; 62 | } 63 | 64 | void Add(b2Contact* contact) 65 | { 66 | b2Assert(m_contactCount < m_contactCapacity); 67 | m_contacts[m_contactCount++] = contact; 68 | } 69 | 70 | void Add(b2Joint* joint) 71 | { 72 | b2Assert(m_jointCount < m_jointCapacity); 73 | m_joints[m_jointCount++] = joint; 74 | } 75 | 76 | void Report(const b2ContactVelocityConstraint* constraints); 77 | 78 | b2StackAllocator* m_allocator; 79 | b2ContactListener* m_listener; 80 | 81 | b2Body** m_bodies; 82 | b2Contact** m_contacts; 83 | b2Joint** m_joints; 84 | 85 | b2Position* m_positions; 86 | b2Velocity* m_velocities; 87 | 88 | int32 m_bodyCount; 89 | int32 m_jointCount; 90 | int32 m_contactCount; 91 | 92 | int32 m_bodyCapacity; 93 | int32 m_contactCapacity; 94 | int32 m_jointCapacity; 95 | }; 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /deps/box2d/extern/glfw/src/posix_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.3 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2016 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerPOSIX(void) 41 | { 42 | #if defined(CLOCK_MONOTONIC) 43 | struct timespec ts; 44 | 45 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 46 | { 47 | _glfw.timer.posix.monotonic = GLFW_TRUE; 48 | _glfw.timer.posix.frequency = 1000000000; 49 | } 50 | else 51 | #endif 52 | { 53 | _glfw.timer.posix.monotonic = GLFW_FALSE; 54 | _glfw.timer.posix.frequency = 1000000; 55 | } 56 | } 57 | 58 | 59 | ////////////////////////////////////////////////////////////////////////// 60 | ////// GLFW platform API ////// 61 | ////////////////////////////////////////////////////////////////////////// 62 | 63 | uint64_t _glfwPlatformGetTimerValue(void) 64 | { 65 | #if defined(CLOCK_MONOTONIC) 66 | if (_glfw.timer.posix.monotonic) 67 | { 68 | struct timespec ts; 69 | clock_gettime(CLOCK_MONOTONIC, &ts); 70 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 71 | } 72 | else 73 | #endif 74 | { 75 | struct timeval tv; 76 | gettimeofday(&tv, NULL); 77 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 78 | } 79 | } 80 | 81 | uint64_t _glfwPlatformGetTimerFrequency(void) 82 | { 83 | return _glfw.timer.posix.frequency; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/conveyor_belt.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class ConveyorBelt : public Test 26 | { 27 | public: 28 | 29 | ConveyorBelt() 30 | { 31 | // Ground 32 | { 33 | b2BodyDef bd; 34 | b2Body* ground = m_world->CreateBody(&bd); 35 | 36 | b2EdgeShape shape; 37 | shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f)); 38 | ground->CreateFixture(&shape, 0.0f); 39 | } 40 | 41 | // Platform 42 | { 43 | b2BodyDef bd; 44 | bd.position.Set(-5.0f, 5.0f); 45 | b2Body* body = m_world->CreateBody(&bd); 46 | 47 | b2PolygonShape shape; 48 | shape.SetAsBox(10.0f, 0.5f); 49 | 50 | b2FixtureDef fd; 51 | fd.shape = &shape; 52 | fd.friction = 0.8f; 53 | m_platform = body->CreateFixture(&fd); 54 | } 55 | 56 | // Boxes 57 | for (int32 i = 0; i < 5; ++i) 58 | { 59 | b2BodyDef bd; 60 | bd.type = b2_dynamicBody; 61 | bd.position.Set(-10.0f + 2.0f * i, 7.0f); 62 | b2Body* body = m_world->CreateBody(&bd); 63 | 64 | b2PolygonShape shape; 65 | shape.SetAsBox(0.5f, 0.5f); 66 | body->CreateFixture(&shape, 20.0f); 67 | } 68 | } 69 | 70 | void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override 71 | { 72 | Test::PreSolve(contact, oldManifold); 73 | 74 | b2Fixture* fixtureA = contact->GetFixtureA(); 75 | b2Fixture* fixtureB = contact->GetFixtureB(); 76 | 77 | if (fixtureA == m_platform) 78 | { 79 | contact->SetTangentSpeed(5.0f); 80 | } 81 | 82 | if (fixtureB == m_platform) 83 | { 84 | contact->SetTangentSpeed(-5.0f); 85 | } 86 | } 87 | 88 | void Step(Settings& settings) override 89 | { 90 | Test::Step(settings); 91 | } 92 | 93 | static Test* Create() 94 | { 95 | return new ConveyorBelt; 96 | } 97 | 98 | b2Fixture* m_platform; 99 | }; 100 | 101 | static int testIndex = RegisterTest("Examples", "Conveyor Belt", ConveyorBelt::Create); 102 | -------------------------------------------------------------------------------- /deps/box2d/src/dynamics/b2_contact_solver.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_CONTACT_SOLVER_H 24 | #define B2_CONTACT_SOLVER_H 25 | 26 | #include "box2d/b2_collision.h" 27 | #include "box2d/b2_math.h" 28 | #include "box2d/b2_time_step.h" 29 | 30 | class b2Contact; 31 | class b2Body; 32 | class b2StackAllocator; 33 | struct b2ContactPositionConstraint; 34 | 35 | struct b2VelocityConstraintPoint 36 | { 37 | b2Vec2 rA; 38 | b2Vec2 rB; 39 | float normalImpulse; 40 | float tangentImpulse; 41 | float normalMass; 42 | float tangentMass; 43 | float velocityBias; 44 | }; 45 | 46 | struct b2ContactVelocityConstraint 47 | { 48 | b2VelocityConstraintPoint points[b2_maxManifoldPoints]; 49 | b2Vec2 normal; 50 | b2Mat22 normalMass; 51 | b2Mat22 K; 52 | int32 indexA; 53 | int32 indexB; 54 | float invMassA, invMassB; 55 | float invIA, invIB; 56 | float friction; 57 | float restitution; 58 | float threshold; 59 | float tangentSpeed; 60 | int32 pointCount; 61 | int32 contactIndex; 62 | }; 63 | 64 | struct b2ContactSolverDef 65 | { 66 | b2TimeStep step; 67 | b2Contact** contacts; 68 | int32 count; 69 | b2Position* positions; 70 | b2Velocity* velocities; 71 | b2StackAllocator* allocator; 72 | }; 73 | 74 | class b2ContactSolver 75 | { 76 | public: 77 | b2ContactSolver(b2ContactSolverDef* def); 78 | ~b2ContactSolver(); 79 | 80 | void InitializeVelocityConstraints(); 81 | 82 | void WarmStart(); 83 | void SolveVelocityConstraints(); 84 | void StoreImpulses(); 85 | 86 | bool SolvePositionConstraints(); 87 | bool SolveTOIPositionConstraints(int32 toiIndexA, int32 toiIndexB); 88 | 89 | b2TimeStep m_step; 90 | b2Position* m_positions; 91 | b2Velocity* m_velocities; 92 | b2StackAllocator* m_allocator; 93 | b2ContactPositionConstraint* m_positionConstraints; 94 | b2ContactVelocityConstraint* m_velocityConstraints; 95 | b2Contact** m_contacts; 96 | int m_count; 97 | }; 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/pulley_joint.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class PulleyJoint : public Test 26 | { 27 | public: 28 | PulleyJoint() 29 | { 30 | float y = 16.0f; 31 | float L = 12.0f; 32 | float a = 1.0f; 33 | float b = 2.0f; 34 | 35 | b2Body* ground = NULL; 36 | { 37 | b2BodyDef bd; 38 | ground = m_world->CreateBody(&bd); 39 | 40 | b2CircleShape circle; 41 | circle.m_radius = 2.0f; 42 | 43 | circle.m_p.Set(-10.0f, y + b + L); 44 | ground->CreateFixture(&circle, 0.0f); 45 | 46 | circle.m_p.Set(10.0f, y + b + L); 47 | ground->CreateFixture(&circle, 0.0f); 48 | } 49 | 50 | { 51 | 52 | b2PolygonShape shape; 53 | shape.SetAsBox(a, b); 54 | 55 | b2BodyDef bd; 56 | bd.type = b2_dynamicBody; 57 | 58 | //bd.fixedRotation = true; 59 | bd.position.Set(-10.0f, y); 60 | b2Body* body1 = m_world->CreateBody(&bd); 61 | body1->CreateFixture(&shape, 5.0f); 62 | 63 | bd.position.Set(10.0f, y); 64 | b2Body* body2 = m_world->CreateBody(&bd); 65 | body2->CreateFixture(&shape, 5.0f); 66 | 67 | b2PulleyJointDef pulleyDef; 68 | b2Vec2 anchor1(-10.0f, y + b); 69 | b2Vec2 anchor2(10.0f, y + b); 70 | b2Vec2 groundAnchor1(-10.0f, y + b + L); 71 | b2Vec2 groundAnchor2(10.0f, y + b + L); 72 | pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 1.5f); 73 | 74 | m_joint1 = (b2PulleyJoint*)m_world->CreateJoint(&pulleyDef); 75 | } 76 | } 77 | 78 | void Step(Settings& settings) override 79 | { 80 | Test::Step(settings); 81 | 82 | float ratio = m_joint1->GetRatio(); 83 | float L = m_joint1->GetCurrentLengthA() + ratio * m_joint1->GetCurrentLengthB(); 84 | g_debugDraw.DrawString(5, m_textLine, "L1 + %4.2f * L2 = %4.2f", (float) ratio, (float) L); 85 | m_textLine += m_textIncrement; 86 | } 87 | 88 | static Test* Create() 89 | { 90 | return new PulleyJoint; 91 | } 92 | 93 | b2PulleyJoint* m_joint1; 94 | }; 95 | 96 | static int testIndex = RegisterTest("Joints", "Pulley", PulleyJoint::Create); 97 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/dump_loader.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | // This test holds worlds dumped using b2World::Dump. 26 | class DumpLoader : public Test 27 | { 28 | public: 29 | 30 | DumpLoader() 31 | { 32 | b2ChainShape chainShape; 33 | b2Vec2 vertices[] = {b2Vec2(-5,0), b2Vec2(5,0), b2Vec2(5,5), b2Vec2(4,1), b2Vec2(-4,1), b2Vec2(-5,5)}; 34 | chainShape.CreateLoop(vertices, 6); 35 | 36 | b2FixtureDef groundFixtureDef; 37 | groundFixtureDef.density = 0; 38 | groundFixtureDef.shape = &chainShape; 39 | 40 | b2BodyDef groundBodyDef; 41 | groundBodyDef.type = b2_staticBody; 42 | 43 | b2Body *groundBody = m_world->CreateBody(&groundBodyDef); 44 | b2Fixture *groundBodyFixture = groundBody->CreateFixture(&groundFixtureDef); 45 | 46 | b2CircleShape ballShape; 47 | ballShape.m_radius = 1; 48 | 49 | b2FixtureDef ballFixtureDef; 50 | ballFixtureDef.restitution = 0.75f; 51 | ballFixtureDef.density = 1; 52 | ballFixtureDef.shape = &ballShape; 53 | 54 | b2BodyDef ballBodyDef; 55 | ballBodyDef.type = b2BodyType::b2_dynamicBody; 56 | ballBodyDef.position = b2Vec2(0, 10); 57 | // ballBodyDef.angularDamping = 0.2f; 58 | 59 | m_ball = m_world->CreateBody(&ballBodyDef); 60 | b2Fixture *ballFixture = m_ball->CreateFixture(&ballFixtureDef); 61 | m_ball->ApplyForceToCenter(b2Vec2(-1000, -400), true); 62 | } 63 | 64 | void Step(Settings& settings) override 65 | { 66 | b2Vec2 v = m_ball->GetLinearVelocity(); 67 | float omega = m_ball->GetAngularVelocity(); 68 | 69 | b2MassData massData; 70 | m_ball->GetMassData(&massData); 71 | 72 | float ke = 0.5f * massData.mass * b2Dot(v, v) + 0.5f * massData.I * omega * omega; 73 | 74 | g_debugDraw.DrawString(5, m_textLine, "kinetic energy = %.6f", ke); 75 | m_textLine += m_textIncrement; 76 | 77 | Test::Step(settings); 78 | } 79 | 80 | static Test* Create() 81 | { 82 | return new DumpLoader; 83 | } 84 | 85 | b2Body* m_ball; 86 | }; 87 | 88 | static int testIndex = RegisterTest("Bugs", "Dump Loader", DumpLoader::Create); 89 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/tumbler.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class Tumbler : public Test 26 | { 27 | public: 28 | 29 | enum 30 | { 31 | e_count = 800 32 | }; 33 | 34 | Tumbler() 35 | { 36 | b2Body* ground = NULL; 37 | { 38 | b2BodyDef bd; 39 | ground = m_world->CreateBody(&bd); 40 | } 41 | 42 | { 43 | b2BodyDef bd; 44 | bd.type = b2_dynamicBody; 45 | bd.allowSleep = false; 46 | bd.position.Set(0.0f, 10.0f); 47 | b2Body* body = m_world->CreateBody(&bd); 48 | 49 | b2PolygonShape shape; 50 | shape.SetAsBox(0.5f, 10.0f, b2Vec2( 10.0f, 0.0f), 0.0); 51 | body->CreateFixture(&shape, 5.0f); 52 | shape.SetAsBox(0.5f, 10.0f, b2Vec2(-10.0f, 0.0f), 0.0); 53 | body->CreateFixture(&shape, 5.0f); 54 | shape.SetAsBox(10.0f, 0.5f, b2Vec2(0.0f, 10.0f), 0.0); 55 | body->CreateFixture(&shape, 5.0f); 56 | shape.SetAsBox(10.0f, 0.5f, b2Vec2(0.0f, -10.0f), 0.0); 57 | body->CreateFixture(&shape, 5.0f); 58 | 59 | b2RevoluteJointDef jd; 60 | jd.bodyA = ground; 61 | jd.bodyB = body; 62 | jd.localAnchorA.Set(0.0f, 10.0f); 63 | jd.localAnchorB.Set(0.0f, 0.0f); 64 | jd.referenceAngle = 0.0f; 65 | jd.motorSpeed = 0.05f * b2_pi; 66 | jd.maxMotorTorque = 1e8f; 67 | jd.enableMotor = true; 68 | m_joint = (b2RevoluteJoint*)m_world->CreateJoint(&jd); 69 | } 70 | 71 | m_count = 0; 72 | } 73 | 74 | void Step(Settings& settings) override 75 | { 76 | Test::Step(settings); 77 | 78 | if (m_count < e_count) 79 | { 80 | b2BodyDef bd; 81 | bd.type = b2_dynamicBody; 82 | bd.position.Set(0.0f, 10.0f); 83 | b2Body* body = m_world->CreateBody(&bd); 84 | 85 | b2PolygonShape shape; 86 | shape.SetAsBox(0.125f, 0.125f); 87 | body->CreateFixture(&shape, 1.0f); 88 | 89 | ++m_count; 90 | } 91 | } 92 | 93 | static Test* Create() 94 | { 95 | return new Tumbler; 96 | } 97 | 98 | b2RevoluteJoint* m_joint; 99 | int32 m_count; 100 | }; 101 | 102 | static int testIndex = RegisterTest("Benchmark", "Tumbler", Tumbler::Create); 103 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/convex_hull.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class ConvexHull : public Test 26 | { 27 | public: 28 | enum 29 | { 30 | e_count = b2_maxPolygonVertices 31 | }; 32 | 33 | ConvexHull() 34 | { 35 | Generate(); 36 | m_auto = false; 37 | } 38 | 39 | void Generate() 40 | { 41 | b2Vec2 lowerBound(-8.0f, -8.0f); 42 | b2Vec2 upperBound(8.0f, 8.0f); 43 | 44 | for (int32 i = 0; i < e_count; ++i) 45 | { 46 | float x = 10.0f * RandomFloat(); 47 | float y = 10.0f * RandomFloat(); 48 | 49 | // Clamp onto a square to help create collinearities. 50 | // This will stress the convex hull algorithm. 51 | b2Vec2 v(x, y); 52 | v = b2Clamp(v, lowerBound, upperBound); 53 | m_points[i] = v; 54 | } 55 | 56 | m_count = e_count; 57 | } 58 | 59 | void Keyboard(int key) override 60 | { 61 | switch (key) 62 | { 63 | case GLFW_KEY_A: 64 | m_auto = !m_auto; 65 | break; 66 | 67 | case GLFW_KEY_G: 68 | Generate(); 69 | break; 70 | } 71 | } 72 | 73 | void Step(Settings& settings) override 74 | { 75 | Test::Step(settings); 76 | 77 | b2PolygonShape shape; 78 | shape.Set(m_points, m_count); 79 | 80 | g_debugDraw.DrawString(5, m_textLine, "Press g to generate a new random convex hull"); 81 | m_textLine += m_textIncrement; 82 | 83 | g_debugDraw.DrawPolygon(shape.m_vertices, shape.m_count, b2Color(0.9f, 0.9f, 0.9f)); 84 | 85 | for (int32 i = 0; i < m_count; ++i) 86 | { 87 | g_debugDraw.DrawPoint(m_points[i], 3.0f, b2Color(0.3f, 0.9f, 0.3f)); 88 | g_debugDraw.DrawString(m_points[i] + b2Vec2(0.05f, 0.05f), "%d", i); 89 | } 90 | 91 | if (shape.Validate() == false) 92 | { 93 | m_textLine += 0; 94 | } 95 | 96 | if (m_auto) 97 | { 98 | Generate(); 99 | } 100 | } 101 | 102 | static Test* Create() 103 | { 104 | return new ConvexHull; 105 | } 106 | 107 | b2Vec2 m_points[b2_maxPolygonVertices]; 108 | int32 m_count; 109 | bool m_auto; 110 | }; 111 | 112 | static int testIndex = RegisterTest("Geometry", "Convex Hull", ConvexHull::Create); 113 | -------------------------------------------------------------------------------- /deps/box2d/src/common/b2_math.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "box2d/b2_math.h" 24 | 25 | const b2Vec2 b2Vec2_zero(0.0f, 0.0f); 26 | 27 | /// Solve A * x = b, where b is a column vector. This is more efficient 28 | /// than computing the inverse in one-shot cases. 29 | b2Vec3 b2Mat33::Solve33(const b2Vec3& b) const 30 | { 31 | float det = b2Dot(ex, b2Cross(ey, ez)); 32 | if (det != 0.0f) 33 | { 34 | det = 1.0f / det; 35 | } 36 | b2Vec3 x; 37 | x.x = det * b2Dot(b, b2Cross(ey, ez)); 38 | x.y = det * b2Dot(ex, b2Cross(b, ez)); 39 | x.z = det * b2Dot(ex, b2Cross(ey, b)); 40 | return x; 41 | } 42 | 43 | /// Solve A * x = b, where b is a column vector. This is more efficient 44 | /// than computing the inverse in one-shot cases. 45 | b2Vec2 b2Mat33::Solve22(const b2Vec2& b) const 46 | { 47 | float a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y; 48 | float det = a11 * a22 - a12 * a21; 49 | if (det != 0.0f) 50 | { 51 | det = 1.0f / det; 52 | } 53 | b2Vec2 x; 54 | x.x = det * (a22 * b.x - a12 * b.y); 55 | x.y = det * (a11 * b.y - a21 * b.x); 56 | return x; 57 | } 58 | 59 | /// 60 | void b2Mat33::GetInverse22(b2Mat33* M) const 61 | { 62 | float a = ex.x, b = ey.x, c = ex.y, d = ey.y; 63 | float det = a * d - b * c; 64 | if (det != 0.0f) 65 | { 66 | det = 1.0f / det; 67 | } 68 | 69 | M->ex.x = det * d; M->ey.x = -det * b; M->ex.z = 0.0f; 70 | M->ex.y = -det * c; M->ey.y = det * a; M->ey.z = 0.0f; 71 | M->ez.x = 0.0f; M->ez.y = 0.0f; M->ez.z = 0.0f; 72 | } 73 | 74 | /// Returns the zero matrix if singular. 75 | void b2Mat33::GetSymInverse33(b2Mat33* M) const 76 | { 77 | float det = b2Dot(ex, b2Cross(ey, ez)); 78 | if (det != 0.0f) 79 | { 80 | det = 1.0f / det; 81 | } 82 | 83 | float a11 = ex.x, a12 = ey.x, a13 = ez.x; 84 | float a22 = ey.y, a23 = ez.y; 85 | float a33 = ez.z; 86 | 87 | M->ex.x = det * (a22 * a33 - a23 * a23); 88 | M->ex.y = det * (a13 * a23 - a12 * a33); 89 | M->ex.z = det * (a12 * a23 - a13 * a22); 90 | 91 | M->ey.x = M->ex.y; 92 | M->ey.y = det * (a11 * a33 - a13 * a13); 93 | M->ey.z = det * (a13 * a12 - a11 * a23); 94 | 95 | M->ez.x = M->ex.z; 96 | M->ez.y = M->ey.z; 97 | M->ez.z = det * (a11 * a22 - a12 * a12); 98 | } 99 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/mobile_unbalanced.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class MobileUnbalanced : public Test 26 | { 27 | public: 28 | 29 | enum 30 | { 31 | e_depth = 4 32 | }; 33 | 34 | MobileUnbalanced() 35 | { 36 | b2Body* ground; 37 | 38 | // Create ground body. 39 | { 40 | b2BodyDef bodyDef; 41 | bodyDef.position.Set(0.0f, 20.0f); 42 | ground = m_world->CreateBody(&bodyDef); 43 | } 44 | 45 | float a = 0.5f; 46 | b2Vec2 h(0.0f, a); 47 | 48 | b2Body* root = AddNode(ground, b2Vec2_zero, 0, 3.0f, a); 49 | 50 | b2RevoluteJointDef jointDef; 51 | jointDef.bodyA = ground; 52 | jointDef.bodyB = root; 53 | jointDef.localAnchorA.SetZero(); 54 | jointDef.localAnchorB = h; 55 | m_world->CreateJoint(&jointDef); 56 | } 57 | 58 | b2Body* AddNode(b2Body* parent, const b2Vec2& localAnchor, int32 depth, float offset, float a) 59 | { 60 | float density = 20.0f; 61 | b2Vec2 h(0.0f, a); 62 | 63 | b2Vec2 p = parent->GetPosition() + localAnchor - h; 64 | 65 | b2BodyDef bodyDef; 66 | bodyDef.type = b2_dynamicBody; 67 | bodyDef.position = p; 68 | b2Body* body = m_world->CreateBody(&bodyDef); 69 | 70 | b2PolygonShape shape; 71 | shape.SetAsBox(0.25f * a, a); 72 | body->CreateFixture(&shape, density); 73 | 74 | if (depth == e_depth) 75 | { 76 | return body; 77 | } 78 | 79 | b2Vec2 a1 = b2Vec2(offset, -a); 80 | b2Vec2 a2 = b2Vec2(-offset, -a); 81 | b2Body* body1 = AddNode(body, a1, depth + 1, 0.5f * offset, a); 82 | b2Body* body2 = AddNode(body, a2, depth + 1, 0.5f * offset, a); 83 | 84 | b2RevoluteJointDef jointDef; 85 | jointDef.bodyA = body; 86 | jointDef.localAnchorB = h; 87 | 88 | jointDef.localAnchorA = a1; 89 | jointDef.bodyB = body1; 90 | m_world->CreateJoint(&jointDef); 91 | 92 | jointDef.localAnchorA = a2; 93 | jointDef.bodyB = body2; 94 | m_world->CreateJoint(&jointDef); 95 | 96 | return body; 97 | } 98 | 99 | static Test* Create() 100 | { 101 | return new MobileUnbalanced; 102 | } 103 | }; 104 | 105 | static int testIndex = RegisterTest("Solver", "Mobile Unbalanced", MobileUnbalanced::Create); 106 | -------------------------------------------------------------------------------- /deps/box2d/testbed/tests/shape_editing.cpp: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #include "test.h" 24 | 25 | class ShapeEditing : public Test 26 | { 27 | public: 28 | 29 | ShapeEditing() 30 | { 31 | { 32 | b2BodyDef bd; 33 | b2Body* ground = m_world->CreateBody(&bd); 34 | 35 | b2EdgeShape shape; 36 | shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 37 | ground->CreateFixture(&shape, 0.0f); 38 | } 39 | 40 | b2BodyDef bd; 41 | bd.type = b2_dynamicBody; 42 | bd.position.Set(0.0f, 10.0f); 43 | m_body = m_world->CreateBody(&bd); 44 | 45 | b2PolygonShape shape; 46 | shape.SetAsBox(4.0f, 4.0f, b2Vec2(0.0f, 0.0f), 0.0f); 47 | m_fixture1 = m_body->CreateFixture(&shape, 10.0f); 48 | 49 | m_fixture2 = NULL; 50 | 51 | m_sensor = false; 52 | } 53 | 54 | void Keyboard(int key) override 55 | { 56 | switch (key) 57 | { 58 | case GLFW_KEY_C: 59 | if (m_fixture2 == NULL) 60 | { 61 | b2CircleShape shape; 62 | shape.m_radius = 3.0f; 63 | shape.m_p.Set(0.5f, -4.0f); 64 | m_fixture2 = m_body->CreateFixture(&shape, 10.0f); 65 | m_body->SetAwake(true); 66 | } 67 | break; 68 | 69 | case GLFW_KEY_D: 70 | if (m_fixture2 != NULL) 71 | { 72 | m_body->DestroyFixture(m_fixture2); 73 | m_fixture2 = NULL; 74 | m_body->SetAwake(true); 75 | } 76 | break; 77 | 78 | case GLFW_KEY_S: 79 | if (m_fixture2 != NULL) 80 | { 81 | m_sensor = !m_sensor; 82 | m_fixture2->SetSensor(m_sensor); 83 | } 84 | break; 85 | } 86 | } 87 | 88 | void Step(Settings& settings) override 89 | { 90 | Test::Step(settings); 91 | g_debugDraw.DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape."); 92 | m_textLine += m_textIncrement; 93 | g_debugDraw.DrawString(5, m_textLine, "sensor = %d", m_sensor); 94 | m_textLine += m_textIncrement; 95 | } 96 | 97 | static Test* Create() 98 | { 99 | return new ShapeEditing; 100 | } 101 | 102 | b2Body* m_body; 103 | b2Fixture* m_fixture1; 104 | b2Fixture* m_fixture2; 105 | bool m_sensor; 106 | }; 107 | 108 | static int testIndex = RegisterTest("Examples", "Shape Editing", ShapeEditing::Create); 109 | -------------------------------------------------------------------------------- /deps/box2d/testbed/draw.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef DRAW_H 24 | #define DRAW_H 25 | 26 | #define GLFW_INCLUDE_NONE 27 | #include "glad/gl.h" 28 | #include "GLFW/glfw3.h" 29 | 30 | #include "box2d/box2d.h" 31 | 32 | struct b2AABB; 33 | struct GLRenderPoints; 34 | struct GLRenderLines; 35 | struct GLRenderTriangles; 36 | struct GLFWwindow; 37 | 38 | // 39 | struct Camera 40 | { 41 | Camera() 42 | { 43 | m_center.Set(0.0f, 20.0f); 44 | m_zoom = 1.0f; 45 | m_width = 1280; 46 | m_height = 800; 47 | } 48 | 49 | b2Vec2 ConvertScreenToWorld(const b2Vec2& screenPoint); 50 | b2Vec2 ConvertWorldToScreen(const b2Vec2& worldPoint); 51 | void BuildProjectionMatrix(float* m, float zBias); 52 | 53 | b2Vec2 m_center; 54 | float m_zoom; 55 | int32 m_width; 56 | int32 m_height; 57 | }; 58 | 59 | // This class implements debug drawing callbacks that are invoked 60 | // inside b2World::Step. 61 | class DebugDraw : public b2Draw 62 | { 63 | public: 64 | DebugDraw(); 65 | ~DebugDraw(); 66 | 67 | void Create(); 68 | void Destroy(); 69 | 70 | void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) override; 71 | 72 | void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) override; 73 | 74 | void DrawCircle(const b2Vec2& center, float radius, const b2Color& color) override; 75 | 76 | void DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color) override; 77 | 78 | void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) override; 79 | 80 | void DrawTransform(const b2Transform& xf) override; 81 | 82 | void DrawPoint(const b2Vec2& p, float size, const b2Color& color) override; 83 | 84 | void DrawString(int x, int y, const char* string, ...); 85 | 86 | void DrawString(const b2Vec2& p, const char* string, ...); 87 | 88 | void DrawAABB(b2AABB* aabb, const b2Color& color); 89 | 90 | void Flush(); 91 | 92 | bool m_showUI; 93 | GLRenderPoints* m_points; 94 | GLRenderLines* m_lines; 95 | GLRenderTriangles* m_triangles; 96 | }; 97 | 98 | extern DebugDraw g_debugDraw; 99 | extern Camera g_camera; 100 | extern GLFWwindow* g_mainWindow; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /deps/box2d/include/box2d/b2_edge_shape.h: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2019 Erin Catto 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef B2_EDGE_SHAPE_H 24 | #define B2_EDGE_SHAPE_H 25 | 26 | #include "b2_api.h" 27 | #include "b2_shape.h" 28 | 29 | /// A line segment (edge) shape. These can be connected in chains or loops 30 | /// to other edge shapes. Edges created independently are two-sided and do 31 | /// no provide smooth movement across junctions. 32 | class B2_API b2EdgeShape : public b2Shape 33 | { 34 | public: 35 | b2EdgeShape(); 36 | 37 | /// Set this as a part of a sequence. Vertex v0 precedes the edge and vertex v3 38 | /// follows. These extra vertices are used to provide smooth movement 39 | /// across junctions. This also makes the collision one-sided. The edge 40 | /// normal points to the right looking from v1 to v2. 41 | void SetOneSided(const b2Vec2& v0, const b2Vec2& v1,const b2Vec2& v2, const b2Vec2& v3); 42 | 43 | /// Set this as an isolated edge. Collision is two-sided. 44 | void SetTwoSided(const b2Vec2& v1, const b2Vec2& v2); 45 | 46 | /// Implement b2Shape. 47 | b2Shape* Clone(b2BlockAllocator* allocator) const override; 48 | 49 | /// @see b2Shape::GetChildCount 50 | int32 GetChildCount() const override; 51 | 52 | /// @see b2Shape::TestPoint 53 | bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override; 54 | 55 | /// Implement b2Shape. 56 | bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, 57 | const b2Transform& transform, int32 childIndex) const override; 58 | 59 | /// @see b2Shape::ComputeAABB 60 | void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override; 61 | 62 | /// @see b2Shape::ComputeMass 63 | void ComputeMass(b2MassData* massData, float density) const override; 64 | 65 | /// These are the edge vertices 66 | b2Vec2 m_vertex1, m_vertex2; 67 | 68 | /// Optional adjacent vertices. These are used for smooth collision. 69 | b2Vec2 m_vertex0, m_vertex3; 70 | 71 | /// Uses m_vertex0 and m_vertex3 to create smooth collision. 72 | bool m_oneSided; 73 | }; 74 | 75 | inline b2EdgeShape::b2EdgeShape() 76 | { 77 | m_type = e_edge; 78 | m_radius = b2_polygonRadius; 79 | m_vertex0.x = 0.0f; 80 | m_vertex0.y = 0.0f; 81 | m_vertex3.x = 0.0f; 82 | m_vertex3.y = 0.0f; 83 | m_oneSided = false; 84 | } 85 | 86 | #endif 87 | --------------------------------------------------------------------------------