summaryrefslogtreecommitdiff
path: root/Client/ThirdParty/Box2D
diff options
context:
space:
mode:
Diffstat (limited to 'Client/ThirdParty/Box2D')
-rw-r--r--Client/ThirdParty/Box2D/.gitignore7
-rw-r--r--Client/ThirdParty/Box2D/.travis.yml32
-rw-r--r--Client/ThirdParty/Box2D/CHANGELOG.md60
-rw-r--r--Client/ThirdParty/Box2D/CMakeLists.txt65
-rw-r--r--Client/ThirdParty/Box2D/LICENSE21
-rw-r--r--Client/ThirdParty/Box2D/README.md115
-rw-r--r--Client/ThirdParty/Box2D/build.bat7
-rw-r--r--Client/ThirdParty/Box2D/build.sh8
-rw-r--r--Client/ThirdParty/Box2D/build_docs.sh8
-rw-r--r--Client/ThirdParty/Box2D/deploy_docs.sh4
-rw-r--r--Client/ThirdParty/Box2D/docs/CMakeLists.txt32
-rw-r--r--Client/ThirdParty/Box2D/docs/Doxyfile.in2578
-rw-r--r--Client/ThirdParty/Box2D/docs/FAQ.md146
-rw-r--r--Client/ThirdParty/Box2D/docs/collision.md433
-rw-r--r--Client/ThirdParty/Box2D/docs/common.md66
-rw-r--r--Client/ThirdParty/Box2D/docs/copycss.sh2
-rw-r--r--Client/ThirdParty/Box2D/docs/dynamics.md1674
-rw-r--r--Client/ThirdParty/Box2D/docs/extra.css605
-rw-r--r--Client/ThirdParty/Box2D/docs/hello.md246
-rw-r--r--Client/ThirdParty/Box2D/docs/images/body_origin.gifbin0 -> 912 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/captured_toi.svg124
-rw-r--r--Client/ThirdParty/Box2D/docs/images/chain_loop_inwards.svg310
-rw-r--r--Client/ThirdParty/Box2D/docs/images/chain_loop_outwards.svg310
-rw-r--r--Client/ThirdParty/Box2D/docs/images/chain_shape.svg198
-rw-r--r--Client/ThirdParty/Box2D/docs/images/convex_concave.gifbin0 -> 2303 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/debug_draw.pngbin0 -> 48950 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/distance.svg178
-rw-r--r--Client/ThirdParty/Box2D/docs/images/distance_joint.gifbin0 -> 2358 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/gear_joint.gifbin0 -> 2119 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/ghost_collision.svg237
-rw-r--r--Client/ThirdParty/Box2D/docs/images/ghost_vertices.svg265
-rw-r--r--Client/ThirdParty/Box2D/docs/images/logo.svg126
-rw-r--r--Client/ThirdParty/Box2D/docs/images/manifolds.svg256
-rw-r--r--Client/ThirdParty/Box2D/docs/images/missed_toi.svg153
-rw-r--r--Client/ThirdParty/Box2D/docs/images/modules.svg222
-rw-r--r--Client/ThirdParty/Box2D/docs/images/overlap_test.svg148
-rw-r--r--Client/ThirdParty/Box2D/docs/images/prismatic_joint.gifbin0 -> 2298 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/pulley_joint.gifbin0 -> 3526 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/raycast.svg151
-rw-r--r--Client/ThirdParty/Box2D/docs/images/revolute_joint.gifbin0 -> 1920 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/self_intersect.svg149
-rw-r--r--Client/ThirdParty/Box2D/docs/images/skin_collision.svg140
-rw-r--r--Client/ThirdParty/Box2D/docs/images/skinned_polygon.svg181
-rw-r--r--Client/ThirdParty/Box2D/docs/images/testbed.pngbin0 -> 42221 bytes
-rw-r--r--Client/ThirdParty/Box2D/docs/images/tunneling1.svg162
-rw-r--r--Client/ThirdParty/Box2D/docs/images/tunneling2.svg140
-rw-r--r--Client/ThirdParty/Box2D/docs/images/wheel_joint.svg193
-rw-r--r--Client/ThirdParty/Box2D/docs/images/winding.svg241
-rw-r--r--Client/ThirdParty/Box2D/docs/loose_ends.md214
-rw-r--r--Client/ThirdParty/Box2D/docs/overview.md216
-rw-r--r--Client/ThirdParty/Box2D/docs/references.md4
-rw-r--r--Client/ThirdParty/Box2D/docs/testbed.md21
-rw-r--r--Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt11
-rw-r--r--Client/ThirdParty/Box2D/extern/glad/include/KHR/khrplatform.h290
-rw-r--r--Client/ThirdParty/Box2D/extern/glad/include/glad/gl.h2114
-rw-r--r--Client/ThirdParty/Box2D/extern/glad/src/gl.c949
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt92
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3.h5556
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3native.h525
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_init.m403
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.h50
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.m462
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_monitor.m527
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_platform.h169
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_time.c60
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/cocoa_window.m1855
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/context.c758
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/egl_context.c786
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/egl_context.h215
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/glfw_config.h45
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/glx_context.c698
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/glx_context.h181
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/init.c338
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/input.c1307
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/internal.h772
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.c434
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.h62
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/mappings.h478
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/mappings.h.in73
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/monitor.c517
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.h56
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.m340
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/null_init.c50
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.c42
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.h31
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/null_monitor.c69
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/null_platform.h62
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/null_window.c321
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.c370
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.h94
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.c103
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.h51
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/posix_time.c85
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/posix_time.h44
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/vulkan.c326
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.c732
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.h159
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_init.c627
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.c753
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.h56
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_monitor.c515
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_platform.h449
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_thread.c97
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_time.c74
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/win32_window.c2205
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/window.c1113
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/wl_init.c1318
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/wl_monitor.c208
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/wl_platform.h359
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/wl_window.c1857
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/x11_init.c1096
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/x11_monitor.c517
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/x11_platform.h444
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/x11_window.c3066
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.c940
-rw-r--r--Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.h28
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt19
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imconfig.h73
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imgui.cpp9349
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imgui.h2130
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imgui_demo.cpp4211
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imgui_draw.cpp3199
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imgui_internal.h1466
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imgui_widgets.cpp6557
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imstb_rectpack.h623
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imstb_textedit.h1409
-rw-r--r--Client/ThirdParty/Box2D/extern/imgui/imstb_truetype.h4854
-rw-r--r--Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt10
-rw-r--r--Client/ThirdParty/Box2D/extern/sajson/sajson.cpp2
-rw-r--r--Client/ThirdParty/Box2D/extern/sajson/sajson.h2493
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_api.h52
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_block_allocator.h60
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_body.h878
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_broad_phase.h238
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_chain_shape.h101
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_circle_shape.h67
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_collision.h283
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_common.h138
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_contact.h386
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_contact_manager.h57
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_distance.h171
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_distance_joint.h176
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_draw.h102
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_dynamic_tree.h308
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_edge_shape.h86
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_fixture.h365
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_friction_joint.h124
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_gear_joint.h130
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_growable_stack.h91
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_joint.h228
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_math.h715
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_motor_joint.h138
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_mouse_joint.h134
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_polygon_shape.h95
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_prismatic_joint.h205
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_pulley_joint.h157
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_revolute_joint.h211
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_rope.h153
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_settings.h127
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_shape.h110
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_stack_allocator.h65
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_time_of_impact.h63
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_time_step.h74
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_timer.h55
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_types.h33
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_weld_joint.h133
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_wheel_joint.h240
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_world.h345
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/b2_world_callbacks.h161
-rw-r--r--Client/ThirdParty/Box2D/include/box2d/box2d.h58
-rw-r--r--Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj201
-rw-r--r--Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj.filters8
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeCache.txt441
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/049e1eb7380682ec4cf9a2c62dad57db/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/14f8a92cc8883d19b638672092016c39/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake72
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake83
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_C.binbin0 -> 35840 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_CXX.binbin0 -> 35840 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake6
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeSystem.cmake15
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CMakeCCompilerId.c803
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.exebin0 -> 11264 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.vcxproj71
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.objbin0 -> 1949 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlogbin0 -> 906 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlogbin0 -> 668 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlogbin0 -> 544 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate2
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlogbin0 -> 1122 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlogbin0 -> 3730 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlogbin0 -> 538 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CMakeCXXCompilerId.cpp791
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.exebin0 -> 11264 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.vcxproj71
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.objbin0 -> 1967 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlogbin0 -> 930 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlogbin0 -> 680 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlogbin0 -> 564 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate2
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlogbin0 -> 1146 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlogbin0 -> 3746 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlogbin0 -> 554 bytes
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate2
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.txt1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.vcxproj28
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/generate.stamp.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/455517aeb2285a20077dbce51065d1ef/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/5db6461968e3a28c7176c305697cc35c/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/6ddefecedef78174b7ed9b2bc8a1e035/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/9ab13db7d2176474a16e440b6b1b97a8/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeError.log16
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeOutput.log123
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/TargetDirectories.txt17
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/bfe9de955132cd9d067c24acf7d98bef/INSTALL_force.rule1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/cmake.check_cache1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.depend96
-rw-r--r--Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.list8
-rw-r--r--Client/ThirdParty/Box2D/proj/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj167
-rw-r--r--Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/box2d.sln164
-rw-r--r--Client/ThirdParty/Box2D/proj/cmake_install.cmake60
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp.depend2
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/cmake_install.cmake34
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj279
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj.filters33
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp.depend10
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/cmake_install.cmake34
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj300
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj.filters93
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp.depend2
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/cmake_install.cmake34
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj286
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj.filters22
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp.depend2
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/cmake_install.cmake34
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj278
-rw-r--r--Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj.filters14
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-debug.cmake19
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-minsizerel.cmake19
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-release.cmake19
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-relwithdebinfo.cmake19
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig.cmake94
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp.depend5
-rw-r--r--Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/src/box2d.vcxproj374
-rw-r--r--Client/ThirdParty/Box2D/proj/src/box2d.vcxproj.filters315
-rw-r--r--Client/ThirdParty/Box2D/proj/src/box2dConfigVersion.cmake70
-rw-r--r--Client/ThirdParty/Box2D/proj/src/cmake_install.cmake90
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp.depend2
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/cmake_install.cmake34
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj465
-rw-r--r--Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj.filters200
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp1
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp.depend2
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj193
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj.filters13
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/cmake_install.cmake34
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj334
-rw-r--r--Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj.filters18
-rw-r--r--Client/ThirdParty/Box2D/src/CMakeLists.txt163
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_broad_phase.cpp131
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_chain_shape.cpp185
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_circle_shape.cpp105
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_collide_circle.cpp158
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_collide_edge.cpp524
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_collide_polygon.cpp243
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_collision.cpp258
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_distance.cpp746
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_dynamic_tree.cpp801
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_edge_shape.cpp158
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_polygon_shape.cpp459
-rw-r--r--Client/ThirdParty/Box2D/src/collision/b2_time_of_impact.cpp490
-rw-r--r--Client/ThirdParty/Box2D/src/common/b2_block_allocator.cpp230
-rw-r--r--Client/ThirdParty/Box2D/src/common/b2_draw.cpp47
-rw-r--r--Client/ThirdParty/Box2D/src/common/b2_math.cpp98
-rw-r--r--Client/ThirdParty/Box2D/src/common/b2_settings.cpp74
-rw-r--r--Client/ThirdParty/Box2D/src/common/b2_stack_allocator.cpp87
-rw-r--r--Client/ThirdParty/Box2D/src/common/b2_timer.cpp125
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_body.cpp565
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.cpp57
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.h43
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.cpp57
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.h43
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.cpp56
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.h43
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_contact.cpp252
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_contact_manager.cpp293
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.cpp843
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.h100
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_distance_joint.cpp421
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.cpp54
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.h43
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.cpp54
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.h43
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_fixture.cpp305
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_friction_joint.cpp255
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_gear_joint.cpp429
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_island.cpp544
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_island.h97
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_joint.cpp301
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_motor_joint.cpp311
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_mouse_joint.cpp192
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.cpp54
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.h42
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.cpp57
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.h43
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_prismatic_joint.cpp643
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_pulley_joint.cpp352
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_revolute_joint.cpp501
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_weld_joint.cpp344
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_wheel_joint.cpp672
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_world.cpp1322
-rw-r--r--Client/ThirdParty/Box2D/src/dynamics/b2_world_callbacks.cpp40
-rw-r--r--Client/ThirdParty/Box2D/src/rope/b2_rope.cpp809
-rw-r--r--Client/ThirdParty/Box2D/testbed/CMakeLists.txt92
-rw-r--r--Client/ThirdParty/Box2D/testbed/MacOSXBundleInfo.plist.in41
-rw-r--r--Client/ThirdParty/Box2D/testbed/data/droid_sans.ttfbin0 -> 190044 bytes
-rw-r--r--Client/ThirdParty/Box2D/testbed/draw.cpp829
-rw-r--r--Client/ThirdParty/Box2D/testbed/draw.h102
-rw-r--r--Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.cpp324
-rw-r--r--Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.h33
-rw-r--r--Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.cpp556
-rw-r--r--Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.h44
-rw-r--r--Client/ThirdParty/Box2D/testbed/main.cpp651
-rw-r--r--Client/ThirdParty/Box2D/testbed/settings.cpp176
-rw-r--r--Client/ThirdParty/Box2D/testbed/settings.h83
-rw-r--r--Client/ThirdParty/Box2D/testbed/test.cpp469
-rw-r--r--Client/ThirdParty/Box2D/testbed/test.h156
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/add_pair.cpp71
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/apply_force.cpp203
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/body_types.cpp163
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/box_stack.cpp174
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/breakable.cpp158
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/bridge.cpp128
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/bullet_test.cpp139
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/cantilever.cpp218
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/car.cpp284
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/chain.cpp92
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/chain_problem.cpp94
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/character_collision.cpp256
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/circle_stack.cpp89
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/collision_filtering.cpp179
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/collision_processing.cpp191
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/compound_shapes.cpp227
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/confined.cpp170
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/continuous_test.cpp160
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/convex_hull.cpp112
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/conveyor_belt.cpp101
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/distance_joint.cpp123
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/distance_test.cpp139
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/dominos.cpp220
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/dump_loader.cpp88
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/dynamic_tree.cpp360
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/edge_shapes.cpp253
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/edge_test.cpp282
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/friction.cpp127
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/gear_joint.cpp180
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/heavy1.cpp61
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/heavy2.cpp94
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/mobile_balanced.cpp108
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/mobile_unbalanced.cpp105
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/motor_joint.cpp118
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/pinball.cpp170
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/platformer.cpp133
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/polygon_collision.cpp127
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/polygon_shapes.cpp265
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/prismatic_joint.cpp118
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/pulley_joint.cpp96
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/pyramid.cpp92
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/ray_cast.cpp479
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/restitution.cpp79
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/revolute_joint.cpp162
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/rope.cpp286
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/sensor.cpp195
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/shape_cast.cpp193
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/shape_editing.cpp108
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/skier.cpp150
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/slider_crank_1.cpp106
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/slider_crank_2.cpp160
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/theo_jansen.cpp266
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/tiles.cpp159
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/time_of_impact.cpp131
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/tumbler.cpp102
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/web.cpp218
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/wheel_joint.cpp126
-rw-r--r--Client/ThirdParty/Box2D/testbed/tests/wrecking_ball.cpp165
-rw-r--r--Client/ThirdParty/Box2D/unit-test/CMakeLists.txt18
-rw-r--r--Client/ThirdParty/Box2D/unit-test/collision_test.cpp81
-rw-r--r--Client/ThirdParty/Box2D/unit-test/doctest.h6580
-rw-r--r--Client/ThirdParty/Box2D/unit-test/hello_world.cpp112
-rw-r--r--Client/ThirdParty/Box2D/unit-test/joint_test.cpp106
-rw-r--r--Client/ThirdParty/Box2D/unit-test/math_test.cpp54
-rw-r--r--Client/ThirdParty/Box2D/unit-test/world_test.cpp73
415 files changed, 136532 insertions, 0 deletions
diff --git a/Client/ThirdParty/Box2D/.gitignore b/Client/ThirdParty/Box2D/.gitignore
new file mode 100644
index 0000000..8b45738
--- /dev/null
+++ b/Client/ThirdParty/Box2D/.gitignore
@@ -0,0 +1,7 @@
+build/
+imgui.ini
+settings.ini
+.vscode/
+CMakeSettings.json
+out/
+.vs/
diff --git a/Client/ThirdParty/Box2D/.travis.yml b/Client/ThirdParty/Box2D/.travis.yml
new file mode 100644
index 0000000..6c67aec
--- /dev/null
+++ b/Client/ThirdParty/Box2D/.travis.yml
@@ -0,0 +1,32 @@
+language: cpp
+
+dist: bionic
+
+# This is clang on macOS
+compiler: gcc
+
+branches:
+ only:
+ - master
+
+addons:
+ apt:
+ packages:
+ - libxrandr-dev
+ - libxinerama-dev
+ - libxcursor-dev
+ - libxi-dev
+
+jobs:
+ include:
+ - os: linux
+ env:
+ - os: osx
+ env:
+
+script:
+ - mkdir build
+ - cd build
+ - cmake ..
+ - cmake --build .
+ - ./bin/unit_test
diff --git a/Client/ThirdParty/Box2D/CHANGELOG.md b/Client/ThirdParty/Box2D/CHANGELOG.md
new file mode 100644
index 0000000..c192fb9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/CHANGELOG.md
@@ -0,0 +1,60 @@
+# Changes for version 2.4.1
+
+## API Changes
+- Extended distance joint to have a minimum and maximum limit.
+- Removed rope joint. Use the distance joint instead.
+- B2_USER_SETTINGS and b2_user_settings.h can control user data, length units, and maximum polygon vertices.
+- Default user data is now uintptr_t instead of void*
+- b2FixtureDef::restitutionThreshold lets you set the restitution velocity threshold per fixture.
+
+## BREAKING Changes
+- BREAKING: distance joint 0 stiffness now means the spring is turned off rather than making the joint rigid.
+- BREAKING: distance joint minimum and maximum must be set correctly to get old behavior.
+
+## Infrastructure
+- Library installation function available in CMake.
+- Shared library (DLL) option available.
+- Bug fixes
+
+# Changes for version 2.4.0
+
+## Infrastructure
+- Documentation in Doxygen format
+- CMake build system
+- Unit test support
+- Continuous integration testing using Travis CI
+- Limited use of C++11 (nullptr and override)
+- Restructured folders and renamed files to better match open-source standards
+- MIT License
+- Removed float32 and float64
+- Linked the Box2D project to GitHub Sponsors
+
+## Collision
+- Chain and edge shape must now be one-sided to eliminate ghost collisions
+- Broad-phase optimizations
+- Added b2ShapeCast for linear shape casting
+
+## Dynamics
+- Joint limits are now predictive and not stateful
+- Experimental 2D cloth (rope)
+- b2Body::SetActive -> b2Body::SetEnabled
+- Better support for running multiple worlds
+- Handle zero density better
+ - The body behaves like a static body
+ - The body is drawn with a red color
+- Added translation limit to wheel joint
+- World dump now writes to box2d_dump.inl
+- Static bodies are never awake
+- All joints with spring-dampers now use stiffness and damping
+- Added utility functions to convert frequency and damping ratio to stiffness and damping
+
+## Testbed
+- Testbed uses dear imgui
+- glad OpenGL loader
+- OpenGL 3.3 required
+
+# Changes for version 2.3.0
+- Polygon creation now computes the convex hull. Vertices no longer need to be ordered.
+- The convex hull code will merge vertices closer than dm_linearSlop. This may lead to failure on very small polygons.
+- Added b2MotorJoint.
+- Bug fixes.
diff --git a/Client/ThirdParty/Box2D/CMakeLists.txt b/Client/ThirdParty/Box2D/CMakeLists.txt
new file mode 100644
index 0000000..c38243c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/CMakeLists.txt
@@ -0,0 +1,65 @@
+cmake_minimum_required(VERSION 3.8)
+
+# https://cmake.org/cmake/help/latest/command/project.html
+project(box2d VERSION 2.4.1)
+
+# set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo" CACHE STRING "" FORCE)
+
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
+
+option(BOX2D_BUILD_UNIT_TESTS "Build the Box2D unit tests" ON)
+option(BOX2D_BUILD_TESTBED "Build the Box2D testbed" ON)
+option(BOX2D_BUILD_DOCS "Build the Box2D documentation" OFF)
+option(BOX2D_USER_SETTINGS "Override Box2D settings with b2UserSettings.h" OFF)
+
+option(BUILD_SHARED_LIBS "Build Box2D as a shared library" OFF)
+
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+include(GNUInstallDirs)
+
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+if (BOX2D_USER_SETTINGS)
+ add_compile_definitions(B2_USER_SETTINGS)
+endif()
+
+add_subdirectory(src)
+
+if (BOX2D_BUILD_DOCS)
+ set(DOXYGEN_SKIP_DOT TRUE)
+ find_package(Doxygen)
+endif()
+
+if (DOXYGEN_FOUND AND BOX2D_BUILD_DOCS)
+ add_subdirectory(docs)
+endif()
+
+if (BOX2D_BUILD_UNIT_TESTS)
+ add_subdirectory(unit-test)
+endif()
+
+if (BOX2D_BUILD_TESTBED)
+ add_subdirectory(extern/glad)
+ add_subdirectory(extern/glfw)
+ add_subdirectory(extern/imgui)
+ add_subdirectory(extern/sajson)
+ add_subdirectory(testbed)
+
+ # default startup project for Visual Studio
+ if (MSVC)
+ set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT testbed)
+ set_property(TARGET testbed PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/testbed")
+ endif()
+endif()
+
+install(
+ DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/box2d"
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+)
diff --git a/Client/ThirdParty/Box2D/LICENSE b/Client/ThirdParty/Box2D/LICENSE
new file mode 100644
index 0000000..3600714
--- /dev/null
+++ b/Client/ThirdParty/Box2D/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Erin Catto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/README.md b/Client/ThirdParty/Box2D/README.md
new file mode 100644
index 0000000..e016563
--- /dev/null
+++ b/Client/ThirdParty/Box2D/README.md
@@ -0,0 +1,115 @@
+![Box2D Logo](https://box2d.org/images/logo.svg)
+
+# Build Status
+[![Build Status](https://travis-ci.org/erincatto/box2d.svg?branch=master)](https://travis-ci.org/erincatto/box2d)
+
+# Box2D
+
+Box2D is a 2D physics engine for games.
+
+## Contributing
+
+Please do not submit pull requests with new features or core library changes. Instead, please file an issue first for discussion. For bugs, I prefer detailed bug reports over pull requests.
+
+## Features
+
+### Collision
+- Continuous collision detection
+- Contact callbacks: begin, end, pre-solve, post-solve
+- Convex polygons and circles
+- Multiple shapes per body
+- One-shot contact manifolds
+- Dynamic tree broadphase
+- Efficient pair management
+- Fast broadphase AABB queries
+- Collision groups and categories
+
+### Physics
+- Continuous physics with time of impact solver
+- Persistent body-joint-contact graph
+- Island solution and sleep management
+- Contact, friction, and restitution
+- Stable stacking with a linear-time solver
+- Revolute, prismatic, distance, pulley, gear, mouse joint, and other joint types
+- Joint limits, motors, and friction
+- Momentum decoupled position correction
+- Fairly accurate reaction forces/impulses
+
+### System
+- Small block and stack allocators
+- Centralized tuning parameters
+- Highly portable C++ with no use of STL containers
+
+### Testbed
+- OpenGL with GLFW
+- Graphical user interface with imgui
+- Extensible test framework
+- Support for loading world dumps
+
+## Building
+- Install [CMake](https://cmake.org/)
+- Ensure CMake is in the user `PATH`
+- Visual Studio: run `build.bat` from the command prompt
+- Otherwise: run `build.sh` from a bash shell
+- Results are in the build sub-folder
+- On Windows you can open box2d.sln
+
+## Building Box2D - Using vcpkg
+You can download and install Box2D using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
+
+- git clone https://github.com/Microsoft/vcpkg.git
+- cd vcpkg
+- ./bootstrap-vcpkg.sh
+- ./vcpkg integrate install
+- ./vcpkg install box2d
+
+The Box2D port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
+
+Note: vcpkg support is not provided by the Box2D project
+
+## Building for Xcode
+- Install [CMake](https://cmake.org)
+- Add Cmake to the path in .zprofile (the default Terminal shell is zsh)
+ - export PATH="/Applications/CMake.app/Contents/bin:$PATH"
+- mkdir build
+- cd build
+- cmake -G Xcode ..
+- open box2d.xcodeproj
+- Select the testbed scheme
+- Edit the scheme to set a custom working directory, make this be in box2d/testbed
+- You can now build and run the testbed
+
+## Installing using CMake
+You can use the CMake install feature to deploy the library to a central location that can
+be accessed using:
+```
+find_package(box2d REQUIRED)
+target_link_libraries(mytarget PRIVATE box2d)
+```
+You can build and install the library and docs using this command sequence (requires Doxygen):
+```
+mkdir build
+cd build
+cmake -DBOX2D_BUILD_DOCS=ON ..
+cmake --build .
+cmake --build . --target INSTALL
+```
+On Windows this tries to install in `Program Files` and thus requires admin privileges. Alternatively you can target another directory using something like this:
+```
+mkdir build
+cd build
+cmake -DBOX2D_BUILD_DOCS=ON -DCMAKE_INSTALL_PREFIX="C:/packages" ..
+cmake --build .
+cmake --build . --target INSTALL
+```
+
+## Documentation
+- [Manual](https://box2d.org/documentation/)
+- [reddit](https://www.reddit.com/r/box2d/)
+- [Discord](https://discord.gg/NKYgCBP)
+
+## License
+Box2D is developed by Erin Catto, and uses the [MIT license](https://en.wikipedia.org/wiki/MIT_License).
+
+## Sponsorship
+Support development of Box2D through [Github Sponsors](https://github.com/sponsors/erincatto)
diff --git a/Client/ThirdParty/Box2D/build.bat b/Client/ThirdParty/Box2D/build.bat
new file mode 100644
index 0000000..216561a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/build.bat
@@ -0,0 +1,7 @@
+rem Use this batch file to build box2d for Visual Studio
+rmdir /s /q build
+mkdir build
+cd build
+cmake ..
+cmake --build .
+start box2d.sln
diff --git a/Client/ThirdParty/Box2D/build.sh b/Client/ThirdParty/Box2D/build.sh
new file mode 100644
index 0000000..3433595
--- /dev/null
+++ b/Client/ThirdParty/Box2D/build.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+# Use this to build box2d on any system with a bash shell
+rm -rf build
+mkdir build
+cd build
+cmake -DBOX2D_BUILD_DOCS=OFF ..
+cmake --build .
diff --git a/Client/ThirdParty/Box2D/build_docs.sh b/Client/ThirdParty/Box2D/build_docs.sh
new file mode 100644
index 0000000..93e124d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/build_docs.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+# Builds Box2D along with documentation
+rm -rf build
+mkdir build
+cd build
+cmake -DBOX2D_BUILD_DOCS=ON ..
+cmake --build .
diff --git a/Client/ThirdParty/Box2D/deploy_docs.sh b/Client/ThirdParty/Box2D/deploy_docs.sh
new file mode 100644
index 0000000..1813f85
--- /dev/null
+++ b/Client/ThirdParty/Box2D/deploy_docs.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+# Copies documentation to blog
+cp -R build/docs/html/. ../blog/public/documentation/
diff --git a/Client/ThirdParty/Box2D/docs/CMakeLists.txt b/Client/ThirdParty/Box2D/docs/CMakeLists.txt
new file mode 100644
index 0000000..edffb4e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/CMakeLists.txt
@@ -0,0 +1,32 @@
+
+# NOTE: The order of this list determines the order of items in the Guides
+# (i.e. Pages) list in the generated documentation
+
+set(BOX2D_DOXYGEN_SOURCES
+ "include/box2d"
+ "docs/overview.md"
+ "docs/hello.md"
+ "docs/testbed.md"
+ "docs/common.md"
+ "docs/collision.md"
+ "docs/dynamics.md"
+ "docs/loose_ends.md"
+ "docs/references.md"
+ "docs/FAQ.md")
+
+# Format the source list into a Doxyfile INPUT value that Doxygen can parse
+foreach(path IN LISTS BOX2D_DOXYGEN_SOURCES)
+ set(BOX2D_DOXYGEN_INPUT "${BOX2D_DOXYGEN_INPUT} \\\n\"${CMAKE_SOURCE_DIR}/${path}\"")
+endforeach()
+
+# https://cmake.org/cmake/help/latest/command/configure_file.html
+configure_file(Doxyfile.in Doxyfile @ONLY)
+
+add_custom_target(docs ALL "${DOXYGEN_EXECUTABLE}"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/docs"
+ COMMENT "Generating HTML documentation" VERBATIM)
+
+install(
+ DIRECTORY "${CMAKE_BINARY_DIR}/docs/html"
+ DESTINATION "${CMAKE_INSTALL_DOCDIR}"
+)
diff --git a/Client/ThirdParty/Box2D/docs/Doxyfile.in b/Client/ThirdParty/Box2D/docs/Doxyfile.in
new file mode 100644
index 0000000..523c925
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/Doxyfile.in
@@ -0,0 +1,2578 @@
+# Doxyfile 1.8.17
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the configuration
+# file that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
+PROJECT_NAME = "Box2D"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
+PROJECT_NUMBER = @CMAKE_PROJECT_VERSION@
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF = "A 2D physics engine for games"
+
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
+
+PROJECT_LOGO = "@CMAKE_SOURCE_DIR@/docs/images/logo.svg"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = "@CMAKE_BINARY_DIR@/docs"
+
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
+CREATE_SUBDIRS = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
+OUTPUT_LANGUAGE = English
+
+# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all generated output in the proper direction.
+# Possible values are: None, LTR, RTL and Context.
+# The default value is: None.
+
+OUTPUT_TEXT_DIRECTION = None
+
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES = YES
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
+# such as
+# /***************
+# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
+# Javadoc-style will behave just like regular comments and it will not be
+# interpreted by doxygen.
+# The default value is: NO.
+
+JAVADOC_BANNER = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines (in the resulting output). You can put ^^ in the value part of an
+# alias to insert a newline as if a physical newline was in the original file.
+# When you need a literal { or } or , in the value part of an alias you have to
+# escape them by means of a backslash (\), this can lead to conflicts with the
+# commands \{ and \} for these it is advised to use the version @{ and @} or use
+# a double escape (\\{ and \\})
+
+ALIASES =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice
+# sources only. Doxygen will then generate output that is more tailored for that
+# language. For instance, namespaces will be presented as modules, types will be
+# separated into more groups, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_SLICE = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
+# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice,
+# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
+# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
+# tries to guess whether the code is fixed or free formatted code, this is the
+# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is
+# Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See https://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT = YES
+
+# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
+# to that level are automatically included in the table of contents, even if
+# they do not have an id attribute.
+# Note: This feature currently applies only to Markdown headings.
+# Minimum value: 0, maximum value: 99, default value: 5.
+# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
+
+TOC_INCLUDE_HEADINGS = 5
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
+# methods of a class will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIV_VIRTUAL = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE = NO
+
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# declarations. If set to NO, these declarations will be included in the
+# documentation.
+# The default value is: NO.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# (including Cygwin) ands Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
+CASE_SENSE_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
+SHOW_USED_FILES = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
+
+CITE_BIB_FILES =
+
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
+WARNINGS = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED = NO
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation. If
+# EXTRACT_ALL is set to YES then this flag will automatically be disabled.
+# The default value is: NO.
+
+WARN_NO_PARAMDOC = NO
+
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE = "@BOX2D_BINARY_DIR@/docs/warnings.txt"
+
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
+
+INPUT = @BOX2D_DOXYGEN_INPUT@
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
+# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen
+# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd,
+# *.vhdl, *.ucf, *.qsf and *.ice.
+
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.idl \
+ *.ddl \
+ *.odl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.cs \
+ *.d \
+ *.php \
+ *.php4 \
+ *.php5 \
+ *.phtml \
+ *.inc \
+ *.m \
+ *.markdown \
+ *.md \
+ *.mm \
+ *.dox \
+ *.doc \
+ *.txt \
+ *.py \
+ *.pyw \
+ *.f90 \
+ *.f95 \
+ *.f03 \
+ *.f08 \
+ *.f \
+ *.for \
+ *.tcl \
+ *.vhd \
+ *.vhdl \
+ *.ucf \
+ *.qsf \
+ *.ice
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH = "@CMAKE_SOURCE_DIR@/docs/images"
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE = "@CMAKE_SOURCE_DIR@/docs/overview.md"
+
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# entity all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see https://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS = YES
+
+# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
+# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
+# cost of reduced performance. This can be particularly helpful with template
+# rich C++ code for which doxygen's built-in parser lacks the necessary type
+# information.
+# Note: The availability of this option depends on whether or not doxygen was
+# generated with the -Duse_libclang=ON option for CMake.
+# The default value is: NO.
+
+CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified with INPUT and INCLUDE_PATH.
+# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
+
+CLANG_OPTIONS =
+
+# If clang assisted parsing is enabled you can provide the clang parser with the
+# path to the compilation database (see:
+# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files
+# were built. This is equivalent to specifying the "-p" option to a clang tool,
+# such as clang-check. These options will then be passed to the parser.
+# Note: The availability of this option depends on whether or not doxygen was
+# generated with the -Duse_libclang=ON option for CMake.
+
+CLANG_DATABASE_PATH =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
+ALPHABETICAL_INDEX = YES
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET = "@CMAKE_SOURCE_DIR@/docs/extra.css"
+
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP = NO
+
+# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
+# documentation will contain a main index with vertical navigation menus that
+# are dynamically created via JavaScript. If disabled, the navigation index will
+# consists of multiple levels of tabs that are statically embedded in every HTML
+# page. Disable this option to support browsers that do not have JavaScript,
+# like the Qt help browser.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_MENUS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: https://developer.apple.com/xcode/), introduced with OSX
+# 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy
+# genXcode/_index.html for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE =
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION =
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING =
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-
+# folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS =
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW = YES
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH = 250
+
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT = YES
+
+# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
+# to create new LaTeX commands to be used in formulas as building blocks. See
+# the section "Including formulas" for details.
+
+FORMULA_MACROFILE =
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# https://www.mathjax.org) which uses client side JavaScript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from https://www.mathjax.org before deployment.
+# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using JavaScript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when not enabling USE_PDFLATEX the default is latex when enabling
+# USE_PDFLATEX the default is pdflatex and when in the later case latex is
+# chosen this is overwritten by pdflatex. For specific output languages the
+# default can have been set differently, this depends on the implementation of
+# the output language.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_CMD_NAME =
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# Note: This tag is used in the Makefile / make.bat.
+# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file
+# (.tex).
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
+# generate index for LaTeX. In case there is no backslash (\) as first character
+# it will be automatically added in the LaTeX code.
+# Note: This tag is used in the generated output file (.tex).
+# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
+# The default value is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_MAKEINDEX_CMD = makeindex
+
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PAPER_TYPE = a4
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER =
+
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BATCHMODE = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HIDE_INDICES = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE = plain
+
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP = NO
+
+# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
+# path from which the emoji images will be read. If a relative path is entered,
+# it will be relative to the LATEX_OUTPUT directory. If left blank the
+# LATEX_OUTPUT directory will be used.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EMOJI_DIRECTORY =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# configuration file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's configuration file. A template extensions file can be
+# generated using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE =
+
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_EXTENSION = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_OUTPUT = xml
+
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_PROGRAMLISTING = YES
+
+# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include
+# namespace members in file scope as well, matching the HTML output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_NS_MEMB_FILE_SCOPE = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
+# the structure of the code including all documentation. Note that this feature
+# is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
+EXTERNAL_GROUPS = YES
+
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
+CLASS_DIAGRAMS = YES
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH =
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: NO.
+
+HAVE_DOT = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS = 0
+
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LOOK = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS = NO
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDE_GRAPH = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_IMAGE_FORMAT = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG = NO
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS =
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH =
+
+# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
+# configuration file for plantuml.
+
+PLANTUML_CFG_FILE =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_CLEANUP = YES
diff --git a/Client/ThirdParty/Box2D/docs/FAQ.md b/Client/ThirdParty/Box2D/docs/FAQ.md
new file mode 100644
index 0000000..7f18a3c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/FAQ.md
@@ -0,0 +1,146 @@
+# FAQ
+
+## What is Box2D?
+
+Box2D is a feature rich 2D rigid body physics engine, written in C++ by Erin Catto. It has been used in many games, including Crayon Physics Deluxe, winner of the 2008 Independant Game Festival Grand Prize.
+
+Box2D uses the [MIT license](https://en.wikipedia.org/wiki/MIT_License) license and can be used free of charge.
+
+## What platforms does Box2D support?
+
+Box2D is developed on Windows using Visual C++. Ports are also available for Flash, Java, C#, Python.
+
+Erin Catto maintains the C++ version, but provides no support for other languages. Other languages are supported by the community and possibly by the authors of those ports.
+
+## Who makes it?
+
+Erin Catto is the driving force behind Box2D, with various others supporting the ports. Box2D is an open source project, and accepts community feedback.
+
+## How do I get help?
+
+You should read the documentation and the rest of this FAQ first. Also, you should study the examples included in the source distribution. Then you can visit the [subreddit](https://www.reddit.com/r/box2d/) to ask any remaining questions.
+
+Please to not PM or email Erin Catto for support. It is best to ask questions in the forum so that everyone can benefit from the discussion.
+
+## Documentation
+
+### Why isn't feature foo documented?
+
+If you grab the latest code from the git master branch you will likely find features that are not documented in the manual. New features are added to the manual after they are mature and a new point release is imminent. However, all major features added to Box2D are accompanied by example code in the testbed to test the feature and show the intended usage.
+
+## Prerequisites
+
+### Programming
+
+You should have a working knowledge of C++ before you use Box2D. You should understand classes, inheritance, and pointers. There are plenty of resources on the web for learning C++. You should also understand your development environment: compilation, linking, and debugging.
+
+### Math and Physics
+
+You should have a basic knowledge of rigid bodies, force, torque, and impulses. If you come across a math or physics concept you don't understand, please read about it on Wikipedia. Visit this [page](http://box2d.org/publications/) if you want a deeper knowledge of the algorithms used in Box2D.
+
+## API
+
+### What units does Box2D use?
+
+Box2D is tuned for meters-kilograms-seconds (MKS). Your moving objects should be between 0.1 - 10 meters. Do not use pixels as units! You will get a jittery simulation.
+
+### How do I convert pixels to meters?
+
+Suppose you have a sprite for a character that is 100x100 pixels. You decide to use a scaling factor that is 0.01. This will make the character physics box 1m x 1m. So go make a physics box that is 1x1. Now suppose the character starts out at pixel coordinate (345,679). So position the physics box at (3.45,6.79). Now simulate the physics world. Suppose the character physics box moves to (2.31,4.98), so move your character sprite to pixel coordinates (231,498).
+Now the only tricky part is choosing a scaling factor. This really depends on your game. You should try to get your moving objects in the range 0.1 - 10 meters, with 1 meter being the sweet spot.
+
+### Why don't you use this awesome C++ feature?
+
+Box2D is designed to be portable, so I try to keep the C++ usage simple. Also, I don't use the STL (except sort) or other libraries to keep the dependencies low. I keep template usage low and don't use name spaces. Remember, just because a C++ feature exists, that doesn't mean you need to use it.
+
+The many ports of Box2D to other languages platforms shows that this strategy has been successful.
+
+### Can I use Box2D in a DLL?
+
+Box2D was not designed to be used in a DLL. You may have to change how static data is used to make this work.
+
+### Is Box2D thread-safe?
+
+No. Box2D will likely never be thread-safe. Box2D has a large API and trying to make such an API thread-safe would have a large performance and complexity impact.
+
+## Build Issues
+
+### Why doesn't my code compile and/or link?
+
+There are many reasons why a build can go bad. Here are a few that have come up:
+
+* Using old Box2D headers with new code
+* Not linking the Box2D library with your application
+* Using old project files that don't include some new source files
+
+## Rendering
+
+### What are Box2D's rendering capabilities?
+
+Box2D is only a physics engine. How you draw stuff is up to you.
+
+### But the Testbed draws stuff
+
+Visualization is very important for debugging collision and physics. I wrote the test bed to help me test Box2D and give you examples of how to use Box2D. The TestBed is not part of the Box2D library.
+
+### How do I draw shapes?
+
+Drawing shapes is not supported and shape internal data is likely to change. Instead you should implement the `b2DebugDraw` interface.
+
+## Accuracy
+
+Box2D uses approximate methods for a few reasons.
+
+* Performance
+* Some differential equations don't have known solutions
+* Some constraints cannot be determined uniquely
+
+What this means is that constraints are not perfectly rigid and sometimes you will see some bounce even when the restitution is zero.
+Box2D uses Gauss-Seidel to approximately solve constraints.
+Box2D also uses Semi-implicit Euler to approximately solve the differential equations.
+Box2D also does not have exact collision. Polygons are covered with a thin skin (around 0.5cm thick) to avoid numerical problems. This can sometimes lead to unexpected contact normals. Also, some shapes may begin to overlap and then be pushed apart by the solver.
+
+## Making Games
+
+### Worms Clones
+
+Making a worms clone requires arbitrarily destructible terrain. This is beyond the scope of Box2D, so you will have to figure out how to do this on your own.
+
+### Tile Based Environment
+
+Using many boxes for your terrain may not work well because box-like characters can get snagged on internal corners. A future update to Box2D should allow for smooth motion over edge chains. In general you should avoid using a rectangular character because collision tolerances will still lead to undesirable snagging.
+
+### Asteroid Type Coordinate Systems
+
+Box2D does not have any support for coordinate frame wrapping. You would likely need to customize Box2D for this purpose. You may need to use a different broad-phase for this to work.
+
+## Determinism
+
+### Is Box2D deterministic?
+
+For the same input, and same binary, Box2D will reproduce any simulation. Box2D does not use any random numbers nor base any computation on random events (such as timers, etc).
+
+However, people often want more stringent determinism. People often want to know if Box2D can produce identical results on different binaries and on different platforms. The answer is no. The reason for this answer has to do with how floating point math is implemented in many compilers and processors. I recommend reading this article if you are curious: http://www.yosefk.com/blog/consistency-how-to-defeat-the-purpose-of-ieee-floating-point.html
+
+### But I really want determinism
+
+This naturally leads to the question of fixed-point math. Box2D does not support fixed-point math. In the past Box2D was ported to the NDS in fixed-point and apparently it worked okay. Fixed-point math is slower and more tedious to develop, so I have chosen not to use fixed-point for the development of Box2D.
+
+## Why is the restitution/friction mixing inaccurate?
+
+A physically correct restitution value must be measured in experiments. But as soon as you change the geometry from the experiment then the value is wrong. Next, adding simultaneous collision makes the answer worse. We've been down this road before.
+
+So the question of accuracy has been answered: failure.
+
+The only remaining question is how do we make it convenient. On this opinions may vary.
+
+`b2Settings` is just that. Settings you can adjust if you know what you are doing.
+
+## What are the biggest mistakes made by new users?
+
+* Using pixels for length instead of meters.
+* Expecting Box2D to give pixel perfect results.
+* Using b2Polygon to create concave polygons.
+* Testing their code in release mode.
+* Not learning C++ before using Box2D.
+* Not reading this FAQ. :)
diff --git a/Client/ThirdParty/Box2D/docs/collision.md b/Client/ThirdParty/Box2D/docs/collision.md
new file mode 100644
index 0000000..fe00aa4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/collision.md
@@ -0,0 +1,433 @@
+# Collision Module
+The Collision module contains shapes and functions that operate on them.
+The module also contains a dynamic tree and broad-phase to acceleration
+collision processing of large systems.
+
+The collision module is designed to be usable outside of the dynamic
+system. For example, you can use the dynamic tree for other aspects of
+your game besides physics.
+
+However, the main purpose of Box2D is to provide a rigid body physics
+engine, so the using the collision module by itself may feel limited for
+some applications. Likewise, I will not make a strong effort to document
+it or polish the APIs.
+
+## Shapes
+Shapes describe collision geometry and may be used independently of
+physics simulation. At a minimum, you should understand how to create
+shapes that can be later attached to rigid bodies.
+
+Box2D shapes implement the b2Shape base class. The base class defines
+functions to:
+- Test a point for overlap with the shape.
+- Perform a ray cast against the shape.
+- Compute the shape's AABB.
+- Compute the mass properties of the shape.
+
+In addition, each shape has a type member and a radius. The radius even
+applies to polygons, as discussed below.
+
+Keep in mind that a shape does not know about bodies and stand apart
+from the dynamics system. Shapes are stored in a compact form that is
+optimized for size and performance. As such, shapes are not easily moved
+around. You have to manually set the shape vertex positions to move a
+shape. However, when a shape is attached to a body using a fixture, the
+shapes move rigidly with the host body. In summary:
+- When a shape is **not** attached to a body, you can view it's vertices as being expressed in world-space.
+- When a shape is attached to a body, you can view it's vertices as being expressed in local coordinates.
+
+### Circle Shapes
+Circle shapes have a position and radius. Circles are solid. You cannot
+make a hollow circle using the circle shape.
+
+```cpp
+b2CircleShape circle;
+circle.m_p.Set(2.0f, 3.0f);
+circle.m_radius = 0.5f;
+```
+
+### Polygon Shapes
+Polygon shapes are solid convex polygons. A polygon is convex when all
+line segments connecting two points in the interior do not cross any
+edge of the polygon. Polygons are solid and never hollow. A polygon must
+have 3 or more vertices.
+
+![Convex and Concave Polygons](images/convex_concave.gif)
+
+Polygons vertices are stored with a counter clockwise winding (CCW). We
+must be careful because the notion of CCW is with respect to a
+right-handed coordinate system with the z-axis pointing out of the
+plane. This might turn out to be clockwise on your screen, depending on
+your coordinate system conventions.
+
+![Polygon Winding Order](images/winding.svg)
+
+The polygon members are public, but you should use initialization
+functions to create a polygon. The initialization functions create
+normal vectors and perform validation.
+
+You can create a polygon shape by passing in a vertex array. The maximal
+size of the array is controlled by `b2_maxPolygonVertices` which has a
+default value of 8. This is sufficient to describe most convex polygons.
+
+The `b2PolygonShape::Set` function automatically computes the convex hull
+and establishes the proper winding order. This function is fast when the
+number of vertices is low. If you increase `b2_maxPolygonVertices`, then
+the convex hull computation might become slow. Also note that the convex
+hull function may eliminate and/or re-order the points you provide.
+Vertices that are closer than `b2_linearSlop` may be merged.
+
+```cpp
+// This defines a triangle in CCW order.
+b2Vec2 vertices[3];
+vertices[0].Set(0.0f, 0.0f);
+vertices[1].Set(1.0f, 0.0f);
+vertices[2].Set(0.0f, 1.0f);
+
+int32 count = 3;
+b2PolygonShape polygon;
+polygon.Set(vertices, count);
+```
+
+The polygon shape has some convenience functions to create boxes.
+
+```cpp
+void SetAsBox(float hx, float hy);
+void SetAsBox(float hx, float hy, const b2Vec2& center, float angle);
+```
+
+Polygons inherit a radius from b2Shape. The radius creates a skin around
+the polygon. The skin is used in stacking scenarios to keep polygons
+slightly separated. This allows continuous collision to work against the
+core polygon.
+
+![Polygon Skin](images/skinned_polygon.svg)
+
+The polygon skin helps prevent tunneling by keeping the polygons
+separated. This results in small gaps between the shapes. Your visual
+representation can be larger than the polygon to hide any gaps.
+
+![Skin Collision](images/skin_collision.svg)
+
+Not that polygon skin is only provided to help with continuous collision.
+The purpose is not to simulate rounded polygons.
+
+### Edge Shapes
+Edge shapes are line segments. These are provided to assist in making a
+free-form static environment for your game. A major limitation of edge
+shapes is that they can collide with circles and polygons but not with
+themselves. The collision algorithms used by Box2D require that at least
+one of two colliding shapes have volume. Edge shapes have no volume, so
+edge-edge collision is not possible.
+
+```cpp
+// This an edge shape.
+b2Vec2 v1(0.0f, 0.0f);
+b2Vec2 v2(1.0f, 0.0f);
+
+b2EdgeShape edge;
+edge.SetTwoSided(v1, v2);
+```
+
+In many cases a game environment is constructed by connecting several
+edge shapes end-to-end. This can give rise to an unexpected artifact
+when a polygon slides along the chain of edges. In the figure below we
+see a box colliding with an internal vertex. These *ghost* collisions
+are caused when the polygon collides with an internal vertex generating
+an internal collision normal.
+
+![Ghost Collision](images/ghost_collision.svg)
+
+If edge1 did not exist this collision would seem fine. With edge1
+present, the internal collision seems like a bug. But normally when
+Box2D collides two shapes, it views them in isolation.
+
+Fortunately, the edge shape provides a mechanism for eliminating ghost
+collisions by storing the adjacent *ghost* vertices. Box2D uses these
+ghost vertices to prevent internal collisions.
+
+![Ghost Vertices](images/ghost_vertices.svg)
+
+The Box2D algorithm for dealing with ghost collisions only supports
+one-sided collision. The front face is to the right when looking from the first
+vertex towards the second vertex. This matches the CCW winding order
+used by polygons.
+
+```cpp
+// This is an edge shape with ghost vertices.
+b2Vec2 v0(1.7f, 0.0f);
+b2Vec2 v1(1.0f, 0.25f);
+b2Vec2 v2(0.0f, 0.0f);
+b2Vec2 v3(-1.7f, 0.4f);
+
+b2EdgeShape edge;
+edge.SetOneSided(v0, v1, v2, v3);
+```
+
+In general stitching edges together this way is a bit wasteful and
+tedious. This brings us to chain shapes.
+
+### Chain Shapes
+
+The chain shape provides an efficient way to connect many edges together
+to construct your static game worlds. Chain shapes automatically
+eliminate ghost collisions and provide one-sided collision. The collision is
+one-sided to eliminate ghost collisions.
+
+If you don't care about ghost collisions, you can just create a bunch of
+two-sided edge shapes. The efficiency is similar.
+
+The simplest way to use chain shapes is to create loops. Simply provide an
+array of vertices.
+
+```cpp
+b2Vec2 vs[4];
+vs[0].Set(1.7f, 0.0f);
+vs[1].Set(1.0f, 0.25f);
+vs[2].Set(0.0f, 0.0f);
+vs[3].Set(-1.7f, 0.4f);
+
+b2ChainShape chain;
+chain.CreateLoop(vs, 4);
+```
+
+The edge normal depends on the winding order. A counter-clockwise winding order orients the normal outwards and a clockwise winding order orients the normal inwards.
+
+![Chain Shape Outwards Loop](images/chain_loop_outwards.svg)
+
+![Chain Shape Inwards Loop](images/chain_loop_inwards.svg)
+
+You may have a scrolling game world and would like to connect several chains together.
+You can connect chains together using ghost vertices, like we did with b2EdgeShape.
+
+![Chain Shape](images/chain_shape.svg)
+
+```cpp
+b2ChainShape::CreateChain(const b2Vec2* vertices, int32 count,
+ const b2Vec2& prevVertex, const b2Vec2& nextVertex);
+```
+
+Self-intersection of chain shapes is not supported. It might work, it
+might not. The code that prevents ghost collisions assumes there are no
+self-intersections of the chain. Also, very close vertices can cause
+problems. Make sure all your edges are longer than b2_linearSlop (5mm).
+
+![Self Intersection is Bad](images/self_intersect.svg)
+
+Each edge in the chain is treated as a child shape and can be accessed
+by index. When a chain shape is connected to a body, each edge gets its
+own bounding box in the broad-phase collision tree.
+
+```cpp
+// Visit each child edge.
+for (int32 i = 0; i \< chain.GetChildCount(); ++i)
+{
+ b2EdgeShape edge;
+ chain.GetChildEdge(&edge, i);
+
+ ...
+}
+```
+
+## Geometric Queries
+You can perform a couple geometric queries on a single shape.
+
+### Shape Point Test
+You can test a point for overlap with a shape. You provide a transform
+for the shape and a world point.
+
+```cpp
+b2Transform transform;
+transform.SetIdentity();
+b2Vec2 point(5.0f, 2.0f);
+
+bool hit = shape->TestPoint(transform, point);
+```
+
+Edge and chain shapes always return false, even if the chain is a loop.
+
+### Shape Ray Cast
+You can cast a ray at a shape to get the point of first intersection and normal vector. A child index is included for chain shapes because the ray cast will only check a single edge at a time.
+
+> **Caution**:
+> No hit will register if the ray starts inside a convex shape like a circle or polygon. This is consistent with Box2D treating convex shapes as solid.
+>
+
+```cpp
+b2Transfrom transform;
+transform.SetIdentity();
+
+b2RayCastInput input;
+input.p1.Set(0.0f, 0.0f);
+input.p2.Set(1.0f, 0.0f);
+input.maxFraction = 1.0f;
+int32 childIndex = 0;
+
+b2RayCastOutput output;
+bool hit = shape->RayCast(&output, input, transform, childIndex);
+
+if (hit)
+{
+ b2Vec2 hitPoint = input.p1 + output.fraction * (input.p2 -- input.p1);
+ ...
+}
+```
+
+## Pairwise Functions
+The Collision module contains functions that take a pair of shapes and compute some results. These include:
+- Overlap
+- Contact manifolds
+- Distance
+- Time of impact
+
+### Overlap
+You can test two shapes for overlap using this function:
+
+```cpp
+b2Transform xfA = ..., xfB = ...;
+bool overlap = b2TestOverlap(shapeA, indexA, shapeB, indexB, xfA, xfB);
+```
+
+Again you must provide child indices to for the case of chain shapes.
+
+### Contact Manifolds
+Box2D has functions to compute contact points for overlapping shapes. If
+we consider circle-circle or circle-polygon, we can only get one contact
+point and normal. In the case of polygon-polygon we can get two points.
+These points share the same normal vector so Box2D groups them into a
+manifold structure. The contact solver takes advantage of this to
+improve stacking stability.
+
+![Contact Manifold](images/manifolds.svg)
+
+Normally you don't need to compute contact manifolds directly, however
+you will likely use the results produced in the simulation.
+
+The b2Manifold structure holds a normal vector and up to two contact
+points. The normal and points are held in local coordinates. As a
+convenience for the contact solver, each point stores the normal and
+tangential (friction) impulses.
+
+The data stored in b2Manifold is optimized for internal use. If you need
+this data, it is usually best to use the b2WorldManifold structure to
+generate the world coordinates of the contact normal and points. You
+need to provide a b2Manifold and the shape transforms and radii.
+
+```cpp
+b2WorldManifold worldManifold;
+worldManifold.Initialize(&manifold, transformA, shapeA.m_radius,
+transformB, shapeB.m_radius);
+
+for (int32 i = 0; i \< manifold.pointCount; ++i)
+{
+ b2Vec2 point = worldManifold.points[i];
+ ...
+}
+```
+
+Notice that the world manifold uses the point count from the original
+manifold.
+
+During simulation shapes may move and the manifolds may change. Points
+may be added or removed. You can detect this using b2GetPointStates.
+
+```cpp
+b2PointState state1[2], state2[2];
+b2GetPointStates(state1, state2, &manifold1, &manifold2);
+
+if (state1[0] == b2_removeState)
+{
+ // process event
+}
+```
+
+### Distance
+The `b2Distance` function can be used to compute the distance between two
+shapes. The distance function needs both shapes to be converted into a
+b2DistanceProxy. There is also some caching used to warm start the
+distance function for repeated calls.
+
+![Distance Function](images/distance.svg)
+
+### Time of Impact
+If two shapes are moving fast, they may *tunnel* through each other in a
+single time step.
+
+![Tunneling](images/tunneling2.svg)
+
+The `b2TimeOfImpact` function is used to determine the time when two
+moving shapes collide. This is called the *time of impact* (TOI). The
+main purpose of `b2TimeOfImpact` is for tunnel prevention. In particular,
+it is designed to prevent moving objects from tunneling outside of
+static level geometry.
+
+This function accounts for rotation and translation of both shapes,
+however if the rotations are large enough, then the function may miss a
+collision. However the function will still report a non-overlapped time
+and will capture all translational collisions.
+
+The time of impact function identities an initial separating axis and
+ensures the shapes do not cross on that axis. This might miss collisions
+that are clear at the final positions. While this approach may miss some
+collisions, it is very fast and adequate for tunnel prevention.
+
+![Captured Collision](images/captured_toi.svg)
+
+![Missed Collision](images/missed_toi.svg)
+
+It is difficult to put a restriction on the rotation magnitude. There
+may be cases where collisions are missed for small rotations. Normally,
+these missed rotational collisions should not harm game play. They tend
+to be glancing collisions.
+
+The function requires two shapes (converted to b2DistanceProxy) and two
+b2Sweep structures. The sweep structure defines the initial and final
+transforms of the shapes.
+
+You can use fixed rotations to perform a *shape cast*. In this case, the
+time of impact function will not miss any collisions.
+
+## Dynamic Tree
+The b2DynamicTree class is used by Box2D to organize large numbers of
+shapes efficiently. The class does not know about shapes. Instead it
+operates on axis-aligned bounding boxes (AABBs) with user data pointers.
+
+The dynamic tree is a hierarchical AABB tree. Each internal node in the
+tree has two children. A leaf node is a single user AABB. The tree uses
+rotations to keep the tree balanced, even in the case of degenerate
+input.
+
+The tree structure allows for efficient ray casts and region queries.
+For example, you may have hundreds of shapes in your scene. You could
+perform a ray cast against the scene in a brute force manner by ray
+casting each shape. This would be inefficient because it does not take
+advantage of shapes being spread out. Instead, you can maintain a
+dynamic tree and perform ray casts against the tree. This traverses the
+ray through the tree skipping large numbers of shapes.
+
+A region query uses the tree to find all leaf AABBs that overlap a query
+AABB. This is faster than a brute force approach because many shapes can
+be skipped.
+
+![Raycast](images/raycast.svg)
+
+![Overlap Test](images/overlap_test.svg)
+
+Normally you will not use the dynamic tree directly. Rather you will go
+through the b2World class for ray casts and region queries. If you plan
+to instantiate your own dynamic tree, you can learn how to use it by
+looking at how Box2D uses it.
+
+## Broad-phase
+Collision processing in a physics step can be divided into narrow-phase
+and broad-phase. In the narrow-phase we compute contact points between
+pairs of shapes. Imagine we have N shapes. Using brute force, we would
+need to perform the narrow-phase for N*N/2 pairs.
+
+The b2BroadPhase class reduces this load by using a dynamic tree for
+pair management. This greatly reduces the number of narrow-phase calls.
+
+Normally you do not interact with the broad-phase directly. Instead,
+Box2D creates and manages a broad-phase internally. Also, b2BroadPhase
+is designed with Box2D's simulation loop in mind, so it is likely not
+suited for other use cases.
diff --git a/Client/ThirdParty/Box2D/docs/common.md b/Client/ThirdParty/Box2D/docs/common.md
new file mode 100644
index 0000000..0534ff7
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/common.md
@@ -0,0 +1,66 @@
+# Common Module
+The Common module contains settings, memory management, and vector math.
+
+## Settings
+The header b2Settings.h contains:
+- Types such as int32 and float
+- Constants
+- Allocation wrappers
+- The version number
+
+### Types
+Box2D defines various types such as int8, etc. to make it easy
+to determine the size of structures.
+
+### Constants
+Box2D defines several constants. These are all documented in
+b2Settings.h. Normally you do not need to adjust these constants.
+
+Box2D uses floating point math for collision and simulation. Due to
+round-off error some numerical tolerances are defined. Some tolerances
+are absolute and some are relative. Absolute tolerances use MKS units.
+
+### Allocation wrappers
+The settings file defines b2Alloc and b2Free for large allocations. You
+may forward these calls to your own memory management system.
+
+### Version
+The b2Version structure holds the current version so you can query this
+at run-time.
+
+## Memory Management
+A large number of the decisions about the design of Box2D were based on
+the need for quick and efficient use of memory. In this section I will
+discuss how and why Box2D allocates memory.
+
+Box2D tends to allocate a large number of small objects (around 50-300
+bytes). Using the system heap through malloc or new for small objects is
+inefficient and can cause fragmentation. Many of these small objects may
+have a short life span, such as contacts, but can persist for several
+time steps. So we need an allocator that can efficiently provide heap
+memory for these objects.
+
+Box2D's solution is to use a small object allocator (SOA) called
+b2BlockAllocator. The SOA keeps a number of growable pools of varying
+sizes. When a request is made for memory, the SOA returns a block of
+memory that best fits the requested size. When a block is freed, it is
+returned to the pool. Both of these operations are fast and cause little
+heap traffic.
+
+Since Box2D uses a SOA, you should never new or malloc a body, fixture,
+or joint. However, you do have to allocate a b2World on your own. The
+b2World class provides factories for you to create bodies, fixtures, and
+joints. This allows Box2D to use the SOA and hide the gory details from
+you. Never, call delete or free on a body, fixture, or joint.
+
+While executing a time step, Box2D needs some temporary workspace
+memory. For this, it uses a stack allocator called b2StackAllocator to
+avoid per-step heap allocations. You don't need to interact with the
+stack allocator, but it's good to know it's there.
+
+## Math
+Box2D includes a simple small vector and matrix module. This has been
+designed to suit the internal needs of Box2D and the API. All the
+members are exposed, so you may use them freely in your application.
+
+The math library is kept simple to make Box2D easy to port and maintain.
diff --git a/Client/ThirdParty/Box2D/docs/copycss.sh b/Client/ThirdParty/Box2D/docs/copycss.sh
new file mode 100644
index 0000000..989a774
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/copycss.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+cp *.css ../build/docs/html/
diff --git a/Client/ThirdParty/Box2D/docs/dynamics.md b/Client/ThirdParty/Box2D/docs/dynamics.md
new file mode 100644
index 0000000..e8b45fc
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/dynamics.md
@@ -0,0 +1,1674 @@
+# Dynamics Module
+The Dynamics module is the most complex part of Box2D and is the part
+you likely interact with the most. The Dynamics module sits on top of
+the Common and Collision modules, so you should be somewhat familiar
+with those by now.
+
+The Dynamics module contains:
+- fixture class
+- rigid body class
+- contact class
+- joint classes
+- world class
+- listener classes
+
+There are many dependencies between these classes so it is difficult to
+describe one class without referring to another. In the following, you
+may see some references to classes that have not been described yet.
+Therefore, you may want to quickly skim this chapter before reading it
+closely.
+
+The dynamics module is covered in the following chapters.
+
+## Bodies
+Bodies have position and velocity. You can apply forces, torques, and
+impulses to bodies. Bodies can be static, kinematic, or dynamic. Here
+are the body type definitions:
+
+#### b2_staticBody
+A static body does not move under simulation and behaves as if it has
+infinite mass. Internally, Box2D stores zero for the mass and the
+inverse mass. Static bodies can be moved manually by the user. A static
+body has zero velocity. Static bodies do not collide with other static
+or kinematic bodies.
+
+#### b2_kinematicBody
+A kinematic body moves under simulation according to its velocity.
+Kinematic bodies do not respond to forces. They can be moved manually by
+the user, but normally a kinematic body is moved by setting its
+velocity. A kinematic body behaves as if it has infinite mass, however,
+Box2D stores zero for the mass and the inverse mass. Kinematic bodies do
+not collide with other kinematic or static bodies.
+
+#### b2_dynamicBody
+A dynamic body is fully simulated. They can be moved manually by the
+user, but normally they move according to forces. A dynamic body can
+collide with all body types. A dynamic body always has finite, non-zero
+mass. If you try to set the mass of a dynamic body to zero, it will
+automatically acquire a mass of one kilogram and it won't rotate.
+
+Bodies are the backbone for fixtures (shapes). Bodies carry fixtures and
+move them around in the world. Bodies are always rigid bodies in Box2D.
+That means that two fixtures attached to the same rigid body never move
+relative to each other and fixtures attached to the same body don't
+collide.
+
+Fixtures have collision geometry and density. Normally, bodies acquire
+their mass properties from the fixtures. However, you can override the
+mass properties after a body is constructed.
+
+You usually keep pointers to all the bodies you create. This way you can
+query the body positions to update the positions of your graphical
+entities. You should also keep body pointers so you can destroy them
+when you are done with them.
+
+### Body Definition
+Before a body is created you must create a body definition (b2BodyDef).
+The body definition holds the data needed to create and initialize a
+body.
+
+Box2D copies the data out of the body definition; it does not keep a
+pointer to the body definition. This means you can recycle a body
+definition to create multiple bodies.
+
+Let's go over some of the key members of the body definition.
+
+### Body Type
+As discussed at the beginning of this chapter, there are three different
+body types: static, kinematic, and dynamic. You should establish the
+body type at creation because changing the body type later is expensive.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.type = b2_dynamicBody;
+```
+
+Setting the body type is mandatory.
+
+### Position and Angle
+The body definition gives you the chance to initialize the position of
+the body on creation. This has far better performance than creating the
+body at the world origin and then moving the body.
+
+> **Caution**:
+> Do not create a body at the origin and then move it. If you create
+> several bodies at the origin, then performance will suffer.
+
+A body has two main points of interest. The first point is the body's
+origin. Fixtures and joints are attached relative to the body's origin.
+The second point of interest is the center of mass. The center of mass
+is determined from mass distribution of the attached shapes or is
+explicitly set with b2MassData. Much of Box2D's internal computations
+use the center of mass position. For example b2Body stores the linear
+velocity for the center of mass.
+
+When you are building the body definition, you may not know where the
+center of mass is located. Therefore you specify the position of the
+body's origin. You may also specify the body's angle in radians, which
+is not affected by the position of the center of mass. If you later
+change the mass properties of the body, then the center of mass may move
+on the body, but the origin position does not change and the attached
+shapes and joints do not move.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.position.Set(0.0f, 2.0f); // the body's origin position.
+bodyDef.angle = 0.25f * b2_pi; // the body's angle in radians.
+```
+
+A rigid body is also a frame of reference. You can define fixtures and
+joints in that frame. Those fixtures and joint anchors never move in the
+local frame of the body.
+
+### Damping
+Damping is used to reduce the world velocity of bodies. Damping is
+different than friction because friction only occurs with contact.
+Damping is not a replacement for friction and the two effects should be
+used together.
+
+Damping parameters should be between 0 and infinity, with 0 meaning no
+damping, and infinity meaning full damping. Normally you will use a
+damping value between 0 and 0.1. I generally do not use linear damping
+because it makes bodies look like they are floating.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.linearDamping = 0.0f;
+bodyDef.angularDamping = 0.01f;
+```
+
+Damping is approximated for stability and performance. At small damping
+values the damping effect is mostly independent of the time step. At
+larger damping values, the damping effect will vary with the time step.
+This is not an issue if you use a fixed time step (recommended).
+
+### Gravity Scale
+You can use the gravity scale to adjust the gravity on a single body. Be
+careful though, increased gravity can decrease stability.
+
+```cpp
+// Set the gravity scale to zero so this body will float
+b2BodyDef bodyDef;
+bodyDef.gravityScale = 0.0f;
+```
+
+### Sleep Parameters
+What does sleep mean? Well it is expensive to simulate bodies, so the
+less we have to simulate the better. When a body comes to rest we would
+like to stop simulating it.
+
+When Box2D determines that a body (or group of bodies) has come to rest,
+the body enters a sleep state which has very little CPU overhead. If a
+body is awake and collides with a sleeping body, then the sleeping body
+wakes up. Bodies will also wake up if a joint or contact attached to
+them is destroyed. You can also wake a body manually.
+
+The body definition lets you specify whether a body can sleep and
+whether a body is created sleeping.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.allowSleep = true;
+bodyDef.awake = true;
+```
+
+### Fixed Rotation
+You may want a rigid body, such as a character, to have a fixed
+rotation. Such a body should not rotate, even under load. You can use
+the fixed rotation setting to achieve this:
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.fixedRotation = true;
+```
+
+The fixed rotation flag causes the rotational inertia and its inverse to
+be set to zero.
+
+### Bullets
+Game simulation usually generates a sequence of images that are played
+at some frame rate. This is called discrete simulation. In discrete
+simulation, rigid bodies can move by a large amount in one time step. If
+a physics engine doesn't account for the large motion, you may see some
+objects incorrectly pass through each other. This effect is called
+tunneling.
+
+By default, Box2D uses continuous collision detection (CCD) to prevent
+dynamic bodies from tunneling through static bodies. This is done by
+sweeping shapes from their old position to their new positions. The
+engine looks for new collisions during the sweep and computes the time
+of impact (TOI) for these collisions. Bodies are moved to their first
+TOI and then the solver performs a sub-step to complete the full time
+step. There may be additional TOI events within a sub-step.
+
+Normally CCD is not used between dynamic bodies. This is done to keep
+performance reasonable. In some game scenarios you need dynamic bodies
+to use CCD. For example, you may want to shoot a high speed bullet at a
+stack of dynamic bricks. Without CCD, the bullet might tunnel through
+the bricks.
+
+Fast moving objects in Box2D can be labeled as bullets. Bullets will
+perform CCD with both static and dynamic bodies. You should decide what
+bodies should be bullets based on your game design. If you decide a body
+should be treated as a bullet, use the following setting.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.bullet = true;
+```
+
+The bullet flag only affects dynamic bodies.
+
+### Activation
+You may wish a body to be created but not participate in collision or
+dynamics. This state is similar to sleeping except the body will not be
+woken by other bodies and the body's fixtures will not be placed in the
+broad-phase. This means the body will not participate in collisions, ray
+casts, etc.
+
+You can create a body in an inactive state and later re-activate it.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.active = true;
+```
+
+Joints may be connected to inactive bodies. These joints will not be
+simulated. You should be careful when you activate a body that its
+joints are not distorted.
+
+Note that activating a body is almost as expensive as creating the body
+from scratch. So you should not use activation for streaming worlds. Use
+creation/destruction for streaming worlds to save memory.
+
+### User Data
+User data is a void pointer. This gives you a hook to link your
+application objects to bodies. You should be consistent to use the same
+object type for all body user data.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.userData.pointer = reinterpret_cast<uintptr_t>(&myActor);
+```
+
+### Body Factory
+Bodies are created and destroyed using a body factory provided by the
+world class. This lets the world create the body with an efficient
+allocator and add the body to the world data structure.
+
+```cpp
+b2World* myWorld;
+b2Body* dynamicBody = myWorld->CreateBody(&bodyDef);
+
+// ... do stuff ...
+
+myWorld->DestroyBody(dynamicBody);
+dynamicBody = nullptr;
+```
+
+> **Caution**:
+> You should never use new or malloc to create a body. The world won't
+> know about the body and the body won't be properly initialized.
+
+Box2D does not keep a reference to the body definition or any of the
+data it holds (except user data pointers). So you can create temporary
+body definitions and reuse the same body definitions.
+
+Box2D allows you to avoid destroying bodies by deleting your b2World
+object, which does all the cleanup work for you. However, you should be
+mindful to nullify body pointers that you keep in your game engine.
+
+When you destroy a body, the attached fixtures and joints are
+automatically destroyed. This has important implications for how you
+manage shape and joint pointers.
+
+### Using a Body
+After creating a body, there are many operations you can perform on the
+body. These include setting mass properties, accessing position and
+velocity, applying forces, and transforming points and vectors.
+
+### Mass Data
+A body has mass (scalar), center of mass (2-vector), and rotational
+inertia (scalar). For static bodies, the mass and rotational inertia are
+set to zero. When a body has fixed rotation, its rotational inertia is
+zero.
+
+Normally the mass properties of a body are established automatically
+when fixtures are added to the body. You can also adjust the mass of a
+body at run-time. This is usually done when you have special game
+scenarios that require altering the mass.
+
+```cpp
+void b2Body::SetMassData(const b2MassData* data);
+```
+
+After setting a body's mass directly, you may wish to revert to the
+natural mass dictated by the fixtures. You can do this with:
+
+```cpp
+void b2Body::ResetMassData();
+```
+
+The body's mass data is available through the following functions:
+
+```cpp
+float b2Body::GetMass() const;
+float b2Body::GetInertia() const;
+const b2Vec2& b2Body::GetLocalCenter() const;
+void b2Body::GetMassData(b2MassData* data) const;
+```
+
+### State Information
+There are many aspects to the body's state. You can access this state
+data efficiently through the following functions:
+
+```cpp
+void b2Body::SetType(b2BodyType type);
+b2BodyType b2Body::GetType();
+void b2Body::SetBullet(bool flag);
+bool b2Body::IsBullet() const;
+void b2Body::SetSleepingAllowed(bool flag);
+bool b2Body::IsSleepingAllowed() const;
+void b2Body::SetAwake(bool flag);
+bool b2Body::IsAwake() const;
+void b2Body::SetEnabled(bool flag);
+bool b2Body::IsEnabled() const;
+void b2Body::SetFixedRotation(bool flag);
+bool b2Body::IsFixedRotation() const;
+```
+
+### Position and Velocity
+You can access the position and rotation of a body. This is common when
+rendering your associated game actor. You can also set the position,
+although this is less common since you will normally use Box2D to
+simulate movement.
+
+```cpp
+bool b2Body::SetTransform(const b2Vec2& position, float angle);
+const b2Transform& b2Body::GetTransform() const;
+const b2Vec2& b2Body::GetPosition() const;
+float b2Body::GetAngle() const;
+```
+
+You can access the center of mass position in local and world
+coordinates. Much of the internal simulation in Box2D uses the center of
+mass. However, you should normally not need to access it. Instead you
+will usually work with the body transform. For example, you may have a
+body that is square. The body origin might be a corner of the square,
+while the center of mass is located at the center of the square.
+
+```cpp
+const b2Vec2& b2Body::GetWorldCenter() const;
+const b2Vec2& b2Body::GetLocalCenter() const;
+```
+
+You can access the linear and angular velocity. The linear velocity is
+for the center of mass. Therefore, the linear velocity may change if the
+mass properties change.
+
+### Forces and Impulses
+You can apply forces, torques, and impulses to a body. When you apply a
+force or an impulse, you provide a world point where the load is
+applied. This often results in a torque about the center of mass.
+
+```cpp
+void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point);
+void b2Body::ApplyTorque(float torque);
+void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point);
+void b2Body::ApplyAngularImpulse(float impulse);
+```
+
+Applying a force, torque, or impulse wakes the body. Sometimes this is
+undesirable. For example, you may be applying a steady force and want to
+allow the body to sleep to improve performance. In this case you can use
+the following code.
+
+```cpp
+if (myBody->IsAwake() == true)
+{
+ myBody->ApplyForce(myForce, myPoint);
+}
+```
+
+### Coordinate Transformations
+The body class has some utility functions to help you transform points
+and vectors between local and world space. If you don't understand
+these concepts, please read \"Essential Mathematics for Games and
+Interactive Applications\" by Jim Van Verth and Lars Bishop. These
+functions are efficient (when inlined).
+
+```cpp
+b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint);
+b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector);
+b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint);
+b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector);
+```
+
+### Acessing Fixtures, Joints, and Contacts
+You can iterate over a body's fixtures. This is mainly useful if you
+need to access the fixture's user data.
+
+```cpp
+for (b2Fixture* f = body->GetFixtureList(); f; f = f->GetNext())
+{
+ MyFixtureData* data = (MyFixtureData*)f->GetUserData();
+ // do something with data ...
+}
+```
+
+You can similarly iterate over the body's joint list.
+
+The body also provides a list of associated contacts. You can use this
+to get information about the current contacts. Be careful, because the
+contact list may not contain all the contacts that existed during the
+previous time step.
+
+## Fixtures
+Recall that shapes don't know about bodies and may be used independently
+of the physics simulation. Therefore Box2D provides the b2Fixture class
+to attach shapes to bodies. A body may have zero or more fixtures. A
+body with multiple fixtures is sometimes called a *compound body.*
+
+Fixtures hold the following:
+- a single shape
+- broad-phase proxies
+- density, friction, and restitution
+- collision filtering flags
+- back pointer to the parent body
+- user data
+- sensor flag
+
+These are described in the following sections.
+
+### Fixture Creation
+Fixtures are created by initializing a fixture definition and then
+passing the definition to the parent body.
+
+```cpp
+b2Body* myBody;
+b2FixtureDef fixtureDef;
+fixtureDef.shape = &myShape;
+fixtureDef.density = 1.0f;
+b2Fixture* myFixture = myBody->CreateFixture(&fixtureDef);
+```
+
+This creates the fixture and attaches it to the body. You do not need to
+store the fixture pointer since the fixture will automatically be
+destroyed when the parent body is destroyed. You can create multiple
+fixtures on a single body.
+
+You can destroy a fixture on the parent body. You may do this to model a
+breakable object. Otherwise you can just leave the fixture alone and let
+the body destruction take care of destroying the attached fixtures.
+
+```cpp
+myBody->DestroyFixture(myFixture);
+```
+
+### Density
+The fixture density is used to compute the mass properties of the parent
+body. The density can be zero or positive. You should generally use
+similar densities for all your fixtures. This will improve stacking
+stability.
+
+The mass of a body is not adjusted when you set the density. You must
+call ResetMassData for this to occur.
+
+```cpp
+b2Fixture* fixture;
+fixture->SetDensity(5.0f);
+b2Body*
+body->ResetMassData();
+```
+
+### Friction
+Friction is used to make objects slide along each other realistically.
+Box2D supports static and dynamic friction, but uses the same parameter
+for both. Friction is simulated accurately in Box2D and the friction
+strength is proportional to the normal force (this is called Coulomb
+friction). The friction parameter is usually set between 0 and 1, but
+can be any non-negative value. A friction value of 0 turns off friction
+and a value of 1 makes the friction strong. When the friction force is
+computed between two shapes, Box2D must combine the friction parameters
+of the two parent fixtures. This is done with the geometric mean:
+
+```cpp
+b2Fixture* fixtureA;
+b2Fixture* fixtureB;
+float friction;
+friction = sqrtf(fixtureA->friction * fixtureB->friction);
+```
+
+So if one fixture has zero friction then the contact will have zero
+friction.
+
+You can override the default mixed friction using
+`b2Contact::SetFriction`. This is usually done in the `b2ContactListener`
+callback.
+
+### Restitution
+Restitution is used to make objects bounce. The restitution value is
+usually set to be between 0 and 1. Consider dropping a ball on a table.
+A value of zero means the ball won't bounce. This is called an
+inelastic collision. A value of one means the ball's velocity will be
+exactly reflected. This is called a perfectly elastic collision.
+Restitution is combined using the following formula.
+
+```cpp
+b2Fixture* fixtureA;
+b2Fixture* fixtureB;
+float restitution;
+restitution = b2Max(fixtureA->restitution, fixtureB->restitution);
+```
+
+Restitution is combined this way so that you can have a bouncy super
+ball without having a bouncy floor.
+
+You can override the default mixed restitution using
+`b2Contact::SetRestitution`. This is usually done in the b2ContactListener
+callback.
+
+When a shape develops multiple contacts, restitution is simulated
+approximately. This is because Box2D uses an iterative solver. Box2D
+also uses inelastic collisions when the collision velocity is small.
+This is done to prevent jitter. See `b2_velocityThreshold`.
+
+### Filtering
+Collision filtering allows you to prevent collision between fixtures.
+For example, say you make a character that rides a bicycle. You want the
+bicycle to collide with the terrain and the character to collide with
+the terrain, but you don't want the character to collide with the
+bicycle (because they must overlap). Box2D supports such collision
+filtering using categories and groups.
+
+Box2D supports 16 collision categories. For each fixture you can specify
+which category it belongs to. You also specify what other categories
+this fixture can collide with. For example, you could specify in a
+multiplayer game that all players don't collide with each other and
+monsters don't collide with each other, but players and monsters should
+collide. This is done with masking bits. For example:
+
+```cpp
+b2FixtureDef playerFixtureDef, monsterFixtureDef;
+playerFixtureDef.filter.categoryBits = 0x0002;
+monsterFixtureDef.filter.categoryBits = 0x0004;
+playerFixtureDef.filter.maskBits = 0x0004;
+monsterFixtureDef.filter.maskBits = 0x0002;
+```
+
+Here is the rule for a collision to occur:
+
+```cpp
+uint16 catA = fixtureA.filter.categoryBits;
+uint16 maskA = fixtureA.filter.maskBits;
+uint16 catB = fixtureB.filter.categoryBits;
+uint16 maskB = fixtureB.filter.maskBits;
+
+if ((catA & maskB) != 0 && (catB & maskA) != 0)
+{
+ // fixtures can collide
+}
+```
+
+Collision groups let you specify an integral group index. You can have
+all fixtures with the same group index always collide (positive index)
+or never collide (negative index). Group indices are usually used for
+things that are somehow related, like the parts of a bicycle. In the
+following example, fixture1 and fixture2 always collide, but fixture3
+and fixture4 never collide.
+
+```cpp
+fixture1Def.filter.groupIndex = 2;
+fixture2Def.filter.groupIndex = 2;
+fixture3Def.filter.groupIndex = -8;
+fixture4Def.filter.groupIndex = -8;
+```
+
+Collisions between fixtures of different group indices are filtered
+according the category and mask bits. In other words, group filtering
+has higher precedence than category filtering.
+
+Note that additional collision filtering occurs in Box2D. Here is a
+list:
+- A fixture on a static body can only collide with a dynamic body.
+- A fixture on a kinematic body can only collide with a dynamic body.
+- Fixtures on the same body never collide with each other.
+- You can optionally enable/disable collision between fixtures on bodies connected by a joint.
+
+Sometimes you might need to change collision filtering after a fixture
+has already been created. You can get and set the b2Filter structure on
+an existing fixture using b2Fixture::GetFilterData and
+b2Fixture::SetFilterData. Note that changing the filter data will not
+add or remove contacts until the next time step (see the World class).
+
+### Sensors
+Sometimes game logic needs to know when two fixtures overlap yet there
+should be no collision response. This is done by using sensors. A sensor
+is a fixture that detects collision but does not produce a response.
+
+You can flag any fixture as being a sensor. Sensors may be static,
+kinematic, or dynamic. Remember that you may have multiple fixtures per
+body and you can have any mix of sensors and solid fixtures. Also,
+sensors only form contacts when at least one body is dynamic, so you
+will not get a contact for kinematic versus kinematic, kinematic versus
+static, or static versus static.
+
+Sensors do not generate contact points. There are two ways to get the
+state of a sensor:
+1. `b2Contact::IsTouching`
+2. `b2ContactListener::BeginContact` and `b2ContactListener::EndContact`
+
+## Joints
+Joints are used to constrain bodies to the world or to each other.
+Typical examples in games include ragdolls, teeters, and pulleys. Joints
+can be combined in many different ways to create interesting motions.
+
+Some joints provide limits so you can control the range of motion. Some
+joint provide motors which can be used to drive the joint at a
+prescribed speed until a prescribed force/torque is exceeded.
+
+Joint motors can be used in many ways. You can use motors to control
+position by specifying a joint velocity that is proportional to the
+difference between the actual and desired position. You can also use
+motors to simulate joint friction: set the joint velocity to zero and
+provide a small, but significant maximum motor force/torque. Then the
+motor will attempt to keep the joint from moving until the load becomes
+too strong.
+
+### Joint Definition
+Each joint type has a definition that derives from b2JointDef. All
+joints are connected between two different bodies. One body may static.
+Joints between static and/or kinematic bodies are allowed, but have no
+effect and use some processing time.
+
+You can specify user data for any joint type and you can provide a flag
+to prevent the attached bodies from colliding with each other. This is
+actually the default behavior and you must set the collideConnected
+Boolean to allow collision between to connected bodies.
+
+Many joint definitions require that you provide some geometric data.
+Often a joint will be defined by anchor points. These are points fixed
+in the attached bodies. Box2D requires these points to be specified in
+local coordinates. This way the joint can be specified even when the
+current body transforms violate the joint constraint \-\-- a common
+occurrence when a game is saved and reloaded. Additionally, some joint
+definitions need to know the default relative angle between the bodies.
+This is necessary to constrain rotation correctly.
+
+Initializing the geometric data can be tedious, so many joints have
+initialization functions that use the current body transforms to remove
+much of the work. However, these initialization functions should usually
+only be used for prototyping. Production code should define the geometry
+directly. This will make joint behavior more robust.
+
+The rest of the joint definition data depends on the joint type. We
+cover these now.
+
+### Joint Factory
+Joints are created and destroyed using the world factory methods. This
+brings up an old issue:
+
+> **Caution**:
+> Don't try to create a joint on the stack or on the heap using new or
+> malloc. You must create and destroy bodies and joints using the create
+> and destroy methods of the b2World class.
+
+Here's an example of the lifetime of a revolute joint:
+
+```cpp
+b2World* myWorld;
+b2RevoluteJointDef jointDef;
+jointDef.bodyA = myBodyA;
+jointDef.bodyB = myBodyB;
+jointDef.anchorPoint = myBodyA->GetCenterPosition();
+
+b2RevoluteJoint* joint = (b2RevoluteJoint*)myWorld->CreateJoint(&jointDef);
+
+// ... do stuff ...
+
+myWorld->DestroyJoint(joint);
+joint = nullptr;
+```
+
+It is always good to nullify your pointer after they are destroyed. This
+will make the program crash in a controlled manner if you try to reuse
+the pointer.
+
+The lifetime of a joint is not simple. Heed this warning well:
+
+> **Caution**:
+> Joints are destroyed when an attached body is destroyed.
+
+This precaution is not always necessary. You may organize your game
+engine so that joints are always destroyed before the attached bodies.
+In this case you don't need to implement the listener class. See the
+section on Implicit Destruction for details.
+
+### Using Joints
+Many simulations create the joints and don't access them again until
+they are destroyed. However, there is a lot of useful data contained in
+joints that you can use to create a rich simulation.
+
+First of all, you can get the bodies, anchor points, and user data from
+a joint.
+
+```cpp
+b2Body* b2Joint::GetBodyA();
+b2Body* b2Joint::GetBodyB();
+b2Vec2 b2Joint::GetAnchorA();
+b2Vec2 b2Joint::GetAnchorB();
+void* b2Joint::GetUserData();
+```
+
+All joints have a reaction force and torque. This the reaction force
+applied to body 2 at the anchor point. You can use reaction forces to
+break joints or trigger other game events. These functions may do some
+computations, so don't call them if you don't need the result.
+
+```cpp
+b2Vec2 b2Joint::GetReactionForce();
+float b2Joint::GetReactionTorque();
+```
+
+### Distance Joint
+One of the simplest joint is a distance joint which says that the
+distance between two points on two bodies must be constant. When you
+specify a distance joint the two bodies should already be in place. Then
+you specify the two anchor points in world coordinates. The first anchor
+point is connected to body 1, and the second anchor point is connected
+to body 2. These points imply the length of the distance constraint.
+
+![Distance Joint](images/distance_joint.gif)
+
+Here is an example of a distance joint definition. In this case we
+decide to allow the bodies to collide.
+
+```cpp
+b2DistanceJointDef jointDef;
+jointDef.Initialize(myBodyA, myBodyB, worldAnchorOnBodyA,
+worldAnchorOnBodyB);
+jointDef.collideConnected = true;
+```
+
+The distance joint can also be made soft, like a spring-damper
+connection. See the Web example in the testbed to see how this behaves.
+
+Softness is achieved by tuning two constants in the definition:
+stiffness and damping. It can be non-intuitive setting these values directly
+since they have units in terms on Newtons. Box2D provides and API to compute
+these values in terms of frequency and damping ratio.
+```cpp
+void b2LinearStiffness(float& stiffness, float& damping,
+ float frequencyHertz, float dampingRatio,
+ const b2Body* bodyA, const b2Body* bodyB);
+```
+
+Think of the frequency as the frequency of a harmonic oscillator (like a
+guitar string). The frequency is specified in Hertz. Typically the frequency
+should be less than a half the frequency of the time step. So if you are using
+a 60Hz time step, the frequency of the distance joint should be less than 30Hz.
+The reason is related to the Nyquist frequency.
+
+The damping ratio is non-dimensional and is typically between 0 and 1,
+but can be larger. At 1, the damping is critical (all oscillations
+should vanish).
+
+```cpp
+float frequencyHz = 4.0f;
+float dampingRatio = 0.5f;
+b2LinearStiffness(jointDef.stiffness, jointDef.damping, frequencyHz, dampingRatio, jointDef.bodyA, jointDef.bodyB);
+```
+
+It is also possible to define a minimum and maximum length for the distance joint.
+See `b2DistanceJointDef` for details.
+
+### Revolute Joint
+A revolute joint forces two bodies to share a common anchor point, often
+called a hinge point. The revolute joint has a single degree of freedom:
+the relative rotation of the two bodies. This is called the joint angle.
+
+![Revolute Joint](images/revolute_joint.gif)
+
+To specify a revolute you need to provide two bodies and a single anchor
+point in world space. The initialization function assumes that the
+bodies are already in the correct position.
+
+In this example, two bodies are connected by a revolute joint at the
+first body's center of mass.
+
+```cpp
+b2RevoluteJointDef jointDef;
+jointDef.Initialize(myBodyA, myBodyB, myBodyA->GetWorldCenter());
+```
+
+The revolute joint angle is positive when bodyB rotates CCW about the
+angle point. Like all angles in Box2D, the revolute angle is measured in
+radians. By convention the revolute joint angle is zero when the joint
+is created using Initialize(), regardless of the current rotation of the
+two bodies.
+
+In some cases you might wish to control the joint angle. For this, the
+revolute joint can optionally simulate a joint limit and/or a motor.
+
+A joint limit forces the joint angle to remain between a lower and upper
+bound. The limit will apply as much torque as needed to make this
+happen. The limit range should include zero, otherwise the joint will
+lurch when the simulation begins.
+
+A joint motor allows you to specify the joint speed (the time derivative
+of the angle). The speed can be negative or positive. A motor can have
+infinite force, but this is usually not desirable. Recall the eternal
+question:
+
+> *What happens when an irresistible force meets an immovable object?*
+
+I can tell you it's not pretty. So you can provide a maximum torque for
+the joint motor. The joint motor will maintain the specified speed
+unless the required torque exceeds the specified maximum. When the
+maximum torque is exceeded, the joint will slow down and can even
+reverse.
+
+You can use a joint motor to simulate joint friction. Just set the joint
+speed to zero, and set the maximum torque to some small, but significant
+value. The motor will try to prevent the joint from rotating, but will
+yield to a significant load.
+
+Here's a revision of the revolute joint definition above; this time the
+joint has a limit and a motor enabled. The motor is setup to simulate
+joint friction.
+
+```cpp
+b2RevoluteJointDef jointDef;
+jointDef.Initialize(bodyA, bodyB, myBodyA->GetWorldCenter());
+jointDef.lowerAngle = -0.5f * b2_pi; // -90 degrees
+jointDef.upperAngle = 0.25f * b2_pi; // 45 degrees
+jointDef.enableLimit = true;
+jointDef.maxMotorTorque = 10.0f;
+jointDef.motorSpeed = 0.0f;
+jointDef.enableMotor = true;
+```
+You can access a revolute joint's angle, speed, and motor torque.
+
+```cpp
+float b2RevoluteJoint::GetJointAngle() const;
+float b2RevoluteJoint::GetJointSpeed() const;
+float b2RevoluteJoint::GetMotorTorque() const;
+```
+
+You also update the motor parameters each step.
+
+```cpp
+void b2RevoluteJoint::SetMotorSpeed(float speed);
+void b2RevoluteJoint::SetMaxMotorTorque(float torque);
+```
+
+Joint motors have some interesting abilities. You can update the joint
+speed every time step so you can make the joint move back-and-forth like
+a sine-wave or according to whatever function you want.
+
+```cpp
+// ... Game Loop Begin ...
+
+myJoint->SetMotorSpeed(cosf(0.5f * time));
+
+// ... Game Loop End ...
+```
+
+You can also use joint motors to track a desired joint angle. For example:
+
+```cpp
+// ... Game Loop Begin ...
+
+float angleError = myJoint->GetJointAngle() - angleTarget;
+float gain = 0.1f;
+myJoint->SetMotorSpeed(-gain * angleError);
+
+// ... Game Loop End ...
+```
+
+Generally your gain parameter should not be too large. Otherwise your
+joint may become unstable.
+
+### Prismatic Joint
+A prismatic joint allows for relative translation of two bodies along a
+specified axis. A prismatic joint prevents relative rotation. Therefore,
+a prismatic joint has a single degree of freedom.
+
+![Prismatic Joint](images/prismatic_joint.gif)
+
+The prismatic joint definition is similar to the revolute joint
+description; just substitute translation for angle and force for torque.
+Using this analogy provides an example prismatic joint definition with a
+joint limit and a friction motor:
+
+```cpp
+b2PrismaticJointDef jointDef;
+b2Vec2 worldAxis(1.0f, 0.0f);
+jointDef.Initialize(myBodyA, myBodyB, myBodyA->GetWorldCenter(), worldAxis);
+jointDef.lowerTranslation = -5.0f;
+jointDef.upperTranslation = 2.5f;
+jointDef.enableLimit = true;
+jointDef.maxMotorForce = 1.0f;
+jointDef.motorSpeed = 0.0f;
+jointDef.enableMotor = true;
+```
+
+The revolute joint has an implicit axis coming out of the screen. The
+prismatic joint needs an explicit axis parallel to the screen. This axis
+is fixed in the two bodies and follows their motion.
+
+Like the revolute joint, the prismatic joint translation is zero when
+the joint is created using Initialize(). So be sure zero is between your
+lower and upper translation limits.
+
+Using a prismatic joint is similar to using a revolute joint. Here are
+the relevant member functions:
+
+```cpp
+float PrismaticJoint::GetJointTranslation() const;
+float PrismaticJoint::GetJointSpeed() const;
+float PrismaticJoint::GetMotorForce() const;
+void PrismaticJoint::SetMotorSpeed(float speed);
+void PrismaticJoint::SetMotorForce(float force);
+```
+
+### Pulley Joint
+A pulley is used to create an idealized pulley. The pulley connects two
+bodies to ground and to each other. As one body goes up, the other goes
+down. The total length of the pulley rope is conserved according to the
+initial configuration.
+
+```
+length1 + length2 == constant
+```
+
+You can supply a ratio that simulates a block and tackle. This causes
+one side of the pulley to extend faster than the other. At the same time
+the constraint force is smaller on one side than the other. You can use
+this to create mechanical leverage.
+
+```
+length1 + ratio * length2 == constant
+```
+
+For example, if the ratio is 2, then length1 will vary at twice the rate
+of length2. Also the force in the rope attached to body1 will have half
+the constraint force as the rope attached to body2.
+
+![Pulley Joint](images/pulley_joint.gif)
+
+Pulleys can be troublesome when one side is fully extended. The rope on
+the other side will have zero length. At this point the constraint
+equations become singular (bad). You should configure collision shapes
+to prevent this.
+
+Here is an example pulley definition:
+
+```cpp
+b2Vec2 anchor1 = myBody1->GetWorldCenter();
+b2Vec2 anchor2 = myBody2->GetWorldCenter();
+
+b2Vec2 groundAnchor1(p1.x, p1.y + 10.0f);
+b2Vec2 groundAnchor2(p2.x, p2.y + 12.0f);
+
+float ratio = 1.0f;
+
+b2PulleyJointDef jointDef;
+jointDef.Initialize(myBody1, myBody2, groundAnchor1, groundAnchor2, anchor1, anchor2, ratio);
+```
+
+Pulley joints provide the current lengths.
+
+```cpp
+float PulleyJoint::GetLengthA() const;
+float PulleyJoint::GetLengthB() const;
+```
+
+### Gear Joint
+If you want to create a sophisticated mechanical contraption you might
+want to use gears. In principle you can create gears in Box2D by using
+compound shapes to model gear teeth. This is not very efficient and
+might be tedious to author. You also have to be careful to line up the
+gears so the teeth mesh smoothly. Box2D has a simpler method of creating
+gears: the gear joint.
+
+![Gear Joint](images/gear_joint.gif)
+
+The gear joint can only connect revolute and/or prismatic joints.
+
+Like the pulley ratio, you can specify a gear ratio. However, in this
+case the gear ratio can be negative. Also keep in mind that when one
+joint is a revolute joint (angular) and the other joint is prismatic
+(translation), and then the gear ratio will have units of length or one
+over length.
+
+```
+coordinate1 + ratio * coordinate2 == constant
+```
+
+Here is an example gear joint. The bodies myBodyA and myBodyB are any
+bodies from the two joints, as long as they are not the same bodies.
+
+```cpp
+b2GearJointDef jointDef;
+jointDef.bodyA = myBodyA;
+jointDef.bodyB = myBodyB;
+jointDef.joint1 = myRevoluteJoint;
+jointDef.joint2 = myPrismaticJoint;
+jointDef.ratio = 2.0f * b2_pi / myLength;
+```
+
+Note that the gear joint depends on two other joints. This creates a
+fragile situation. What happens if those joints are deleted?
+
+> **Caution**:
+> Always delete gear joints before the revolute/prismatic joints on the
+> gears. Otherwise your code will crash in a bad way due to the orphaned
+> joint pointers in the gear joint. You should also delete the gear joint
+> before you delete any of the bodies involved.
+
+### Mouse Joint
+The mouse joint is used in the testbed to manipulate bodies with the
+mouse. It attempts to drive a point on a body towards the current
+position of the cursor. There is no restriction on rotation.
+
+The mouse joint definition has a target point, maximum force, frequency,
+and damping ratio. The target point initially coincides with the body's
+anchor point. The maximum force is used to prevent violent reactions
+when multiple dynamic bodies interact. You can make this as large as you
+like. The frequency and damping ratio are used to create a spring/damper
+effect similar to the distance joint.
+
+Many users have tried to adapt the mouse joint for game play. Users
+often want to achieve precise positioning and instantaneous response.
+The mouse joint doesn't work very well in that context. You may wish to
+consider using kinematic bodies instead.
+
+### Wheel Joint
+The wheel joint restricts a point on bodyB to a line on bodyA. The wheel
+joint also provides a suspension spring. See b2WheelJoint.h and Car.h
+for details.
+
+![Wheel Joint](images/wheel_joint.svg)
+
+### Weld Joint
+The weld joint attempts to constrain all relative motion between two
+bodies. See the Cantilever.h in the testbed to see how the weld joint
+behaves.
+
+It is tempting to use the weld joint to define breakable structures.
+However, the Box2D solver is iterative so the joints are a bit soft. So
+chains of bodies connected by weld joints will flex.
+
+Instead it is better to create breakable bodies starting with a single
+body with multiple fixtures. When the body breaks, you can destroy a
+fixture and recreate it on a new body. See the Breakable example in the
+testbed.
+
+### Rope Joint
+The rope joint restricts the maximum distance between two points. This
+can be useful to prevent chains of bodies from stretching, even under
+high load. See b2RopeJoint.h and rope_joint.cpp for details.
+
+### Friction Joint
+The friction joint is used for top-down friction. The joint provides 2D
+translational friction and angular friction. See b2FrictionJoint.h and
+apply_force.cpp for details.
+
+### Motor Joint
+A motor joint lets you control the motion of a body by specifying target
+position and rotation offsets. You can set the maximum motor force and
+torque that will be applied to reach the target position and rotation.
+If the body is blocked, it will stop and the contact forces will be
+proportional the maximum motor force and torque. See b2MotorJoint and
+motor_joint.cpp for details.
+
+### Wheel Joint
+The wheel joint is designed specifically for vehicles. It provides a translation
+and rotation. The translation has a spring and damper to simulate the vehicle
+suspension. The rotation allows the wheel to rotate. You can specify an rotational
+motor to drive the wheel and to apply braking. See b2WheelJoint, wheel_joint.cpp,
+and car.cpp for details.
+
+## Contacts
+Contacts are objects created by Box2D to manage collision between two
+fixtures. If the fixture has children, such as a chain shape, then a
+contact exists for each relevant child. There are different kinds of
+contacts, derived from b2Contact, for managing contact between different
+kinds of fixtures. For example there is a contact class for managing
+polygon-polygon collision and another contact class for managing
+circle-circle collision.
+
+Here is some terminology associated with contacts.
+
+##### contact point
+A contact point is a point where two shapes touch. Box2D approximates
+contact with a small number of points.
+
+##### contact normal
+A contact normal is a unit vector that points from one shape to another.
+By convention, the normal points from fixtureA to fixtureB.
+
+##### contact separation
+Separation is the opposite of penetration. Separation is negative when
+shapes overlap. It is possible that future versions of Box2D will create
+contact points with positive separation, so you may want to check the
+sign when contact points are reported.
+
+##### contact manifold
+Contact between two convex polygons may generate up to 2 contact points.
+Both of these points use the same normal, so they are grouped into a
+contact manifold, which is an approximation of a continuous region of
+contact.
+
+##### normal impulse
+The normal force is the force applied at a contact point to prevent the
+shapes from penetrating. For convenience, Box2D works with impulses. The
+normal impulse is just the normal force multiplied by the time step.
+
+##### tangent impulse
+The tangent force is generated at a contact point to simulate friction.
+For convenience, this is stored as an impulse.
+
+##### contact ids
+Box2D tries to re-use the contact force results from a time step as the
+initial guess for the next time step. Box2D uses contact ids to match
+contact points across time steps. The ids contain geometric features
+indices that help to distinguish one contact point from another.
+
+Contacts are created when two fixture's AABBs overlap. Sometimes
+collision filtering will prevent the creation of contacts. Contacts are
+destroyed with the AABBs cease to overlap.
+
+So you might gather that there may be contacts created for fixtures that
+are not touching (just their AABBs). Well, this is correct. It's a
+\"chicken or egg\" problem. We don't know if we need a contact object
+until one is created to analyze the collision. We could delete the
+contact right away if the shapes are not touching, or we can just wait
+until the AABBs stop overlapping. Box2D takes the latter approach
+because it lets the system cache information to improve performance.
+
+### Contact Class
+As mentioned before, the contact class is created and destroyed by
+Box2D. Contact objects are not created by the user. However, you are
+able to access the contact class and interact with it.
+
+You can access the raw contact manifold:
+
+```cpp
+b2Manifold* b2Contact::GetManifold();
+const b2Manifold* b2Contact::GetManifold() const;
+```
+
+You can potentially modify the manifold, but this is generally not
+supported and is for advanced usage.
+
+There is a helper function to get the `b2WorldManifold`:
+
+```cpp
+void b2Contact::GetWorldManifold(b2WorldManifold* worldManifold) const;
+```
+
+This uses the current positions of the bodies to compute world positions
+of the contact points.
+
+Sensors do not create manifolds, so for them use:
+
+```cpp
+bool touching = sensorContact->IsTouching();
+```
+
+This function also works for non-sensors.
+
+You can get the fixtures from a contact. From those you can get the
+bodies.
+
+```cpp
+b2Fixture* fixtureA = myContact->GetFixtureA();
+b2Body* bodyA = fixtureA->GetBody();
+MyActor* actorA = (MyActor*)bodyA->GetUserData().pointer;
+```
+
+You can disable a contact. This only works inside the
+b2ContactListener::PreSolve event, discussed below.
+
+### Accessing Contacts
+You can get access to contacts in several ways. You can access the
+contacts directly on the world and body structures. You can also
+implement a contact listener.
+
+You can iterate over all contacts in the world:
+
+```cpp
+for (b2Contact* c = myWorld->GetContactList(); c; c = c->GetNext())
+{
+ // process c
+}
+```
+
+You can also iterate over all the contacts on a body. These are stored
+in a graph using a contact edge structure.
+
+```cpp
+for (b2ContactEdge* ce = myBody->GetContactList(); ce; ce = ce->next)
+{
+ b2Contact* c = ce->contact;
+ // process c
+}
+```
+
+You can also access contacts using the contact listener that is
+described below.
+
+> **Caution**:
+> Accessing contacts off b2World and b2Body may miss some transient
+> contacts that occur in the middle of the time step. Use
+> b2ContactListener to get the most accurate results.
+
+### Contact Listener
+You can receive contact data by implementing b2ContactListener. The
+contact listener supports several events: begin, end, pre-solve, and
+post-solve.
+
+```cpp
+class MyContactListener : public b2ContactListener
+{
+public:
+
+void BeginContact(b2Contact* contact)
+{ /* handle begin event */ }
+
+void EndContact(b2Contact* contact)
+{ /* handle end event */ }
+
+void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
+{ /* handle pre-solve event */ }
+
+void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
+{ /* handle post-solve event */ }
+};
+```
+
+> **Caution**:
+> Do not keep a reference to the pointers sent to b2ContactListener.
+> Instead make a deep copy of the contact point data into your own buffer.
+> The example below shows one way of doing this.
+
+At run-time you can create an instance of the listener and register it
+with b2World::SetContactListener. Be sure your listener remains in scope
+while the world object exists.
+
+#### Begin Contact Event
+This is called when two fixtures begin to overlap. This is called for
+sensors and non-sensors. This event can only occur inside the time step.
+
+#### End Contact Event
+This is called when two fixtures cease to overlap. This is called for
+sensors and non-sensors. This may be called when a body is destroyed, so
+this event can occur outside the time step.
+
+#### Pre-Solve Event
+This is called after collision detection, but before collision
+resolution. This gives you a chance to disable the contact based on the
+current configuration. For example, you can implement a one-sided
+platform using this callback and calling b2Contact::SetEnabled(false).
+The contact will be re-enabled each time through collision processing,
+so you will need to disable the contact every time-step. The pre-solve
+event may be fired multiple times per time step per contact due to
+continuous collision detection.
+
+```cpp
+void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
+{
+ b2WorldManifold worldManifold;
+ contact->GetWorldManifold(&worldManifold);
+ if (worldManifold.normal.y < -0.5f)
+ {
+ contact->SetEnabled(false);
+ }
+}
+```
+
+The pre-solve event is also a good place to determine the point state
+and the approach velocity of collisions.
+
+```cpp
+void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
+{
+ b2WorldManifold worldManifold;
+ contact->GetWorldManifold(&worldManifold);
+
+ b2PointState state1[2], state2[2];
+ b2GetPointStates(state1, state2, oldManifold, contact->GetManifold());
+
+ if (state2[0] == b2_addState)
+ {
+ const b2Body* bodyA = contact->GetFixtureA()->GetBody();
+ const b2Body* bodyB = contact->GetFixtureB()->GetBody();
+ b2Vec2 point = worldManifold.points[0];
+ b2Vec2 vA = bodyA->GetLinearVelocityFromWorldPoint(point);
+ b2Vec2 vB = bodyB->GetLinearVelocityFromWorldPoint(point);
+
+ float approachVelocity = b2Dot(vB -- vA, worldManifold.normal);
+
+ if (approachVelocity > 1.0f)
+ {
+ MyPlayCollisionSound();
+ }
+ }
+}
+```
+
+#### Post-Solve Event
+The post solve event is where you can gather collision impulse results.
+If you don't care about the impulses, you should probably just implement
+the pre-solve event.
+
+It is tempting to implement game logic that alters the physics world
+inside a contact callback. For example, you may have a collision that
+applies damage and try to destroy the associated actor and its rigid
+body. However, Box2D does not allow you to alter the physics world
+inside a callback because you might destroy objects that Box2D is
+currently processing, leading to orphaned pointers.
+
+The recommended practice for processing contact points is to buffer all
+contact data that you care about and process it after the time step. You
+should always process the contact points immediately after the time
+step; otherwise some other client code might alter the physics world,
+invalidating the contact buffer. When you process the contact buffer you
+can alter the physics world, but you still need to be careful that you
+don't orphan pointers stored in the contact point buffer. The testbed
+has example contact point processing that is safe from orphaned
+pointers.
+
+This code from the CollisionProcessing test shows how to handle orphaned
+bodies when processing the contact buffer. Here is an excerpt. Be sure
+to read the comments in the listing. This code assumes that all contact
+points have been buffered in the b2ContactPoint array m_points.
+
+```cpp
+// We are going to destroy some bodies according to contact
+// points. We must buffer the bodies that should be destroyed
+// because they may belong to multiple contact points.
+const int32 k_maxNuke = 6;
+b2Body* nuke[k_maxNuke];
+int32 nukeCount = 0;
+
+// Traverse the contact buffer. Destroy bodies that
+// are touching heavier bodies.
+for (int32 i = 0; i < m_pointCount; ++i)
+{
+ ContactPoint* point = m_points + i;
+ b2Body* bodyA = point->fixtureA->GetBody();
+ b2Body* bodyB = point->FixtureB->GetBody();
+ float massA = bodyA->GetMass();
+ float massB = bodyB->GetMass();
+
+ if (massA > 0.0f && massB > 0.0f)
+ {
+ if (massB > massA)
+ {
+ nuke[nukeCount++] = bodyA;
+ }
+ else
+ {
+ nuke[nukeCount++] = bodyB;
+ }
+
+ if (nukeCount == k_maxNuke)
+ {
+ break;
+ }
+ }
+}
+
+// Sort the nuke array to group duplicates.
+std::sort(nuke, nuke + nukeCount);
+
+// Destroy the bodies, skipping duplicates.
+int32 i = 0;
+while (i < nukeCount)
+{
+ b2Body* b = nuke[i++];
+ while (i < nukeCount && nuke[i] == b)
+ {
+ ++i;
+ }
+
+ m_world->DestroyBody(b);
+}
+```
+
+### Contact Filtering
+Often in a game you don't want all objects to collide. For example, you
+may want to create a door that only certain characters can pass through.
+This is called contact filtering, because some interactions are filtered
+out.
+
+Box2D allows you to achieve custom contact filtering by implementing a
+b2ContactFilter class. This class requires you to implement a
+ShouldCollide function that receives two b2Shape pointers. Your function
+returns true if the shapes should collide.
+
+The default implementation of ShouldCollide uses the b2FilterData
+defined in Chapter 6, Fixtures.
+
+```cpp
+bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB)
+{
+ const b2Filter& filterA = fixtureA->GetFilterData();
+ const b2Filter& filterB = fixtureB->GetFilterData();
+
+ if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0)
+ {
+ return filterA.groupIndex > 0;
+ }
+
+ bool collideA = (filterA.maskBits & filterB.categoryBits) != 0;
+ bool collideB = (filterA.categoryBits & filterB.maskBits) != 0
+ bool collide = collideA && collideB;
+ return collide;
+}
+```
+
+At run-time you can create an instance of your contact filter and
+register it with b2World::SetContactFilter. Make sure your filter stays
+in scope while the world exists.
+
+```cpp
+MyContactFilter filter;
+world->SetContactFilter(&filter);
+// filter remains in scope ...
+```
+
+## World
+The `b2World` class contains the bodies and joints. It manages all aspects
+of the simulation and allows for asynchronous queries (like AABB queries
+and ray-casts). Much of your interactions with Box2D will be with a
+b2World object.
+
+### Creating and Destroying a World
+Creating a world is fairly simple. You just need to provide a gravity
+vector and a Boolean indicating if bodies can sleep. Usually you will
+create and destroy a world using new and delete.
+
+```cpp
+b2World* myWorld = new b2World(gravity, doSleep);
+
+// ... do stuff ...
+
+delete myWorld;
+```
+
+### Using a World
+The world class contains factories for creating and destroying bodies
+and joints. These factories are discussed later in the sections on
+bodies and joints. There are some other interactions with b2World that I
+will cover now.
+
+### Simulation
+The world class is used to drive the simulation. You specify a time step
+and a velocity and position iteration count. For example:
+
+```cpp
+float timeStep = 1.0f / 60.f;
+int32 velocityIterations = 10;
+int32 positionIterations = 8;
+myWorld->Step(timeStep, velocityIterations, positionIterations);
+```
+
+After the time step you can examine your bodies and joints for
+information. Most likely you will grab the position off the bodies so
+that you can update your actors and render them. You can perform the
+time step anywhere in your game loop, but you should be aware of the
+order of things. For example, you must create bodies before the time
+step if you want to get collision results for the new bodies in that
+frame.
+
+As I discussed above in the HelloWorld tutorial, you should use a fixed
+time step. By using a larger time step you can improve performance in
+low frame rate scenarios. But generally you should use a time step no
+larger than 1/30 seconds. A time step of 1/60 seconds will usually
+deliver a high quality simulation.
+
+The iteration count controls how many times the constraint solver sweeps
+over all the contacts and joints in the world. More iteration always
+yields a better simulation. But don't trade a small time step for a
+large iteration count. 60Hz and 10 iterations is far better than 30Hz
+and 20 iterations.
+
+After stepping, you should clear any forces you have applied to your
+bodies. This is done with the command `b2World::ClearForces`. This lets
+you take multiple sub-steps with the same force field.
+
+```cpp
+myWorld->ClearForces();
+```
+
+### Exploring the World
+The world is a container for bodies, contacts, and joints. You can grab
+the body, contact, and joint lists off the world and iterate over them.
+For example, this code wakes up all the bodies in the world:
+
+```cpp
+for (b2Body* b = myWorld->GetBodyList(); b; b = b->GetNext())
+{
+ b->SetAwake(true);
+}
+```
+
+Unfortunately real programs can be more complicated. For example, the
+following code is broken:
+
+```cpp
+for (b2Body* b = myWorld->GetBodyList(); b; b = b->GetNext())
+{
+ GameActor* myActor = (GameActor*)b->GetUserData().pointer;
+ if (myActor->IsDead())
+ {
+ myWorld->DestroyBody(b); // ERROR: now GetNext returns garbage.
+ }
+}
+```
+
+Everything goes ok until a body is destroyed. Once a body is destroyed,
+its next pointer becomes invalid. So the call to `b2Body::GetNext()` will
+return garbage. The solution to this is to copy the next pointer before
+destroying the body.
+
+```cpp
+b2Body* node = myWorld->GetBodyList();
+while (node)
+{
+ b2Body* b = node;
+ node = node->GetNext();
+
+ GameActor* myActor = (GameActor*)b->GetUserData().pointer;
+ if (myActor->IsDead())
+ {
+ myWorld->DestroyBody(b);
+ }
+}
+```
+
+This safely destroys the current body. However, you may want to call a
+game function that may destroy multiple bodies. In this case you need to
+be very careful. The solution is application specific, but for
+convenience I'll show one method of solving the problem.
+
+```cpp
+b2Body* node = myWorld->GetBodyList();
+while (node)
+{
+ b2Body* b = node;
+ node = node->GetNext();
+
+ GameActor* myActor = (GameActor*)b->GetUserData().pointer;
+ if (myActor->IsDead())
+ {
+ bool otherBodiesDestroyed = GameCrazyBodyDestroyer(b);
+ if (otherBodiesDestroyed)
+ {
+ node = myWorld->GetBodyList();
+ }
+ }
+}
+```
+
+Obviously to make this work, GameCrazyBodyDestroyer must be honest about
+what it has destroyed.
+
+### AABB Queries
+Sometimes you want to determine all the shapes in a region. The b2World
+class has a fast log(N) method for this using the broad-phase data
+structure. You provide an AABB in world coordinates and an
+implementation of b2QueryCallback. The world calls your class with each
+fixture whose AABB overlaps the query AABB. Return true to continue the
+query, otherwise return false. For example, the following code finds all
+the fixtures that potentially intersect a specified AABB and wakes up
+all of the associated bodies.
+
+```cpp
+class MyQueryCallback : public b2QueryCallback
+{
+public:
+ bool ReportFixture(b2Fixture* fixture)
+ {
+ b2Body* body = fixture->GetBody();
+ body->SetAwake(true);
+
+ // Return true to continue the query.
+ return true;
+ }
+};
+
+// Elsewhere ...
+MyQueryCallback callback;
+b2AABB aabb;
+
+aabb.lowerBound.Set(-1.0f, -1.0f);
+aabb.upperBound.Set(1.0f, 1.0f);
+myWorld->Query(&callback, aabb);
+```
+
+You cannot make any assumptions about the order of the callbacks.
+
+### Ray Casts
+You can use ray casts to do line-of-sight checks, fire guns, etc. You
+perform a ray cast by implementing a callback class and providing the
+start and end points. The world class calls your class with each fixture
+hit by the ray. Your callback is provided with the fixture, the point of
+intersection, the unit normal vector, and the fractional distance along
+the ray. You cannot make any assumptions about the order of the
+callbacks.
+
+You control the continuation of the ray cast by returning a fraction.
+Returning a fraction of zero indicates the ray cast should be
+terminated. A fraction of one indicates the ray cast should continue as
+if no hit occurred. If you return the fraction from the argument list,
+the ray will be clipped to the current intersection point. So you can
+ray cast any shape, ray cast all shapes, or ray cast the closest shape
+by returning the appropriate fraction.
+
+You may also return of fraction of -1 to filter the fixture. Then the
+ray cast will proceed as if the fixture does not exist.
+
+Here is an example:
+
+```cpp
+// This class captures the closest hit shape.
+class MyRayCastCallback : public b2RayCastCallback
+{
+public:
+ MyRayCastCallback()
+ {
+ m_fixture = NULL;
+ }
+
+ float ReportFixture(b2Fixture* fixture, const b2Vec2& point,
+ const b2Vec2& normal, float fraction)
+ {
+ m_fixture = fixture;
+ m_point = point;
+ m_normal = normal;
+ m_fraction = fraction;
+ return fraction;
+ }
+
+ b2Fixture* m_fixture;
+ b2Vec2 m_point;
+ b2Vec2 m_normal;
+ float m_fraction;
+};
+
+// Elsewhere ...
+MyRayCastCallback callback;
+b2Vec2 point1(-1.0f, 0.0f);
+b2Vec2 point2(3.0f, 1.0f);
+myWorld->RayCast(&callback, point1, point2);
+```
+
+> **Caution**:
+> Due to round-off errors, ray casts can sneak through small cracks
+> between polygons in your static environment. If this is not acceptable
+> in your application, trying slightly overlapping your polygons.
diff --git a/Client/ThirdParty/Box2D/docs/extra.css b/Client/ThirdParty/Box2D/docs/extra.css
new file mode 100644
index 0000000..bf67831
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/extra.css
@@ -0,0 +1,605 @@
+/*
+Doxygen CSS overrides
+Adapted from: https://github.com/MaJerle/doxygen-dark-theme
+blog-light: #fafafa
+blog-dark: #252627
+Dark background: #353629;
+New light dark background #32363d
+Light background: #dfe5f2;
+*/
+
+body {
+ background: #292a2d;
+ background-image: none;
+ color: #D8D8D8;
+}
+
+#titlearea {
+ border-bottom: 1px solid #32363d;
+}
+
+div.contents {
+ max-width: 900px;
+}
+
+.image {
+ background-color: #CCCCCC;
+ border: 10px solid #CCCCCC;
+ margin: 0px;
+ padding: 0px;
+}
+
+/*
+.image img, object {
+ padding: 10px;
+ margin: 10px 0px;
+ background-color: white;
+ border: 1px solid #000000;
+}
+*/
+
+.caption {
+ padding-top: 10px;
+ color: black;
+}
+
+div.fragment, pre.fragment {
+ margin: 20px 0px;
+ padding: 10px;
+}
+
+blockquote.doxtable {
+ border: 1px solid #000000;
+ background: #32363d;
+ background-color: #bf5f82;
+ background-color: #456114;
+ margin: 10px 24px 10px 4px;
+}
+
+div.toc {
+ margin: 0 !important;
+ border-radius: 4px !important;
+}
+
+div.toc h3 {
+ font-size: 150%;
+ color: inherit;
+}
+
+.contents table.doxtable {
+ margin: 0 auto;
+}
+
+.fieldtable {
+ box-shadow: none !important;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+}
+
+.memitem,
+.memproto,
+.memdoc {
+ box-shadow: none;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ background-image: none;
+}
+
+.tablist a:hover,
+.tablist li.current a {
+ text-shadow: none;
+ -moz-text-shadow: none;
+ -webkit-text-shadow: none;
+}
+
+.textblock h1 {
+ border-bottom: 1px solid #32363d;
+ border-left: 3px solid #32363d;
+ margin: 40px 0px 10px 0px;
+ padding-bottom: 10px;
+ padding-top: 10px;
+ padding-left: 5px;
+}
+
+.textblock h1:first-child {
+ margin-top: 10px;
+}
+
+dl.note,
+dl.warning,
+dl.todo,
+dl.deprecated,
+dl.reflist {
+ border: 0;
+ padding: 0px;
+ margin: 4px 0px 4px 0px;
+ border-radius: 4px;
+}
+
+dl.note dt,
+dl.warning dt,
+dl.todo dt,
+dl.deprecated dt,
+dl.reflist dt {
+ margin: 0;
+ font-size: 14px;
+ padding: 2px 4px;
+
+ border: none;
+ border-top-left-radius: 0px;
+ border-top-right-radius:0px;
+
+ font-weight: bold;
+ text-transform: uppercase;
+ color: #FFFFFF !important;
+
+ box-shadow: none;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ text-shadow: none;
+}
+
+dl.note dd,
+dl.warning dd,
+dl.todo dd,
+dl.deprecated dd,
+dl.reflist dd {
+ margin: 0;
+ padding: 4px;
+ background: none;
+
+ color: #222222;
+
+ border: 1px solid;
+ border-bottom-left-radius: 0px;
+ border-bottom-right-radius: 0px;
+ border-top: none;
+
+ box-shadow: none;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ text-shadow: none;
+}
+
+dl.reflist dd {
+ margin-bottom: 15px;
+}
+
+dl.note dt {
+ background-color: #cbc693;
+}
+
+dl.warning dt {
+ background-color: #bf5f82;
+}
+
+dl.todo dt {
+ background-color: #82b3c9;
+}
+
+dl.deprecated dt {
+ background-color: #af8eb5;
+}
+
+dl.reflist dt {
+ background-color: #cbae82;
+}
+
+dl.note dd {
+ background-color: #fff9c4;
+ border-color: #cbc693;
+}
+
+dl.warning dd {
+ background-color: #f48fb1;
+ border-color: #bf5f82;
+}
+
+dl.todo dd {
+ background-color: #b3e5fc;
+ border-color: #82b3c9;
+}
+
+dl.deprecated dd {
+ background-color: #e1bee7;
+ border-color: #af8eb5;
+}
+
+dl.reflist dd {
+ background-color: #ffe0b2;
+ border-color: #cbae82;
+}
+
+#docs_list {
+ padding: 0 10px;
+}
+
+#docs_list ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+#docs_list ul li {
+ display: inline-block;
+ border-right: 1px solid #BFBFBF;
+}
+
+#docs_list ul li:last-child {
+ border-right: none;
+}
+
+#docs_list ul li a {
+ display: block;
+ padding: 8px 13px;
+ font-weight: bold;
+ font-size: 15px;
+}
+
+#docs_list ul li a:hover,
+#docs_list ul li a.docs_current {
+ text-decoration: underline;
+}
+
+.ui-resizable-e {
+ width: 3px;
+}
+
+.download_url {
+ font-weight: bold;
+ font-size: 150%;
+ line-height: 150%;
+}
+
+span.lineno a {
+ text-decoration: none;
+}
+
+.directory .arrow {
+ height: initial;
+}
+
+.directory td.entry {
+ padding: 3px 6px;
+}
+
+.memproto table td {
+ font-family: monospace, fixed !important;
+}
+
+td.memItemLeft, td.memItemRight {
+ font-family: monospace, fixed;
+}
+
+.paramname, .paramname em {
+ font-style: italic;
+}
+
+.memdoc {
+ text-shadow: none;
+}
+
+.memItem {
+ font-family: monospace, fixed;
+}
+
+.memItem table {
+ font-family: inherit;
+}
+
+img.footer {
+ height: 22px;
+}
+
+.sm-dox {
+ background: #dfe5f2 !important;
+}
+
+.sm-dox a {
+ background: none;
+}
+
+div.fragment, pre.fragment {
+ border: 1px solid #000000;
+ background: #32363d;
+}
+
+a, a:link, a:visited {
+ color: #67d8ef !important;
+}
+
+.highlighted {
+ background: none !important;
+}
+
+a.highlighted {
+ background: none !important;
+}
+
+#main-nav {
+ border-bottom: 1px solid #32363d;
+}
+
+#main-nav .sm-dox {
+ background: transparent !important;
+}
+
+.sm-dox a {
+ text-shadow: none !important;
+ background: transparent !important;
+}
+
+.sm-dox a:hover {
+ background: #282923 !important;
+}
+
+.sm-dox {
+ text-shadow: none !important;
+ box-shadow: none !important;
+}
+
+.sm-dox ul {
+ border: 1px solid #000000;
+ background: #32363d;
+}
+
+.directory tr.even {
+ background: #32363d;
+}
+
+#MSearchSelectWindow {
+ border: 1px solid #000000;
+ background: #32363d;
+}
+
+a.selectItem {
+ padding: 3px;
+}
+
+a.SelectItem:hover {
+ background: #282923 !important;
+}
+
+#MSearchResultsWindow {
+ border: 1px solid #000000;
+ background: #32363d;
+ color: #67d8ef !important;;
+}
+
+#nav-tree {
+ background: transparent;
+}
+
+#nav-tree .selected {
+ background-image: none;
+ background: #32363d;
+}
+
+
+div.toc {
+ background: #32363d;
+ border: 1px solid #000000;
+}
+
+div.toc h3 {
+ font-size: 150%;
+ color: inherit;
+}
+
+table.doxtable tr:nth-child(even) td {
+ background: #32363d;
+}
+
+div.header {
+ background: transparent;
+ border-bottom: 1px solid #32363d;
+}
+
+.fieldtable th {
+ background: #282923;
+ color: inherit;
+}
+
+.memdoc {
+ border: 1px solid #A8B8D9;
+}
+
+.tabs, .tabs2, .tabs3 {
+ background: #DDDDDD;
+}
+
+.tablist li {
+ background: transparent !important;
+}
+
+.tablist a {
+ background-image: none;
+ border-right: 1px solid #999999;
+
+ color: #32363d;
+}
+
+.tablist a:hover,
+.tablist li.current a {
+ text-decoration: none;
+ color: #000000;
+ background: #CCCCCC;
+ background-image: none;
+}
+
+#docs_list {
+ background: #32363d;
+}
+
+#docs_list ul li {
+ border-right: 1px solid #BFBFBF;
+}
+
+#docs_list ul li a {
+ color: #1b1e21;
+}
+
+#docs_list ul li a:hover,
+#docs_list ul li a.docs_current {
+ background: #282923;
+}
+
+.ui-resizable-e {
+ background: #32363d;
+}
+
+div.line {
+ background: transparent;
+ color: inherit;
+}
+
+div.line a {
+ text-decoration: underline;
+ color: inherit;
+}
+
+span.keyword {
+ color: #f92472;
+ font-style: italic;
+}
+
+span.keywordtype {
+ color: #67cfc1;
+ font-style: italic;
+}
+
+span.keywordflow {
+ color: #f92472;
+ font-style: italic;
+}
+
+span.comment {
+ color: #74705a;
+}
+
+span.preprocessor {
+ color: #a6e22b;
+}
+
+span.stringliteral {
+ color: #e7db74;
+}
+
+span.charliteral {
+ color: #e7db74;
+}
+
+span.vhdldigit {
+ color: #ff00ff;
+}
+
+span.vhdlchar {
+ color: #000000;
+}
+
+span.vhdlkeyword {
+ color: #700070;
+}
+
+span.vhdllogic {
+ color: #ff0000;
+}
+
+span.lineno {
+ background: transparent;
+}
+
+span.lineno a {
+ background: transparent;
+}
+
+.mdescLeft, .mdescRight, .memItemLeft, .memItemRight,
+.memTemplItemLeft, .memTemplItemRight, .memTemplParams {
+ background: #32363d;
+ color: inherit;
+}
+
+.memSeparator {
+ border: none;
+ background: transparent;
+}
+
+h2.groupheader {
+ color: #67d8ef;
+}
+
+.memtitle {
+ background: #32363d !important;
+ border-color: #000000;
+}
+
+.memitem {
+ background: #32363d !important;
+ color: inherit;
+ text-shadow: none;
+}
+
+.memproto {
+ background: inherit;
+ border-color: #000000;
+ color: inherit;
+ text-shadow: none;
+}
+
+.memproto table td {
+ font-family: monospace, fixed !important;
+}
+
+td.memItemLeft, td.memItemRight {
+ font-family: monospace, fixed;
+}
+
+.paramname, .paramname em {
+ color: #bf5f82;
+}
+
+.memdoc {
+ background: inherit;
+ border-color: #000000;
+}
+
+#nav-path {
+ background: transparent;
+}
+
+#nav-path ul {
+ background: transparent;
+ color: inherit;
+ border: none;
+ border-top: 1px solid #32363d;
+}
+
+.navpath li.footer {
+ color: inherit;
+}
+
+.navpath li.navelem a {
+ text-shadow: none;
+}
+
+::-webkit-scrollbar {
+ width: 10px;
+}
+
+::-webkit-scrollbar-track {
+ border-radius: 10px;
+}
+
+::-webkit-scrollbar-thumb {
+ background: #234567;
+ border: none;
+}
+
+::-webkit-scrollbar-thumb:hover {
+ background: #32363d;
+}
+
+h1.glow, h2.glow, h3.glow,
+h4.glow, h5.glow, h6.glow {
+ text-shadow: 0 0 15px #67d8ef;
+}
diff --git a/Client/ThirdParty/Box2D/docs/hello.md b/Client/ThirdParty/Box2D/docs/hello.md
new file mode 100644
index 0000000..40d8de6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/hello.md
@@ -0,0 +1,246 @@
+# Hello Box2D
+In the distribution of Box2D is a Hello World project. The program
+creates a large ground box and a small dynamic box. This code does not
+contain any graphics. All you will see is text output in the console of
+the box's position over time.
+
+This is a good example of how to get up and running with Box2D.
+
+## Creating a World
+Every Box2D program begins with the creation of a b2World object.
+b2World is the physics hub that manages memory, objects, and simulation.
+You can allocate the physics world on the stack, heap, or data section.
+
+It is easy to create a Box2D world. First, we define the gravity vector.
+
+```cpp
+b2Vec2 gravity(0.0f, -10.0f);
+```
+
+Now we create the world object. Note that we are creating the world on
+the stack, so the world must remain in scope.
+
+```cpp
+b2World world(gravity);
+```
+
+So now we have our physics world, let's start adding some stuff to it.
+
+## Creating a Ground Box
+Bodies are built using the following steps:
+1. Define a body with position, damping, etc.
+2. Use the world object to create the body.
+3. Define fixtures with a shape, friction, density, etc.
+4. Create fixtures on the body.
+
+For step 1 we create the ground body. For this we need a body
+definition. With the body definition we specify the initial position of
+the ground body.
+
+```cpp
+b2BodyDef groundBodyDef;
+groundBodyDef.position.Set(0.0f, -10.0f);
+```
+
+For step 2 the body definition is passed to the world object to create
+the ground body. The world object does not keep a reference to the body
+definition. Bodies are static by default. Static bodies don't collide
+with other static bodies and are immovable.
+
+```cpp
+b2Body* groundBody = world.CreateBody(&groundBodyDef);
+```
+
+For step 3 we create a ground polygon. We use the SetAsBox shortcut to
+form the ground polygon into a box shape, with the box centered on the
+origin of the parent body.
+
+```cpp
+b2PolygonShape groundBox;
+groundBox.SetAsBox(50.0f, 10.0f);
+```
+
+The SetAsBox function takes the **half**-**width** and
+**half**-**height** (extents). So in this case the ground box is 100
+units wide (x-axis) and 20 units tall (y-axis). Box2D is tuned for
+meters, kilograms, and seconds. So you can consider the extents to be in
+meters. Box2D generally works best when objects are the size of typical
+real world objects. For example, a barrel is about 1 meter tall. Due to
+the limitations of floating point arithmetic, using Box2D to model the
+movement of glaciers or dust particles is not a good idea.
+
+We finish the ground body in step 4 by creating the shape fixture. For
+this step we have a shortcut. We do not have a need to alter the default
+fixture material properties, so we can pass the shape directly to the
+body without creating a fixture definition. Later we will see how to use
+a fixture definition for customized material properties. The second
+parameter is the shape density in kilograms per meter squared. A static
+body has zero mass by definition, so the density is not used in this
+case.
+
+```cpp
+groundBody->CreateFixture(&groundBox, 0.0f);
+```
+
+Box2D does not keep a reference to the shape. It clones the data into a
+new b2Shape object.
+
+Note that every fixture must have a parent body, even fixtures that are
+static. However, you can attach all static fixtures to a single static
+body.
+
+When you attach a shape to a body using a fixture, the shape's
+coordinates become local to the body. So when the body moves, so does
+the shape. A fixture's world transform is inherited from the parent
+body. A fixture does not have a transform independent of the body. So we
+don't move a shape around on the body. Moving or modifying a shape that
+is on a body is not supported. The reason is simple: a body with
+morphing shapes is not a rigid body, but Box2D is a rigid body engine.
+Many of the assumptions made in Box2D are based on the rigid body model.
+If this is violated many things will break
+
+## Creating a Dynamic Body
+So now we have a ground body. We can use the same technique to create a
+dynamic body. The main difference, besides dimensions, is that we must
+establish the dynamic body's mass properties.
+
+First we create the body using CreateBody. By default bodies are static,
+so we should set the b2BodyType at construction time to make the body
+dynamic.
+
+```cpp
+b2BodyDef bodyDef;
+bodyDef.type = b2_dynamicBody;
+bodyDef.position.Set(0.0f, 4.0f);
+b2Body* body = world.CreateBody(&bodyDef);
+```
+
+> **Caution**:
+> You must set the body type to b2_dynamicBody if you want the body to
+> move in response to forces.
+
+Next we create and attach a polygon shape using a fixture definition.
+First we create a box shape:
+
+```cpp
+b2PolygonShape dynamicBox;
+dynamicBox.SetAsBox(1.0f, 1.0f);
+```
+
+Next we create a fixture definition using the box. Notice that we set
+density to 1. The default density is zero. Also, the friction on the
+shape is set to 0.3.
+
+```cpp
+b2FixtureDef fixtureDef;
+fixtureDef.shape = &dynamicBox;
+fixtureDef.density = 1.0f;
+fixtureDef.friction = 0.3f;
+```
+
+> **Caution**:
+> A dynamic body should have at least one fixture with a non-zero density.
+> Otherwise you will get strange behavior.
+
+Using the fixture definition we can now create the fixture. This
+automatically updates the mass of the body. You can add as many fixtures
+as you like to a body. Each one contributes to the total mass.
+
+```cpp
+body->CreateFixture(&fixtureDef);
+```
+
+That's it for initialization. We are now ready to begin simulating.
+
+## Simulating the World
+So we have initialized the ground box and a dynamic box. Now we are
+ready to set Newton loose to do his thing. We just have a couple more
+issues to consider.
+
+Box2D uses a computational algorithm called an integrator. Integrators
+simulate the physics equations at discrete points of time. This goes
+along with the traditional game loop where we essentially have a flip
+book of movement on the screen. So we need to pick a time step for
+Box2D. Generally physics engines for games like a time step at least as
+fast as 60Hz or 1/60 seconds. You can get away with larger time steps,
+but you will have to be more careful about setting up the definitions
+for your world. We also don't like the time step to change much. A
+variable time step produces variable results, which makes it difficult
+to debug. So don't tie the time step to your frame rate (unless you
+really, really have to). Without further ado, here is the time step.
+
+```cpp
+float timeStep = 1.0f / 60.0f;
+```
+
+In addition to the integrator, Box2D also uses a larger bit of code
+called a constraint solver. The constraint solver solves all the
+constraints in the simulation, one at a time. A single constraint can be
+solved perfectly. However, when we solve one constraint, we slightly
+disrupt other constraints. To get a good solution, we need to iterate
+over all constraints a number of times.
+
+There are two phases in the constraint solver: a velocity phase and a
+position phase. In the velocity phase the solver computes the impulses
+necessary for the bodies to move correctly. In the position phase the
+solver adjusts the positions of the bodies to reduce overlap and joint
+detachment. Each phase has its own iteration count. In addition, the
+position phase may exit iterations early if the errors are small.
+
+The suggested iteration count for Box2D is 8 for velocity and 3 for
+position. You can tune this number to your liking, just keep in mind
+that this has a trade-off between performance and accuracy. Using fewer
+iterations increases performance but accuracy suffers. Likewise, using
+more iterations decreases performance but improves the quality of your
+simulation. For this simple example, we don't need much iteration. Here
+are our chosen iteration counts.
+
+```cpp
+int32 velocityIterations = 6;
+int32 positionIterations = 2;
+```
+
+Note that the time step and the iteration count are completely
+unrelated. An iteration is not a sub-step. One solver iteration is a
+single pass over all the constraints within a time step. You can have
+multiple passes over the constraints within a single time step.
+
+We are now ready to begin the simulation loop. In your game the
+simulation loop can be merged with your game loop. In each pass through
+your game loop you call b2World::Step. Just one call is usually enough,
+depending on your frame rate and your physics time step.
+
+The Hello World program was designed to be simple, so it has no
+graphical output. The code prints out the position and rotation of the
+dynamic body. Here is the simulation loop that simulates 60 time steps
+for a total of 1 second of simulated time.
+
+```cpp
+for (int32 i = 0; i < 60; ++i)
+{
+ world.Step(timeStep, velocityIterations, positionIterations);
+ b2Vec2 position = body->GetPosition();
+ float angle = body->GetAngle();
+ printf("%4.2f %4.2f %4.2f\n", position.x, position.y, angle);
+}
+```
+
+The output shows the box falling and landing on the ground box. Your
+output should look like this:
+
+```
+0.00 4.00 0.00
+0.00 3.99 0.00
+0.00 3.98 0.00
+...
+0.00 1.25 0.00
+0.00 1.13 0.00
+0.00 1.01 0.00
+```
+
+## Cleanup
+When a world leaves scope or is deleted by calling delete on a pointer,
+all the memory reserved for bodies, fixtures, and joints is freed. This
+is done to improve performance and make your life easier. However, you
+will need to nullify any body, fixture, or joint pointers you have
+because they will become invalid.
diff --git a/Client/ThirdParty/Box2D/docs/images/body_origin.gif b/Client/ThirdParty/Box2D/docs/images/body_origin.gif
new file mode 100644
index 0000000..cef1707
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/body_origin.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/captured_toi.svg b/Client/ThirdParty/Box2D/docs/images/captured_toi.svg
new file mode 100644
index 0000000..e5d951d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/captured_toi.svg
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="296.5"
+ height="142.84351"
+ id="svg4080"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="captured.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\captured.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4082">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective4088" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.4142136"
+ inkscape:cx="-105.19711"
+ inkscape:cy="-99.626528"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1138"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata4085">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-245,-431.01868)">
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4090"
+ width="295.5"
+ height="17"
+ x="245.5"
+ y="556.36218" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4602"
+ width="8"
+ height="134"
+ x="565.5022"
+ y="92.054398"
+ transform="rotate(39.650005)" />
+ <rect
+ y="502.45367"
+ x="298.04913"
+ height="134"
+ width="8"
+ id="rect4604"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ transform="rotate(-11.210987)" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="328"
+ y="465.36218"
+ id="text4608"><tspan
+ sodipodi:role="line"
+ id="tspan4610"
+ x="328"
+ y="465.36218"
+ style="font-size:12px;line-height:1.25">t=0</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="419.5"
+ y="465.33875"
+ id="text4612"><tspan
+ sodipodi:role="line"
+ id="tspan4614"
+ x="419.5"
+ y="465.33875"
+ style="font-size:12px;line-height:1.25">t=1</tspan></text>
+ <rect
+ transform="rotate(30.564716)"
+ y="182.57234"
+ x="547.54456"
+ height="134"
+ width="8"
+ id="rect2822"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:1, 2;stroke-dashoffset:0;stroke-opacity:1" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/chain_loop_inwards.svg b/Client/ThirdParty/Box2D/docs/images/chain_loop_inwards.svg
new file mode 100644
index 0000000..9fea243
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/chain_loop_inwards.svg
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="385.42209"
+ height="201.11388"
+ id="svg9044"
+ version="1.1"
+ inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
+ sodipodi:docname="chain_loop.svg">
+ <defs
+ id="defs9046">
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="Arrow1Mend"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Mend">
+ <path
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ style="fill:#767676;fill-opacity:1;fill-rule:evenodd;stroke:#767676;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ id="path911" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="Arrow2Lend"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow2Lend">
+ <path
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ style="fill:#767676;fill-opacity:1;fill-rule:evenodd;stroke:#767676;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ id="path923" />
+ </marker>
+ <linearGradient
+ id="linearGradient9562"
+ osb:paint="solid">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop9564" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.979899"
+ inkscape:cx="168.58169"
+ inkscape:cy="-21.83025"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1359"
+ inkscape:window-height="1041"
+ inkscape:window-x="150"
+ inkscape:window-y="60"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ inkscape:document-rotation="0" />
+ <metadata
+ id="metadata9049">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-194.29952,-275.90446)">
+ <path
+ id="path848"
+ d="m 229.2724,347.82772 0.71428,70 60,54.28571 125,-30 122.14286,32.14286 39.28571,-103.57143 -49.28571,-92.14286 -97.14286,47.85715 -104.28571,-47.14286 -128.57143,2.85714 z"
+ style="fill:none;stroke:#767676;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path6867"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="228.97542"
+ cy="348.89066"
+ r="2.5253813" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9620"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="230.76782"
+ cy="418.05508"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9622"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="290.03033"
+ cy="471.81509"
+ r="2.5253813" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9624"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="413.70074"
+ cy="443.18237"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9626"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="430.03122"
+ cy="326.42294"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9628"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="536.83978"
+ cy="473.99295"
+ r="2.5253813" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9630"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="526.38983"
+ cy="278.92984"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9632"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="576.69623"
+ cy="371.42444"
+ r="2.5253813" />
+ <path
+ id="path850"
+ d="m 253.47669,467.02956 v 0"
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="279.28699"
+ cx="324.60413"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="circle852"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="circle854"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="197.32491"
+ cy="281.81238"
+ r="2.5253813" />
+ <text
+ id="text862"
+ y="344.07681"
+ x="425.94608"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="344.07681"
+ x="425.94608"
+ id="tspan860"
+ sodipodi:role="line">1</tspan></text>
+ <text
+ id="text866"
+ y="295.57101"
+ x="519.9389"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="295.57101"
+ x="519.9389"
+ id="tspan864"
+ sodipodi:role="line">2</tspan></text>
+ <text
+ id="text870"
+ y="376.38321"
+ x="558.82983"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="376.38321"
+ x="558.82983"
+ id="tspan868"
+ sodipodi:role="line">3</tspan></text>
+ <text
+ id="text874"
+ y="463.25635"
+ x="524.98969"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="463.25635"
+ x="524.98969"
+ id="tspan872"
+ sodipodi:role="line">4</tspan></text>
+ <text
+ id="text878"
+ y="430.93146"
+ x="408.82214"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="430.93146"
+ x="408.82214"
+ id="tspan876"
+ sodipodi:role="line">5</tspan></text>
+ <text
+ id="text882"
+ y="460.73096"
+ x="289.11905"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="460.73096"
+ x="289.11905"
+ id="tspan880"
+ sodipodi:role="line">6</tspan></text>
+ <text
+ id="text886"
+ y="417.2944"
+ x="241.1368"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="417.2944"
+ x="241.1368"
+ id="tspan884"
+ sodipodi:role="line">7</tspan></text>
+ <text
+ id="text890"
+ y="354.15985"
+ x="236.08604"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="354.15985"
+ x="236.08604"
+ id="tspan888"
+ sodipodi:role="line">8</tspan></text>
+ <text
+ id="text894"
+ y="299.6116"
+ x="212.34746"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="299.6116"
+ x="212.34746"
+ id="tspan892"
+ sodipodi:role="line">9</tspan></text>
+ <text
+ id="text898"
+ y="301.63193"
+ x="313.36273"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="301.63193"
+ x="313.36273"
+ id="tspan896"
+ sodipodi:role="line">10</tspan></text>
+ <path
+ sodipodi:nodetypes="cc"
+ id="path900"
+ d="m 479.45824,302.18069 17.90441,37.1805"
+ style="fill:none;stroke:#767676;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Mend)" />
+ <text
+ id="text1200"
+ y="354.91748"
+ x="473.72443"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ y="354.91748"
+ x="473.72443"
+ id="tspan1198"
+ sodipodi:role="line">normal</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/chain_loop_outwards.svg b/Client/ThirdParty/Box2D/docs/images/chain_loop_outwards.svg
new file mode 100644
index 0000000..1f03926
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/chain_loop_outwards.svg
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ sodipodi:docname="chain_loop_reversed.svg"
+ inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
+ version="1.1"
+ id="svg9044"
+ height="204.77463"
+ width="385.42209">
+ <defs
+ id="defs9046">
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mend"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path911"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill:#767676;fill-opacity:1;fill-rule:evenodd;stroke:#767676;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path923"
+ style="fill:#767676;fill-opacity:1;fill-rule:evenodd;stroke:#767676;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)" />
+ </marker>
+ <linearGradient
+ osb:paint="solid"
+ id="linearGradient9562">
+ <stop
+ id="stop9564"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ inkscape:document-rotation="0"
+ fit-margin-bottom="0"
+ fit-margin-right="0"
+ fit-margin-left="0"
+ fit-margin-top="0"
+ inkscape:window-maximized="0"
+ inkscape:window-y="60"
+ inkscape:window-x="150"
+ inkscape:window-height="1041"
+ inkscape:window-width="1359"
+ showgrid="false"
+ inkscape:current-layer="layer1"
+ inkscape:document-units="px"
+ inkscape:cy="79.63377"
+ inkscape:cx="82.971281"
+ inkscape:zoom="2.8"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base" />
+ <metadata
+ id="metadata9049">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ transform="translate(-194.29952,-272.2437)"
+ id="layer1"
+ inkscape:groupmode="layer"
+ inkscape:label="Layer 1">
+ <path
+ style="fill:none;stroke:#767676;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 229.2724,347.82772 0.71428,70 60,54.28571 125,-30 122.14286,32.14286 39.28571,-103.57143 -49.28571,-92.14286 -97.14286,47.85715 -104.28571,-47.14286 -128.57143,2.85714 z"
+ id="path848" />
+ <circle
+ r="2.5253813"
+ cy="348.89066"
+ cx="228.97542"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path6867"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="418.05508"
+ cx="230.76782"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9620"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="471.81509"
+ cx="290.03033"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9622"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="443.18237"
+ cx="413.70074"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9624"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="326.42294"
+ cx="430.03122"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9626"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="473.99295"
+ cx="536.83978"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9628"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="278.92984"
+ cx="526.38983"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9630"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="371.42444"
+ cx="576.69623"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="path9632"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 253.47669,467.02956 v 0"
+ id="path850" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="circle852"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="324.60413"
+ cy="279.28699"
+ r="2.5253813" />
+ <circle
+ r="2.5253813"
+ cy="281.81238"
+ cx="197.32491"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="circle854"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="425.94608"
+ y="344.07681"
+ id="text862"><tspan
+ sodipodi:role="line"
+ id="tspan860"
+ x="425.94608"
+ y="344.07681">1</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="316.62775"
+ y="298.60147"
+ id="text866"><tspan
+ sodipodi:role="line"
+ id="tspan864"
+ x="316.62775"
+ y="298.60147">2</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="211.25813"
+ y="296.85907"
+ id="text870"><tspan
+ sodipodi:role="line"
+ id="tspan868"
+ x="211.25813"
+ y="296.85907">3</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="236.15477"
+ y="352.01703"
+ id="text874"><tspan
+ sodipodi:role="line"
+ id="tspan872"
+ x="236.15477"
+ y="352.01703">4</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="239.87413"
+ y="418.30457"
+ id="text878"><tspan
+ sodipodi:role="line"
+ id="tspan876"
+ x="239.87413"
+ y="418.30457">5</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="289.11905"
+ y="460.73096"
+ id="text882"><tspan
+ sodipodi:role="line"
+ id="tspan880"
+ x="289.11905"
+ y="460.73096">6</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="413.11526"
+ y="434.21445"
+ id="text886"><tspan
+ sodipodi:role="line"
+ id="tspan884"
+ x="413.11526"
+ y="434.21445">7</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="528.52521"
+ y="464.51904"
+ id="text890"><tspan
+ sodipodi:role="line"
+ id="tspan888"
+ x="528.52521"
+ y="464.51904">8</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="558.0722"
+ y="376.88828"
+ id="text894"><tspan
+ sodipodi:role="line"
+ id="tspan892"
+ x="558.0722"
+ y="376.88828">9</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="513.62549"
+ y="300.36923"
+ id="text898"><tspan
+ sodipodi:role="line"
+ id="tspan896"
+ x="513.62549"
+ y="300.36923">10</tspan></text>
+ <path
+ style="fill:none;stroke:#767676;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend)"
+ d="M 383.79198,305.30043 397.6917,274.04436"
+ id="path900"
+ sodipodi:nodetypes="cc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:13.3333px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="400.48837"
+ y="290.26773"
+ id="text1200"><tspan
+ sodipodi:role="line"
+ id="tspan1198"
+ x="400.48837"
+ y="290.26773">normal</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/chain_shape.svg b/Client/ThirdParty/Box2D/docs/images/chain_shape.svg
new file mode 100644
index 0000000..04ea959
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/chain_shape.svg
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ sodipodi:docname="chain_shape.svg"
+ inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
+ version="1.1"
+ id="svg9044"
+ height="225.19205"
+ width="402.73563">
+ <defs
+ id="defs9046">
+ <linearGradient
+ osb:paint="solid"
+ id="linearGradient9562">
+ <stop
+ id="stop9564"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ inkscape:document-rotation="0"
+ fit-margin-bottom="0"
+ fit-margin-right="0"
+ fit-margin-left="0"
+ fit-margin-top="0"
+ inkscape:window-maximized="0"
+ inkscape:window-y="60"
+ inkscape:window-x="150"
+ inkscape:window-height="1041"
+ inkscape:window-width="1359"
+ showgrid="false"
+ inkscape:current-layer="layer1"
+ inkscape:document-units="px"
+ inkscape:cy="186.37568"
+ inkscape:cx="193.56931"
+ inkscape:zoom="2.8"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base" />
+ <metadata
+ id="metadata9049">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ transform="translate(-183.55811,-264.25629)"
+ id="layer1"
+ inkscape:groupmode="layer"
+ inkscape:label="Layer 1">
+ <path
+ sodipodi:nodetypes="csccc"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:connector-curvature="0"
+ id="path9052"
+ d="m 323.77573,448.72257 c 17.00369,9.32859 68.03674,37.35768 70.04901,38.08934 4.02453,1.46331 83.91263,-37.80722 83.91263,-37.80722 l 105.40088,-34.7384 -76.62636,-97.92976"
+ style="fill:none;stroke:#767676;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path845"
+ d="m 506.51189,316.33653 58.7583,-35.85104"
+ style="fill:none;stroke:#767676;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4, 4;stroke-dashoffset:0;stroke-opacity:1" />
+ <path
+ id="path847"
+ d="M 253.47669,467.02956 187.05916,434.70468"
+ style="fill:none;stroke:#767676;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4, 4;stroke-dashoffset:0;stroke-opacity:1" />
+ <path
+ id="path849"
+ d="m 253.47669,467.02956 70.29904,-18.30699"
+ style="fill:none;stroke:#767676;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ transform="translate(-54.372373,-177.18205)"
+ id="path6867"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9620"
+ transform="translate(11.817253,-145.14071)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ transform="translate(81.49165,-163.51344)"
+ id="path9622"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9624"
+ transform="translate(235.87634,-162.86043)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ transform="translate(152.3854,-125.51272)"
+ id="path9626"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ transform="translate(341.33682,-197.58559)"
+ id="path9628"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9630"
+ transform="translate(265.17257,-295.86296)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ transform="translate(323.65299,-332.43511)"
+ id="path9632"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ id="text9634"
+ y="426.1131"
+ x="183.1958"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ style="font-size:14px;line-height:1.25"
+ y="426.1131"
+ x="183.1958"
+ id="tspan9636"
+ sodipodi:role="line">ghost</tspan></text>
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Chain1.png"
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="549.41998"
+ y="273.77875"
+ id="text9638"><tspan
+ style="font-size:14px;line-height:1.25"
+ sodipodi:role="line"
+ id="tspan9640"
+ x="549.41998"
+ y="273.77875">ghost</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/convex_concave.gif b/Client/ThirdParty/Box2D/docs/images/convex_concave.gif
new file mode 100644
index 0000000..feefdf0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/convex_concave.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/debug_draw.png b/Client/ThirdParty/Box2D/docs/images/debug_draw.png
new file mode 100644
index 0000000..8b4d56f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/debug_draw.png
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/distance.svg b/Client/ThirdParty/Box2D/docs/images/distance.svg
new file mode 100644
index 0000000..afefe85
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/distance.svg
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="271.28311"
+ height="111.33035"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="distance.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\distance.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path3696"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3690"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2830"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2852"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3648"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective4310"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend-0"
+ style="overflow:visible">
+ <path
+ id="path3696-9"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ id="perspective4342"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2"
+ inkscape:cx="26.976981"
+ inkscape:cy="-103.40251"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1467"
+ inkscape:window-height="1068"
+ inkscape:window-x="196"
+ inkscape:window-y="16"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-209.30148,-534.31362)">
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.21355975;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1.21355975, 2.4271195;stroke-dashoffset:0;stroke-opacity:1;marker-end:none"
+ d="m 388,603.62582 -62,0.47272"
+ id="path3664"
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 387,546.86218 79,-1 14,56 -91,43 z"
+ id="path2816"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 246.19848,535.12334 80.64122,69.26034 -116.72691,8.47526 z"
+ id="path2818"
+ inkscape:connector-curvature="0" />
+ <rect
+ style="fill:#00ff00;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820"
+ width="7"
+ height="7"
+ x="385.5"
+ y="599.36218" />
+ <rect
+ style="fill:#00ff00;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820-1"
+ width="7"
+ height="7"
+ x="323"
+ y="599.86218" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/distance_joint.gif b/Client/ThirdParty/Box2D/docs/images/distance_joint.gif
new file mode 100644
index 0000000..3fd44a4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/distance_joint.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/gear_joint.gif b/Client/ThirdParty/Box2D/docs/images/gear_joint.gif
new file mode 100644
index 0000000..9737d7d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/gear_joint.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/ghost_collision.svg b/Client/ThirdParty/Box2D/docs/images/ghost_collision.svg
new file mode 100644
index 0000000..8ca172c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/ghost_collision.svg
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="262.62952"
+ height="103.72113"
+ id="svg6349"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="ghost_collision.svg">
+ <defs
+ id="defs6351">
+ <marker
+ inkscape:stockid="Arrow1Send"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Send"
+ style="overflow:visible">
+ <path
+ id="path4500"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.2,0,0,-0.2,-1.2,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mend"
+ style="overflow:visible">
+ <path
+ id="path4494"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path4488"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="TriangleOutL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="TriangleOutL"
+ style="overflow:visible">
+ <path
+ id="path4628"
+ d="M 5.77,0 -2.88,5 V -5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="scale(0.8)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.8"
+ inkscape:cx="16.976506"
+ inkscape:cy="8.3597391"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1413"
+ inkscape:window-height="1038"
+ inkscape:window-x="408"
+ inkscape:window-y="0"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata6354">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-286.8884,-532.20758)">
+ <path
+ style="fill:none;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 289.91378,613.4509 255.55849,1.51523"
+ id="path6357"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path6867"
+ transform="translate(47.982246,1.5152288)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path6867-1"
+ transform="translate(181.32238,2.525385)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path6867-1-9"
+ transform="translate(304.561,3.5355374)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect6905"
+ width="47.982246"
+ height="41.921329"
+ x="375.23105"
+ y="569.50922"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Send)"
+ d="m 373.75644,552.33667 h 51.0127"
+ id="path6907"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:none;marker-mid:none;marker-end:url(#Arrow1Mend)"
+ d="M 454.54834,609.91537 H 426.26407"
+ id="path7843"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="370.22092"
+ y="541.73004"
+ id="text8977"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ id="tspan8979"
+ x="370.22092"
+ y="541.73004"
+ style="font-size:14px;line-height:1.25">box motion</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="439.28574"
+ y="606.29077"
+ id="text8981"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ id="tspan8983"
+ x="439.28574"
+ y="606.29077"
+ style="font-size:14px;line-height:1.25">internal normal</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="328.92856"
+ y="633.43359"
+ id="text8985"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ id="tspan8987"
+ x="328.92856"
+ y="633.43359"
+ style="font-size:14px;line-height:1.25">edge1</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="460.78262"
+ y="633.36218"
+ id="text8985-3"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ x="460.78262"
+ y="633.36218"
+ id="tspan9010"
+ style="font-size:14px;line-height:1.25">edge2 </tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/ghost_vertices.svg b/Client/ThirdParty/Box2D/docs/images/ghost_vertices.svg
new file mode 100644
index 0000000..0777123
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/ghost_vertices.svg
@@ -0,0 +1,265 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ sodipodi:docname="ghost_vertices.svg"
+ inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
+ version="1.1"
+ id="svg6349"
+ height="95.10083"
+ width="249.00421">
+ <defs
+ id="defs6351">
+ <marker
+ style="overflow:visible"
+ id="Arrow1Send"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Send">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(-0.2,0,0,-0.2,-1.2,0)"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ id="path4500" />
+ </marker>
+ <marker
+ style="overflow:visible"
+ id="Arrow1Mend"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Mend">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ id="path4494" />
+ </marker>
+ <marker
+ style="overflow:visible"
+ id="Arrow1Lend"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Lend">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ id="path4488" />
+ </marker>
+ <marker
+ style="overflow:visible"
+ id="TriangleOutL"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="TriangleOutL">
+ <path
+ inkscape:connector-curvature="0"
+ transform="scale(0.8)"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
+ d="M 5.77,0 -2.88,5 V -5 Z"
+ id="path4628" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ lock-margins="true"
+ inkscape:document-rotation="0"
+ fit-margin-bottom="0.5"
+ fit-margin-right="0.5"
+ fit-margin-left="0.5"
+ fit-margin-top="0.5"
+ inkscape:window-maximized="0"
+ inkscape:window-y="66"
+ inkscape:window-x="1946"
+ inkscape:window-height="1038"
+ inkscape:window-width="1413"
+ showgrid="false"
+ inkscape:current-layer="layer1"
+ inkscape:document-units="px"
+ inkscape:cy="-1.4711953"
+ inkscape:cx="34.170039"
+ inkscape:zoom="2.8"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base" />
+ <metadata
+ id="metadata6354">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ transform="translate(-269.69485,-530.99694)"
+ id="layer1"
+ inkscape:groupmode="layer"
+ inkscape:label="Layer 1">
+ <path
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ inkscape:connector-curvature="0"
+ id="path9018"
+ d="m 291.78571,534.50504 66.42858,52.5"
+ style="fill:none;stroke:#7d7d7d;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1" />
+ <path
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ inkscape:connector-curvature="0"
+ id="path9020"
+ d="m 358.21429,586.6479 80.71429,-26.07143"
+ style="fill:none;stroke:#7d7d7d;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ inkscape:connector-curvature="0"
+ id="path9022"
+ d="m 438.57143,560.57647 56.78572,32.14286"
+ style="fill:none;stroke:#7d7d7d;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ transform="translate(49.053675,-77.413343)"
+ id="path6867"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ transform="translate(116.32238,-24.974615)"
+ id="path6867-1"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9012"
+ transform="translate(254.91814,-18.60732)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ r="2.5253813"
+ cy="611.93567"
+ cx="241.93153"
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ transform="translate(197.06099,-51.10732)"
+ id="path9014"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ id="text9024"
+ y="610.57648"
+ x="492.14285"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ style="font-size:14px;line-height:1.25"
+ y="610.57648"
+ x="492.14285"
+ id="tspan9026"
+ sodipodi:role="line">v0</tspan></text>
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="432.5"
+ y="577.36218"
+ id="text9028"><tspan
+ style="font-size:14px;line-height:1.25"
+ sodipodi:role="line"
+ id="tspan9030"
+ x="432.5"
+ y="577.36218">v1</tspan></text>
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ id="text9032"
+ y="602.7193"
+ x="349.64285"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ style="font-size:14px;line-height:1.25"
+ y="602.7193"
+ x="349.64285"
+ id="tspan9034"
+ sodipodi:role="line">v2</tspan></text>
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="283.92856"
+ y="552.00507"
+ id="text9036"><tspan
+ style="font-size:14px;line-height:1.25"
+ sodipodi:role="line"
+ id="tspan9038"
+ x="283.92856"
+ y="552.00507">v3</tspan></text>
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ id="text9040"
+ y="565.93359"
+ x="269.28568"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ style="font-size:14px;line-height:1.25"
+ y="565.93359"
+ x="269.28568"
+ id="tspan9042"
+ sodipodi:role="line">(ghost)</tspan></text>
+ <text
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\GhostVertices.png"
+ id="text9040-2"
+ y="623.10266"
+ x="479.21371"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ style="font-size:14px;line-height:1.25"
+ y="623.10266"
+ x="479.21371"
+ id="tspan9042-0"
+ sodipodi:role="line">(ghost)</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/logo.svg b/Client/ThirdParty/Box2D/docs/images/logo.svg
new file mode 100644
index 0000000..f002689
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/logo.svg
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="23.160606mm"
+ height="19.770294mm"
+ viewBox="0 0 23.160606 19.770294"
+ version="1.1"
+ id="svg8"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="Logo.svg">
+ <defs
+ id="defs2" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.8"
+ inkscape:cx="91.164312"
+ inkscape:cy="2.0199043"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:snap-grids="false"
+ inkscape:snap-to-guides="false"
+ inkscape:snap-others="false"
+ inkscape:object-nodes="false"
+ inkscape:snap-nodes="false"
+ inkscape:snap-global="false"
+ inkscape:window-width="2560"
+ inkscape:window-height="1377"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata5">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-4.3336132,-2.5558382)">
+ <rect
+ id="rect3724"
+ width="5.3740902"
+ height="4.9586015"
+ x="12.262583"
+ y="10.94324"
+ style="fill:none;stroke:#30aebf;stroke-width:0.60000002;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ inkscape:export-xdpi="208.37"
+ inkscape:export-ydpi="208.37" />
+ <rect
+ id="rect3724-5"
+ width="5.3740902"
+ height="4.9586015"
+ x="15.178779"
+ y="16.447105"
+ style="fill:none;stroke:#30aebf;stroke-width:0.60000002;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <rect
+ id="rect3724-7"
+ width="5.3740902"
+ height="4.9586015"
+ x="9.251893"
+ y="16.447105"
+ style="fill:none;stroke:#30aebf;stroke-width:0.60000002;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ style="fill:none;stroke:#8cc924;stroke-width:0.60000002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 4.3348411,22.026134 21.1823269,-0.0867"
+ id="path4552"
+ inkscape:connector-curvature="0"
+ inkscape:export-xdpi="208.37"
+ inkscape:export-ydpi="208.37" />
+ <circle
+ style="fill:none;stroke:#dc3132;stroke-width:0.60000002;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path4554"
+ cx="21.845764"
+ cy="8.3044558"
+ r="2.5724692"
+ inkscape:export-xdpi="208.37"
+ inkscape:export-ydpi="208.37" />
+ <path
+ style="fill:none;stroke:#eb8788;stroke-width:0.60000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 22.547358,4.9301842 2.104747,-2.07134"
+ id="path4556"
+ inkscape:connector-curvature="0"
+ inkscape:export-xdpi="208.37"
+ inkscape:export-ydpi="208.37" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4558"
+ d="m 24.184383,5.7319842 2.104747,-2.07134"
+ style="fill:none;stroke:#eb8788;stroke-width:0.60000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ inkscape:export-xdpi="208.37"
+ inkscape:export-ydpi="208.37" />
+ <path
+ style="fill:none;stroke:#eb8788;stroke-width:0.60000002;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 25.086418,7.1685542 2.104747,-2.07134"
+ id="path4562"
+ inkscape:connector-curvature="0"
+ inkscape:export-xdpi="208.37"
+ inkscape:export-ydpi="208.37" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/manifolds.svg b/Client/ThirdParty/Box2D/docs/images/manifolds.svg
new file mode 100644
index 0000000..564fe9f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/manifolds.svg
@@ -0,0 +1,256 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="278.64941"
+ height="199.68138"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="manifolds.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path3696"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3690"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2830"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2852"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3648"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective4310"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend-0"
+ style="overflow:visible">
+ <path
+ id="path3696-9"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ id="perspective4342"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2"
+ inkscape:cx="107.80664"
+ inkscape:cy="78.632812"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1097"
+ inkscape:window-height="1068"
+ inkscape:window-x="214"
+ inkscape:window-y="23"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-208.19336,-534.31362)">
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 227,602.36218 79,-1 14,56 -91,43 z"
+ id="path2816"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 246.19848,535.12334 80.64122,69.26034 -116.72691,8.47526 z"
+ id="path2818"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"
+ inkscape:connector-curvature="0" />
+ <rect
+ style="fill:#00ff00;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820"
+ width="7"
+ height="7"
+ x="224"
+ y="608.36218"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958" />
+ <rect
+ style="fill:#00ff00;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820-1"
+ width="7"
+ height="7"
+ x="303.5"
+ y="602.36218"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 386,601.86218 79,-1 14,56 -91,43 z"
+ id="path2816-7"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"
+ inkscape:connector-curvature="0" />
+ <circle
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path2866"
+ transform="translate(-2,14)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"
+ cx="428.75"
+ cy="556.61218"
+ r="34.75" />
+ <rect
+ style="fill:#00ff00;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820-4"
+ width="7"
+ height="7"
+ x="424.5"
+ y="602.86218"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ d="m 264,601.36218 v -26.5"
+ id="path3664"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ d="m 427.50961,601.02437 v -26.5"
+ id="path3664-4"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"
+ inkscape:connector-curvature="0" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="208"
+ y="731.86218"
+ id="text4330"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"><tspan
+ sodipodi:role="line"
+ id="tspan4332"
+ x="208"
+ y="731.86218"
+ style="font-size:12px;line-height:1.25">two points, one normal</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="378.83105"
+ y="731.86218"
+ id="text4330-8"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\manifolds.png"
+ inkscape:export-xdpi="180.11958"
+ inkscape:export-ydpi="180.11958"><tspan
+ sodipodi:role="line"
+ id="tspan4332-8"
+ x="378.83105"
+ y="731.86218"
+ style="font-size:12px;line-height:1.25">one point, one normal</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/missed_toi.svg b/Client/ThirdParty/Box2D/docs/images/missed_toi.svg
new file mode 100644
index 0000000..a8fbbe4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/missed_toi.svg
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="296.5"
+ height="148.6571"
+ id="svg4080"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="missed_toi.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\missed.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4082">
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path3626"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective4088" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2"
+ inkscape:cx="-118.5"
+ inkscape:cy="37.499998"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1138"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata4085">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-245,-425.20508)">
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4090"
+ width="295.5"
+ height="17"
+ x="245.5"
+ y="556.36218" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4602"
+ width="8"
+ height="134"
+ x="506.24817"
+ y="262.38239"
+ transform="rotate(20.920228)" />
+ <rect
+ y="542.29114"
+ x="223.04268"
+ height="134"
+ width="8"
+ id="rect4604"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ transform="rotate(-20.611746)" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:2, 4;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4606"
+ width="8"
+ height="134"
+ x="389"
+ y="429.36218" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="340.5"
+ y="466.36218"
+ id="text4608"><tspan
+ sodipodi:role="line"
+ id="tspan4610"
+ x="340.5"
+ y="466.36218"
+ style="font-size:12px;line-height:1.25">t=0</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="432.5"
+ y="466.33875"
+ id="text4612"><tspan
+ sodipodi:role="line"
+ id="tspan4614"
+ x="432.5"
+ y="466.33875"
+ style="font-size:12px;line-height:1.25">t=1</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ d="m 500.5,556.36218 v -40.5"
+ id="path2822"
+ inkscape:connector-curvature="0" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="462.5"
+ y="507.86218"
+ id="text4044"><tspan
+ sodipodi:role="line"
+ id="tspan4046"
+ x="462.5"
+ y="507.86218"
+ style="font-size:12px;line-height:1.25">separating axis</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/modules.svg b/Client/ThirdParty/Box2D/docs/images/modules.svg
new file mode 100644
index 0000000..08200be
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/modules.svg
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="216.625"
+ height="229"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="modules.svg">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3683"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2838"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2860"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2888"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2845"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective2867"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="-354.80283"
+ inkscape:cy="43.76881"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1138"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-183,-324.36218)">
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820-7-9-1-7"
+ width="120"
+ height="46"
+ x="183"
+ y="416.36218"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820-7-9-1"
+ width="120"
+ height="46"
+ x="279.625"
+ y="324.36218"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="310.13672"
+ y="351.92664"
+ id="text2826"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"><tspan
+ sodipodi:role="line"
+ id="tspan2828"
+ x="310.13672"
+ y="351.92664"
+ style="font-size:16px;line-height:1.25">Common</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="215.79297"
+ y="442.92664"
+ id="text2826-4"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"><tspan
+ sodipodi:role="line"
+ id="tspan2828-0"
+ x="215.79297"
+ y="442.92664"
+ style="font-size:16px;line-height:1.25">Collision</tspan></text>
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none"
+ id="rect2820-7-9"
+ width="120"
+ height="46"
+ x="279.625"
+ y="507.36218"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="307.94531"
+ y="535.92664"
+ id="text2826-4-4"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"><tspan
+ sodipodi:role="line"
+ id="tspan2828-0-8"
+ x="307.94531"
+ y="535.92664"
+ style="font-size:16px;line-height:1.25">Dynamics</tspan></text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="m 315.46875,370.36218 -48.3125,46"
+ id="path2881"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#rect2820-7-9-1"
+ inkscape:connection-end="#rect2820-7-9-1-7"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="m 267.4217,462.36218 47.7816,45"
+ id="path2883"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#rect2820-7-9-1-7"
+ inkscape:connection-end="#rect2820-7-9"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
+ d="m 339.625,370.36218 v 137"
+ id="path2885"
+ inkscape:connector-type="polyline"
+ inkscape:connection-start="#rect2820-7-9-1"
+ inkscape:connection-end="#rect2820-7-9"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\modules.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/overlap_test.svg b/Client/ThirdParty/Box2D/docs/images/overlap_test.svg
new file mode 100644
index 0000000..be78e9b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/overlap_test.svg
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="231.14912"
+ height="184.62988"
+ id="svg3598"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="overlap_test.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\regionquery.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs3600">
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path4314"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective3606" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="4.3325546"
+ inkscape:cx="115.57456"
+ inkscape:cy="79.495605"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1138"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata3603">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-209.87013,-406.2323)">
+ <rect
+ y="473.70428"
+ x="232.34212"
+ height="16.815773"
+ width="19.815773"
+ id="rect4120"
+ style="fill:none;stroke:#00d200;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="429.19492"
+ x="378.33273"
+ height="36.334541"
+ width="54.334541"
+ id="rect4122"
+ style="fill:none;stroke:#00d200;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="548.88507"
+ x="222.02287"
+ height="21.954247"
+ width="35.454247"
+ id="rect4124"
+ style="fill:none;stroke:#00d200;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="508.34296"
+ x="408.48077"
+ height="20.538485"
+ width="32.038483"
+ id="rect4126"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="524.32886"
+ x="306.46667"
+ height="61.066628"
+ width="43.566628"
+ id="rect4128"
+ style="fill:none;stroke:#00d200;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="429.74796"
+ x="292.88577"
+ height="66.228439"
+ width="33.728436"
+ id="rect4130"
+ style="fill:none;stroke:#00d200;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ style="fill:none;stroke:#00d200;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4276"
+ width="33.790939"
+ height="30.790941"
+ x="374.60455"
+ y="547.46674" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4278"
+ width="49.259716"
+ height="43.759716"
+ x="210.37013"
+ y="406.7323" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:2, 4;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2826"
+ width="149.5"
+ height="128"
+ x="248"
+ y="462.36218" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/prismatic_joint.gif b/Client/ThirdParty/Box2D/docs/images/prismatic_joint.gif
new file mode 100644
index 0000000..ac2037f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/prismatic_joint.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/pulley_joint.gif b/Client/ThirdParty/Box2D/docs/images/pulley_joint.gif
new file mode 100644
index 0000000..ad8d4fb
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/pulley_joint.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/raycast.svg b/Client/ThirdParty/Box2D/docs/images/raycast.svg
new file mode 100644
index 0000000..78ac5df
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/raycast.svg
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="248.01385"
+ height="218.69197"
+ id="svg3598"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="raycast.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\raycast.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs3600">
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path4314"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective3606" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="3.6543567"
+ inkscape:cx="124.00693"
+ inkscape:cy="94.046232"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1246"
+ inkscape:window-height="849"
+ inkscape:window-x="100"
+ inkscape:window-y="100"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata3603">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-193.0054,-367.20351)">
+ <rect
+ y="473.70428"
+ x="232.34212"
+ height="16.815773"
+ width="19.815773"
+ id="rect4120"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="429.19492"
+ x="378.33273"
+ height="36.334541"
+ width="54.334541"
+ id="rect4122"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="548.88507"
+ x="222.02287"
+ height="21.954247"
+ width="35.454247"
+ id="rect4124"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="508.34296"
+ x="408.48077"
+ height="20.538485"
+ width="32.038483"
+ id="rect4126"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="524.32886"
+ x="306.46667"
+ height="61.066628"
+ width="43.566628"
+ id="rect4128"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ y="429.74796"
+ x="292.88577"
+ height="66.228439"
+ width="33.728436"
+ id="rect4130"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4276"
+ width="33.790939"
+ height="30.790941"
+ x="374.60455"
+ y="547.46674" />
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4278"
+ width="49.259716"
+ height="43.759716"
+ x="210.37013"
+ y="406.7323" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1, 2;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ d="m 413.96525,367.89693 -219.9305,175.4305"
+ id="path4282"
+ inkscape:connector-curvature="0" />
+ <path
+ id="path4732"
+ d="m 414.26779,367.59439 -86.85587,69.28175"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/revolute_joint.gif b/Client/ThirdParty/Box2D/docs/images/revolute_joint.gif
new file mode 100644
index 0000000..39b74e2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/revolute_joint.gif
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/self_intersect.svg b/Client/ThirdParty/Box2D/docs/images/self_intersect.svg
new file mode 100644
index 0000000..9970d4b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/self_intersect.svg
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="335.57034"
+ height="156.77301"
+ id="svg9044"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="self_intersect.svg">
+ <defs
+ id="defs9046">
+ <linearGradient
+ id="linearGradient9562"
+ osb:paint="solid">
+ <stop
+ style="stop-color:#000000;stop-opacity:1;"
+ offset="0"
+ id="stop9564" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="4.3657018"
+ inkscape:cx="167.78516"
+ inkscape:cy="67.620514"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1359"
+ inkscape:window-height="1041"
+ inkscape:window-x="150"
+ inkscape:window-y="60"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata9049">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-250.72341,-313.04733)">
+ <path
+ style="fill:none;stroke:#767676;stroke-width:0.7596947px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 253.77069,466.3256 70.02703,-17.5597 c 0,0 71.55832,-119.48587 75.58286,-118.02256 4.02453,1.46331 78.86187,117.75627 78.86187,117.75627 l 104.73573,-34.12145 -76.46629,-98.04163 -191.10691,74.53424 z"
+ id="path9052"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ sodipodi:nodetypes="ccsccccc" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ transform="translate(11.817253,-145.14071)"
+ id="path9620"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9622"
+ transform="translate(81.49165,-163.51344)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ transform="translate(235.87634,-162.86043)"
+ id="path9624"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9626"
+ transform="translate(72.583349,-220.46706)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9628"
+ transform="translate(341.33682,-197.58559)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ inkscape:export-ydpi="179.94545"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ transform="translate(265.17257,-295.86296)"
+ id="path9630"
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ <circle
+ style="fill:#b0ddb3;fill-opacity:1;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path9632"
+ transform="translate(157.4829,-281.42241)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SelfIntersect.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="241.93153"
+ cy="611.93567"
+ r="2.5253813" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/skin_collision.svg b/Client/ThirdParty/Box2D/docs/images/skin_collision.svg
new file mode 100644
index 0000000..29ac847
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/skin_collision.svg
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="322.26855"
+ height="108.76013"
+ id="svg5128"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="skin-collision.svg">
+ <defs
+ id="defs5130" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.8"
+ inkscape:cx="149.63278"
+ inkscape:cy="38.587018"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1148"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata5133">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-178.07143,-467.67348)">
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect5140"
+ width="56.568542"
+ height="42.426407"
+ x="314.03363"
+ y="471.8606"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="3.2142856"
+ inkscape:original="M 329.9375 406.5 L 329.9375 448.9375 L 386.5 448.9375 L 386.5 406.5 L 329.9375 406.5 z "
+ style="fill:none;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5700"
+ d="M 329.9375,403.28516 A 3.214607,3.214607 0 0 0 326.72266,406.5 v 42.4375 a 3.214607,3.214607 0 0 0 3.21484,3.21484 H 386.5 a 3.214607,3.214607 0 0 0 3.21484,-3.21484 V 406.5 A 3.214607,3.214607 0 0 0 386.5,403.28516 Z"
+ transform="translate(-15.980776,64.888322)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect5138"
+ width="53.538086"
+ height="47.477169"
+ x="319.46075"
+ y="520.26434"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="3.2926946"
+ inkscape:original="M 319.75 426.21875 L 319.75 473.6875 L 373.28125 473.6875 L 373.28125 426.21875 L 319.75 426.21875 z "
+ style="fill:none;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="path5720"
+ d="m 319.75,422.92578 a 3.2930238,3.2930238 0 0 0 -3.29297,3.29297 v 47.46875 a 3.2930238,3.2930238 0 0 0 3.29297,3.29297 h 53.53125 a 3.2930238,3.2930238 0 0 0 3.29297,-3.29297 v -47.46875 a 3.2930238,3.2930238 0 0 0 -3.29297,-3.29297 z"
+ transform="translate(-0.59098611,95.046407)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 181.82746,572.53972 H 494.97475"
+ id="path5136"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <rect
+ style="fill:none;stroke:#7d7d7d;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect5750"
+ width="321.26855"
+ height="6.0714283"
+ x="178.57143"
+ y="569.86218"
+ ry="3.0357141"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="393.9595"
+ y="501.07144"
+ id="text5770"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinCollision.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ id="tspan5772"
+ x="393.9595"
+ y="501.07144"
+ style="font-size:14px;line-height:1.25">Polygons collide</tspan><tspan
+ sodipodi:role="line"
+ x="393.9595"
+ y="518.57141"
+ id="tspan5774"
+ style="font-size:14px;line-height:1.25">with their skin</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/skinned_polygon.svg b/Client/ThirdParty/Box2D/docs/images/skinned_polygon.svg
new file mode 100644
index 0000000..d93934c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/skinned_polygon.svg
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="174.87"
+ height="149.37024"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="skinned_polygon.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mstart"
+ style="overflow:visible">
+ <path
+ id="path3660"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path3663"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mend"
+ style="overflow:visible">
+ <path
+ id="path3645"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3657"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path3639"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lstart"
+ style="overflow:visible">
+ <path
+ id="path3654"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(1.1,0,0,1.1,1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2835"
+ inkscape:persp3d-origin="292.5 : 75.212601 : 1"
+ inkscape:vp_z="585 : 112.8189 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 112.8189 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.8284271"
+ inkscape:cx="64.699886"
+ inkscape:cy="74.828007"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1737"
+ inkscape:window-height="1054"
+ inkscape:window-x="65"
+ inkscape:window-y="121"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-283.1327,-415.03117)">
+ <path
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 289.5,466.36218 26,47.5 57.5,43.5 77.5,-70 -17,-61.5 -70.5,-4 z"
+ id="path5829"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinnedPolygon.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ inkscape:connector-curvature="0" />
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="6.4355307"
+ inkscape:original="M 486.25 547.125 L 412.75 591.625 L 438.75 639.125 L 496.25 682.625 L 573.75 612.625 L 556.75 551.125 L 486.25 547.125 z "
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:1, 4;stroke-dashoffset:0;stroke-opacity:1"
+ id="path3928"
+ d="m 485.9707,540.69531 a 6.4361742,6.4361742 0 0 0 -3.05468,0.92383 l -73.5,44.5 a 6.4361742,6.4361742 0 0 0 -2.31055,8.5957 l 26,47.5 a 6.4361742,6.4361742 0 0 0 1.76172,2.04297 l 57.5,43.5 a 6.4361742,6.4361742 0 0 0 8.19726,-0.35742 l 77.5,-70 a 6.4361742,6.4361742 0 0 0 1.88867,-6.49023 l -17,-61.5 a 6.4361742,6.4361742 0 0 0 -5.83789,-4.71094 l -70.5,-4 a 6.4361742,6.4361742 0 0 0 -0.64453,-0.004 z"
+ transform="translate(-122.68303,-125.1579)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\SkinnedPolygon.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/testbed.png b/Client/ThirdParty/Box2D/docs/images/testbed.png
new file mode 100644
index 0000000..e2de2ad
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/testbed.png
Binary files differ
diff --git a/Client/ThirdParty/Box2D/docs/images/tunneling1.svg b/Client/ThirdParty/Box2D/docs/images/tunneling1.svg
new file mode 100644
index 0000000..b6d68b0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/tunneling1.svg
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="274.69003"
+ height="244.50266"
+ id="svg3938"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="tunnel1.svg">
+ <defs
+ id="defs3940">
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path4488"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.98994949"
+ inkscape:cx="42.598267"
+ inkscape:cy="2.3289626"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1402"
+ inkscape:window-height="1069"
+ inkscape:window-x="299"
+ inkscape:window-y="26"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata3943">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-241.98927,-300.82514)">
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 348.57143,300.93361 54.28571,244.28572"
+ id="path3946"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Tunnel1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ sodipodi:type="star"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path3952"
+ sodipodi:sides="5"
+ sodipodi:cx="144.28571"
+ sodipodi:cy="343.79074"
+ sodipodi:r1="37.252586"
+ sodipodi:r2="30.137976"
+ sodipodi:arg1="1.0040671"
+ sodipodi:arg2="1.6323856"
+ inkscape:flatsided="true"
+ inkscape:rounded="0"
+ inkscape:randomized="0"
+ d="m 164.28571,375.21931 -43.71001,-2.69547 -10.94359,-42.40364 36.94651,-23.51141 33.77777,27.87278 z"
+ inkscape:transform-center-x="-0.70854843"
+ inkscape:transform-center-y="-2.876691"
+ transform="translate(132.85715,125.71429)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Tunnel1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ sodipodi:type="star"
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path3952-2"
+ sodipodi:sides="5"
+ sodipodi:cx="144.28571"
+ sodipodi:cy="343.79074"
+ sodipodi:r1="37.252586"
+ sodipodi:r2="30.137976"
+ sodipodi:arg1="1.0040671"
+ sodipodi:arg2="1.6323856"
+ inkscape:flatsided="true"
+ inkscape:rounded="0"
+ inkscape:randomized="0"
+ d="m 164.28571,375.21931 -43.71001,-2.69547 -10.94359,-42.40364 36.94651,-23.51141 33.77777,27.87278 z"
+ inkscape:transform-center-x="-1.9942167"
+ inkscape:transform-center-y="1.6069069"
+ transform="rotate(22.495262,160.88661,1216.0763)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Tunnel1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.79999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:7.19999981, 7.19999981;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
+ d="m 290,413.79075 c 27.14286,-48.57142 84.28571,-68.57142 144.28571,-51.42857"
+ id="path4480"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Tunnel1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="260"
+ y="533.79077"
+ id="text5108"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Tunnel1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ id="tspan5110"
+ x="260"
+ y="533.79077"
+ style="font-size:14px;line-height:1.25">time0</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="466.85715"
+ y="472.07648"
+ id="text5112"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\Tunnel1.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"><tspan
+ sodipodi:role="line"
+ id="tspan5114"
+ x="466.85715"
+ y="472.07648"
+ style="font-size:14px;line-height:1.25">time1</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/tunneling2.svg b/Client/ThirdParty/Box2D/docs/images/tunneling2.svg
new file mode 100644
index 0000000..fa6d609
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/tunneling2.svg
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="234"
+ height="101.75"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="tunneling2.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\tunneling.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path3648"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective3602"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2"
+ inkscape:cx="-68"
+ inkscape:cy="83.750001"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1390"
+ inkscape:window-height="1038"
+ inkscape:window-x="50"
+ inkscape:window-y="50"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-210,-490.36218)">
+ <rect
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2816"
+ width="233"
+ height="13.5"
+ x="210.5"
+ y="541.86218" />
+ <circle
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path3592"
+ transform="translate(7.5,3)"
+ cx="295.25"
+ cy="494.11218"
+ r="6.25" />
+ <circle
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path3592-1"
+ transform="translate(7.5,91.25)"
+ cx="295.25"
+ cy="494.11218"
+ r="6.25" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.93691868;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.93691866, 1.87383732;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ d="M 302.99984,505.33064 V 577.0062"
+ id="path3616"
+ inkscape:connector-curvature="0" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ x="319"
+ y="499.86218"
+ id="text4066"><tspan
+ sodipodi:role="line"
+ id="tspan4068"
+ x="319"
+ y="499.86218"
+ style="font-size:12px;line-height:1.25">t=0</tspan></text>
+ <text
+ id="text4070"
+ y="587.86218"
+ x="319"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
+ xml:space="preserve"><tspan
+ sodipodi:role="line"
+ id="tspan4074"
+ x="319"
+ y="587.86218"
+ style="font-size:12px;line-height:1.25">t=1</tspan></text>
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/wheel_joint.svg b/Client/ThirdParty/Box2D/docs/images/wheel_joint.svg
new file mode 100644
index 0000000..9e61929
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/wheel_joint.svg
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="69.631729"
+ height="119.93737"
+ id="svg5128"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="wheel-joint.svg">
+ <defs
+ id="defs5130">
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3807"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path3789"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lstart"
+ style="overflow:visible">
+ <path
+ id="path3804"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(1.1,0,0,1.1,1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mstart"
+ style="overflow:visible">
+ <path
+ id="path3792"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(0.4,0,0,0.4,4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lstart"
+ style="overflow:visible">
+ <path
+ id="path3786"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(0.8,0,0,0.8,10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.979899"
+ inkscape:cx="-0.64333643"
+ inkscape:cy="-13.952543"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1359"
+ inkscape:window-height="1041"
+ inkscape:window-x="150"
+ inkscape:window-y="60"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata5133">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-313.07066,-471.3606)">
+ <rect
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#767676;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect5140"
+ width="56.568542"
+ height="42.426407"
+ x="314.03363"
+ y="471.8606"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\WheelJoint.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#767676;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path2997"
+ transform="translate(-8.5714286,-2.8571429)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\WheelJoint.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="351.25"
+ cy="560.75507"
+ r="16.964285" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 341.78571,492.36218 1.42858,98.92857"
+ id="path3767"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\WheelJoint.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <circle
+ transform="translate(134.22402,67.175144)"
+ id="path3779"
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\WheelJoint.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545"
+ cx="208.57143"
+ cy="490.93362"
+ r="2.1428571" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#Arrow2Lstart);marker-mid:none;marker-end:url(#Arrow2Lend)"
+ d="m 377.85714,506.46933 0.53571,45"
+ id="path3781"
+ inkscape:connector-curvature="0"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\WheelJoint.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ <path
+ sodipodi:type="arc"
+ style="fill:none;stroke:#767676;stroke-opacity:1;marker-start:url(#Arrow2Lstart);marker-end:url(#Arrow2Lend)"
+ id="path5547"
+ sodipodi:cx="313.57144"
+ sodipodi:cy="555.39789"
+ sodipodi:rx="23.392857"
+ sodipodi:ry="23.392857"
+ d="M 308.31133,578.19168 A 23.392857,23.392857 0 0 1 290.45762,559.00025 23.392857,23.392857 0 0 1 301.62433,535.2859"
+ sodipodi:start="1.7975952"
+ sodipodi:end="4.1763713"
+ sodipodi:open="true"
+ transform="translate(23.392857,2.5)"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\WheelJoint.png"
+ inkscape:export-xdpi="179.94545"
+ inkscape:export-ydpi="179.94545" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/images/winding.svg b/Client/ThirdParty/Box2D/docs/images/winding.svg
new file mode 100644
index 0000000..e543df0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/images/winding.svg
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="236.53163"
+ height="176.41858"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
+ sodipodi:docname="winding.svg"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="Arrow2Mstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mstart"
+ style="overflow:visible">
+ <path
+ id="path3660"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Mend"
+ style="overflow:visible">
+ <path
+ id="path3663"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="scale(-0.6)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Mend"
+ style="overflow:visible">
+ <path
+ id="path3645"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.4,0,0,-0.4,-4,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lend"
+ style="overflow:visible">
+ <path
+ id="path3657"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible">
+ <path
+ id="path3639"
+ d="M 0,0 5,-5 -12.5,0 5,5 Z"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;marker-start:none"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Lstart"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow2Lstart"
+ style="overflow:visible">
+ <path
+ id="path3654"
+ style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+ transform="matrix(1.1,0,0,1.1,1.1,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective10" />
+ <inkscape:perspective
+ id="perspective2835"
+ inkscape:persp3d-origin="292.5 : 75.212601 : 1"
+ inkscape:vp_z="585 : 112.8189 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 112.8189 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.70710678"
+ inkscape:cx="-672.64537"
+ inkscape:cy="145.50488"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1737"
+ inkscape:window-height="1054"
+ inkscape:window-x="25"
+ inkscape:window-y="25"
+ inkscape:window-maximized="0"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-245.94154,-381.59189)">
+ <text
+ id="6"
+ xml:space="preserve"
+ x="476.47318"
+ y="507.86407"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">x</text>
+ <text
+ id="7"
+ xml:space="preserve"
+ x="482.47318"
+ y="507.86407"
+ style="font-style:normal;font-weight:normal;font-size:13.80000019px;line-height:0%;font-family:Calibri;text-align:start;text-anchor:start;fill:#000000"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"> </text>
+ <text
+ id="8"
+ xml:space="preserve"
+ x="387.67319"
+ y="387.19345"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">y</text>
+ <text
+ id="9"
+ xml:space="preserve"
+ x="396.32318"
+ y="383.19345"
+ style="font-style:normal;font-weight:normal;font-size:13.80000019px;line-height:0%;font-family:Calibri;text-align:start;text-anchor:start;fill:#000000"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"> </text>
+ <text
+ id="11"
+ xml:space="preserve"
+ x="245.37318"
+ y="420.09586"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:0%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">CCW winding</text>
+ <text
+ id="12"
+ xml:space="preserve"
+ x="294.62317"
+ y="397.59586"
+ style="font-style:normal;font-weight:normal;font-size:13.80000019px;line-height:0%;font-family:Calibri;text-align:start;text-anchor:start;fill:#000000"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"> </text>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow2Mend)"
+ d="m 345.5,414.36218 -56.5,34"
+ id="path4267"
+ sodipodi:nodetypes="cc"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#d7e3f4;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 289.5,466.36218 26,47.5 57.5,43.5 77.5,-70 -17,-61.5 -70.5,-4 z"
+ id="path5829"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow2Mstart);marker-end:url(#Arrow2Mend)"
+ d="m 384,392.86218 v 101 h 95.5"
+ id="path5241"
+ inkscape:export-filename="D:\Development\Box2D\Box2D\Documentation\images\winding.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/Client/ThirdParty/Box2D/docs/loose_ends.md b/Client/ThirdParty/Box2D/docs/loose_ends.md
new file mode 100644
index 0000000..249beef
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/loose_ends.md
@@ -0,0 +1,214 @@
+# Loose Ends
+
+## User Data
+The `b2Fixture`, `b2Body`, and `b2Joint` classes allow you to attach user data
+as a uintptr_t. This is handy when you are examining Box2D data
+structures and you want to determine how they relate to the objects in
+your game engine.
+
+For example, it is typical to attach an actor pointer to the rigid body
+on that actor. This sets up a circular reference. If you have the actor,
+you can get the body. If you have the body, you can get the actor.
+
+```cpp
+GameActor* actor = GameCreateActor();
+b2BodyDef bodyDef;
+bodyDef.userData.pointer = reinterpret_cast<uintptr_t>(actor);
+actor->body = myWorld->CreateBody(&bodyDef);
+```
+
+You can also use this to hold an integral value rather than a pointer.
+
+Here are some examples of cases where you would need the user data:
+- Applying damage to an actor using a collision result.
+- Playing a scripted event if the player is inside an axis-aligned box.
+- Accessing a game structure when Box2D notifies you that a joint is
+ going to be destroyed.
+
+Keep in mind that user data is optional and you can put anything in it.
+However, you should be consistent. For example, if you want to store an
+actor pointer on one body, you should keep an actor pointer on all
+bodies. Don't store an actor pointer on one body, and a foo pointer on
+another body. Casting an actor pointer to a foo pointer may lead to a
+crash.
+
+User data pointers are 0 by default.
+
+For fixtures you might consider defining a user data structure that lets
+you store game specific information, such as material type, effects
+hooks, sound hooks, etc.
+
+```cpp
+struct FixtureUserData
+{
+ int materialIndex;
+ // ...
+};
+
+FixtureUserData myData = new FixtureUserData;
+myData->materialIndex = 2;
+
+b2FixtureDef fixtureDef;
+fixtureDef.shape = &someShape;
+fixtureDef.userData.pointer = reinterpret_cast<uintptr_t>(myData);
+
+b2Fixture* fixture = body->CreateFixture(&fixtureDef);
+// ...
+
+delete fixture->GetUserData();
+body->DestroyFixture(fixture);
+```
+
+## Custom User Data
+You can define custom data structures that are embedded in the Box2D data
+structures. This is done by defining `B2_USER_SETTINGS` and providing the
+file `b2_user_settings.h`. See `b2_settings.h` for details.
+
+## Implicit Destruction
+Box2D doesn't use reference counting. So if you destroy a body it is
+really gone. Accessing a pointer to a destroyed body has undefined
+behavior. In other words, your program will likely crash and burn. To
+help fix these problems, the debug build memory manager fills destroyed
+entities with FDFDFDFD. This can help find problems more easily in some
+cases.
+
+If you destroy a Box2D entity, it is up to you to make sure you remove
+all references to the destroyed object. This is easy if you only have a
+single reference to the entity. If you have multiple references, you
+might consider implementing a handle class to wrap the raw pointer.
+
+Often when using Box2D you will create and destroy many bodies, shapes,
+and joints. Managing these entities is somewhat automated by Box2D. If
+you destroy a body then all associated shapes and joints are
+automatically destroyed. This is called implicit destruction.
+
+When you destroy a body, all its attached shapes, joints, and contacts
+are destroyed. This is called implicit destruction. Any body connected
+to one of those joints and/or contacts is woken. This process is usually
+convenient. However, you must be aware of one crucial issue:
+
+> **Caution**:
+> When a body is destroyed, all fixtures and joints attached to the body
+> are automatically destroyed. You must nullify any pointers you have to
+> those shapes and joints. Otherwise, your program will die horribly if
+> you try to access or destroy those shapes or joints later.
+
+To help you nullify your joint pointers, Box2D provides a listener class
+named b2DestructionListener that you can implement and provide to your
+world object. Then the world object will notify you when a joint is
+going to be implicitly destroyed
+
+Note that there no notification when a joint or fixture is explicitly
+destroyed. In this case ownership is clear and you can perform the
+necessary cleanup on the spot. If you like, you can call your own
+implementation of b2DestructionListener to keep cleanup code
+centralized.
+
+Implicit destruction is a great convenience in many cases. It can also
+make your program fall apart. You may store pointers to shapes and
+joints somewhere in your code. These pointers become orphaned when an
+associated body is destroyed. The situation becomes worse when you
+consider that joints are often created by a part of the code unrelated
+to management of the associated body. For example, the testbed creates a
+b2MouseJoint for interactive manipulation of bodies on the screen.
+
+Box2D provides a callback mechanism to inform your application when
+implicit destruction occurs. This gives your application a chance to
+nullify the orphaned pointers. This callback mechanism is described
+later in this manual.
+
+You can implement a `b2DestructionListener` that allows b2World to inform
+you when a shape or joint is implicitly destroyed because an associated
+body was destroyed. This will help prevent your code from accessing
+orphaned pointers.
+
+```cpp
+class MyDestructionListener : public b2DestructionListener
+{
+ void SayGoodbye(b2Joint* joint)
+ {
+ // remove all references to joint.
+ }
+};
+```
+
+You can then register an instance of your destruction listener with your
+world object. You should do this during world initialization.
+
+```cpp
+myWorld->SetListener(myDestructionListener);
+```
+
+## Pixels and Coordinate Systems
+Recall that Box2D uses MKS (meters, kilograms, and seconds) units and
+radians for angles. You may have trouble working with meters because
+your game is expressed in terms of pixels. To deal with this in the
+testbed I have the whole *game* work in meters and just use an OpenGL
+viewport transformation to scale the world into screen space.
+
+```cpp
+float lowerX = -25.0f, upperX = 25.0f, lowerY = -5.0f, upperY = 25.0f;
+gluOrtho2D(lowerX, upperX, lowerY, upperY);
+```
+
+If your game must work in pixel units then you should convert your
+length units from pixels to meters when passing values from Box2D.
+Likewise you should convert the values received from Box2D from meters
+to pixels. This will improve the stability of the physics simulation.
+
+You have to come up with a reasonable conversion factor. I suggest
+making this choice based on the size of your characters. Suppose you
+have determined to use 50 pixels per meter (because your character is 75
+pixels tall). Then you can convert from pixels to meters using these
+formulas:
+
+```cpp
+xMeters = 0.02f * xPixels;
+yMeters = 0.02f * yPixels;
+```
+
+In reverse:
+
+```cpp
+xPixels = 50.0f * xMeters;
+yPixels = 50.0f * yMeters;
+```
+
+You should consider using MKS units in your game code and just convert
+to pixels when you render. This will simplify your game logic and reduce
+the chance for errors since the rendering conversion can be isolated to
+a small amount of code.
+
+If you use a conversion factor, you should try tweaking it globally to
+make sure nothing breaks. You can also try adjusting it to improve
+stability.
+
+## Debug Drawing
+You can implement the b2DebugDraw class to get detailed drawing of the
+physics world. Here are the available entities:
+- shape outlines
+- joint connectivity
+- broad-phase axis-aligned bounding boxes (AABBs)
+- center of mass
+
+![Debug Draw](images/debug_draw.png)
+
+This is the preferred method of drawing these physics entities, rather
+than accessing the data directly. The reason is that much of the
+necessary data is internal and subject to change.
+
+The testbed draws physics entities using the debug draw facility and the
+contact listener, so it serves as the primary example of how to
+implement debug drawing as well as how to draw contact points.
+
+## Limitations
+Box2D uses several approximations to simulate rigid body physics
+efficiently. This brings some limitations.
+
+Here are the current limitations:
+1. Stacking heavy bodies on top of much lighter bodies is not stable. Stability degrades as the mass ratio passes 10:1.
+2. Chains of bodies connected by joints may stretch if a lighter body is supporting a heavier body. For example, a wrecking ball connect to a chain of light weight bodies may not be stable. Stability degrades as the mass ratio passes 10:1.
+3. There is typically around 0.5cm of slop in shape versus shape collision.
+4. Continuous collision does not handle joints. So you may see joint stretching on fast moving objects.
+5. Box2D uses the symplectic Euler integration scheme. It does not reproduce parabolic motion of projectiles and has only first-order accuracy. However it is fast and has good stability.
+6. Box2D uses an iterative solver to provide real-time performance. You will not get precisely rigid collisions or pixel perfect accuracy. Increasing the iterations will improve accuracy.
diff --git a/Client/ThirdParty/Box2D/docs/overview.md b/Client/ThirdParty/Box2D/docs/overview.md
new file mode 100644
index 0000000..99142f3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/overview.md
@@ -0,0 +1,216 @@
+# Overview
+Box2D is a 2D rigid body simulation library for games. Programmers can
+use it in their games to make objects move in realistic ways and make
+the game world more interactive. From the game engine's point of view,
+a physics engine is just a system for procedural animation.
+
+Box2D is written in portable C++. Most of the types defined in the
+engine begin with the b2 prefix. Hopefully this is sufficient to avoid
+name clashing with your game engine.
+
+## Prerequisites
+In this manual I'll assume you are familiar with basic physics
+concepts, such as mass, force, torque, and impulses. If not, please
+first consult Google search and Wikipedia.
+
+Box2D was created as part of a physics tutorial at the Game Developer
+Conference. You can get these tutorials from the download section of
+box2d.org.
+
+Since Box2D is written in C++, you are expected to be experienced in C++
+programming. Box2D should not be your first C++ programming project! You
+should be comfortable with compiling, linking, and debugging.
+
+> **Caution**:
+> Box2D should not be your first C++ project. Please learn C++
+> programming, compiling, linking, and debugging before working with
+> Box2D. There are many resources for this on the net.
+
+## Scope
+This manual covers the majority of the Box2D API. However, not every
+aspect is covered. Please look at the testbed included
+with Box2D to learn more.
+
+This manual is only updated with new releases. The latest version of
+Box2D may be out of sync with this manual.
+
+## Feedback and Bugs
+Please file bugs and feature requests here:
+[Box2D Issues](https://github.com/erincatto/box2d/issues)
+
+You can help to ensure your issue gets fixed if you provide sufficient
+detail. A testbed example that reproduces the problem is ideal. You can
+read about the testbed later in this document.
+
+There is also a [Discord server](https://discord.gg/NKYgCBP) and a
+[subreddit](https://reddit.com/r/box2d) for Box2D.
+
+## Core Concepts
+Box2D works with several fundamental concepts and objects. We briefly
+define these objects here and more details are given later in this
+document.
+
+#### shape
+A shape is 2D geometrical object, such as a circle or polygon.
+
+#### rigid body
+A chunk of matter that is so strong that the distance between any two
+bits of matter on the chunk is constant. They are hard like a diamond.
+In the following discussion we use body interchangeably with rigid body.
+
+#### fixture
+A fixture binds a shape to a body and adds material properties such as
+density, friction, and restitution. A fixture puts a shape into the
+collision system (broad-phase) so that it can collide with other shapes.
+
+#### constraint
+A constraint is a physical connection that removes degrees of freedom
+from bodies. A 2D body has 3 degrees of freedom (two translation
+coordinates and one rotation coordinate). If we take a body and pin it
+to the wall (like a pendulum) we have constrained the body to the wall.
+At this point the body can only rotate about the pin, so the constraint
+has removed 2 degrees of freedom.
+
+#### contact constraint
+A special constraint designed to prevent penetration of rigid bodies and
+to simulate friction and restitution. You do not create contact
+constraints; they are created automatically by Box2D.
+
+#### joint
+This is a constraint used to hold two or more bodies together. Box2D
+supports several joint types: revolute, prismatic, distance, and more.
+Some joints may have limits and motors.
+
+#### joint limit
+A joint limit restricts the range of motion of a joint. For example, the
+human elbow only allows a certain range of angles.
+
+#### joint motor
+A joint motor drives the motion of the connected bodies according to the
+joint's degrees of freedom. For example, you can use a motor to drive
+the rotation of an elbow.
+
+#### world
+A physics world is a collection of bodies, fixtures, and constraints
+that interact together. Box2D supports the creation of multiple worlds,
+but this is usually not necessary or desirable.
+
+#### solver
+The physics world has a solver that is used to advance time and to
+resolve contact and joint constraints. The Box2D solver is a high
+performance iterative solver that operates in order N time, where N is
+the number of constraints.
+
+#### continuous collision
+The solver advances bodies in time using discrete time steps. Without
+intervention this can lead to tunneling.
+![Tunneling Effect](images/tunneling1.svg)
+
+Box2D contains specialized algorithms to deal with tunneling. First, the
+collision algorithms can interpolate the motion of two bodies to find
+the first time of impact (TOI). Second, there is a sub-stepping solver
+that moves bodies to their first time of impact and then resolves the
+collision.
+
+## Modules
+Box2D is composed of three modules: Common, Collision, and Dynamics. The
+Common module has code for allocation, math, and settings. The Collision
+module defines shapes, a broad-phase, and collision functions/queries.
+Finally the Dynamics module provides the simulation world, bodies,
+fixtures, and joints.
+![Box2D Modules](images/modules.svg)
+
+## Units
+Box2D works with floating point numbers and tolerances have to be used
+to make Box2D perform well. These tolerances have been tuned to work
+well with meters-kilogram-second (MKS) units. In particular, Box2D has
+been tuned to work well with moving shapes between 0.1 and 10 meters. So
+this means objects between soup cans and buses in size should work well.
+Static shapes may be up to 50 meters long without trouble.
+
+Being a 2D physics engine, it is tempting to use pixels as your units.
+Unfortunately this will lead to a poor simulation and possibly weird
+behavior. An object of length 200 pixels would be seen by Box2D as the
+size of a 45 story building.
+
+> **Caution**:
+> Box2D is tuned for MKS units. Keep the size of moving objects roughly
+> between 0.1 and 10 meters. You'll need to use some scaling system when
+> you render your environment and actors. The Box2D testbed does this by
+> using an OpenGL viewport transform. DO NOT USE PIXELS.
+
+It is best to think of Box2D bodies as moving billboards upon which you
+attach your artwork. The billboard may move in a unit system of meters,
+but you can convert that to pixel coordinates with a simple scaling
+factor. You can then use those pixel coordinates to place your sprites,
+etc. You can also account for flipped coordinate axes.
+
+Another limitation to consider is overall world size. If your world units
+become larger than 2 kilometers or so, then the lost precision can affect
+stability.
+
+> **Caution**:
+> Box2D works best with world sizes less than 2 kilometers. Use
+> b2World::ShiftOrigin to support larger worlds.
+
+If you need to have a larger game world, consider using
+b2World::ShiftOrigin to keep the world origin close to your player. I recommend
+to use grid lines along with some hysteresis for triggering calls to ShiftOrigin.
+This call should be made infrequently because it is has CPU cost. You may
+need to store a physics offset when translating between game units and Box2D units.
+
+Box2D uses radians for angles. The body rotation is stored in radians
+and may grow unbounded. Consider normalizing the angle of your bodies if
+the magnitude of the angle becomes too large (use `b2Body::SetTransform`).
+
+> **Caution**:
+> Box2D uses radians, not degrees.
+
+## Changing the length units
+Advanced users may change the length unit modifying `b2_lengthUnitsPerMeter`.
+You can avoid merge conflicts by defining `B2_USER_SETTINGS` and providing
+`b2_user_settings.h`. See the file `b2_settings.h` for details.
+
+## Factories and Definitions
+Fast memory management plays a central role in the design of the Box2D
+API. So when you create a b2Body or a b2Joint, you need to call the
+factory functions on b2World. You should never try to allocate these
+types in another manner.
+
+There are creation functions:
+
+```cpp
+b2Body* b2World::CreateBody(const b2BodyDef* def)
+b2Joint* b2World::CreateJoint(const b2JointDef* def)
+```
+
+And there are corresponding destruction functions:
+
+```cpp
+void b2World::DestroyBody(b2Body* body)
+void b2World::DestroyJoint(b2Joint* joint)
+```
+
+When you create a body or joint, you need to provide a definition. These
+definitions contain all the information needed to build the body or
+joint. By using this approach we can prevent construction errors, keep
+the number of function parameters small, provide sensible defaults, and
+reduce the number of accessors.
+
+Since fixtures (shapes) must be parented to a body, they are created and
+destroyed using a factory method on b2Body:
+
+```cpp
+b2Fixture* b2Body::CreateFixture(const b2FixtureDef* def)
+void b2Body::DestroyFixture(b2Fixture* fixture)
+```
+
+There is also shortcut to create a fixture directly from the shape and
+density.
+
+```cpp
+b2Fixture* b2Body::CreateFixture(const b2Shape* shape, float density)
+```
+
+Factories do not retain references to the definitions. So you can create
+definitions on the stack and keep them in temporary resources.
diff --git a/Client/ThirdParty/Box2D/docs/references.md b/Client/ThirdParty/Box2D/docs/references.md
new file mode 100644
index 0000000..4d2aa5a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/references.md
@@ -0,0 +1,4 @@
+# References
+- [Erin Catto's Publications](https://box2d.org/publications/)
+- Collision Detection in Interactive 3D Environments, Gino van den Bergen, 2004
+- Real-Time Collision Detection, Christer Ericson, 2005
diff --git a/Client/ThirdParty/Box2D/docs/testbed.md b/Client/ThirdParty/Box2D/docs/testbed.md
new file mode 100644
index 0000000..a6f2233
--- /dev/null
+++ b/Client/ThirdParty/Box2D/docs/testbed.md
@@ -0,0 +1,21 @@
+# Testbed
+Once you have conquered the HelloWorld example, you should start looking
+at Box2D's testbed. The testbed is a testing framework and demo
+environment. Here are some of the features:
+- Camera with pan and zoom.
+- Mouse picking of shapes attached to dynamic bodies.
+- Extensible set of tests.
+- GUI for selecting tests, parameter tuning, and debug drawing options.
+- Pause and single step simulation.
+- Text rendering.
+
+![Box2D Testbed](images/testbed.png)
+
+The testbed has many examples of Box2D usage in the test cases and the
+framework itself. I encourage you to explore and tinker with the testbed
+as you learn Box2D.
+
+Note: the testbed is written using [GLFW](https://www.glfw.org) and
+[imgui](https://github.com/ocornut/imgui). The testbed is not part of the
+Box2D library. The Box2D library is agnostic about rendering. As shown by
+the HelloWorld example, you don't need a renderer to use Box2D.
diff --git a/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt b/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt
new file mode 100644
index 0000000..f7e0b8b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(GLAD_SOURCE_FILES
+ src/gl.c)
+
+set(GLAD_HEADER_FILES
+ include/glad/gl.h
+ include/KHR/khrplatform.h)
+
+add_library(glad STATIC ${GLAD_SOURCE_FILES} ${GLAD_HEADER_FILES})
+target_include_directories(glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${GLAD_SOURCE_FILES} ${GLAD_HEADER_FILES})
diff --git a/Client/ThirdParty/Box2D/extern/glad/include/KHR/khrplatform.h b/Client/ThirdParty/Box2D/extern/glad/include/KHR/khrplatform.h
new file mode 100644
index 0000000..5b55ea2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glad/include/KHR/khrplatform.h
@@ -0,0 +1,290 @@
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2018 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * The master copy of khrplatform.h is maintained in the Khronos EGL
+ * Registry repository at https://github.com/KhronosGroup/EGL-Registry
+ * The last semantic modification to khrplatform.h was at commit ID:
+ * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by filing pull requests or issues on
+ * the EGL Registry repository linked above.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ * http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ * #include <KHR/khrplatform.h>
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ * khronos_int8_t signed 8 bit
+ * khronos_uint8_t unsigned 8 bit
+ * khronos_int16_t signed 16 bit
+ * khronos_uint16_t unsigned 16 bit
+ * khronos_int32_t signed 32 bit
+ * khronos_uint32_t unsigned 32 bit
+ * khronos_int64_t signed 64 bit
+ * khronos_uint64_t unsigned 64 bit
+ * khronos_intptr_t signed same number of bits as a pointer
+ * khronos_uintptr_t unsigned same number of bits as a pointer
+ * khronos_ssize_t signed size
+ * khronos_usize_t unsigned size
+ * khronos_float_t signed 32 bit floating point
+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ * nanoseconds
+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ * khronos_boolean_enum_t enumerated boolean type. This should
+ * only be used as a base type when a client API's boolean type is
+ * an enum. Client APIs which use an integer or other type for
+ * booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ * KHRONOS_APICALL
+ * KHRONOS_APIENTRY
+ * KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
+ * int arg1,
+ * int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
+# define KHRONOS_STATIC 1
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(KHRONOS_STATIC)
+ /* If the preprocessor constant KHRONOS_STATIC is defined, make the
+ * header compatible with static linking. */
+# define KHRONOS_APICALL
+#elif defined(_WIN32)
+# define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+# define KHRONOS_APICALL IMPORT_C
+#elif defined(__ANDROID__)
+# define KHRONOS_APICALL __attribute__((visibility("default")))
+#else
+# define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIENTRY
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC)
+ /* Win32 but not WinCE */
+# define KHRONOS_APIENTRY __stdcall
+#else
+# define KHRONOS_APIENTRY
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using <stdint.h>
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using <inttypes.h>
+ */
+#include <inttypes.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32 khronos_int32_t;
+typedef unsigned __int32 khronos_uint32_t;
+typedef __int64 khronos_int64_t;
+typedef unsigned __int64 khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int khronos_int64_t;
+typedef unsigned long int khronos_uint64_t;
+#else
+typedef long long int khronos_int64_t;
+typedef unsigned long long int khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64 0
+#define KHRONOS_SUPPORT_FLOAT 0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed char khronos_int8_t;
+typedef unsigned char khronos_uint8_t;
+typedef signed short int khronos_int16_t;
+typedef unsigned short int khronos_uint16_t;
+
+/*
+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
+ * to be the only LLP64 architecture in current use.
+ */
+#ifdef _WIN64
+typedef signed long long int khronos_intptr_t;
+typedef unsigned long long int khronos_uintptr_t;
+typedef signed long long int khronos_ssize_t;
+typedef unsigned long long int khronos_usize_t;
+#else
+typedef signed long int khronos_intptr_t;
+typedef unsigned long int khronos_uintptr_t;
+typedef signed long int khronos_ssize_t;
+typedef unsigned long int khronos_usize_t;
+#endif
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef float khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted). The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
+typedef khronos_int64_t khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true. Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+ KHRONOS_FALSE = 0,
+ KHRONOS_TRUE = 1,
+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
diff --git a/Client/ThirdParty/Box2D/extern/glad/include/glad/gl.h b/Client/ThirdParty/Box2D/extern/glad/include/glad/gl.h
new file mode 100644
index 0000000..0910038
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glad/include/glad/gl.h
@@ -0,0 +1,2114 @@
+/**
+ * Loader generated by glad 2.0.0-beta on Fri Dec 27 01:40:51 2019
+ *
+ * Generator: C/C++
+ * Specification: gl
+ * Extensions: 0
+ *
+ * APIs:
+ * - gl:core=3.3
+ *
+ * Options:
+ * - MX_GLOBAL = False
+ * - ON_DEMAND = False
+ * - LOADER = False
+ * - ALIAS = False
+ * - HEADER_ONLY = False
+ * - DEBUG = False
+ * - MX = False
+ *
+ * Commandline:
+ * --api='gl:core=3.3' --extensions='' c
+ *
+ * Online:
+ * http://glad.sh/#api=gl%3Acore%3D3.3&extensions=&generator=c&options=
+ *
+ */
+
+#ifndef GLAD_GL_H_
+#define GLAD_GL_H_
+
+#ifdef __gl_h_
+ #error OpenGL header already included (API: gl), remove previous include!
+#endif
+#define __gl_h_ 1
+
+
+#define GLAD_GL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef GLAD_PLATFORM_H_
+#define GLAD_PLATFORM_H_
+
+#ifndef GLAD_PLATFORM_WIN32
+ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
+ #define GLAD_PLATFORM_WIN32 1
+ #else
+ #define GLAD_PLATFORM_WIN32 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_APPLE
+ #ifdef __APPLE__
+ #define GLAD_PLATFORM_APPLE 1
+ #else
+ #define GLAD_PLATFORM_APPLE 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_EMSCRIPTEN
+ #ifdef __EMSCRIPTEN__
+ #define GLAD_PLATFORM_EMSCRIPTEN 1
+ #else
+ #define GLAD_PLATFORM_EMSCRIPTEN 0
+ #endif
+#endif
+
+#ifndef GLAD_PLATFORM_UWP
+ #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
+ #ifdef __has_include
+ #if __has_include(<winapifamily.h>)
+ #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
+ #endif
+ #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
+ #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
+ #endif
+ #endif
+
+ #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
+ #include <winapifamily.h>
+ #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ #define GLAD_PLATFORM_UWP 1
+ #endif
+ #endif
+
+ #ifndef GLAD_PLATFORM_UWP
+ #define GLAD_PLATFORM_UWP 0
+ #endif
+#endif
+
+#ifdef __GNUC__
+ #define GLAD_GNUC_EXTENSION __extension__
+#else
+ #define GLAD_GNUC_EXTENSION
+#endif
+
+#ifndef GLAD_API_CALL
+ #if defined(GLAD_API_CALL_EXPORT)
+ #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
+ #if defined(GLAD_API_CALL_EXPORT_BUILD)
+ #if defined(__GNUC__)
+ #define GLAD_API_CALL __attribute__ ((dllexport)) extern
+ #else
+ #define GLAD_API_CALL __declspec(dllexport) extern
+ #endif
+ #else
+ #if defined(__GNUC__)
+ #define GLAD_API_CALL __attribute__ ((dllimport)) extern
+ #else
+ #define GLAD_API_CALL __declspec(dllimport) extern
+ #endif
+ #endif
+ #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
+ #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
+ #else
+ #define GLAD_API_CALL extern
+ #endif
+ #else
+ #define GLAD_API_CALL extern
+ #endif
+#endif
+
+#ifdef APIENTRY
+ #define GLAD_API_PTR APIENTRY
+#elif GLAD_PLATFORM_WIN32
+ #define GLAD_API_PTR __stdcall
+#else
+ #define GLAD_API_PTR
+#endif
+
+#ifndef GLAPI
+#define GLAPI GLAD_API_CALL
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY GLAD_API_PTR
+#endif
+
+#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
+#define GLAD_VERSION_MAJOR(version) (version / 10000)
+#define GLAD_VERSION_MINOR(version) (version % 10000)
+
+#define GLAD_GENERATOR_VERSION "2.0.0-beta"
+
+typedef void (*GLADapiproc)(void);
+
+typedef GLADapiproc (*GLADloadfunc)(const char *name);
+typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
+
+typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
+typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
+
+#endif /* GLAD_PLATFORM_H_ */
+
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_ALPHA 0x1906
+#define GL_ALREADY_SIGNALED 0x911A
+#define GL_ALWAYS 0x0207
+#define GL_AND 0x1501
+#define GL_AND_INVERTED 0x1504
+#define GL_AND_REVERSE 0x1502
+#define GL_ANY_SAMPLES_PASSED 0x8C2F
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_BACK 0x0405
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_BGRA_INTEGER 0x8D9B
+#define GL_BGR_INTEGER 0x8D9A
+#define GL_BLEND 0x0BE2
+#define GL_BLEND_COLOR 0x8005
+#define GL_BLEND_DST 0x0BE0
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_EQUATION 0x8009
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_BLEND_SRC 0x0BE1
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLUE 0x1905
+#define GL_BLUE_INTEGER 0x8D96
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_ACCESS_FLAGS 0x911F
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_LENGTH 0x9120
+#define GL_BUFFER_MAP_OFFSET 0x9121
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_BYTE 0x1400
+#define GL_CCW 0x0901
+#define GL_CLAMP_READ_COLOR 0x891C
+#define GL_CLAMP_TO_BORDER 0x812D
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_CLEAR 0x1500
+#define GL_CLIP_DISTANCE0 0x3000
+#define GL_CLIP_DISTANCE1 0x3001
+#define GL_CLIP_DISTANCE2 0x3002
+#define GL_CLIP_DISTANCE3 0x3003
+#define GL_CLIP_DISTANCE4 0x3004
+#define GL_CLIP_DISTANCE5 0x3005
+#define GL_CLIP_DISTANCE6 0x3006
+#define GL_CLIP_DISTANCE7 0x3007
+#define GL_COLOR 0x1800
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_ATTACHMENT1 0x8CE1
+#define GL_COLOR_ATTACHMENT10 0x8CEA
+#define GL_COLOR_ATTACHMENT11 0x8CEB
+#define GL_COLOR_ATTACHMENT12 0x8CEC
+#define GL_COLOR_ATTACHMENT13 0x8CED
+#define GL_COLOR_ATTACHMENT14 0x8CEE
+#define GL_COLOR_ATTACHMENT15 0x8CEF
+#define GL_COLOR_ATTACHMENT16 0x8CF0
+#define GL_COLOR_ATTACHMENT17 0x8CF1
+#define GL_COLOR_ATTACHMENT18 0x8CF2
+#define GL_COLOR_ATTACHMENT19 0x8CF3
+#define GL_COLOR_ATTACHMENT2 0x8CE2
+#define GL_COLOR_ATTACHMENT20 0x8CF4
+#define GL_COLOR_ATTACHMENT21 0x8CF5
+#define GL_COLOR_ATTACHMENT22 0x8CF6
+#define GL_COLOR_ATTACHMENT23 0x8CF7
+#define GL_COLOR_ATTACHMENT24 0x8CF8
+#define GL_COLOR_ATTACHMENT25 0x8CF9
+#define GL_COLOR_ATTACHMENT26 0x8CFA
+#define GL_COLOR_ATTACHMENT27 0x8CFB
+#define GL_COLOR_ATTACHMENT28 0x8CFC
+#define GL_COLOR_ATTACHMENT29 0x8CFD
+#define GL_COLOR_ATTACHMENT3 0x8CE3
+#define GL_COLOR_ATTACHMENT30 0x8CFE
+#define GL_COLOR_ATTACHMENT31 0x8CFF
+#define GL_COLOR_ATTACHMENT4 0x8CE4
+#define GL_COLOR_ATTACHMENT5 0x8CE5
+#define GL_COLOR_ATTACHMENT6 0x8CE6
+#define GL_COLOR_ATTACHMENT7 0x8CE7
+#define GL_COLOR_ATTACHMENT8 0x8CE8
+#define GL_COLOR_ATTACHMENT9 0x8CE9
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_COMPARE_REF_TO_TEXTURE 0x884E
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_COMPRESSED_RED 0x8225
+#define GL_COMPRESSED_RED_RGTC1 0x8DBB
+#define GL_COMPRESSED_RG 0x8226
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_COMPRESSED_RG_RGTC2 0x8DBD
+#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
+#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
+#define GL_COMPRESSED_SRGB 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CONDITION_SATISFIED 0x911C
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
+#define GL_CONTEXT_FLAGS 0x821E
+#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
+#define GL_CONTEXT_PROFILE_MASK 0x9126
+#define GL_COPY 0x1503
+#define GL_COPY_INVERTED 0x150C
+#define GL_COPY_READ_BUFFER 0x8F36
+#define GL_COPY_WRITE_BUFFER 0x8F37
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_CURRENT_QUERY 0x8865
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_CW 0x0900
+#define GL_DECR 0x1E03
+#define GL_DECR_WRAP 0x8508
+#define GL_DELETE_STATUS 0x8B80
+#define GL_DEPTH 0x1801
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_DEPTH32F_STENCIL8 0x8CAD
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_DEPTH_CLAMP 0x864F
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_DEPTH_COMPONENT32F 0x8CAC
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_STENCIL 0x84F9
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DITHER 0x0BD0
+#define GL_DONT_CARE 0x1100
+#define GL_DOUBLE 0x140A
+#define GL_DOUBLEBUFFER 0x0C32
+#define GL_DRAW_BUFFER 0x0C01
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_DST_ALPHA 0x0304
+#define GL_DST_COLOR 0x0306
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_EQUAL 0x0202
+#define GL_EQUIV 0x1509
+#define GL_EXTENSIONS 0x1F03
+#define GL_FALSE 0
+#define GL_FASTEST 0x1101
+#define GL_FILL 0x1B02
+#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
+#define GL_FIXED_ONLY 0x891D
+#define GL_FLOAT 0x1406
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_DEFAULT 0x8218
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
+#define GL_FRAMEBUFFER_SRGB 0x8DB9
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_FRONT 0x0404
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_FRONT_FACE 0x0B46
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_GEOMETRY_INPUT_TYPE 0x8917
+#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
+#define GL_GEOMETRY_SHADER 0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT 0x8916
+#define GL_GEQUAL 0x0206
+#define GL_GREATER 0x0204
+#define GL_GREEN 0x1904
+#define GL_GREEN_INTEGER 0x8D95
+#define GL_HALF_FLOAT 0x140B
+#define GL_INCR 0x1E02
+#define GL_INCR_WRAP 0x8507
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_INT 0x1404
+#define GL_INTERLEAVED_ATTRIBS 0x8C8C
+#define GL_INT_2_10_10_10_REV 0x8D9F
+#define GL_INT_SAMPLER_1D 0x8DC9
+#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
+#define GL_INT_SAMPLER_2D_RECT 0x8DCD
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_BUFFER 0x8DD0
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_INVALID_INDEX 0xFFFFFFFF
+#define GL_INVALID_OPERATION 0x0502
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVERT 0x150A
+#define GL_KEEP 0x1E00
+#define GL_LAST_VERTEX_CONVENTION 0x8E4E
+#define GL_LEFT 0x0406
+#define GL_LEQUAL 0x0203
+#define GL_LESS 0x0201
+#define GL_LINE 0x1B01
+#define GL_LINEAR 0x2601
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_LINES 0x0001
+#define GL_LINES_ADJACENCY 0x000A
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_LINE_STRIP 0x0003
+#define GL_LINE_STRIP_ADJACENCY 0x000B
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_LINE_WIDTH_RANGE 0x0B22
+#define GL_LINK_STATUS 0x8B82
+#define GL_LOGIC_OP_MODE 0x0BF0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_MAJOR_VERSION 0x821B
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAX 0x8008
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_MAX_CLIP_DISTANCES 0x0D32
+#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
+#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
+#define GL_MAX_INTEGER_SAMPLES 0x9110
+#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_MAX_SAMPLES 0x8D57
+#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
+#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
+#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#define GL_MAX_VARYING_COMPONENTS 0x8B4B
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MIN 0x8007
+#define GL_MINOR_VERSION 0x821C
+#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_MULTISAMPLE 0x809D
+#define GL_NAND 0x150E
+#define GL_NEAREST 0x2600
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_NEVER 0x0200
+#define GL_NICEST 0x1102
+#define GL_NONE 0
+#define GL_NOOP 0x1505
+#define GL_NOR 0x1508
+#define GL_NOTEQUAL 0x0205
+#define GL_NO_ERROR 0
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_OBJECT_TYPE 0x9112
+#define GL_ONE 1
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
+#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_OR 0x1507
+#define GL_OR_INVERTED 0x150D
+#define GL_OR_REVERSE 0x150B
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_PACK_LSB_FIRST 0x0D01
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SWAP_BYTES 0x0D00
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_POINT 0x1B00
+#define GL_POINTS 0x0000
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_POINT_SIZE 0x0B11
+#define GL_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_POINT_SIZE_RANGE 0x0B12
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_POLYGON_MODE 0x0B40
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_POLYGON_OFFSET_LINE 0x2A02
+#define GL_POLYGON_OFFSET_POINT 0x2A01
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_SMOOTH 0x0B41
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_PRIMITIVES_GENERATED 0x8C87
+#define GL_PRIMITIVE_RESTART 0x8F9D
+#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
+#define GL_PROGRAM_POINT_SIZE 0x8642
+#define GL_PROVOKING_VERTEX 0x8E4F
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
+#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
+#define GL_QUERY_BY_REGION_WAIT 0x8E15
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_QUERY_NO_WAIT 0x8E14
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_QUERY_WAIT 0x8E13
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_R16 0x822A
+#define GL_R16F 0x822D
+#define GL_R16I 0x8233
+#define GL_R16UI 0x8234
+#define GL_R16_SNORM 0x8F98
+#define GL_R32F 0x822E
+#define GL_R32I 0x8235
+#define GL_R32UI 0x8236
+#define GL_R3_G3_B2 0x2A10
+#define GL_R8 0x8229
+#define GL_R8I 0x8231
+#define GL_R8UI 0x8232
+#define GL_R8_SNORM 0x8F94
+#define GL_RASTERIZER_DISCARD 0x8C89
+#define GL_READ_BUFFER 0x0C02
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
+#define GL_READ_ONLY 0x88B8
+#define GL_READ_WRITE 0x88BA
+#define GL_RED 0x1903
+#define GL_RED_INTEGER 0x8D94
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_SAMPLES 0x8CAB
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERER 0x1F01
+#define GL_REPEAT 0x2901
+#define GL_REPLACE 0x1E01
+#define GL_RG 0x8227
+#define GL_RG16 0x822C
+#define GL_RG16F 0x822F
+#define GL_RG16I 0x8239
+#define GL_RG16UI 0x823A
+#define GL_RG16_SNORM 0x8F99
+#define GL_RG32F 0x8230
+#define GL_RG32I 0x823B
+#define GL_RG32UI 0x823C
+#define GL_RG8 0x822B
+#define GL_RG8I 0x8237
+#define GL_RG8UI 0x8238
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB 0x1907
+#define GL_RGB10 0x8052
+#define GL_RGB10_A2 0x8059
+#define GL_RGB10_A2UI 0x906F
+#define GL_RGB12 0x8053
+#define GL_RGB16 0x8054
+#define GL_RGB16F 0x881B
+#define GL_RGB16I 0x8D89
+#define GL_RGB16UI 0x8D77
+#define GL_RGB16_SNORM 0x8F9A
+#define GL_RGB32F 0x8815
+#define GL_RGB32I 0x8D83
+#define GL_RGB32UI 0x8D71
+#define GL_RGB4 0x804F
+#define GL_RGB5 0x8050
+#define GL_RGB5_A1 0x8057
+#define GL_RGB8 0x8051
+#define GL_RGB8I 0x8D8F
+#define GL_RGB8UI 0x8D7D
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGB9_E5 0x8C3D
+#define GL_RGBA 0x1908
+#define GL_RGBA12 0x805A
+#define GL_RGBA16 0x805B
+#define GL_RGBA16F 0x881A
+#define GL_RGBA16I 0x8D88
+#define GL_RGBA16UI 0x8D76
+#define GL_RGBA16_SNORM 0x8F9B
+#define GL_RGBA2 0x8055
+#define GL_RGBA32F 0x8814
+#define GL_RGBA32I 0x8D82
+#define GL_RGBA32UI 0x8D70
+#define GL_RGBA4 0x8056
+#define GL_RGBA8 0x8058
+#define GL_RGBA8I 0x8D8E
+#define GL_RGBA8UI 0x8D7C
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RG_INTEGER 0x8228
+#define GL_RIGHT 0x0407
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_1D_ARRAY 0x8DC0
+#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
+#define GL_SAMPLER_2D_RECT 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_BINDING 0x8919
+#define GL_SAMPLER_BUFFER 0x8DC2
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLES_PASSED 0x8914
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_MASK 0x8E51
+#define GL_SAMPLE_MASK_VALUE 0x8E52
+#define GL_SAMPLE_POSITION 0x8E50
+#define GL_SCISSOR_BOX 0x0C10
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_SEPARATE_ATTRIBS 0x8C8D
+#define GL_SET 0x150F
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_SHORT 0x1402
+#define GL_SIGNALED 0x9119
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SRC1_ALPHA 0x8589
+#define GL_SRC1_COLOR 0x88F9
+#define GL_SRC_ALPHA 0x0302
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_SRC_COLOR 0x0300
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_SRGB_ALPHA 0x8C42
+#define GL_STATIC_COPY 0x88E6
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STENCIL 0x1802
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_INDEX 0x1901
+#define GL_STENCIL_INDEX1 0x8D46
+#define GL_STENCIL_INDEX16 0x8D49
+#define GL_STENCIL_INDEX4 0x8D47
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STEREO 0x0C33
+#define GL_STREAM_COPY 0x88E2
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_SYNC_CONDITION 0x9113
+#define GL_SYNC_FENCE 0x9116
+#define GL_SYNC_FLAGS 0x9115
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#define GL_SYNC_STATUS 0x9114
+#define GL_TEXTURE 0x1702
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE_1D 0x0DE0
+#define GL_TEXTURE_1D_ARRAY 0x8C18
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
+#define GL_TEXTURE_3D 0x806F
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_TEXTURE_ALPHA_TYPE 0x8C13
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_BINDING_1D 0x8068
+#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_BLUE_TYPE 0x8C12
+#define GL_TEXTURE_BORDER_COLOR 0x1004
+#define GL_TEXTURE_BUFFER 0x8C2A
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_TEXTURE_DEPTH_TYPE 0x8C16
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_GREEN_TYPE 0x8C11
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_RECTANGLE 0x84F5
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_RED_TYPE 0x8C10
+#define GL_TEXTURE_SAMPLES 0x9106
+#define GL_TEXTURE_SHARED_SIZE 0x8C3F
+#define GL_TEXTURE_STENCIL_SIZE 0x88F1
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TIMEOUT_EXPIRED 0x911B
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
+#define GL_TIMESTAMP 0x8E28
+#define GL_TIME_ELAPSED 0x88BF
+#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLES_ADJACENCY 0x000C
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
+#define GL_TRUE 1
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
+#define GL_UNIFORM_BUFFER 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING 0x8A28
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
+#define GL_UNIFORM_BUFFER_START 0x8A29
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_UNPACK_LSB_FIRST 0x0CF1
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SWAP_BYTES 0x0CF0
+#define GL_UNSIGNALED 0x9118
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_INT 0x1405
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_UNSIGNED_NORMALIZED 0x8C17
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_VENDOR 0x1F00
+#define GL_VERSION 0x1F02
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_VIEWPORT 0x0BA2
+#define GL_WAIT_FAILED 0x911D
+#define GL_WRITE_ONLY 0x88B9
+#define GL_XOR 0x1506
+#define GL_ZERO 0
+
+
+#include <KHR/khrplatform.h>
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef khronos_int8_t GLbyte;
+typedef khronos_uint8_t GLubyte;
+typedef khronos_int16_t GLshort;
+typedef khronos_uint16_t GLushort;
+typedef int GLint;
+typedef unsigned int GLuint;
+typedef khronos_int32_t GLclampx;
+typedef int GLsizei;
+typedef khronos_float_t GLfloat;
+typedef khronos_float_t GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void *GLeglClientBufferEXT;
+typedef void *GLeglImageOES;
+typedef char GLchar;
+typedef char GLcharARB;
+#ifdef __APPLE__
+typedef void *GLhandleARB;
+#else
+typedef unsigned int GLhandleARB;
+#endif
+typedef khronos_uint16_t GLhalf;
+typedef khronos_uint16_t GLhalfARB;
+typedef khronos_int32_t GLfixed;
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_intptr_t GLintptr;
+#else
+typedef khronos_intptr_t GLintptr;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_intptr_t GLintptrARB;
+#else
+typedef khronos_intptr_t GLintptrARB;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_ssize_t GLsizeiptr;
+#else
+typedef khronos_ssize_t GLsizeiptr;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef khronos_ssize_t GLsizeiptrARB;
+#else
+typedef khronos_ssize_t GLsizeiptrARB;
+#endif
+typedef khronos_int64_t GLint64;
+typedef khronos_int64_t GLint64EXT;
+typedef khronos_uint64_t GLuint64;
+typedef khronos_uint64_t GLuint64EXT;
+typedef struct __GLsync *GLsync;
+struct _cl_context;
+struct _cl_event;
+typedef void (GLAD_API_PTR *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (GLAD_API_PTR *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
+typedef unsigned short GLhalfNV;
+typedef GLintptr GLvdpauSurfaceNV;
+typedef void (GLAD_API_PTR *GLVULKANPROCNV)(void);
+
+
+#define GL_VERSION_1_0 1
+GLAD_API_CALL int GLAD_GL_VERSION_1_0;
+#define GL_VERSION_1_1 1
+GLAD_API_CALL int GLAD_GL_VERSION_1_1;
+#define GL_VERSION_1_2 1
+GLAD_API_CALL int GLAD_GL_VERSION_1_2;
+#define GL_VERSION_1_3 1
+GLAD_API_CALL int GLAD_GL_VERSION_1_3;
+#define GL_VERSION_1_4 1
+GLAD_API_CALL int GLAD_GL_VERSION_1_4;
+#define GL_VERSION_1_5 1
+GLAD_API_CALL int GLAD_GL_VERSION_1_5;
+#define GL_VERSION_2_0 1
+GLAD_API_CALL int GLAD_GL_VERSION_2_0;
+#define GL_VERSION_2_1 1
+GLAD_API_CALL int GLAD_GL_VERSION_2_1;
+#define GL_VERSION_3_0 1
+GLAD_API_CALL int GLAD_GL_VERSION_3_0;
+#define GL_VERSION_3_1 1
+GLAD_API_CALL int GLAD_GL_VERSION_3_1;
+#define GL_VERSION_3_2 1
+GLAD_API_CALL int GLAD_GL_VERSION_3_2;
+#define GL_VERSION_3_3 1
+GLAD_API_CALL int GLAD_GL_VERSION_3_3;
+
+
+typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum texture);
+typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum target, GLuint id);
+typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode);
+typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
+typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
+typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler);
+typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
+typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint array);
+typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
+typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void * data, GLenum usage);
+typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
+typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp);
+typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield mask);
+typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble depth);
+typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint s);
+typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data);
+typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
+typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum type);
+typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint * buffers);
+typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint * framebuffers);
+typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint * ids);
+typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint * renderbuffers);
+typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint * samplers);
+typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync sync);
+typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint * textures);
+typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint * arrays);
+typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum func);
+typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean flag);
+typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f);
+typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
+typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum cap);
+typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
+typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum buf);
+typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum * bufs);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount);
+typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices);
+typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex);
+typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum cap);
+typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum target, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void);
+typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags);
+typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei n, GLuint * buffers);
+typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint * framebuffers);
+typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei n, GLuint * ids);
+typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint * renderbuffers);
+typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint * samplers);
+typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei n, GLuint * textures);
+typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint * arrays);
+typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName);
+typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
+typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean * data);
+typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean * data);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void ** params);
+typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void * data);
+typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void * img);
+typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble * data);
+typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
+typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum pname, GLfloat * data);
+typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar * name);
+typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint * data);
+typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum pname, GLint * data);
+typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat * val);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
+typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint * params);
+typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum name);
+typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
+typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei count, GLsizei * length, GLint * values);
+typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels);
+typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name);
+typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar * uniformBlockName);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices);
+typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar * name);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void ** pointer);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint * params);
+typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum target, GLenum mode);
+typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint buffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum cap);
+typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum target, GLuint index);
+typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint program);
+typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint id);
+typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint sampler);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint shader);
+typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync sync);
+typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint texture);
+typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint array);
+typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat width);
+typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum opcode);
+typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum target, GLenum access);
+typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount);
+typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex);
+typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param);
+typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param);
+typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat size);
+typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
+typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
+typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum mode);
+typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target);
+typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum src);
+typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
+typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
+typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat * param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint * param);
+typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
+typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
+typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
+typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat * params);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
+typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint * params);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels);
+typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
+typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum target);
+typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint program);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort * v);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value);
+typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
+typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
+
+GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
+#define glActiveTexture glad_glActiveTexture
+GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
+#define glAttachShader glad_glAttachShader
+GLAD_API_CALL PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
+#define glBeginConditionalRender glad_glBeginConditionalRender
+GLAD_API_CALL PFNGLBEGINQUERYPROC glad_glBeginQuery;
+#define glBeginQuery glad_glBeginQuery
+GLAD_API_CALL PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
+#define glBeginTransformFeedback glad_glBeginTransformFeedback
+GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
+#define glBindAttribLocation glad_glBindAttribLocation
+GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
+#define glBindBuffer glad_glBindBuffer
+GLAD_API_CALL PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
+#define glBindBufferBase glad_glBindBufferBase
+GLAD_API_CALL PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
+#define glBindBufferRange glad_glBindBufferRange
+GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
+#define glBindFragDataLocation glad_glBindFragDataLocation
+GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
+#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
+GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
+#define glBindFramebuffer glad_glBindFramebuffer
+GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
+#define glBindRenderbuffer glad_glBindRenderbuffer
+GLAD_API_CALL PFNGLBINDSAMPLERPROC glad_glBindSampler;
+#define glBindSampler glad_glBindSampler
+GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
+#define glBindTexture glad_glBindTexture
+GLAD_API_CALL PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
+#define glBindVertexArray glad_glBindVertexArray
+GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
+#define glBlendColor glad_glBlendColor
+GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
+#define glBlendEquation glad_glBlendEquation
+GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
+#define glBlendEquationSeparate glad_glBlendEquationSeparate
+GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
+#define glBlendFunc glad_glBlendFunc
+GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
+#define glBlendFuncSeparate glad_glBlendFuncSeparate
+GLAD_API_CALL PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
+#define glBlitFramebuffer glad_glBlitFramebuffer
+GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
+#define glBufferData glad_glBufferData
+GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
+#define glBufferSubData glad_glBufferSubData
+GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
+#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
+GLAD_API_CALL PFNGLCLAMPCOLORPROC glad_glClampColor;
+#define glClampColor glad_glClampColor
+GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
+#define glClear glad_glClear
+GLAD_API_CALL PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
+#define glClearBufferfi glad_glClearBufferfi
+GLAD_API_CALL PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
+#define glClearBufferfv glad_glClearBufferfv
+GLAD_API_CALL PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
+#define glClearBufferiv glad_glClearBufferiv
+GLAD_API_CALL PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
+#define glClearBufferuiv glad_glClearBufferuiv
+GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
+#define glClearColor glad_glClearColor
+GLAD_API_CALL PFNGLCLEARDEPTHPROC glad_glClearDepth;
+#define glClearDepth glad_glClearDepth
+GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
+#define glClearStencil glad_glClearStencil
+GLAD_API_CALL PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
+#define glClientWaitSync glad_glClientWaitSync
+GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
+#define glColorMask glad_glColorMask
+GLAD_API_CALL PFNGLCOLORMASKIPROC glad_glColorMaski;
+#define glColorMaski glad_glColorMaski
+GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
+#define glCompileShader glad_glCompileShader
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
+#define glCompressedTexImage1D glad_glCompressedTexImage1D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
+#define glCompressedTexImage2D glad_glCompressedTexImage2D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
+#define glCompressedTexImage3D glad_glCompressedTexImage3D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
+#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
+#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
+GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
+#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
+GLAD_API_CALL PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
+#define glCopyBufferSubData glad_glCopyBufferSubData
+GLAD_API_CALL PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
+#define glCopyTexImage1D glad_glCopyTexImage1D
+GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
+#define glCopyTexImage2D glad_glCopyTexImage2D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
+#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
+#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
+GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
+#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
+GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
+#define glCreateProgram glad_glCreateProgram
+GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
+#define glCreateShader glad_glCreateShader
+GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
+#define glCullFace glad_glCullFace
+GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
+#define glDeleteBuffers glad_glDeleteBuffers
+GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
+#define glDeleteFramebuffers glad_glDeleteFramebuffers
+GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
+#define glDeleteProgram glad_glDeleteProgram
+GLAD_API_CALL PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
+#define glDeleteQueries glad_glDeleteQueries
+GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
+#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
+GLAD_API_CALL PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
+#define glDeleteSamplers glad_glDeleteSamplers
+GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
+#define glDeleteShader glad_glDeleteShader
+GLAD_API_CALL PFNGLDELETESYNCPROC glad_glDeleteSync;
+#define glDeleteSync glad_glDeleteSync
+GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
+#define glDeleteTextures glad_glDeleteTextures
+GLAD_API_CALL PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
+#define glDeleteVertexArrays glad_glDeleteVertexArrays
+GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
+#define glDepthFunc glad_glDepthFunc
+GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
+#define glDepthMask glad_glDepthMask
+GLAD_API_CALL PFNGLDEPTHRANGEPROC glad_glDepthRange;
+#define glDepthRange glad_glDepthRange
+GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
+#define glDetachShader glad_glDetachShader
+GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
+#define glDisable glad_glDisable
+GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
+#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
+GLAD_API_CALL PFNGLDISABLEIPROC glad_glDisablei;
+#define glDisablei glad_glDisablei
+GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
+#define glDrawArrays glad_glDrawArrays
+GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
+#define glDrawArraysInstanced glad_glDrawArraysInstanced
+GLAD_API_CALL PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
+#define glDrawBuffer glad_glDrawBuffer
+GLAD_API_CALL PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
+#define glDrawBuffers glad_glDrawBuffers
+GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
+#define glDrawElements glad_glDrawElements
+GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
+#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
+#define glDrawElementsInstanced glad_glDrawElementsInstanced
+GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
+#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
+GLAD_API_CALL PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
+#define glDrawRangeElements glad_glDrawRangeElements
+GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
+#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
+GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
+#define glEnable glad_glEnable
+GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
+#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
+GLAD_API_CALL PFNGLENABLEIPROC glad_glEnablei;
+#define glEnablei glad_glEnablei
+GLAD_API_CALL PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
+#define glEndConditionalRender glad_glEndConditionalRender
+GLAD_API_CALL PFNGLENDQUERYPROC glad_glEndQuery;
+#define glEndQuery glad_glEndQuery
+GLAD_API_CALL PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
+#define glEndTransformFeedback glad_glEndTransformFeedback
+GLAD_API_CALL PFNGLFENCESYNCPROC glad_glFenceSync;
+#define glFenceSync glad_glFenceSync
+GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
+#define glFinish glad_glFinish
+GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
+#define glFlush glad_glFlush
+GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
+#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
+GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
+#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
+#define glFramebufferTexture glad_glFramebufferTexture
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
+#define glFramebufferTexture1D glad_glFramebufferTexture1D
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
+#define glFramebufferTexture2D glad_glFramebufferTexture2D
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
+#define glFramebufferTexture3D glad_glFramebufferTexture3D
+GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
+#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
+GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
+#define glFrontFace glad_glFrontFace
+GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
+#define glGenBuffers glad_glGenBuffers
+GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
+#define glGenFramebuffers glad_glGenFramebuffers
+GLAD_API_CALL PFNGLGENQUERIESPROC glad_glGenQueries;
+#define glGenQueries glad_glGenQueries
+GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
+#define glGenRenderbuffers glad_glGenRenderbuffers
+GLAD_API_CALL PFNGLGENSAMPLERSPROC glad_glGenSamplers;
+#define glGenSamplers glad_glGenSamplers
+GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
+#define glGenTextures glad_glGenTextures
+GLAD_API_CALL PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
+#define glGenVertexArrays glad_glGenVertexArrays
+GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
+#define glGenerateMipmap glad_glGenerateMipmap
+GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
+#define glGetActiveAttrib glad_glGetActiveAttrib
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
+#define glGetActiveUniform glad_glGetActiveUniform
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
+#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
+#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
+#define glGetActiveUniformName glad_glGetActiveUniformName
+GLAD_API_CALL PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
+#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
+GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
+#define glGetAttachedShaders glad_glGetAttachedShaders
+GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
+#define glGetAttribLocation glad_glGetAttribLocation
+GLAD_API_CALL PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
+#define glGetBooleani_v glad_glGetBooleani_v
+GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
+#define glGetBooleanv glad_glGetBooleanv
+GLAD_API_CALL PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
+#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
+GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
+#define glGetBufferParameteriv glad_glGetBufferParameteriv
+GLAD_API_CALL PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
+#define glGetBufferPointerv glad_glGetBufferPointerv
+GLAD_API_CALL PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
+#define glGetBufferSubData glad_glGetBufferSubData
+GLAD_API_CALL PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
+#define glGetCompressedTexImage glad_glGetCompressedTexImage
+GLAD_API_CALL PFNGLGETDOUBLEVPROC glad_glGetDoublev;
+#define glGetDoublev glad_glGetDoublev
+GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
+#define glGetError glad_glGetError
+GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
+#define glGetFloatv glad_glGetFloatv
+GLAD_API_CALL PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
+#define glGetFragDataIndex glad_glGetFragDataIndex
+GLAD_API_CALL PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
+#define glGetFragDataLocation glad_glGetFragDataLocation
+GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
+#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
+GLAD_API_CALL PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
+#define glGetInteger64i_v glad_glGetInteger64i_v
+GLAD_API_CALL PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
+#define glGetInteger64v glad_glGetInteger64v
+GLAD_API_CALL PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
+#define glGetIntegeri_v glad_glGetIntegeri_v
+GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
+#define glGetIntegerv glad_glGetIntegerv
+GLAD_API_CALL PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
+#define glGetMultisamplefv glad_glGetMultisamplefv
+GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
+#define glGetProgramInfoLog glad_glGetProgramInfoLog
+GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
+#define glGetProgramiv glad_glGetProgramiv
+GLAD_API_CALL PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
+#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
+GLAD_API_CALL PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
+#define glGetQueryObjectiv glad_glGetQueryObjectiv
+GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
+#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
+GLAD_API_CALL PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
+#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
+GLAD_API_CALL PFNGLGETQUERYIVPROC glad_glGetQueryiv;
+#define glGetQueryiv glad_glGetQueryiv
+GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
+#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
+#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
+#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
+#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
+GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
+#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
+GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
+#define glGetShaderInfoLog glad_glGetShaderInfoLog
+GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
+#define glGetShaderSource glad_glGetShaderSource
+GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
+#define glGetShaderiv glad_glGetShaderiv
+GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
+#define glGetString glad_glGetString
+GLAD_API_CALL PFNGLGETSTRINGIPROC glad_glGetStringi;
+#define glGetStringi glad_glGetStringi
+GLAD_API_CALL PFNGLGETSYNCIVPROC glad_glGetSynciv;
+#define glGetSynciv glad_glGetSynciv
+GLAD_API_CALL PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
+#define glGetTexImage glad_glGetTexImage
+GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
+#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
+GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
+#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
+GLAD_API_CALL PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
+#define glGetTexParameterIiv glad_glGetTexParameterIiv
+GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
+#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
+GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
+#define glGetTexParameterfv glad_glGetTexParameterfv
+GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
+#define glGetTexParameteriv glad_glGetTexParameteriv
+GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
+#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
+GLAD_API_CALL PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
+#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
+GLAD_API_CALL PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
+#define glGetUniformIndices glad_glGetUniformIndices
+GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
+#define glGetUniformLocation glad_glGetUniformLocation
+GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
+#define glGetUniformfv glad_glGetUniformfv
+GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
+#define glGetUniformiv glad_glGetUniformiv
+GLAD_API_CALL PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
+#define glGetUniformuiv glad_glGetUniformuiv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
+#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
+#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
+#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
+#define glGetVertexAttribdv glad_glGetVertexAttribdv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
+#define glGetVertexAttribfv glad_glGetVertexAttribfv
+GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
+#define glGetVertexAttribiv glad_glGetVertexAttribiv
+GLAD_API_CALL PFNGLHINTPROC glad_glHint;
+#define glHint glad_glHint
+GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
+#define glIsBuffer glad_glIsBuffer
+GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
+#define glIsEnabled glad_glIsEnabled
+GLAD_API_CALL PFNGLISENABLEDIPROC glad_glIsEnabledi;
+#define glIsEnabledi glad_glIsEnabledi
+GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
+#define glIsFramebuffer glad_glIsFramebuffer
+GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
+#define glIsProgram glad_glIsProgram
+GLAD_API_CALL PFNGLISQUERYPROC glad_glIsQuery;
+#define glIsQuery glad_glIsQuery
+GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
+#define glIsRenderbuffer glad_glIsRenderbuffer
+GLAD_API_CALL PFNGLISSAMPLERPROC glad_glIsSampler;
+#define glIsSampler glad_glIsSampler
+GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
+#define glIsShader glad_glIsShader
+GLAD_API_CALL PFNGLISSYNCPROC glad_glIsSync;
+#define glIsSync glad_glIsSync
+GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
+#define glIsTexture glad_glIsTexture
+GLAD_API_CALL PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
+#define glIsVertexArray glad_glIsVertexArray
+GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
+#define glLineWidth glad_glLineWidth
+GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
+#define glLinkProgram glad_glLinkProgram
+GLAD_API_CALL PFNGLLOGICOPPROC glad_glLogicOp;
+#define glLogicOp glad_glLogicOp
+GLAD_API_CALL PFNGLMAPBUFFERPROC glad_glMapBuffer;
+#define glMapBuffer glad_glMapBuffer
+GLAD_API_CALL PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
+#define glMapBufferRange glad_glMapBufferRange
+GLAD_API_CALL PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
+#define glMultiDrawArrays glad_glMultiDrawArrays
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
+#define glMultiDrawElements glad_glMultiDrawElements
+GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
+#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
+GLAD_API_CALL PFNGLPIXELSTOREFPROC glad_glPixelStoref;
+#define glPixelStoref glad_glPixelStoref
+GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
+#define glPixelStorei glad_glPixelStorei
+GLAD_API_CALL PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
+#define glPointParameterf glad_glPointParameterf
+GLAD_API_CALL PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
+#define glPointParameterfv glad_glPointParameterfv
+GLAD_API_CALL PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
+#define glPointParameteri glad_glPointParameteri
+GLAD_API_CALL PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
+#define glPointParameteriv glad_glPointParameteriv
+GLAD_API_CALL PFNGLPOINTSIZEPROC glad_glPointSize;
+#define glPointSize glad_glPointSize
+GLAD_API_CALL PFNGLPOLYGONMODEPROC glad_glPolygonMode;
+#define glPolygonMode glad_glPolygonMode
+GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
+#define glPolygonOffset glad_glPolygonOffset
+GLAD_API_CALL PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
+#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
+GLAD_API_CALL PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
+#define glProvokingVertex glad_glProvokingVertex
+GLAD_API_CALL PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
+#define glQueryCounter glad_glQueryCounter
+GLAD_API_CALL PFNGLREADBUFFERPROC glad_glReadBuffer;
+#define glReadBuffer glad_glReadBuffer
+GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
+#define glReadPixels glad_glReadPixels
+GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
+#define glRenderbufferStorage glad_glRenderbufferStorage
+GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
+#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
+GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
+#define glSampleCoverage glad_glSampleCoverage
+GLAD_API_CALL PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
+#define glSampleMaski glad_glSampleMaski
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
+#define glSamplerParameterIiv glad_glSamplerParameterIiv
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
+#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
+GLAD_API_CALL PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
+#define glSamplerParameterf glad_glSamplerParameterf
+GLAD_API_CALL PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
+#define glSamplerParameterfv glad_glSamplerParameterfv
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
+#define glSamplerParameteri glad_glSamplerParameteri
+GLAD_API_CALL PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
+#define glSamplerParameteriv glad_glSamplerParameteriv
+GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
+#define glScissor glad_glScissor
+GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
+#define glShaderSource glad_glShaderSource
+GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
+#define glStencilFunc glad_glStencilFunc
+GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
+#define glStencilFuncSeparate glad_glStencilFuncSeparate
+GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
+#define glStencilMask glad_glStencilMask
+GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
+#define glStencilMaskSeparate glad_glStencilMaskSeparate
+GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
+#define glStencilOp glad_glStencilOp
+GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
+#define glStencilOpSeparate glad_glStencilOpSeparate
+GLAD_API_CALL PFNGLTEXBUFFERPROC glad_glTexBuffer;
+#define glTexBuffer glad_glTexBuffer
+GLAD_API_CALL PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
+#define glTexImage1D glad_glTexImage1D
+GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
+#define glTexImage2D glad_glTexImage2D
+GLAD_API_CALL PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
+#define glTexImage2DMultisample glad_glTexImage2DMultisample
+GLAD_API_CALL PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
+#define glTexImage3D glad_glTexImage3D
+GLAD_API_CALL PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
+#define glTexImage3DMultisample glad_glTexImage3DMultisample
+GLAD_API_CALL PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
+#define glTexParameterIiv glad_glTexParameterIiv
+GLAD_API_CALL PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
+#define glTexParameterIuiv glad_glTexParameterIuiv
+GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
+#define glTexParameterf glad_glTexParameterf
+GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
+#define glTexParameterfv glad_glTexParameterfv
+GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
+#define glTexParameteri glad_glTexParameteri
+GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
+#define glTexParameteriv glad_glTexParameteriv
+GLAD_API_CALL PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
+#define glTexSubImage1D glad_glTexSubImage1D
+GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
+#define glTexSubImage2D glad_glTexSubImage2D
+GLAD_API_CALL PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
+#define glTexSubImage3D glad_glTexSubImage3D
+GLAD_API_CALL PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
+#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
+GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
+#define glUniform1f glad_glUniform1f
+GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
+#define glUniform1fv glad_glUniform1fv
+GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
+#define glUniform1i glad_glUniform1i
+GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
+#define glUniform1iv glad_glUniform1iv
+GLAD_API_CALL PFNGLUNIFORM1UIPROC glad_glUniform1ui;
+#define glUniform1ui glad_glUniform1ui
+GLAD_API_CALL PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
+#define glUniform1uiv glad_glUniform1uiv
+GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
+#define glUniform2f glad_glUniform2f
+GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
+#define glUniform2fv glad_glUniform2fv
+GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
+#define glUniform2i glad_glUniform2i
+GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
+#define glUniform2iv glad_glUniform2iv
+GLAD_API_CALL PFNGLUNIFORM2UIPROC glad_glUniform2ui;
+#define glUniform2ui glad_glUniform2ui
+GLAD_API_CALL PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
+#define glUniform2uiv glad_glUniform2uiv
+GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
+#define glUniform3f glad_glUniform3f
+GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
+#define glUniform3fv glad_glUniform3fv
+GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
+#define glUniform3i glad_glUniform3i
+GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
+#define glUniform3iv glad_glUniform3iv
+GLAD_API_CALL PFNGLUNIFORM3UIPROC glad_glUniform3ui;
+#define glUniform3ui glad_glUniform3ui
+GLAD_API_CALL PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
+#define glUniform3uiv glad_glUniform3uiv
+GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
+#define glUniform4f glad_glUniform4f
+GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
+#define glUniform4fv glad_glUniform4fv
+GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
+#define glUniform4i glad_glUniform4i
+GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
+#define glUniform4iv glad_glUniform4iv
+GLAD_API_CALL PFNGLUNIFORM4UIPROC glad_glUniform4ui;
+#define glUniform4ui glad_glUniform4ui
+GLAD_API_CALL PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
+#define glUniform4uiv glad_glUniform4uiv
+GLAD_API_CALL PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
+#define glUniformBlockBinding glad_glUniformBlockBinding
+GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
+#define glUniformMatrix2fv glad_glUniformMatrix2fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
+#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
+#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
+#define glUniformMatrix3fv glad_glUniformMatrix3fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
+#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
+#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
+#define glUniformMatrix4fv glad_glUniformMatrix4fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
+#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
+GLAD_API_CALL PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
+#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
+GLAD_API_CALL PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
+#define glUnmapBuffer glad_glUnmapBuffer
+GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
+#define glUseProgram glad_glUseProgram
+GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
+#define glValidateProgram glad_glValidateProgram
+GLAD_API_CALL PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
+#define glVertexAttrib1d glad_glVertexAttrib1d
+GLAD_API_CALL PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
+#define glVertexAttrib1dv glad_glVertexAttrib1dv
+GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
+#define glVertexAttrib1f glad_glVertexAttrib1f
+GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
+#define glVertexAttrib1fv glad_glVertexAttrib1fv
+GLAD_API_CALL PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
+#define glVertexAttrib1s glad_glVertexAttrib1s
+GLAD_API_CALL PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
+#define glVertexAttrib1sv glad_glVertexAttrib1sv
+GLAD_API_CALL PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
+#define glVertexAttrib2d glad_glVertexAttrib2d
+GLAD_API_CALL PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
+#define glVertexAttrib2dv glad_glVertexAttrib2dv
+GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
+#define glVertexAttrib2f glad_glVertexAttrib2f
+GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
+#define glVertexAttrib2fv glad_glVertexAttrib2fv
+GLAD_API_CALL PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
+#define glVertexAttrib2s glad_glVertexAttrib2s
+GLAD_API_CALL PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
+#define glVertexAttrib2sv glad_glVertexAttrib2sv
+GLAD_API_CALL PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
+#define glVertexAttrib3d glad_glVertexAttrib3d
+GLAD_API_CALL PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
+#define glVertexAttrib3dv glad_glVertexAttrib3dv
+GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
+#define glVertexAttrib3f glad_glVertexAttrib3f
+GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
+#define glVertexAttrib3fv glad_glVertexAttrib3fv
+GLAD_API_CALL PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
+#define glVertexAttrib3s glad_glVertexAttrib3s
+GLAD_API_CALL PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
+#define glVertexAttrib3sv glad_glVertexAttrib3sv
+GLAD_API_CALL PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
+#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
+GLAD_API_CALL PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
+#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
+GLAD_API_CALL PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
+#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
+GLAD_API_CALL PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
+#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
+GLAD_API_CALL PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
+#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
+GLAD_API_CALL PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
+#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
+GLAD_API_CALL PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
+#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
+GLAD_API_CALL PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
+#define glVertexAttrib4bv glad_glVertexAttrib4bv
+GLAD_API_CALL PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
+#define glVertexAttrib4d glad_glVertexAttrib4d
+GLAD_API_CALL PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
+#define glVertexAttrib4dv glad_glVertexAttrib4dv
+GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
+#define glVertexAttrib4f glad_glVertexAttrib4f
+GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
+#define glVertexAttrib4fv glad_glVertexAttrib4fv
+GLAD_API_CALL PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
+#define glVertexAttrib4iv glad_glVertexAttrib4iv
+GLAD_API_CALL PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
+#define glVertexAttrib4s glad_glVertexAttrib4s
+GLAD_API_CALL PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
+#define glVertexAttrib4sv glad_glVertexAttrib4sv
+GLAD_API_CALL PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
+#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
+GLAD_API_CALL PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
+#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
+GLAD_API_CALL PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
+#define glVertexAttrib4usv glad_glVertexAttrib4usv
+GLAD_API_CALL PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
+#define glVertexAttribDivisor glad_glVertexAttribDivisor
+GLAD_API_CALL PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
+#define glVertexAttribI1i glad_glVertexAttribI1i
+GLAD_API_CALL PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
+#define glVertexAttribI1iv glad_glVertexAttribI1iv
+GLAD_API_CALL PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
+#define glVertexAttribI1ui glad_glVertexAttribI1ui
+GLAD_API_CALL PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
+#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
+#define glVertexAttribI2i glad_glVertexAttribI2i
+GLAD_API_CALL PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
+#define glVertexAttribI2iv glad_glVertexAttribI2iv
+GLAD_API_CALL PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
+#define glVertexAttribI2ui glad_glVertexAttribI2ui
+GLAD_API_CALL PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
+#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
+#define glVertexAttribI3i glad_glVertexAttribI3i
+GLAD_API_CALL PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
+#define glVertexAttribI3iv glad_glVertexAttribI3iv
+GLAD_API_CALL PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
+#define glVertexAttribI3ui glad_glVertexAttribI3ui
+GLAD_API_CALL PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
+#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
+#define glVertexAttribI4bv glad_glVertexAttribI4bv
+GLAD_API_CALL PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
+#define glVertexAttribI4i glad_glVertexAttribI4i
+GLAD_API_CALL PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
+#define glVertexAttribI4iv glad_glVertexAttribI4iv
+GLAD_API_CALL PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
+#define glVertexAttribI4sv glad_glVertexAttribI4sv
+GLAD_API_CALL PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
+#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
+GLAD_API_CALL PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
+#define glVertexAttribI4ui glad_glVertexAttribI4ui
+GLAD_API_CALL PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
+#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
+#define glVertexAttribI4usv glad_glVertexAttribI4usv
+GLAD_API_CALL PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
+#define glVertexAttribIPointer glad_glVertexAttribIPointer
+GLAD_API_CALL PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
+#define glVertexAttribP1ui glad_glVertexAttribP1ui
+GLAD_API_CALL PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
+#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
+#define glVertexAttribP2ui glad_glVertexAttribP2ui
+GLAD_API_CALL PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
+#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
+#define glVertexAttribP3ui glad_glVertexAttribP3ui
+GLAD_API_CALL PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
+#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
+#define glVertexAttribP4ui glad_glVertexAttribP4ui
+GLAD_API_CALL PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
+#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
+GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
+#define glVertexAttribPointer glad_glVertexAttribPointer
+GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
+#define glViewport glad_glViewport
+GLAD_API_CALL PFNGLWAITSYNCPROC glad_glWaitSync;
+#define glWaitSync glad_glWaitSync
+
+
+
+
+
+GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr);
+GLAD_API_CALL int gladLoadGL( GLADloadfunc load);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/Client/ThirdParty/Box2D/extern/glad/src/gl.c b/Client/ThirdParty/Box2D/extern/glad/src/gl.c
new file mode 100644
index 0000000..071ff2a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glad/src/gl.c
@@ -0,0 +1,949 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glad/gl.h>
+
+#ifndef GLAD_IMPL_UTIL_C_
+#define GLAD_IMPL_UTIL_C_
+
+#ifdef _MSC_VER
+#define GLAD_IMPL_UTIL_SSCANF sscanf_s
+#else
+#define GLAD_IMPL_UTIL_SSCANF sscanf
+#endif
+
+#endif /* GLAD_IMPL_UTIL_C_ */
+
+
+int GLAD_GL_VERSION_1_0 = 0;
+int GLAD_GL_VERSION_1_1 = 0;
+int GLAD_GL_VERSION_1_2 = 0;
+int GLAD_GL_VERSION_1_3 = 0;
+int GLAD_GL_VERSION_1_4 = 0;
+int GLAD_GL_VERSION_1_5 = 0;
+int GLAD_GL_VERSION_2_0 = 0;
+int GLAD_GL_VERSION_2_1 = 0;
+int GLAD_GL_VERSION_3_0 = 0;
+int GLAD_GL_VERSION_3_1 = 0;
+int GLAD_GL_VERSION_3_2 = 0;
+int GLAD_GL_VERSION_3_3 = 0;
+
+
+
+PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
+PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
+PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL;
+PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL;
+PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL;
+PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
+PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
+PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL;
+PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL;
+PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL;
+PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL;
+PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
+PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
+PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL;
+PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
+PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL;
+PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
+PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
+PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
+PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
+PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
+PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL;
+PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
+PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
+PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
+PFNGLCLAMPCOLORPROC glad_glClampColor = NULL;
+PFNGLCLEARPROC glad_glClear = NULL;
+PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL;
+PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL;
+PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL;
+PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL;
+PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
+PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
+PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
+PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL;
+PFNGLCOLORMASKPROC glad_glColorMask = NULL;
+PFNGLCOLORMASKIPROC glad_glColorMaski = NULL;
+PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
+PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL;
+PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
+PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL;
+PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL;
+PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL;
+PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
+PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL;
+PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
+PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL;
+PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
+PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
+PFNGLCULLFACEPROC glad_glCullFace = NULL;
+PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
+PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
+PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
+PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL;
+PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
+PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL;
+PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
+PFNGLDELETESYNCPROC glad_glDeleteSync = NULL;
+PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
+PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL;
+PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
+PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
+PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL;
+PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
+PFNGLDISABLEPROC glad_glDisable = NULL;
+PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
+PFNGLDISABLEIPROC glad_glDisablei = NULL;
+PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
+PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL;
+PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL;
+PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL;
+PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
+PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL;
+PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL;
+PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL;
+PFNGLENABLEPROC glad_glEnable = NULL;
+PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
+PFNGLENABLEIPROC glad_glEnablei = NULL;
+PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL;
+PFNGLENDQUERYPROC glad_glEndQuery = NULL;
+PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL;
+PFNGLFENCESYNCPROC glad_glFenceSync = NULL;
+PFNGLFINISHPROC glad_glFinish = NULL;
+PFNGLFLUSHPROC glad_glFlush = NULL;
+PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL;
+PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
+PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL;
+PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL;
+PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
+PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL;
+PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL;
+PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
+PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
+PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
+PFNGLGENQUERIESPROC glad_glGenQueries = NULL;
+PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
+PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL;
+PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
+PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL;
+PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
+PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
+PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
+PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL;
+PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL;
+PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL;
+PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL;
+PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
+PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
+PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;
+PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
+PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL;
+PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
+PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL;
+PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL;
+PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL;
+PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;
+PFNGLGETERRORPROC glad_glGetError = NULL;
+PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
+PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL;
+PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL;
+PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
+PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;
+PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL;
+PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL;
+PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
+PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL;
+PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
+PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
+PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL;
+PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL;
+PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL;
+PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL;
+PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL;
+PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
+PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL;
+PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL;
+PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL;
+PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL;
+PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
+PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
+PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
+PFNGLGETSTRINGPROC glad_glGetString = NULL;
+PFNGLGETSTRINGIPROC glad_glGetStringi = NULL;
+PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL;
+PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL;
+PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL;
+PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL;
+PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL;
+PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL;
+PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
+PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
+PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL;
+PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL;
+PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL;
+PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
+PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
+PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
+PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL;
+PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL;
+PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL;
+PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
+PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL;
+PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
+PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
+PFNGLHINTPROC glad_glHint = NULL;
+PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
+PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
+PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL;
+PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
+PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
+PFNGLISQUERYPROC glad_glIsQuery = NULL;
+PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
+PFNGLISSAMPLERPROC glad_glIsSampler = NULL;
+PFNGLISSHADERPROC glad_glIsShader = NULL;
+PFNGLISSYNCPROC glad_glIsSync = NULL;
+PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
+PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL;
+PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
+PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
+PFNGLLOGICOPPROC glad_glLogicOp = NULL;
+PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL;
+PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL;
+PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL;
+PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL;
+PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL;
+PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL;
+PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
+PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL;
+PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL;
+PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL;
+PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL;
+PFNGLPOINTSIZEPROC glad_glPointSize = NULL;
+PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL;
+PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
+PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL;
+PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL;
+PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL;
+PFNGLREADBUFFERPROC glad_glReadBuffer = NULL;
+PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
+PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
+PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
+PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
+PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL;
+PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL;
+PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL;
+PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL;
+PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL;
+PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL;
+PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL;
+PFNGLSCISSORPROC glad_glScissor = NULL;
+PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
+PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
+PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
+PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
+PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
+PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
+PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
+PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL;
+PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL;
+PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
+PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL;
+PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL;
+PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL;
+PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL;
+PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL;
+PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
+PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
+PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
+PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
+PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL;
+PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
+PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL;
+PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL;
+PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
+PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
+PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
+PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
+PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL;
+PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL;
+PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
+PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
+PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
+PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
+PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL;
+PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL;
+PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
+PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
+PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
+PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
+PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL;
+PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL;
+PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
+PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
+PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
+PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
+PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL;
+PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL;
+PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL;
+PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
+PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL;
+PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL;
+PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
+PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL;
+PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL;
+PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
+PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL;
+PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL;
+PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL;
+PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
+PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
+PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL;
+PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL;
+PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
+PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
+PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL;
+PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL;
+PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL;
+PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL;
+PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
+PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
+PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL;
+PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL;
+PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL;
+PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL;
+PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
+PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
+PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL;
+PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL;
+PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL;
+PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL;
+PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL;
+PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL;
+PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL;
+PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL;
+PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL;
+PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL;
+PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL;
+PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL;
+PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
+PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
+PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL;
+PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL;
+PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL;
+PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL;
+PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL;
+PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL;
+PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL;
+PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL;
+PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL;
+PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL;
+PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL;
+PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL;
+PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL;
+PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL;
+PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL;
+PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL;
+PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL;
+PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL;
+PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL;
+PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL;
+PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL;
+PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL;
+PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL;
+PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL;
+PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL;
+PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL;
+PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL;
+PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL;
+PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL;
+PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL;
+PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL;
+PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL;
+PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL;
+PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL;
+PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL;
+PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL;
+PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
+PFNGLVIEWPORTPROC glad_glViewport = NULL;
+PFNGLWAITSYNCPROC glad_glWaitSync = NULL;
+
+
+static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_1_0) return;
+ glad_glBlendFunc = (PFNGLBLENDFUNCPROC) load(userptr, "glBlendFunc");
+ glad_glClear = (PFNGLCLEARPROC) load(userptr, "glClear");
+ glad_glClearColor = (PFNGLCLEARCOLORPROC) load(userptr, "glClearColor");
+ glad_glClearDepth = (PFNGLCLEARDEPTHPROC) load(userptr, "glClearDepth");
+ glad_glClearStencil = (PFNGLCLEARSTENCILPROC) load(userptr, "glClearStencil");
+ glad_glColorMask = (PFNGLCOLORMASKPROC) load(userptr, "glColorMask");
+ glad_glCullFace = (PFNGLCULLFACEPROC) load(userptr, "glCullFace");
+ glad_glDepthFunc = (PFNGLDEPTHFUNCPROC) load(userptr, "glDepthFunc");
+ glad_glDepthMask = (PFNGLDEPTHMASKPROC) load(userptr, "glDepthMask");
+ glad_glDepthRange = (PFNGLDEPTHRANGEPROC) load(userptr, "glDepthRange");
+ glad_glDisable = (PFNGLDISABLEPROC) load(userptr, "glDisable");
+ glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC) load(userptr, "glDrawBuffer");
+ glad_glEnable = (PFNGLENABLEPROC) load(userptr, "glEnable");
+ glad_glFinish = (PFNGLFINISHPROC) load(userptr, "glFinish");
+ glad_glFlush = (PFNGLFLUSHPROC) load(userptr, "glFlush");
+ glad_glFrontFace = (PFNGLFRONTFACEPROC) load(userptr, "glFrontFace");
+ glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC) load(userptr, "glGetBooleanv");
+ glad_glGetDoublev = (PFNGLGETDOUBLEVPROC) load(userptr, "glGetDoublev");
+ glad_glGetError = (PFNGLGETERRORPROC) load(userptr, "glGetError");
+ glad_glGetFloatv = (PFNGLGETFLOATVPROC) load(userptr, "glGetFloatv");
+ glad_glGetIntegerv = (PFNGLGETINTEGERVPROC) load(userptr, "glGetIntegerv");
+ glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
+ glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC) load(userptr, "glGetTexImage");
+ glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load(userptr, "glGetTexLevelParameterfv");
+ glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load(userptr, "glGetTexLevelParameteriv");
+ glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load(userptr, "glGetTexParameterfv");
+ glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load(userptr, "glGetTexParameteriv");
+ glad_glHint = (PFNGLHINTPROC) load(userptr, "glHint");
+ glad_glIsEnabled = (PFNGLISENABLEDPROC) load(userptr, "glIsEnabled");
+ glad_glLineWidth = (PFNGLLINEWIDTHPROC) load(userptr, "glLineWidth");
+ glad_glLogicOp = (PFNGLLOGICOPPROC) load(userptr, "glLogicOp");
+ glad_glPixelStoref = (PFNGLPIXELSTOREFPROC) load(userptr, "glPixelStoref");
+ glad_glPixelStorei = (PFNGLPIXELSTOREIPROC) load(userptr, "glPixelStorei");
+ glad_glPointSize = (PFNGLPOINTSIZEPROC) load(userptr, "glPointSize");
+ glad_glPolygonMode = (PFNGLPOLYGONMODEPROC) load(userptr, "glPolygonMode");
+ glad_glReadBuffer = (PFNGLREADBUFFERPROC) load(userptr, "glReadBuffer");
+ glad_glReadPixels = (PFNGLREADPIXELSPROC) load(userptr, "glReadPixels");
+ glad_glScissor = (PFNGLSCISSORPROC) load(userptr, "glScissor");
+ glad_glStencilFunc = (PFNGLSTENCILFUNCPROC) load(userptr, "glStencilFunc");
+ glad_glStencilMask = (PFNGLSTENCILMASKPROC) load(userptr, "glStencilMask");
+ glad_glStencilOp = (PFNGLSTENCILOPPROC) load(userptr, "glStencilOp");
+ glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC) load(userptr, "glTexImage1D");
+ glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC) load(userptr, "glTexImage2D");
+ glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC) load(userptr, "glTexParameterf");
+ glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load(userptr, "glTexParameterfv");
+ glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC) load(userptr, "glTexParameteri");
+ glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load(userptr, "glTexParameteriv");
+ glad_glViewport = (PFNGLVIEWPORTPROC) load(userptr, "glViewport");
+}
+static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_1_1) return;
+ glad_glBindTexture = (PFNGLBINDTEXTUREPROC) load(userptr, "glBindTexture");
+ glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load(userptr, "glCopyTexImage1D");
+ glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load(userptr, "glCopyTexImage2D");
+ glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load(userptr, "glCopyTexSubImage1D");
+ glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load(userptr, "glCopyTexSubImage2D");
+ glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC) load(userptr, "glDeleteTextures");
+ glad_glDrawArrays = (PFNGLDRAWARRAYSPROC) load(userptr, "glDrawArrays");
+ glad_glDrawElements = (PFNGLDRAWELEMENTSPROC) load(userptr, "glDrawElements");
+ glad_glGenTextures = (PFNGLGENTEXTURESPROC) load(userptr, "glGenTextures");
+ glad_glIsTexture = (PFNGLISTEXTUREPROC) load(userptr, "glIsTexture");
+ glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load(userptr, "glPolygonOffset");
+ glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load(userptr, "glTexSubImage1D");
+ glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load(userptr, "glTexSubImage2D");
+}
+static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_1_2) return;
+ glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load(userptr, "glCopyTexSubImage3D");
+ glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load(userptr, "glDrawRangeElements");
+ glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC) load(userptr, "glTexImage3D");
+ glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load(userptr, "glTexSubImage3D");
+}
+static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_1_3) return;
+ glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC) load(userptr, "glActiveTexture");
+ glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load(userptr, "glCompressedTexImage1D");
+ glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load(userptr, "glCompressedTexImage2D");
+ glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load(userptr, "glCompressedTexImage3D");
+ glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load(userptr, "glCompressedTexSubImage1D");
+ glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load(userptr, "glCompressedTexSubImage2D");
+ glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load(userptr, "glCompressedTexSubImage3D");
+ glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load(userptr, "glGetCompressedTexImage");
+ glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load(userptr, "glSampleCoverage");
+}
+static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_1_4) return;
+ glad_glBlendColor = (PFNGLBLENDCOLORPROC) load(userptr, "glBlendColor");
+ glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC) load(userptr, "glBlendEquation");
+ glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load(userptr, "glBlendFuncSeparate");
+ glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load(userptr, "glMultiDrawArrays");
+ glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load(userptr, "glMultiDrawElements");
+ glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load(userptr, "glPointParameterf");
+ glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load(userptr, "glPointParameterfv");
+ glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load(userptr, "glPointParameteri");
+ glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load(userptr, "glPointParameteriv");
+}
+static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_1_5) return;
+ glad_glBeginQuery = (PFNGLBEGINQUERYPROC) load(userptr, "glBeginQuery");
+ glad_glBindBuffer = (PFNGLBINDBUFFERPROC) load(userptr, "glBindBuffer");
+ glad_glBufferData = (PFNGLBUFFERDATAPROC) load(userptr, "glBufferData");
+ glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load(userptr, "glBufferSubData");
+ glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load(userptr, "glDeleteBuffers");
+ glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC) load(userptr, "glDeleteQueries");
+ glad_glEndQuery = (PFNGLENDQUERYPROC) load(userptr, "glEndQuery");
+ glad_glGenBuffers = (PFNGLGENBUFFERSPROC) load(userptr, "glGenBuffers");
+ glad_glGenQueries = (PFNGLGENQUERIESPROC) load(userptr, "glGenQueries");
+ glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load(userptr, "glGetBufferParameteriv");
+ glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load(userptr, "glGetBufferPointerv");
+ glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load(userptr, "glGetBufferSubData");
+ glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load(userptr, "glGetQueryObjectiv");
+ glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load(userptr, "glGetQueryObjectuiv");
+ glad_glGetQueryiv = (PFNGLGETQUERYIVPROC) load(userptr, "glGetQueryiv");
+ glad_glIsBuffer = (PFNGLISBUFFERPROC) load(userptr, "glIsBuffer");
+ glad_glIsQuery = (PFNGLISQUERYPROC) load(userptr, "glIsQuery");
+ glad_glMapBuffer = (PFNGLMAPBUFFERPROC) load(userptr, "glMapBuffer");
+ glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load(userptr, "glUnmapBuffer");
+}
+static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_2_0) return;
+ glad_glAttachShader = (PFNGLATTACHSHADERPROC) load(userptr, "glAttachShader");
+ glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load(userptr, "glBindAttribLocation");
+ glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load(userptr, "glBlendEquationSeparate");
+ glad_glCompileShader = (PFNGLCOMPILESHADERPROC) load(userptr, "glCompileShader");
+ glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC) load(userptr, "glCreateProgram");
+ glad_glCreateShader = (PFNGLCREATESHADERPROC) load(userptr, "glCreateShader");
+ glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load(userptr, "glDeleteProgram");
+ glad_glDeleteShader = (PFNGLDELETESHADERPROC) load(userptr, "glDeleteShader");
+ glad_glDetachShader = (PFNGLDETACHSHADERPROC) load(userptr, "glDetachShader");
+ glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load(userptr, "glDisableVertexAttribArray");
+ glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load(userptr, "glDrawBuffers");
+ glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load(userptr, "glEnableVertexAttribArray");
+ glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load(userptr, "glGetActiveAttrib");
+ glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load(userptr, "glGetActiveUniform");
+ glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load(userptr, "glGetAttachedShaders");
+ glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load(userptr, "glGetAttribLocation");
+ glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load(userptr, "glGetProgramInfoLog");
+ glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load(userptr, "glGetProgramiv");
+ glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load(userptr, "glGetShaderInfoLog");
+ glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load(userptr, "glGetShaderSource");
+ glad_glGetShaderiv = (PFNGLGETSHADERIVPROC) load(userptr, "glGetShaderiv");
+ glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load(userptr, "glGetUniformLocation");
+ glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load(userptr, "glGetUniformfv");
+ glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load(userptr, "glGetUniformiv");
+ glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load(userptr, "glGetVertexAttribPointerv");
+ glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load(userptr, "glGetVertexAttribdv");
+ glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load(userptr, "glGetVertexAttribfv");
+ glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load(userptr, "glGetVertexAttribiv");
+ glad_glIsProgram = (PFNGLISPROGRAMPROC) load(userptr, "glIsProgram");
+ glad_glIsShader = (PFNGLISSHADERPROC) load(userptr, "glIsShader");
+ glad_glLinkProgram = (PFNGLLINKPROGRAMPROC) load(userptr, "glLinkProgram");
+ glad_glShaderSource = (PFNGLSHADERSOURCEPROC) load(userptr, "glShaderSource");
+ glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load(userptr, "glStencilFuncSeparate");
+ glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load(userptr, "glStencilMaskSeparate");
+ glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load(userptr, "glStencilOpSeparate");
+ glad_glUniform1f = (PFNGLUNIFORM1FPROC) load(userptr, "glUniform1f");
+ glad_glUniform1fv = (PFNGLUNIFORM1FVPROC) load(userptr, "glUniform1fv");
+ glad_glUniform1i = (PFNGLUNIFORM1IPROC) load(userptr, "glUniform1i");
+ glad_glUniform1iv = (PFNGLUNIFORM1IVPROC) load(userptr, "glUniform1iv");
+ glad_glUniform2f = (PFNGLUNIFORM2FPROC) load(userptr, "glUniform2f");
+ glad_glUniform2fv = (PFNGLUNIFORM2FVPROC) load(userptr, "glUniform2fv");
+ glad_glUniform2i = (PFNGLUNIFORM2IPROC) load(userptr, "glUniform2i");
+ glad_glUniform2iv = (PFNGLUNIFORM2IVPROC) load(userptr, "glUniform2iv");
+ glad_glUniform3f = (PFNGLUNIFORM3FPROC) load(userptr, "glUniform3f");
+ glad_glUniform3fv = (PFNGLUNIFORM3FVPROC) load(userptr, "glUniform3fv");
+ glad_glUniform3i = (PFNGLUNIFORM3IPROC) load(userptr, "glUniform3i");
+ glad_glUniform3iv = (PFNGLUNIFORM3IVPROC) load(userptr, "glUniform3iv");
+ glad_glUniform4f = (PFNGLUNIFORM4FPROC) load(userptr, "glUniform4f");
+ glad_glUniform4fv = (PFNGLUNIFORM4FVPROC) load(userptr, "glUniform4fv");
+ glad_glUniform4i = (PFNGLUNIFORM4IPROC) load(userptr, "glUniform4i");
+ glad_glUniform4iv = (PFNGLUNIFORM4IVPROC) load(userptr, "glUniform4iv");
+ glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load(userptr, "glUniformMatrix2fv");
+ glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load(userptr, "glUniformMatrix3fv");
+ glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load(userptr, "glUniformMatrix4fv");
+ glad_glUseProgram = (PFNGLUSEPROGRAMPROC) load(userptr, "glUseProgram");
+ glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load(userptr, "glValidateProgram");
+ glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load(userptr, "glVertexAttrib1d");
+ glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load(userptr, "glVertexAttrib1dv");
+ glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load(userptr, "glVertexAttrib1f");
+ glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load(userptr, "glVertexAttrib1fv");
+ glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load(userptr, "glVertexAttrib1s");
+ glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load(userptr, "glVertexAttrib1sv");
+ glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load(userptr, "glVertexAttrib2d");
+ glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load(userptr, "glVertexAttrib2dv");
+ glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load(userptr, "glVertexAttrib2f");
+ glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load(userptr, "glVertexAttrib2fv");
+ glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load(userptr, "glVertexAttrib2s");
+ glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load(userptr, "glVertexAttrib2sv");
+ glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load(userptr, "glVertexAttrib3d");
+ glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load(userptr, "glVertexAttrib3dv");
+ glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load(userptr, "glVertexAttrib3f");
+ glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load(userptr, "glVertexAttrib3fv");
+ glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load(userptr, "glVertexAttrib3s");
+ glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load(userptr, "glVertexAttrib3sv");
+ glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load(userptr, "glVertexAttrib4Nbv");
+ glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load(userptr, "glVertexAttrib4Niv");
+ glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load(userptr, "glVertexAttrib4Nsv");
+ glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load(userptr, "glVertexAttrib4Nub");
+ glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load(userptr, "glVertexAttrib4Nubv");
+ glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load(userptr, "glVertexAttrib4Nuiv");
+ glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load(userptr, "glVertexAttrib4Nusv");
+ glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load(userptr, "glVertexAttrib4bv");
+ glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load(userptr, "glVertexAttrib4d");
+ glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load(userptr, "glVertexAttrib4dv");
+ glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load(userptr, "glVertexAttrib4f");
+ glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load(userptr, "glVertexAttrib4fv");
+ glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load(userptr, "glVertexAttrib4iv");
+ glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load(userptr, "glVertexAttrib4s");
+ glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load(userptr, "glVertexAttrib4sv");
+ glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load(userptr, "glVertexAttrib4ubv");
+ glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load(userptr, "glVertexAttrib4uiv");
+ glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load(userptr, "glVertexAttrib4usv");
+ glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load(userptr, "glVertexAttribPointer");
+}
+static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_2_1) return;
+ glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load(userptr, "glUniformMatrix2x3fv");
+ glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load(userptr, "glUniformMatrix2x4fv");
+ glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load(userptr, "glUniformMatrix3x2fv");
+ glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load(userptr, "glUniformMatrix3x4fv");
+ glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load(userptr, "glUniformMatrix4x2fv");
+ glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load(userptr, "glUniformMatrix4x3fv");
+}
+static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_3_0) return;
+ glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load(userptr, "glBeginConditionalRender");
+ glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load(userptr, "glBeginTransformFeedback");
+ glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
+ glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
+ glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load(userptr, "glBindFragDataLocation");
+ glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load(userptr, "glBindFramebuffer");
+ glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load(userptr, "glBindRenderbuffer");
+ glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load(userptr, "glBindVertexArray");
+ glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load(userptr, "glBlitFramebuffer");
+ glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load(userptr, "glCheckFramebufferStatus");
+ glad_glClampColor = (PFNGLCLAMPCOLORPROC) load(userptr, "glClampColor");
+ glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load(userptr, "glClearBufferfi");
+ glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load(userptr, "glClearBufferfv");
+ glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load(userptr, "glClearBufferiv");
+ glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load(userptr, "glClearBufferuiv");
+ glad_glColorMaski = (PFNGLCOLORMASKIPROC) load(userptr, "glColorMaski");
+ glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load(userptr, "glDeleteFramebuffers");
+ glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load(userptr, "glDeleteRenderbuffers");
+ glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load(userptr, "glDeleteVertexArrays");
+ glad_glDisablei = (PFNGLDISABLEIPROC) load(userptr, "glDisablei");
+ glad_glEnablei = (PFNGLENABLEIPROC) load(userptr, "glEnablei");
+ glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load(userptr, "glEndConditionalRender");
+ glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load(userptr, "glEndTransformFeedback");
+ glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load(userptr, "glFlushMappedBufferRange");
+ glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load(userptr, "glFramebufferRenderbuffer");
+ glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load(userptr, "glFramebufferTexture1D");
+ glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load(userptr, "glFramebufferTexture2D");
+ glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load(userptr, "glFramebufferTexture3D");
+ glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load(userptr, "glFramebufferTextureLayer");
+ glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load(userptr, "glGenFramebuffers");
+ glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load(userptr, "glGenRenderbuffers");
+ glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load(userptr, "glGenVertexArrays");
+ glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load(userptr, "glGenerateMipmap");
+ glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load(userptr, "glGetBooleani_v");
+ glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load(userptr, "glGetFragDataLocation");
+ glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load(userptr, "glGetFramebufferAttachmentParameteriv");
+ glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
+ glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load(userptr, "glGetRenderbufferParameteriv");
+ glad_glGetStringi = (PFNGLGETSTRINGIPROC) load(userptr, "glGetStringi");
+ glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load(userptr, "glGetTexParameterIiv");
+ glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load(userptr, "glGetTexParameterIuiv");
+ glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load(userptr, "glGetTransformFeedbackVarying");
+ glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load(userptr, "glGetUniformuiv");
+ glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load(userptr, "glGetVertexAttribIiv");
+ glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load(userptr, "glGetVertexAttribIuiv");
+ glad_glIsEnabledi = (PFNGLISENABLEDIPROC) load(userptr, "glIsEnabledi");
+ glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load(userptr, "glIsFramebuffer");
+ glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load(userptr, "glIsRenderbuffer");
+ glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load(userptr, "glIsVertexArray");
+ glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load(userptr, "glMapBufferRange");
+ glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load(userptr, "glRenderbufferStorage");
+ glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load(userptr, "glRenderbufferStorageMultisample");
+ glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load(userptr, "glTexParameterIiv");
+ glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load(userptr, "glTexParameterIuiv");
+ glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load(userptr, "glTransformFeedbackVaryings");
+ glad_glUniform1ui = (PFNGLUNIFORM1UIPROC) load(userptr, "glUniform1ui");
+ glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load(userptr, "glUniform1uiv");
+ glad_glUniform2ui = (PFNGLUNIFORM2UIPROC) load(userptr, "glUniform2ui");
+ glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load(userptr, "glUniform2uiv");
+ glad_glUniform3ui = (PFNGLUNIFORM3UIPROC) load(userptr, "glUniform3ui");
+ glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load(userptr, "glUniform3uiv");
+ glad_glUniform4ui = (PFNGLUNIFORM4UIPROC) load(userptr, "glUniform4ui");
+ glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load(userptr, "glUniform4uiv");
+ glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load(userptr, "glVertexAttribI1i");
+ glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load(userptr, "glVertexAttribI1iv");
+ glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load(userptr, "glVertexAttribI1ui");
+ glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load(userptr, "glVertexAttribI1uiv");
+ glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load(userptr, "glVertexAttribI2i");
+ glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load(userptr, "glVertexAttribI2iv");
+ glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load(userptr, "glVertexAttribI2ui");
+ glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load(userptr, "glVertexAttribI2uiv");
+ glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load(userptr, "glVertexAttribI3i");
+ glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load(userptr, "glVertexAttribI3iv");
+ glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load(userptr, "glVertexAttribI3ui");
+ glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load(userptr, "glVertexAttribI3uiv");
+ glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load(userptr, "glVertexAttribI4bv");
+ glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load(userptr, "glVertexAttribI4i");
+ glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load(userptr, "glVertexAttribI4iv");
+ glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load(userptr, "glVertexAttribI4sv");
+ glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load(userptr, "glVertexAttribI4ubv");
+ glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load(userptr, "glVertexAttribI4ui");
+ glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load(userptr, "glVertexAttribI4uiv");
+ glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load(userptr, "glVertexAttribI4usv");
+ glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load(userptr, "glVertexAttribIPointer");
+}
+static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_3_1) return;
+ glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load(userptr, "glBindBufferBase");
+ glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load(userptr, "glBindBufferRange");
+ glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load(userptr, "glCopyBufferSubData");
+ glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load(userptr, "glDrawArraysInstanced");
+ glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load(userptr, "glDrawElementsInstanced");
+ glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load(userptr, "glGetActiveUniformBlockName");
+ glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load(userptr, "glGetActiveUniformBlockiv");
+ glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load(userptr, "glGetActiveUniformName");
+ glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load(userptr, "glGetActiveUniformsiv");
+ glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load(userptr, "glGetIntegeri_v");
+ glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load(userptr, "glGetUniformBlockIndex");
+ glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load(userptr, "glGetUniformIndices");
+ glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load(userptr, "glPrimitiveRestartIndex");
+ glad_glTexBuffer = (PFNGLTEXBUFFERPROC) load(userptr, "glTexBuffer");
+ glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load(userptr, "glUniformBlockBinding");
+}
+static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_3_2) return;
+ glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load(userptr, "glClientWaitSync");
+ glad_glDeleteSync = (PFNGLDELETESYNCPROC) load(userptr, "glDeleteSync");
+ glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glDrawElementsBaseVertex");
+ glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load(userptr, "glDrawElementsInstancedBaseVertex");
+ glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load(userptr, "glDrawRangeElementsBaseVertex");
+ glad_glFenceSync = (PFNGLFENCESYNCPROC) load(userptr, "glFenceSync");
+ glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load(userptr, "glFramebufferTexture");
+ glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load(userptr, "glGetBufferParameteri64v");
+ glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load(userptr, "glGetInteger64i_v");
+ glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC) load(userptr, "glGetInteger64v");
+ glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load(userptr, "glGetMultisamplefv");
+ glad_glGetSynciv = (PFNGLGETSYNCIVPROC) load(userptr, "glGetSynciv");
+ glad_glIsSync = (PFNGLISSYNCPROC) load(userptr, "glIsSync");
+ glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load(userptr, "glMultiDrawElementsBaseVertex");
+ glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load(userptr, "glProvokingVertex");
+ glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC) load(userptr, "glSampleMaski");
+ glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load(userptr, "glTexImage2DMultisample");
+ glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load(userptr, "glTexImage3DMultisample");
+ glad_glWaitSync = (PFNGLWAITSYNCPROC) load(userptr, "glWaitSync");
+}
+static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) {
+ if(!GLAD_GL_VERSION_3_3) return;
+ glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load(userptr, "glBindFragDataLocationIndexed");
+ glad_glBindSampler = (PFNGLBINDSAMPLERPROC) load(userptr, "glBindSampler");
+ glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load(userptr, "glDeleteSamplers");
+ glad_glGenSamplers = (PFNGLGENSAMPLERSPROC) load(userptr, "glGenSamplers");
+ glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load(userptr, "glGetFragDataIndex");
+ glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load(userptr, "glGetQueryObjecti64v");
+ glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load(userptr, "glGetQueryObjectui64v");
+ glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load(userptr, "glGetSamplerParameterIiv");
+ glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load(userptr, "glGetSamplerParameterIuiv");
+ glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load(userptr, "glGetSamplerParameterfv");
+ glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load(userptr, "glGetSamplerParameteriv");
+ glad_glIsSampler = (PFNGLISSAMPLERPROC) load(userptr, "glIsSampler");
+ glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC) load(userptr, "glQueryCounter");
+ glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load(userptr, "glSamplerParameterIiv");
+ glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load(userptr, "glSamplerParameterIuiv");
+ glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load(userptr, "glSamplerParameterf");
+ glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load(userptr, "glSamplerParameterfv");
+ glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load(userptr, "glSamplerParameteri");
+ glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load(userptr, "glSamplerParameteriv");
+ glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load(userptr, "glVertexAttribDivisor");
+ glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load(userptr, "glVertexAttribP1ui");
+ glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load(userptr, "glVertexAttribP1uiv");
+ glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load(userptr, "glVertexAttribP2ui");
+ glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load(userptr, "glVertexAttribP2uiv");
+ glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load(userptr, "glVertexAttribP3ui");
+ glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load(userptr, "glVertexAttribP3uiv");
+ glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load(userptr, "glVertexAttribP4ui");
+ glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load(userptr, "glVertexAttribP4uiv");
+}
+
+
+
+#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
+#define GLAD_GL_IS_SOME_NEW_VERSION 1
+#else
+#define GLAD_GL_IS_SOME_NEW_VERSION 0
+#endif
+
+static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
+#if GLAD_GL_IS_SOME_NEW_VERSION
+ if(GLAD_VERSION_MAJOR(version) < 3) {
+#else
+ (void) version;
+ (void) out_num_exts_i;
+ (void) out_exts_i;
+#endif
+ if (glad_glGetString == NULL) {
+ return 0;
+ }
+ *out_exts = (const char *)glad_glGetString(GL_EXTENSIONS);
+#if GLAD_GL_IS_SOME_NEW_VERSION
+ } else {
+ unsigned int index = 0;
+ unsigned int num_exts_i = 0;
+ char **exts_i = NULL;
+ if (glad_glGetStringi == NULL || glad_glGetIntegerv == NULL) {
+ return 0;
+ }
+ glad_glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
+ if (num_exts_i > 0) {
+ exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
+ }
+ if (exts_i == NULL) {
+ return 0;
+ }
+ for(index = 0; index < num_exts_i; index++) {
+ const char *gl_str_tmp = (const char*) glad_glGetStringi(GL_EXTENSIONS, index);
+ size_t len = strlen(gl_str_tmp) + 1;
+
+ char *local_str = (char*) malloc(len * sizeof(char));
+ if(local_str != NULL) {
+ memcpy(local_str, gl_str_tmp, len * sizeof(char));
+ }
+
+ exts_i[index] = local_str;
+ }
+
+ *out_num_exts_i = num_exts_i;
+ *out_exts_i = exts_i;
+ }
+#endif
+ return 1;
+}
+static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
+ if (exts_i != NULL) {
+ unsigned int index;
+ for(index = 0; index < num_exts_i; index++) {
+ free((void *) (exts_i[index]));
+ }
+ free((void *)exts_i);
+ exts_i = NULL;
+ }
+}
+static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
+ if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
+ const char *extensions;
+ const char *loc;
+ const char *terminator;
+ extensions = exts;
+ if(extensions == NULL || ext == NULL) {
+ return 0;
+ }
+ while(1) {
+ loc = strstr(extensions, ext);
+ if(loc == NULL) {
+ return 0;
+ }
+ terminator = loc + strlen(ext);
+ if((loc == extensions || *(loc - 1) == ' ') &&
+ (*terminator == ' ' || *terminator == '\0')) {
+ return 1;
+ }
+ extensions = terminator;
+ }
+ } else {
+ unsigned int index;
+ for(index = 0; index < num_exts_i; index++) {
+ const char *e = exts_i[index];
+ if(strcmp(e, ext) == 0) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
+ return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
+}
+
+static int glad_gl_find_extensions_gl( int version) {
+ const char *exts = NULL;
+ unsigned int num_exts_i = 0;
+ char **exts_i = NULL;
+ if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
+
+ (void) glad_gl_has_extension;
+
+ glad_gl_free_extensions(exts_i, num_exts_i);
+
+ return 1;
+}
+
+static int glad_gl_find_core_gl(void) {
+ int i, major, minor;
+ const char* version;
+ const char* prefixes[] = {
+ "OpenGL ES-CM ",
+ "OpenGL ES-CL ",
+ "OpenGL ES ",
+ NULL
+ };
+ version = (const char*) glad_glGetString(GL_VERSION);
+ if (!version) return 0;
+ for (i = 0; prefixes[i]; i++) {
+ const size_t length = strlen(prefixes[i]);
+ if (strncmp(version, prefixes[i], length) == 0) {
+ version += length;
+ break;
+ }
+ }
+
+ GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
+
+ GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
+ GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
+ GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
+ GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
+ GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
+ GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
+ GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
+ GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
+ GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
+ GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
+ GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
+ GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
+
+ return GLAD_MAKE_VERSION(major, minor);
+}
+
+int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
+ int version;
+
+ glad_glGetString = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
+ if(glad_glGetString == NULL) return 0;
+ if(glad_glGetString(GL_VERSION) == NULL) return 0;
+ version = glad_gl_find_core_gl();
+
+ glad_gl_load_GL_VERSION_1_0(load, userptr);
+ glad_gl_load_GL_VERSION_1_1(load, userptr);
+ glad_gl_load_GL_VERSION_1_2(load, userptr);
+ glad_gl_load_GL_VERSION_1_3(load, userptr);
+ glad_gl_load_GL_VERSION_1_4(load, userptr);
+ glad_gl_load_GL_VERSION_1_5(load, userptr);
+ glad_gl_load_GL_VERSION_2_0(load, userptr);
+ glad_gl_load_GL_VERSION_2_1(load, userptr);
+ glad_gl_load_GL_VERSION_3_0(load, userptr);
+ glad_gl_load_GL_VERSION_3_1(load, userptr);
+ glad_gl_load_GL_VERSION_3_2(load, userptr);
+ glad_gl_load_GL_VERSION_3_3(load, userptr);
+
+ if (!glad_gl_find_extensions_gl(version)) return 0;
+
+
+
+ return version;
+}
+
+
+int gladLoadGL( GLADloadfunc load) {
+ return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
+}
+
+
+
+
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt b/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt
new file mode 100644
index 0000000..f95070e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt
@@ -0,0 +1,92 @@
+find_package(Threads REQUIRED)
+
+# Establish target libraries and include directories
+if (APPLE)
+
+ list(APPEND glfw_LIBRARIES
+ "-framework Cocoa"
+ "-framework IOKit"
+ "-framework CoreFoundation"
+ "-framework CoreVideo")
+
+elseif (UNIX)
+ find_library(RT_LIBRARY rt)
+ if (RT_LIBRARY)
+ list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
+ endif()
+
+ find_library(MATH_LIBRARY m)
+ if (MATH_LIBRARY)
+ list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}")
+ endif()
+
+ if (CMAKE_DL_LIBS)
+ list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
+ endif()
+
+ find_package(X11 REQUIRED)
+
+ # Set up library and include paths
+ list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
+ list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
+
+ # Check for XRandR (modern resolution switching and gamma control)
+ if (NOT X11_Xrandr_FOUND)
+ message(FATAL_ERROR "The RandR headers were not found")
+ endif()
+
+ # Check for Xinerama (legacy multi-monitor support)
+ if (NOT X11_Xinerama_FOUND)
+ message(FATAL_ERROR "The Xinerama headers were not found")
+ endif()
+
+ # Check for Xkb (X keyboard extension)
+ if (NOT X11_Xkb_FOUND)
+ message(FATAL_ERROR "The X keyboard extension headers were not found")
+ endif()
+
+ # Check for Xcursor (cursor creation from RGBA images)
+ if (NOT X11_Xcursor_FOUND)
+ message(FATAL_ERROR "The Xcursor headers were not found")
+ endif()
+
+ list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
+ "${X11_Xinerama_INCLUDE_PATH}"
+ "${X11_Xkb_INCLUDE_PATH}"
+ "${X11_Xcursor_INCLUDE_PATH}")
+endif()
+
+set(common_HEADERS src/internal.h src/mappings.h
+ include/GLFW/glfw3.h
+ include/GLFW/glfw3native.h)
+set(common_SOURCES src/context.c src/init.c src/input.c src/monitor.c src/vulkan.c src/window.c)
+
+if (APPLE)
+ set(glfw_HEADERS ${common_HEADERS} src/cocoa_platform.h src/cocoa_joystick.h
+ src/posix_thread.h src/nsgl_context.h src/egl_context.h src/osmesa_context.h)
+ set(glfw_SOURCES ${common_SOURCES} src/cocoa_init.m src/cocoa_joystick.m
+ src/cocoa_monitor.m src/cocoa_window.m src/cocoa_time.c src/posix_thread.c
+ src/nsgl_context.m src/egl_context.c src/osmesa_context.c)
+ set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
+elseif (WIN32)
+ set(glfw_HEADERS ${common_HEADERS} src/win32_platform.h src/win32_joystick.h
+ src/wgl_context.h src/egl_context.h src/osmesa_context.h)
+ set(glfw_SOURCES ${common_SOURCES} src/win32_init.c src/win32_joystick.c
+ src/win32_monitor.c src/win32_time.c src/win32_thread.c src/win32_window.c
+ src/wgl_context.c src/egl_context.c src/osmesa_context.c)
+elseif (UNIX)
+ set(glfw_HEADERS ${common_HEADERS} src/x11_platform.h src/xkb_unicode.h src/posix_time.h
+ src/posix_thread.h src/glx_context.h src/egl_context.h src/osmesa_context.h)
+ set(glfw_SOURCES ${common_SOURCES} src/x11_init.c src/x11_monitor.c src/x11_window.c
+ src/xkb_unicode.c src/posix_time.c src/posix_thread.c src/glx_context.c
+ src/egl_context.c src/osmesa_context.c)
+ set(glfw_HEADERS ${glfw_HEADERS} src/linux_joystick.h)
+ set(glfw_SOURCES ${glfw_SOURCES} src/linux_joystick.c)
+endif()
+
+add_library(glfw STATIC ${glfw_SOURCES} ${glfw_HEADERS})
+target_include_directories(glfw PUBLIC include)
+target_include_directories(glfw PRIVATE ${glfw_INCLUDE_DIRS})
+target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${glfw_SOURCES} ${glfw_HEADERS})
diff --git a/Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3.h b/Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3.h
new file mode 100644
index 0000000..099cd8e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3.h
@@ -0,0 +1,5556 @@
+/*************************************************************************
+ * GLFW 3.3 - www.glfw.org
+ * A library for OpenGL, window and input
+ *------------------------------------------------------------------------
+ * Copyright (c) 2002-2006 Marcus Geelnard
+ * Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would
+ * be appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not
+ * be misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ *
+ *************************************************************************/
+
+#ifndef _glfw3_h_
+#define _glfw3_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*************************************************************************
+ * Doxygen documentation
+ *************************************************************************/
+
+/*! @file glfw3.h
+ * @brief The header of the GLFW 3 API.
+ *
+ * This is the header file of the GLFW 3 API. It defines all its types and
+ * declares all its functions.
+ *
+ * For more information about how to use this file, see @ref build_include.
+ */
+/*! @defgroup context Context reference
+ * @brief Functions and types related to OpenGL and OpenGL ES contexts.
+ *
+ * This is the reference documentation for OpenGL and OpenGL ES context related
+ * functions. For more task-oriented information, see the @ref context_guide.
+ */
+/*! @defgroup vulkan Vulkan reference
+ * @brief Functions and types related to Vulkan.
+ *
+ * This is the reference documentation for Vulkan related functions and types.
+ * For more task-oriented information, see the @ref vulkan_guide.
+ */
+/*! @defgroup init Initialization, version and error reference
+ * @brief Functions and types related to initialization and error handling.
+ *
+ * This is the reference documentation for initialization and termination of
+ * the library, version management and error handling. For more task-oriented
+ * information, see the @ref intro_guide.
+ */
+/*! @defgroup input Input reference
+ * @brief Functions and types related to input handling.
+ *
+ * This is the reference documentation for input related functions and types.
+ * For more task-oriented information, see the @ref input_guide.
+ */
+/*! @defgroup monitor Monitor reference
+ * @brief Functions and types related to monitors.
+ *
+ * This is the reference documentation for monitor related functions and types.
+ * For more task-oriented information, see the @ref monitor_guide.
+ */
+/*! @defgroup window Window reference
+ * @brief Functions and types related to windows.
+ *
+ * This is the reference documentation for window related functions and types,
+ * including creation, deletion and event polling. For more task-oriented
+ * information, see the @ref window_guide.
+ */
+
+
+/*************************************************************************
+ * Compiler- and platform-specific preprocessor work
+ *************************************************************************/
+
+/* If we are we on Windows, we want a single define for it.
+ */
+#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
+ #define _WIN32
+#endif /* _WIN32 */
+
+/* It is customary to use APIENTRY for OpenGL function pointer declarations on
+ * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
+ */
+#ifndef APIENTRY
+ #ifdef _WIN32
+ #define APIENTRY __stdcall
+ #else
+ #define APIENTRY
+ #endif
+ #define GLFW_APIENTRY_DEFINED
+#endif /* APIENTRY */
+
+/* Some Windows OpenGL headers need this.
+ */
+#if !defined(WINGDIAPI) && defined(_WIN32)
+ #define WINGDIAPI __declspec(dllimport)
+ #define GLFW_WINGDIAPI_DEFINED
+#endif /* WINGDIAPI */
+
+/* Some Windows GLU headers need this.
+ */
+#if !defined(CALLBACK) && defined(_WIN32)
+ #define CALLBACK __stdcall
+ #define GLFW_CALLBACK_DEFINED
+#endif /* CALLBACK */
+
+/* Include because most Windows GLU headers need wchar_t and
+ * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
+ * Include it unconditionally to avoid surprising side-effects.
+ */
+#include <stddef.h>
+
+/* Include because it is needed by Vulkan and related functions.
+ * Include it unconditionally to avoid surprising side-effects.
+ */
+#include <stdint.h>
+
+/* Include the chosen OpenGL or OpenGL ES headers.
+ */
+#if defined(GLFW_INCLUDE_ES1)
+
+ #include <GLES/gl.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GLES/glext.h>
+ #endif
+
+#elif defined(GLFW_INCLUDE_ES2)
+
+ #include <GLES2/gl2.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GLES2/gl2ext.h>
+ #endif
+
+#elif defined(GLFW_INCLUDE_ES3)
+
+ #include <GLES3/gl3.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GLES2/gl2ext.h>
+ #endif
+
+#elif defined(GLFW_INCLUDE_ES31)
+
+ #include <GLES3/gl31.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GLES2/gl2ext.h>
+ #endif
+
+#elif defined(GLFW_INCLUDE_ES32)
+
+ #include <GLES3/gl32.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GLES2/gl2ext.h>
+ #endif
+
+#elif defined(GLFW_INCLUDE_GLCOREARB)
+
+ #if defined(__APPLE__)
+
+ #include <OpenGL/gl3.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <OpenGL/gl3ext.h>
+ #endif /*GLFW_INCLUDE_GLEXT*/
+
+ #else /*__APPLE__*/
+
+ #include <GL/glcorearb.h>
+
+ #endif /*__APPLE__*/
+
+#elif !defined(GLFW_INCLUDE_NONE)
+
+ #if defined(__APPLE__)
+
+ #if !defined(GLFW_INCLUDE_GLEXT)
+ #define GL_GLEXT_LEGACY
+ #endif
+ #include <OpenGL/gl.h>
+ #if defined(GLFW_INCLUDE_GLU)
+ #include <OpenGL/glu.h>
+ #endif
+
+ #else /*__APPLE__*/
+
+ #include <GL/gl.h>
+ #if defined(GLFW_INCLUDE_GLEXT)
+ #include <GL/glext.h>
+ #endif
+ #if defined(GLFW_INCLUDE_GLU)
+ #include <GL/glu.h>
+ #endif
+
+ #endif /*__APPLE__*/
+
+#endif /* OpenGL and OpenGL ES headers */
+
+#if defined(GLFW_INCLUDE_VULKAN)
+ #include <vulkan/vulkan.h>
+#endif /* Vulkan header */
+
+#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
+ /* GLFW_DLL must be defined by applications that are linking against the DLL
+ * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
+ * configuration header when compiling the DLL version of the library.
+ */
+ #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
+#endif
+
+/* GLFWAPI is used to declare public API functions for export
+ * from the DLL / shared library / dynamic library.
+ */
+#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
+ /* We are building GLFW as a Win32 DLL */
+ #define GLFWAPI __declspec(dllexport)
+#elif defined(_WIN32) && defined(GLFW_DLL)
+ /* We are calling GLFW as a Win32 DLL */
+ #define GLFWAPI __declspec(dllimport)
+#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
+ /* We are building GLFW as a shared / dynamic library */
+ #define GLFWAPI __attribute__((visibility("default")))
+#else
+ /* We are building or calling GLFW as a static library */
+ #define GLFWAPI
+#endif
+
+
+/*************************************************************************
+ * GLFW API tokens
+ *************************************************************************/
+
+/*! @name GLFW version macros
+ * @{ */
+/*! @brief The major version number of the GLFW library.
+ *
+ * This is incremented when the API is changed in non-compatible ways.
+ * @ingroup init
+ */
+#define GLFW_VERSION_MAJOR 3
+/*! @brief The minor version number of the GLFW library.
+ *
+ * This is incremented when features are added to the API but it remains
+ * backward-compatible.
+ * @ingroup init
+ */
+#define GLFW_VERSION_MINOR 3
+/*! @brief The revision number of the GLFW library.
+ *
+ * This is incremented when a bug fix release is made that does not contain any
+ * API changes.
+ * @ingroup init
+ */
+#define GLFW_VERSION_REVISION 0
+/*! @} */
+
+/*! @brief One.
+ *
+ * This is only semantic sugar for the number 1. You can instead use `1` or
+ * `true` or `_True` or `GL_TRUE` or anything else that is equal to one.
+ *
+ * @ingroup init
+ */
+#define GLFW_TRUE 1
+/*! @brief Zero.
+ *
+ * This is only semantic sugar for the number 0. You can instead use `0` or
+ * `false` or `_False` or `GL_FALSE` or anything else that is equal to zero.
+ *
+ * @ingroup init
+ */
+#define GLFW_FALSE 0
+
+/*! @name Key and button actions
+ * @{ */
+/*! @brief The key or mouse button was released.
+ *
+ * The key or mouse button was released.
+ *
+ * @ingroup input
+ */
+#define GLFW_RELEASE 0
+/*! @brief The key or mouse button was pressed.
+ *
+ * The key or mouse button was pressed.
+ *
+ * @ingroup input
+ */
+#define GLFW_PRESS 1
+/*! @brief The key was held down until it repeated.
+ *
+ * The key was held down until it repeated.
+ *
+ * @ingroup input
+ */
+#define GLFW_REPEAT 2
+/*! @} */
+
+/*! @defgroup hat_state Joystick hat states
+ * @brief Joystick hat states.
+ *
+ * See [joystick hat input](@ref joystick_hat) for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+#define GLFW_HAT_CENTERED 0
+#define GLFW_HAT_UP 1
+#define GLFW_HAT_RIGHT 2
+#define GLFW_HAT_DOWN 4
+#define GLFW_HAT_LEFT 8
+#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
+#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
+#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
+#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
+/*! @} */
+
+/*! @defgroup keys Keyboard keys
+ * @brief Keyboard key IDs.
+ *
+ * See [key input](@ref input_key) for how these are used.
+ *
+ * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
+ * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
+ * put in the 256+ range).
+ *
+ * The naming of the key codes follow these rules:
+ * - The US keyboard layout is used
+ * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
+ * "3", etc.)
+ * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
+ * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
+ * correspond to the Unicode standard (usually for brevity)
+ * - Keys that lack a clear US mapping are named "WORLD_x"
+ * - For non-printable keys, custom names are used (e.g. "F4",
+ * "BACKSPACE", etc.)
+ *
+ * @ingroup input
+ * @{
+ */
+
+/* The unknown key */
+#define GLFW_KEY_UNKNOWN -1
+
+/* Printable keys */
+#define GLFW_KEY_SPACE 32
+#define GLFW_KEY_APOSTROPHE 39 /* ' */
+#define GLFW_KEY_COMMA 44 /* , */
+#define GLFW_KEY_MINUS 45 /* - */
+#define GLFW_KEY_PERIOD 46 /* . */
+#define GLFW_KEY_SLASH 47 /* / */
+#define GLFW_KEY_0 48
+#define GLFW_KEY_1 49
+#define GLFW_KEY_2 50
+#define GLFW_KEY_3 51
+#define GLFW_KEY_4 52
+#define GLFW_KEY_5 53
+#define GLFW_KEY_6 54
+#define GLFW_KEY_7 55
+#define GLFW_KEY_8 56
+#define GLFW_KEY_9 57
+#define GLFW_KEY_SEMICOLON 59 /* ; */
+#define GLFW_KEY_EQUAL 61 /* = */
+#define GLFW_KEY_A 65
+#define GLFW_KEY_B 66
+#define GLFW_KEY_C 67
+#define GLFW_KEY_D 68
+#define GLFW_KEY_E 69
+#define GLFW_KEY_F 70
+#define GLFW_KEY_G 71
+#define GLFW_KEY_H 72
+#define GLFW_KEY_I 73
+#define GLFW_KEY_J 74
+#define GLFW_KEY_K 75
+#define GLFW_KEY_L 76
+#define GLFW_KEY_M 77
+#define GLFW_KEY_N 78
+#define GLFW_KEY_O 79
+#define GLFW_KEY_P 80
+#define GLFW_KEY_Q 81
+#define GLFW_KEY_R 82
+#define GLFW_KEY_S 83
+#define GLFW_KEY_T 84
+#define GLFW_KEY_U 85
+#define GLFW_KEY_V 86
+#define GLFW_KEY_W 87
+#define GLFW_KEY_X 88
+#define GLFW_KEY_Y 89
+#define GLFW_KEY_Z 90
+#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
+#define GLFW_KEY_BACKSLASH 92 /* \ */
+#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
+#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
+#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
+#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
+
+/* Function keys */
+#define GLFW_KEY_ESCAPE 256
+#define GLFW_KEY_ENTER 257
+#define GLFW_KEY_TAB 258
+#define GLFW_KEY_BACKSPACE 259
+#define GLFW_KEY_INSERT 260
+#define GLFW_KEY_DELETE 261
+#define GLFW_KEY_RIGHT 262
+#define GLFW_KEY_LEFT 263
+#define GLFW_KEY_DOWN 264
+#define GLFW_KEY_UP 265
+#define GLFW_KEY_PAGE_UP 266
+#define GLFW_KEY_PAGE_DOWN 267
+#define GLFW_KEY_HOME 268
+#define GLFW_KEY_END 269
+#define GLFW_KEY_CAPS_LOCK 280
+#define GLFW_KEY_SCROLL_LOCK 281
+#define GLFW_KEY_NUM_LOCK 282
+#define GLFW_KEY_PRINT_SCREEN 283
+#define GLFW_KEY_PAUSE 284
+#define GLFW_KEY_F1 290
+#define GLFW_KEY_F2 291
+#define GLFW_KEY_F3 292
+#define GLFW_KEY_F4 293
+#define GLFW_KEY_F5 294
+#define GLFW_KEY_F6 295
+#define GLFW_KEY_F7 296
+#define GLFW_KEY_F8 297
+#define GLFW_KEY_F9 298
+#define GLFW_KEY_F10 299
+#define GLFW_KEY_F11 300
+#define GLFW_KEY_F12 301
+#define GLFW_KEY_F13 302
+#define GLFW_KEY_F14 303
+#define GLFW_KEY_F15 304
+#define GLFW_KEY_F16 305
+#define GLFW_KEY_F17 306
+#define GLFW_KEY_F18 307
+#define GLFW_KEY_F19 308
+#define GLFW_KEY_F20 309
+#define GLFW_KEY_F21 310
+#define GLFW_KEY_F22 311
+#define GLFW_KEY_F23 312
+#define GLFW_KEY_F24 313
+#define GLFW_KEY_F25 314
+#define GLFW_KEY_KP_0 320
+#define GLFW_KEY_KP_1 321
+#define GLFW_KEY_KP_2 322
+#define GLFW_KEY_KP_3 323
+#define GLFW_KEY_KP_4 324
+#define GLFW_KEY_KP_5 325
+#define GLFW_KEY_KP_6 326
+#define GLFW_KEY_KP_7 327
+#define GLFW_KEY_KP_8 328
+#define GLFW_KEY_KP_9 329
+#define GLFW_KEY_KP_DECIMAL 330
+#define GLFW_KEY_KP_DIVIDE 331
+#define GLFW_KEY_KP_MULTIPLY 332
+#define GLFW_KEY_KP_SUBTRACT 333
+#define GLFW_KEY_KP_ADD 334
+#define GLFW_KEY_KP_ENTER 335
+#define GLFW_KEY_KP_EQUAL 336
+#define GLFW_KEY_LEFT_SHIFT 340
+#define GLFW_KEY_LEFT_CONTROL 341
+#define GLFW_KEY_LEFT_ALT 342
+#define GLFW_KEY_LEFT_SUPER 343
+#define GLFW_KEY_RIGHT_SHIFT 344
+#define GLFW_KEY_RIGHT_CONTROL 345
+#define GLFW_KEY_RIGHT_ALT 346
+#define GLFW_KEY_RIGHT_SUPER 347
+#define GLFW_KEY_MENU 348
+
+#define GLFW_KEY_LAST GLFW_KEY_MENU
+
+/*! @} */
+
+/*! @defgroup mods Modifier key flags
+ * @brief Modifier key flags.
+ *
+ * See [key input](@ref input_key) for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+
+/*! @brief If this bit is set one or more Shift keys were held down.
+ *
+ * If this bit is set one or more Shift keys were held down.
+ */
+#define GLFW_MOD_SHIFT 0x0001
+/*! @brief If this bit is set one or more Control keys were held down.
+ *
+ * If this bit is set one or more Control keys were held down.
+ */
+#define GLFW_MOD_CONTROL 0x0002
+/*! @brief If this bit is set one or more Alt keys were held down.
+ *
+ * If this bit is set one or more Alt keys were held down.
+ */
+#define GLFW_MOD_ALT 0x0004
+/*! @brief If this bit is set one or more Super keys were held down.
+ *
+ * If this bit is set one or more Super keys were held down.
+ */
+#define GLFW_MOD_SUPER 0x0008
+/*! @brief If this bit is set the Caps Lock key is enabled.
+ *
+ * If this bit is set the Caps Lock key is enabled and the @ref
+ * GLFW_LOCK_KEY_MODS input mode is set.
+ */
+#define GLFW_MOD_CAPS_LOCK 0x0010
+/*! @brief If this bit is set the Num Lock key is enabled.
+ *
+ * If this bit is set the Num Lock key is enabled and the @ref
+ * GLFW_LOCK_KEY_MODS input mode is set.
+ */
+#define GLFW_MOD_NUM_LOCK 0x0020
+
+/*! @} */
+
+/*! @defgroup buttons Mouse buttons
+ * @brief Mouse button IDs.
+ *
+ * See [mouse button input](@ref input_mouse_button) for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+#define GLFW_MOUSE_BUTTON_1 0
+#define GLFW_MOUSE_BUTTON_2 1
+#define GLFW_MOUSE_BUTTON_3 2
+#define GLFW_MOUSE_BUTTON_4 3
+#define GLFW_MOUSE_BUTTON_5 4
+#define GLFW_MOUSE_BUTTON_6 5
+#define GLFW_MOUSE_BUTTON_7 6
+#define GLFW_MOUSE_BUTTON_8 7
+#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
+#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
+#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
+#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
+/*! @} */
+
+/*! @defgroup joysticks Joysticks
+ * @brief Joystick IDs.
+ *
+ * See [joystick input](@ref joystick) for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+#define GLFW_JOYSTICK_1 0
+#define GLFW_JOYSTICK_2 1
+#define GLFW_JOYSTICK_3 2
+#define GLFW_JOYSTICK_4 3
+#define GLFW_JOYSTICK_5 4
+#define GLFW_JOYSTICK_6 5
+#define GLFW_JOYSTICK_7 6
+#define GLFW_JOYSTICK_8 7
+#define GLFW_JOYSTICK_9 8
+#define GLFW_JOYSTICK_10 9
+#define GLFW_JOYSTICK_11 10
+#define GLFW_JOYSTICK_12 11
+#define GLFW_JOYSTICK_13 12
+#define GLFW_JOYSTICK_14 13
+#define GLFW_JOYSTICK_15 14
+#define GLFW_JOYSTICK_16 15
+#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
+/*! @} */
+
+/*! @defgroup gamepad_buttons Gamepad buttons
+ * @brief Gamepad buttons.
+ *
+ * See @ref gamepad for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+#define GLFW_GAMEPAD_BUTTON_A 0
+#define GLFW_GAMEPAD_BUTTON_B 1
+#define GLFW_GAMEPAD_BUTTON_X 2
+#define GLFW_GAMEPAD_BUTTON_Y 3
+#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
+#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
+#define GLFW_GAMEPAD_BUTTON_BACK 6
+#define GLFW_GAMEPAD_BUTTON_START 7
+#define GLFW_GAMEPAD_BUTTON_GUIDE 8
+#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
+#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
+#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
+#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
+#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
+#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
+#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
+
+#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
+#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
+#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
+#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
+/*! @} */
+
+/*! @defgroup gamepad_axes Gamepad axes
+ * @brief Gamepad axes.
+ *
+ * See @ref gamepad for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+#define GLFW_GAMEPAD_AXIS_LEFT_X 0
+#define GLFW_GAMEPAD_AXIS_LEFT_Y 1
+#define GLFW_GAMEPAD_AXIS_RIGHT_X 2
+#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
+#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
+#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
+#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
+/*! @} */
+
+/*! @defgroup errors Error codes
+ * @brief Error codes.
+ *
+ * See [error handling](@ref error_handling) for how these are used.
+ *
+ * @ingroup init
+ * @{ */
+/*! @brief No error has occurred.
+ *
+ * No error has occurred.
+ *
+ * @analysis Yay.
+ */
+#define GLFW_NO_ERROR 0
+/*! @brief GLFW has not been initialized.
+ *
+ * This occurs if a GLFW function was called that must not be called unless the
+ * library is [initialized](@ref intro_init).
+ *
+ * @analysis Application programmer error. Initialize GLFW before calling any
+ * function that requires initialization.
+ */
+#define GLFW_NOT_INITIALIZED 0x00010001
+/*! @brief No context is current for this thread.
+ *
+ * This occurs if a GLFW function was called that needs and operates on the
+ * current OpenGL or OpenGL ES context but no context is current on the calling
+ * thread. One such function is @ref glfwSwapInterval.
+ *
+ * @analysis Application programmer error. Ensure a context is current before
+ * calling functions that require a current context.
+ */
+#define GLFW_NO_CURRENT_CONTEXT 0x00010002
+/*! @brief One of the arguments to the function was an invalid enum value.
+ *
+ * One of the arguments to the function was an invalid enum value, for example
+ * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
+ *
+ * @analysis Application programmer error. Fix the offending call.
+ */
+#define GLFW_INVALID_ENUM 0x00010003
+/*! @brief One of the arguments to the function was an invalid value.
+ *
+ * One of the arguments to the function was an invalid value, for example
+ * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
+ *
+ * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
+ * result in a @ref GLFW_VERSION_UNAVAILABLE error.
+ *
+ * @analysis Application programmer error. Fix the offending call.
+ */
+#define GLFW_INVALID_VALUE 0x00010004
+/*! @brief A memory allocation failed.
+ *
+ * A memory allocation failed.
+ *
+ * @analysis A bug in GLFW or the underlying operating system. Report the bug
+ * to our [issue tracker](https://github.com/glfw/glfw/issues).
+ */
+#define GLFW_OUT_OF_MEMORY 0x00010005
+/*! @brief GLFW could not find support for the requested API on the system.
+ *
+ * GLFW could not find support for the requested API on the system.
+ *
+ * @analysis The installed graphics driver does not support the requested
+ * API, or does not support it via the chosen context creation backend.
+ * Below are a few examples.
+ *
+ * @par
+ * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
+ * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
+ * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
+ * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
+ * driver. Older graphics drivers do not support Vulkan.
+ */
+#define GLFW_API_UNAVAILABLE 0x00010006
+/*! @brief The requested OpenGL or OpenGL ES version is not available.
+ *
+ * The requested OpenGL or OpenGL ES version (including any requested context
+ * or framebuffer hints) is not available on this machine.
+ *
+ * @analysis The machine does not support your requirements. If your
+ * application is sufficiently flexible, downgrade your requirements and try
+ * again. Otherwise, inform the user that their machine does not match your
+ * requirements.
+ *
+ * @par
+ * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
+ * comes out before the 4.x series gets that far, also fail with this error and
+ * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
+ * will exist.
+ */
+#define GLFW_VERSION_UNAVAILABLE 0x00010007
+/*! @brief A platform-specific error occurred that does not match any of the
+ * more specific categories.
+ *
+ * A platform-specific error occurred that does not match any of the more
+ * specific categories.
+ *
+ * @analysis A bug or configuration error in GLFW, the underlying operating
+ * system or its drivers, or a lack of required resources. Report the issue to
+ * our [issue tracker](https://github.com/glfw/glfw/issues).
+ */
+#define GLFW_PLATFORM_ERROR 0x00010008
+/*! @brief The requested format is not supported or available.
+ *
+ * If emitted during window creation, the requested pixel format is not
+ * supported.
+ *
+ * If emitted when querying the clipboard, the contents of the clipboard could
+ * not be converted to the requested format.
+ *
+ * @analysis If emitted during window creation, one or more
+ * [hard constraints](@ref window_hints_hard) did not match any of the
+ * available pixel formats. If your application is sufficiently flexible,
+ * downgrade your requirements and try again. Otherwise, inform the user that
+ * their machine does not match your requirements.
+ *
+ * @par
+ * If emitted when querying the clipboard, ignore the error or report it to
+ * the user, as appropriate.
+ */
+#define GLFW_FORMAT_UNAVAILABLE 0x00010009
+/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
+ *
+ * A window that does not have an OpenGL or OpenGL ES context was passed to
+ * a function that requires it to have one.
+ *
+ * @analysis Application programmer error. Fix the offending call.
+ */
+#define GLFW_NO_WINDOW_CONTEXT 0x0001000A
+/*! @} */
+
+/*! @addtogroup window
+ * @{ */
+/*! @brief Input focus window hint and attribute
+ *
+ * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
+ * [window attribute](@ref GLFW_FOCUSED_attrib).
+ */
+#define GLFW_FOCUSED 0x00020001
+/*! @brief Window iconification window attribute
+ *
+ * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
+ */
+#define GLFW_ICONIFIED 0x00020002
+/*! @brief Window resize-ability window hint and attribute
+ *
+ * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
+ * [window attribute](@ref GLFW_RESIZABLE_attrib).
+ */
+#define GLFW_RESIZABLE 0x00020003
+/*! @brief Window visibility window hint and attribute
+ *
+ * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
+ * [window attribute](@ref GLFW_VISIBLE_attrib).
+ */
+#define GLFW_VISIBLE 0x00020004
+/*! @brief Window decoration window hint and attribute
+ *
+ * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
+ * [window attribute](@ref GLFW_DECORATED_attrib).
+ */
+#define GLFW_DECORATED 0x00020005
+/*! @brief Window auto-iconification window hint and attribute
+ *
+ * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
+ * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
+ */
+#define GLFW_AUTO_ICONIFY 0x00020006
+/*! @brief Window decoration window hint and attribute
+ *
+ * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
+ * [window attribute](@ref GLFW_FLOATING_attrib).
+ */
+#define GLFW_FLOATING 0x00020007
+/*! @brief Window maximization window hint and attribute
+ *
+ * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
+ * [window attribute](@ref GLFW_MAXIMIZED_attrib).
+ */
+#define GLFW_MAXIMIZED 0x00020008
+/*! @brief Cursor centering window hint
+ *
+ * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
+ */
+#define GLFW_CENTER_CURSOR 0x00020009
+/*! @brief Window framebuffer transparency hint and attribute
+ *
+ * Window framebuffer transparency
+ * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
+ * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
+ */
+#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
+/*! @brief Mouse cursor hover window attribute.
+ *
+ * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
+ */
+#define GLFW_HOVERED 0x0002000B
+/*! @brief Input focus on calling show window hint and attribute
+ *
+ * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
+ * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
+ */
+#define GLFW_FOCUS_ON_SHOW 0x0002000C
+
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
+ */
+#define GLFW_RED_BITS 0x00021001
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
+ */
+#define GLFW_GREEN_BITS 0x00021002
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
+ */
+#define GLFW_BLUE_BITS 0x00021003
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
+ */
+#define GLFW_ALPHA_BITS 0x00021004
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
+ */
+#define GLFW_DEPTH_BITS 0x00021005
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
+ */
+#define GLFW_STENCIL_BITS 0x00021006
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
+ */
+#define GLFW_ACCUM_RED_BITS 0x00021007
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
+ */
+#define GLFW_ACCUM_GREEN_BITS 0x00021008
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
+ */
+#define GLFW_ACCUM_BLUE_BITS 0x00021009
+/*! @brief Framebuffer bit depth hint.
+ *
+ * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
+ */
+#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
+/*! @brief Framebuffer auxiliary buffer hint.
+ *
+ * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
+ */
+#define GLFW_AUX_BUFFERS 0x0002100B
+/*! @brief OpenGL stereoscopic rendering hint.
+ *
+ * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
+ */
+#define GLFW_STEREO 0x0002100C
+/*! @brief Framebuffer MSAA samples hint.
+ *
+ * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
+ */
+#define GLFW_SAMPLES 0x0002100D
+/*! @brief Framebuffer sRGB hint.
+ *
+ * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
+ */
+#define GLFW_SRGB_CAPABLE 0x0002100E
+/*! @brief Monitor refresh rate hint.
+ *
+ * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
+ */
+#define GLFW_REFRESH_RATE 0x0002100F
+/*! @brief Framebuffer double buffering hint.
+ *
+ * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
+ */
+#define GLFW_DOUBLEBUFFER 0x00021010
+
+/*! @brief Context client API hint and attribute.
+ *
+ * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CLIENT_API 0x00022001
+/*! @brief Context client API major version hint and attribute.
+ *
+ * Context client API major version [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
+/*! @brief Context client API minor version hint and attribute.
+ *
+ * Context client API minor version [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
+/*! @brief Context client API revision number hint and attribute.
+ *
+ * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_REVISION 0x00022004
+/*! @brief Context robustness hint and attribute.
+ *
+ * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_ROBUSTNESS 0x00022005
+/*! @brief OpenGL forward-compatibility hint and attribute.
+ *
+ * OpenGL forward-compatibility [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
+/*! @brief OpenGL debug context hint and attribute.
+ *
+ * OpenGL debug context [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
+/*! @brief OpenGL profile hint and attribute.
+ *
+ * OpenGL profile [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_OPENGL_PROFILE 0x00022008
+/*! @brief Context flush-on-release hint and attribute.
+ *
+ * Context flush-on-release [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
+/*! @brief Context error suppression hint and attribute.
+ *
+ * Context error suppression [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_NO_ERROR 0x0002200A
+/*! @brief Context creation API hint and attribute.
+ *
+ * Context creation API [hint](@ref GLFW_CLIENT_API_hint) and
+ * [attribute](@ref GLFW_CLIENT_API_attrib).
+ */
+#define GLFW_CONTEXT_CREATION_API 0x0002200B
+/*! @brief Window content area scaling window
+ * [window hint](@ref GLFW_SCALE_TO_MONITOR).
+ */
+#define GLFW_SCALE_TO_MONITOR 0x0002200C
+
+#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
+#define GLFW_COCOA_FRAME_NAME 0x00023002
+#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
+
+#define GLFW_X11_CLASS_NAME 0x00024001
+#define GLFW_X11_INSTANCE_NAME 0x00024002
+/*! @} */
+
+#define GLFW_NO_API 0
+#define GLFW_OPENGL_API 0x00030001
+#define GLFW_OPENGL_ES_API 0x00030002
+
+#define GLFW_NO_ROBUSTNESS 0
+#define GLFW_NO_RESET_NOTIFICATION 0x00031001
+#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
+
+#define GLFW_OPENGL_ANY_PROFILE 0
+#define GLFW_OPENGL_CORE_PROFILE 0x00032001
+#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
+
+#define GLFW_CURSOR 0x00033001
+#define GLFW_STICKY_KEYS 0x00033002
+#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
+#define GLFW_LOCK_KEY_MODS 0x00033004
+
+#define GLFW_CURSOR_NORMAL 0x00034001
+#define GLFW_CURSOR_HIDDEN 0x00034002
+#define GLFW_CURSOR_DISABLED 0x00034003
+
+#define GLFW_ANY_RELEASE_BEHAVIOR 0
+#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
+#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
+
+#define GLFW_NATIVE_CONTEXT_API 0x00036001
+#define GLFW_EGL_CONTEXT_API 0x00036002
+#define GLFW_OSMESA_CONTEXT_API 0x00036003
+
+/*! @defgroup shapes Standard cursor shapes
+ * @brief Standard system cursor shapes.
+ *
+ * See [standard cursor creation](@ref cursor_standard) for how these are used.
+ *
+ * @ingroup input
+ * @{ */
+
+/*! @brief The regular arrow cursor shape.
+ *
+ * The regular arrow cursor.
+ */
+#define GLFW_ARROW_CURSOR 0x00036001
+/*! @brief The text input I-beam cursor shape.
+ *
+ * The text input I-beam cursor shape.
+ */
+#define GLFW_IBEAM_CURSOR 0x00036002
+/*! @brief The crosshair shape.
+ *
+ * The crosshair shape.
+ */
+#define GLFW_CROSSHAIR_CURSOR 0x00036003
+/*! @brief The hand shape.
+ *
+ * The hand shape.
+ */
+#define GLFW_HAND_CURSOR 0x00036004
+/*! @brief The horizontal resize arrow shape.
+ *
+ * The horizontal resize arrow shape.
+ */
+#define GLFW_HRESIZE_CURSOR 0x00036005
+/*! @brief The vertical resize arrow shape.
+ *
+ * The vertical resize arrow shape.
+ */
+#define GLFW_VRESIZE_CURSOR 0x00036006
+/*! @} */
+
+#define GLFW_CONNECTED 0x00040001
+#define GLFW_DISCONNECTED 0x00040002
+
+/*! @addtogroup init
+ * @{ */
+/*! @brief Joystick hat buttons init hint.
+ *
+ * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS)
+ */
+#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
+/*! @brief macOS specific init hint.
+ *
+ * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES)
+ */
+#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
+/*! @brief macOS specific init hint.
+ *
+ * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR)
+ */
+#define GLFW_COCOA_MENUBAR 0x00051002
+/*! @} */
+
+#define GLFW_DONT_CARE -1
+
+
+/*************************************************************************
+ * GLFW API types
+ *************************************************************************/
+
+/*! @brief Client API function pointer type.
+ *
+ * Generic function pointer used for returning client API function pointers
+ * without forcing a cast from a regular pointer.
+ *
+ * @sa @ref context_glext
+ * @sa @ref glfwGetProcAddress
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup context
+ */
+typedef void (*GLFWglproc)(void);
+
+/*! @brief Vulkan API function pointer type.
+ *
+ * Generic function pointer used for returning Vulkan API function pointers
+ * without forcing a cast from a regular pointer.
+ *
+ * @sa @ref vulkan_proc
+ * @sa @ref glfwGetInstanceProcAddress
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup vulkan
+ */
+typedef void (*GLFWvkproc)(void);
+
+/*! @brief Opaque monitor object.
+ *
+ * Opaque monitor object.
+ *
+ * @see @ref monitor_object
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+typedef struct GLFWmonitor GLFWmonitor;
+
+/*! @brief Opaque window object.
+ *
+ * Opaque window object.
+ *
+ * @see @ref window_object
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+typedef struct GLFWwindow GLFWwindow;
+
+/*! @brief Opaque cursor object.
+ *
+ * Opaque cursor object.
+ *
+ * @see @ref cursor_object
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+typedef struct GLFWcursor GLFWcursor;
+
+/*! @brief The function signature for error callbacks.
+ *
+ * This is the function signature for error callback functions.
+ *
+ * @param[in] error An [error code](@ref errors).
+ * @param[in] description A UTF-8 encoded string describing the error.
+ *
+ * @sa @ref error_handling
+ * @sa @ref glfwSetErrorCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup init
+ */
+typedef void (* GLFWerrorfun)(int,const char*);
+
+/*! @brief The function signature for window position callbacks.
+ *
+ * This is the function signature for window position callback functions.
+ *
+ * @param[in] window The window that was moved.
+ * @param[in] xpos The new x-coordinate, in screen coordinates, of the
+ * upper-left corner of the client area of the window.
+ * @param[in] ypos The new y-coordinate, in screen coordinates, of the
+ * upper-left corner of the client area of the window.
+ *
+ * @sa @ref window_pos
+ * @sa @ref glfwSetWindowPosCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
+
+/*! @brief The function signature for window resize callbacks.
+ *
+ * This is the function signature for window size callback functions.
+ *
+ * @param[in] window The window that was resized.
+ * @param[in] width The new width, in screen coordinates, of the window.
+ * @param[in] height The new height, in screen coordinates, of the window.
+ *
+ * @sa @ref window_size
+ * @sa @ref glfwSetWindowSizeCallback
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
+
+/*! @brief The function signature for window close callbacks.
+ *
+ * This is the function signature for window close callback functions.
+ *
+ * @param[in] window The window that the user attempted to close.
+ *
+ * @sa @ref window_close
+ * @sa @ref glfwSetWindowCloseCallback
+ *
+ * @since Added in version 2.5.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowclosefun)(GLFWwindow*);
+
+/*! @brief The function signature for window content refresh callbacks.
+ *
+ * This is the function signature for window refresh callback functions.
+ *
+ * @param[in] window The window whose content needs to be refreshed.
+ *
+ * @sa @ref window_refresh
+ * @sa @ref glfwSetWindowRefreshCallback
+ *
+ * @since Added in version 2.5.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
+
+/*! @brief The function signature for window focus/defocus callbacks.
+ *
+ * This is the function signature for window focus callback functions.
+ *
+ * @param[in] window The window that gained or lost input focus.
+ * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
+ * `GLFW_FALSE` if it lost it.
+ *
+ * @sa @ref window_focus
+ * @sa @ref glfwSetWindowFocusCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
+
+/*! @brief The function signature for window iconify/restore callbacks.
+ *
+ * This is the function signature for window iconify/restore callback
+ * functions.
+ *
+ * @param[in] window The window that was iconified or restored.
+ * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
+ * `GLFW_FALSE` if it was restored.
+ *
+ * @sa @ref window_iconify
+ * @sa @ref glfwSetWindowIconifyCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
+
+/*! @brief The function signature for window maximize/restore callbacks.
+ *
+ * This is the function signature for window maximize/restore callback
+ * functions.
+ *
+ * @param[in] window The window that was maximized or restored.
+ * @param[in] iconified `GLFW_TRUE` if the window was maximized, or
+ * `GLFW_FALSE` if it was restored.
+ *
+ * @sa @ref window_maximize
+ * @sa glfwSetWindowMaximizeCallback
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
+
+/*! @brief The function signature for framebuffer resize callbacks.
+ *
+ * This is the function signature for framebuffer resize callback
+ * functions.
+ *
+ * @param[in] window The window whose framebuffer was resized.
+ * @param[in] width The new width, in pixels, of the framebuffer.
+ * @param[in] height The new height, in pixels, of the framebuffer.
+ *
+ * @sa @ref window_fbsize
+ * @sa @ref glfwSetFramebufferSizeCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
+
+/*! @brief The function signature for window content scale callbacks.
+ *
+ * This is the function signature for window content scale callback
+ * functions.
+ *
+ * @param[in] window The window whose content scale changed.
+ * @param[in] xscale The new x-axis content scale of the window.
+ * @param[in] yscale The new y-axis content scale of the window.
+ *
+ * @sa @ref window_scale
+ * @sa @ref glfwSetWindowContentScaleCallback
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
+
+/*! @brief The function signature for mouse button callbacks.
+ *
+ * This is the function signature for mouse button callback functions.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] button The [mouse button](@ref buttons) that was pressed or
+ * released.
+ * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
+ * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
+ * held down.
+ *
+ * @sa @ref input_mouse_button
+ * @sa @ref glfwSetMouseButtonCallback
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle and modifier mask parameters.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
+
+/*! @brief The function signature for cursor position callbacks.
+ *
+ * This is the function signature for cursor position callback functions.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
+ * the client area.
+ * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
+ * client area.
+ *
+ * @sa @ref cursor_pos
+ * @sa @ref glfwSetCursorPosCallback
+ *
+ * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
+
+/*! @brief The function signature for cursor enter/leave callbacks.
+ *
+ * This is the function signature for cursor enter/leave callback functions.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] entered `GLFW_TRUE` if the cursor entered the window's client
+ * area, or `GLFW_FALSE` if it left it.
+ *
+ * @sa @ref cursor_enter
+ * @sa @ref glfwSetCursorEnterCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
+
+/*! @brief The function signature for scroll callbacks.
+ *
+ * This is the function signature for scroll callback functions.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] xoffset The scroll offset along the x-axis.
+ * @param[in] yoffset The scroll offset along the y-axis.
+ *
+ * @sa @ref scrolling
+ * @sa @ref glfwSetScrollCallback
+ *
+ * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
+
+/*! @brief The function signature for keyboard key callbacks.
+ *
+ * This is the function signature for keyboard key callback functions.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
+ * @param[in] scancode The system-specific scancode of the key.
+ * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
+ * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
+ * held down.
+ *
+ * @sa @ref input_key
+ * @sa @ref glfwSetKeyCallback
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle, scancode and modifier mask parameters.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
+
+/*! @brief The function signature for Unicode character callbacks.
+ *
+ * This is the function signature for Unicode character callback functions.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] codepoint The Unicode code point of the character.
+ *
+ * @sa @ref input_char
+ * @sa @ref glfwSetCharCallback
+ *
+ * @since Added in version 2.4.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
+
+/*! @brief The function signature for Unicode character with modifiers
+ * callbacks.
+ *
+ * This is the function signature for Unicode character with modifiers callback
+ * functions. It is called for each input character, regardless of what
+ * modifier keys are held down.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] codepoint The Unicode code point of the character.
+ * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
+ * held down.
+ *
+ * @sa @ref input_char
+ * @sa @ref glfwSetCharModsCallback
+ *
+ * @deprecated Scheduled for removal in version 4.0.
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
+
+/*! @brief The function signature for file drop callbacks.
+ *
+ * This is the function signature for file drop callbacks.
+ *
+ * @param[in] window The window that received the event.
+ * @param[in] count The number of dropped files.
+ * @param[in] paths The UTF-8 encoded file and/or directory path names.
+ *
+ * @sa @ref path_drop
+ * @sa @ref glfwSetDropCallback
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
+
+/*! @brief The function signature for monitor configuration callbacks.
+ *
+ * This is the function signature for monitor configuration callback functions.
+ *
+ * @param[in] monitor The monitor that was connected or disconnected.
+ * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
+ * values reserved for future use.
+ *
+ * @sa @ref monitor_event
+ * @sa @ref glfwSetMonitorCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
+
+/*! @brief The function signature for joystick configuration callbacks.
+ *
+ * This is the function signature for joystick configuration callback
+ * functions.
+ *
+ * @param[in] jid The joystick that was connected or disconnected.
+ * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
+ * values reserved for future use.
+ *
+ * @sa @ref joystick_event
+ * @sa @ref glfwSetJoystickCallback
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup input
+ */
+typedef void (* GLFWjoystickfun)(int,int);
+
+/*! @brief Video mode type.
+ *
+ * This describes a single video mode.
+ *
+ * @sa @ref monitor_modes
+ * @sa @ref glfwGetVideoMode
+ * @sa @ref glfwGetVideoModes
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added refresh rate member.
+ *
+ * @ingroup monitor
+ */
+typedef struct GLFWvidmode
+{
+ /*! The width, in screen coordinates, of the video mode.
+ */
+ int width;
+ /*! The height, in screen coordinates, of the video mode.
+ */
+ int height;
+ /*! The bit depth of the red channel of the video mode.
+ */
+ int redBits;
+ /*! The bit depth of the green channel of the video mode.
+ */
+ int greenBits;
+ /*! The bit depth of the blue channel of the video mode.
+ */
+ int blueBits;
+ /*! The refresh rate, in Hz, of the video mode.
+ */
+ int refreshRate;
+} GLFWvidmode;
+
+/*! @brief Gamma ramp.
+ *
+ * This describes the gamma ramp for a monitor.
+ *
+ * @sa @ref monitor_gamma
+ * @sa @ref glfwGetGammaRamp
+ * @sa @ref glfwSetGammaRamp
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+typedef struct GLFWgammaramp
+{
+ /*! An array of value describing the response of the red channel.
+ */
+ unsigned short* red;
+ /*! An array of value describing the response of the green channel.
+ */
+ unsigned short* green;
+ /*! An array of value describing the response of the blue channel.
+ */
+ unsigned short* blue;
+ /*! The number of elements in each array.
+ */
+ unsigned int size;
+} GLFWgammaramp;
+
+/*! @brief Image data.
+ *
+ * This describes a single 2D image. See the documentation for each related
+ * function what the expected pixel format is.
+ *
+ * @sa @ref cursor_custom
+ * @sa @ref window_icon
+ *
+ * @since Added in version 2.1.
+ * @glfw3 Removed format and bytes-per-pixel members.
+ *
+ * @ingroup window
+ */
+typedef struct GLFWimage
+{
+ /*! The width, in pixels, of this image.
+ */
+ int width;
+ /*! The height, in pixels, of this image.
+ */
+ int height;
+ /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
+ */
+ unsigned char* pixels;
+} GLFWimage;
+
+/*! @brief Gamepad input state
+ *
+ * This describes the input state of a gamepad.
+ *
+ * @sa @ref gamepad
+ * @sa @ref glfwGetGamepadState
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+typedef struct GLFWgamepadstate
+{
+ /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
+ * or `GLFW_RELEASE`.
+ */
+ unsigned char buttons[15];
+ /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
+ * to 1.0 inclusive.
+ */
+ float axes[6];
+} GLFWgamepadstate;
+
+
+/*************************************************************************
+ * GLFW API functions
+ *************************************************************************/
+
+/*! @brief Initializes the GLFW library.
+ *
+ * This function initializes the GLFW library. Before most GLFW functions can
+ * be used, GLFW must be initialized, and before an application terminates GLFW
+ * should be terminated in order to free any resources allocated during or
+ * after initialization.
+ *
+ * If this function fails, it calls @ref glfwTerminate before returning. If it
+ * succeeds, you should call @ref glfwTerminate before the application exits.
+ *
+ * Additional calls to this function after successful initialization but before
+ * termination will return `GLFW_TRUE` immediately.
+ *
+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark @macos This function will change the current directory of the
+ * application to the `Contents/Resources` subdirectory of the application's
+ * bundle, if present. This can be disabled with the @ref
+ * GLFW_COCOA_CHDIR_RESOURCES init hint.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref intro_init
+ * @sa @ref glfwTerminate
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup init
+ */
+GLFWAPI int glfwInit(void);
+
+/*! @brief Terminates the GLFW library.
+ *
+ * This function destroys all remaining windows and cursors, restores any
+ * modified gamma ramps and frees any other allocated resources. Once this
+ * function is called, you must again call @ref glfwInit successfully before
+ * you will be able to use most GLFW functions.
+ *
+ * If GLFW has been successfully initialized, this function should be called
+ * before the application exits. If initialization fails, there is no need to
+ * call this function, as it is called by @ref glfwInit before it returns
+ * failure.
+ *
+ * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @warning The contexts of any remaining windows must not be current on any
+ * other thread when this function is called.
+ *
+ * @reentrancy This function must not be called from a callback.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref intro_init
+ * @sa @ref glfwInit
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup init
+ */
+GLFWAPI void glfwTerminate(void);
+
+/*! @brief Sets the specified init hint to the desired value.
+ *
+ * This function sets hints for the next initialization of GLFW.
+ *
+ * The values you set hints to are never reset by GLFW, but they only take
+ * effect during initialization. Once GLFW has been initialized, any values
+ * you set will be ignored until the library is terminated and initialized
+ * again.
+ *
+ * Some hints are platform specific. These may be set on any platform but they
+ * will only affect their specific platform. Other platforms will ignore them.
+ * Setting these hints requires no platform specific headers or functions.
+ *
+ * @param[in] hint The [init hint](@ref init_hints) to set.
+ * @param[in] value The new value of the init hint.
+ *
+ * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
+ * GLFW_INVALID_VALUE.
+ *
+ * @remarks This function may be called before @ref glfwInit.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa init_hints
+ * @sa glfwInit
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup init
+ */
+GLFWAPI void glfwInitHint(int hint, int value);
+
+/*! @brief Retrieves the version of the GLFW library.
+ *
+ * This function retrieves the major, minor and revision numbers of the GLFW
+ * library. It is intended for when you are using GLFW as a shared library and
+ * want to ensure that you are using the minimum required version.
+ *
+ * Any or all of the version arguments may be `NULL`.
+ *
+ * @param[out] major Where to store the major version number, or `NULL`.
+ * @param[out] minor Where to store the minor version number, or `NULL`.
+ * @param[out] rev Where to store the revision number, or `NULL`.
+ *
+ * @errors None.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref intro_version
+ * @sa @ref glfwGetVersionString
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup init
+ */
+GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
+
+/*! @brief Returns a string describing the compile-time configuration.
+ *
+ * This function returns the compile-time generated
+ * [version string](@ref intro_version_string) of the GLFW library binary. It
+ * describes the version, platform, compiler and any platform-specific
+ * compile-time options. It should not be confused with the OpenGL or OpenGL
+ * ES version string, queried with `glGetString`.
+ *
+ * __Do not use the version string__ to parse the GLFW library version. The
+ * @ref glfwGetVersion function provides the version of the running library
+ * binary in numerical format.
+ *
+ * @return The ASCII encoded GLFW version string.
+ *
+ * @errors None.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @pointer_lifetime The returned string is static and compile-time generated.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref intro_version
+ * @sa @ref glfwGetVersion
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup init
+ */
+GLFWAPI const char* glfwGetVersionString(void);
+
+/*! @brief Returns and clears the last error for the calling thread.
+ *
+ * This function returns and clears the [error code](@ref errors) of the last
+ * error that occurred on the calling thread, and optionally a UTF-8 encoded
+ * human-readable description of it. If no error has occurred since the last
+ * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
+ * set to `NULL`.
+ *
+ * @param[in] description Where to store the error description pointer, or `NULL`.
+ * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
+ * (zero).
+ *
+ * @errors None.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is guaranteed to be valid only until the
+ * next error occurs or the library is terminated.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref error_handling
+ * @sa @ref glfwSetErrorCallback
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup init
+ */
+GLFWAPI int glfwGetError(const char** description);
+
+/*! @brief Sets the error callback.
+ *
+ * This function sets the error callback, which is called with an error code
+ * and a human-readable description each time a GLFW error occurs.
+ *
+ * The error code is set before the callback is called. Calling @ref
+ * glfwGetError from the error callback will return the same value as the error
+ * code argument.
+ *
+ * The error callback is called on the thread where the error occurred. If you
+ * are using GLFW from multiple threads, your error callback needs to be
+ * written accordingly.
+ *
+ * Because the description string may have been generated specifically for that
+ * error, it is not guaranteed to be valid after the callback has returned. If
+ * you wish to use it after the callback returns, you need to make a copy.
+ *
+ * Once set, the error callback remains set even after the library has been
+ * terminated.
+ *
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set.
+ *
+ * @errors None.
+ *
+ * @remark This function may be called before @ref glfwInit.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref error_handling
+ * @sa @ref glfwGetError
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup init
+ */
+GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
+
+/*! @brief Returns the currently connected monitors.
+ *
+ * This function returns an array of handles for all currently connected
+ * monitors. The primary monitor is always first in the returned array. If no
+ * monitors were found, this function returns `NULL`.
+ *
+ * @param[out] count Where to store the number of monitors in the returned
+ * array. This is set to zero if an error occurred.
+ * @return An array of monitor handles, or `NULL` if no monitors were found or
+ * if an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is guaranteed to be valid only until the
+ * monitor configuration changes or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_monitors
+ * @sa @ref monitor_event
+ * @sa @ref glfwGetPrimaryMonitor
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
+
+/*! @brief Returns the primary monitor.
+ *
+ * This function returns the primary monitor. This is usually the monitor
+ * where elements like the task bar or global menu bar are located.
+ *
+ * @return The primary monitor, or `NULL` if no monitors were found or if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @remark The primary monitor is always first in the array returned by @ref
+ * glfwGetMonitors.
+ *
+ * @sa @ref monitor_monitors
+ * @sa @ref glfwGetMonitors
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
+
+/*! @brief Returns the position of the monitor's viewport on the virtual screen.
+ *
+ * This function returns the position, in screen coordinates, of the upper-left
+ * corner of the specified monitor.
+ *
+ * Any or all of the position arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` position arguments will be set to zero.
+ *
+ * @param[in] monitor The monitor to query.
+ * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
+ * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_properties
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
+
+/*! @brief Returns the physical size of the monitor.
+ *
+ * This function returns the size, in millimetres, of the display area of the
+ * specified monitor.
+ *
+ * Some systems do not provide accurate monitor size information, either
+ * because the monitor
+ * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
+ * data is incorrect or because the driver does not report it accurately.
+ *
+ * Any or all of the size arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` size arguments will be set to zero.
+ *
+ * @param[in] monitor The monitor to query.
+ * @param[out] widthMM Where to store the width, in millimetres, of the
+ * monitor's display area, or `NULL`.
+ * @param[out] heightMM Where to store the height, in millimetres, of the
+ * monitor's display area, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @remark @win32 calculates the returned physical size from the
+ * current resolution and system DPI instead of querying the monitor EDID data.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_properties
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
+
+/*! @brief Retrieves the content scale for the specified monitor.
+ *
+ * This function retrieves the content scale for the specified monitor. The
+ * content scale is the ratio between the current DPI and the platform's
+ * default DPI. If you scale all pixel dimensions by this scale then your
+ * content should appear at an appropriate size. This is especially important
+ * for text and any UI elements.
+ *
+ * The content scale may depend on both the monitor resolution and pixel
+ * density and on user settings. It may be very different from the raw DPI
+ * calculated from the physical size and current resolution.
+ *
+ * @param[in] monitor The monitor to query.
+ * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
+ * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_scale
+ * @sa @ref glfwGetWindowContentScale
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
+
+/*! @brief Returns the name of the specified monitor.
+ *
+ * This function returns a human-readable name, encoded as UTF-8, of the
+ * specified monitor. The name typically reflects the make and model of the
+ * monitor and is not guaranteed to be unique among the connected monitors.
+ *
+ * @param[in] monitor The monitor to query.
+ * @return The UTF-8 encoded name of the monitor, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified monitor is
+ * disconnected or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_properties
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
+
+/*! @brief Sets the user pointer of the specified monitor.
+ *
+ * This function sets the user-defined pointer of the specified monitor. The
+ * current value is retained until the monitor is disconnected. The initial
+ * value is `NULL`.
+ *
+ * This function may be called from the monitor callback, even for a monitor
+ * that is being disconnected.
+ *
+ * @param[in] monitor The monitor whose pointer to set.
+ * @param[in] pointer The new value.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref monitor_userptr
+ * @sa @ref glfwGetMonitorUserPointer
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
+
+/*! @brief Returns the user pointer of the specified monitor.
+ *
+ * This function returns the current value of the user-defined pointer of the
+ * specified monitor. The initial value is `NULL`.
+ *
+ * This function may be called from the monitor callback, even for a monitor
+ * that is being disconnected.
+ *
+ * @param[in] monitor The monitor whose pointer to return.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref monitor_userptr
+ * @sa @ref glfwSetMonitorUserPointer
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
+
+/*! @brief Sets the monitor configuration callback.
+ *
+ * This function sets the monitor configuration callback, or removes the
+ * currently set callback. This is called when a monitor is connected to or
+ * disconnected from the system.
+ *
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_event
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
+
+/*! @brief Returns the available video modes for the specified monitor.
+ *
+ * This function returns an array of all video modes supported by the specified
+ * monitor. The returned array is sorted in ascending order, first by color
+ * bit depth (the sum of all channel depths) and then by resolution area (the
+ * product of width and height).
+ *
+ * @param[in] monitor The monitor to query.
+ * @param[out] count Where to store the number of video modes in the returned
+ * array. This is set to zero if an error occurred.
+ * @return An array of video modes, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified monitor is
+ * disconnected, this function is called again for that monitor or the library
+ * is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_modes
+ * @sa @ref glfwGetVideoMode
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Changed to return an array of modes for a specific monitor.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
+
+/*! @brief Returns the current mode of the specified monitor.
+ *
+ * This function returns the current video mode of the specified monitor. If
+ * you have created a full screen window for that monitor, the return value
+ * will depend on whether that window is iconified.
+ *
+ * @param[in] monitor The monitor to query.
+ * @return The current mode of the monitor, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified monitor is
+ * disconnected or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_modes
+ * @sa @ref glfwGetVideoModes
+ *
+ * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
+
+/*! @brief Generates a gamma ramp and sets it for the specified monitor.
+ *
+ * This function generates an appropriately sized gamma ramp from the specified
+ * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
+ * a finite number greater than zero.
+ *
+ * The software controlled gamma ramp is applied _in addition_ to the hardware
+ * gamma correction, which today is usually an approximation of sRGB gamma.
+ * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
+ * the default (usually sRGB-like) behavior.
+ *
+ * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
+ * GLFW_SRGB_CAPABLE hint.
+ *
+ * @param[in] monitor The monitor whose gamma ramp to set.
+ * @param[in] gamma The desired exponent.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland Gamma handling is a priviledged protocol, this function
+ * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_gamma
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
+
+/*! @brief Returns the current gamma ramp for the specified monitor.
+ *
+ * This function returns the current gamma ramp of the specified monitor.
+ *
+ * @param[in] monitor The monitor to query.
+ * @return The current gamma ramp, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland Gamma handling is a priviledged protocol, this function
+ * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
+ * returning `NULL`.
+ *
+ * @pointer_lifetime The returned structure and its arrays are allocated and
+ * freed by GLFW. You should not free them yourself. They are valid until the
+ * specified monitor is disconnected, this function is called again for that
+ * monitor or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_gamma
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
+
+/*! @brief Sets the current gamma ramp for the specified monitor.
+ *
+ * This function sets the current gamma ramp for the specified monitor. The
+ * original gamma ramp for that monitor is saved by GLFW the first time this
+ * function is called and is restored by @ref glfwTerminate.
+ *
+ * The software controlled gamma ramp is applied _in addition_ to the hardware
+ * gamma correction, which today is usually an approximation of sRGB gamma.
+ * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
+ * the default (usually sRGB-like) behavior.
+ *
+ * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
+ * GLFW_SRGB_CAPABLE hint.
+ *
+ * @param[in] monitor The monitor whose gamma ramp to set.
+ * @param[in] ramp The gamma ramp to use.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark The size of the specified gamma ramp should match the size of the
+ * current ramp for that monitor.
+ *
+ * @remark @win32 The gamma ramp size must be 256.
+ *
+ * @remark @wayland Gamma handling is a priviledged protocol, this function
+ * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The specified gamma ramp is copied before this function
+ * returns.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref monitor_gamma
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup monitor
+ */
+GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
+
+/*! @brief Resets all window hints to their default values.
+ *
+ * This function resets all window hints to their
+ * [default values](@ref window_hints_values).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_hints
+ * @sa @ref glfwWindowHint
+ * @sa @ref glfwWindowHintString
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwDefaultWindowHints(void);
+
+/*! @brief Sets the specified window hint to the desired value.
+ *
+ * This function sets hints for the next call to @ref glfwCreateWindow. The
+ * hints, once set, retain their values until changed by a call to this
+ * function or @ref glfwDefaultWindowHints, or until the library is terminated.
+ *
+ * Only integer value hints can be set with this function. String value hints
+ * are set with @ref glfwWindowHintString.
+ *
+ * This function does not check whether the specified hint values are valid.
+ * If you set hints to invalid values this will instead be reported by the next
+ * call to @ref glfwCreateWindow.
+ *
+ * Some hints are platform specific. These may be set on any platform but they
+ * will only affect their specific platform. Other platforms will ignore them.
+ * Setting these hints requires no platform specific headers or functions.
+ *
+ * @param[in] hint The [window hint](@ref window_hints) to set.
+ * @param[in] value The new value of the window hint.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_hints
+ * @sa @ref glfwWindowHintString
+ * @sa @ref glfwDefaultWindowHints
+ *
+ * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwWindowHint(int hint, int value);
+
+/*! @brief Sets the specified window hint to the desired value.
+ *
+ * This function sets hints for the next call to @ref glfwCreateWindow. The
+ * hints, once set, retain their values until changed by a call to this
+ * function or @ref glfwDefaultWindowHints, or until the library is terminated.
+ *
+ * Only string type hints can be set with this function. Integer value hints
+ * are set with @ref glfwWindowHint.
+ *
+ * This function does not check whether the specified hint values are valid.
+ * If you set hints to invalid values this will instead be reported by the next
+ * call to @ref glfwCreateWindow.
+ *
+ * Some hints are platform specific. These may be set on any platform but they
+ * will only affect their specific platform. Other platforms will ignore them.
+ * Setting these hints requires no platform specific headers or functions.
+ *
+ * @param[in] hint The [window hint](@ref window_hints) to set.
+ * @param[in] value The new value of the window hint.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @pointer_lifetime The specified string is copied before this function
+ * returns.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_hints
+ * @sa @ref glfwWindowHint
+ * @sa @ref glfwDefaultWindowHints
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwWindowHintString(int hint, const char* value);
+
+/*! @brief Creates a window and its associated context.
+ *
+ * This function creates a window and its associated OpenGL or OpenGL ES
+ * context. Most of the options controlling how the window and its context
+ * should be created are specified with [window hints](@ref window_hints).
+ *
+ * Successful creation does not change which context is current. Before you
+ * can use the newly created context, you need to
+ * [make it current](@ref context_current). For information about the `share`
+ * parameter, see @ref context_sharing.
+ *
+ * The created window, framebuffer and context may differ from what you
+ * requested, as not all parameters and hints are
+ * [hard constraints](@ref window_hints_hard). This includes the size of the
+ * window, especially for full screen windows. To query the actual attributes
+ * of the created window, framebuffer and context, see @ref
+ * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
+ *
+ * To create a full screen window, you need to specify the monitor the window
+ * will cover. If no monitor is specified, the window will be windowed mode.
+ * Unless you have a way for the user to choose a specific monitor, it is
+ * recommended that you pick the primary monitor. For more information on how
+ * to query connected monitors, see @ref monitor_monitors.
+ *
+ * For full screen windows, the specified size becomes the resolution of the
+ * window's _desired video mode_. As long as a full screen window is not
+ * iconified, the supported video mode most closely matching the desired video
+ * mode is set for the specified monitor. For more information about full
+ * screen windows, including the creation of so called _windowed full screen_
+ * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
+ *
+ * Once you have created the window, you can switch it between windowed and
+ * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
+ * OpenGL or OpenGL ES context.
+ *
+ * By default, newly created windows use the placement recommended by the
+ * window system. To create the window at a specific position, make it
+ * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
+ * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
+ * it.
+ *
+ * As long as at least one full screen window is not iconified, the screensaver
+ * is prohibited from starting.
+ *
+ * Window systems put limits on window sizes. Very large or very small window
+ * dimensions may be overridden by the window system on creation. Check the
+ * actual [size](@ref window_size) after creation.
+ *
+ * The [swap interval](@ref buffer_swap) is not set during window creation and
+ * the initial value may vary depending on driver settings and defaults.
+ *
+ * @param[in] width The desired width, in screen coordinates, of the window.
+ * This must be greater than zero.
+ * @param[in] height The desired height, in screen coordinates, of the window.
+ * This must be greater than zero.
+ * @param[in] title The initial, UTF-8 encoded window title.
+ * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
+ * windowed mode.
+ * @param[in] share The window whose context to share resources with, or `NULL`
+ * to not share resources.
+ * @return The handle of the created window, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
+ * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @win32 Window creation will fail if the Microsoft GDI software
+ * OpenGL implementation is the only one available.
+ *
+ * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
+ * will be set as the initial icon for the window. If no such icon is present,
+ * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
+ * see @ref glfwSetWindowIcon.
+ *
+ * @remark @win32 The context to share resources with must not be current on
+ * any other thread.
+ *
+ * @remark @macos The OS only supports forward-compatible core profile contexts
+ * for OpenGL versions 3.2 and later. Before creating an OpenGL context of
+ * version 3.2 or later you must set the
+ * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and
+ * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly.
+ * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
+ *
+ * @remark @macos The GLFW window has no icon, as it is not a document
+ * window, but the dock icon will be the same as the application bundle's icon.
+ * For more information on bundles, see the
+ * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
+ * in the Mac Developer Library.
+ *
+ * @remark @macos The first time a window is created the menu bar is created.
+ * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu
+ * bar. Otherwise a minimal menu bar is created manually with common commands
+ * like Hide, Quit and About. The About entry opens a minimal about dialog
+ * with information from the application's bundle. Menu bar creation can be
+ * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint.
+ *
+ * @remark @macos On OS X 10.10 and later the window frame will not be rendered
+ * at full resolution on Retina displays unless the
+ * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
+ * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
+ * application bundle's `Info.plist`. For more information, see
+ * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
+ * in the Mac Developer Library. The GLFW test and example programs use
+ * a custom `Info.plist` template for this, which can be found as
+ * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
+ *
+ * @remark @macos When activating frame autosaving with
+ * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
+ * window size and position may be overriden by previously saved values.
+ *
+ * @remark @x11 Some window managers will not respect the placement of
+ * initially hidden windows.
+ *
+ * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
+ * a window to reach its requested state. This means you may not be able to
+ * query the final size, position or other attributes directly after window
+ * creation.
+ *
+ * @remark @x11 The class part of the `WM_CLASS` window property will by
+ * default be set to the window title passed to this function. The instance
+ * part will use the contents of the `RESOURCE_NAME` environment variable, if
+ * present and not empty, or fall back to the window title. Set the @ref
+ * GLFW_X11_CLASS_NAME and @ref GLFW_X11_INSTANCE_NAME window hints to override
+ * this.
+ *
+ * @remark @wayland The window frame is currently very simple, only allowing
+ * window resize or move. A compositor can still emit close, maximize or
+ * fullscreen events, using for example a keybind mechanism. Additionally,
+ * the wp_viewporter protocol is required for this feature, otherwise the
+ * window will not be decorated.
+ *
+ * @remark @wayland A full screen window will not attempt to change the mode,
+ * no matter what the requested size or refresh rate.
+ *
+ * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
+ * to be implemented in the user's compositor.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_creation
+ * @sa @ref glfwDestroyWindow
+ *
+ * @since Added in version 3.0. Replaces `glfwOpenWindow`.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
+
+/*! @brief Destroys the specified window and its context.
+ *
+ * This function destroys the specified window and its context. On calling
+ * this function, no further callbacks will be called for that window.
+ *
+ * If the context of the specified window is current on the main thread, it is
+ * detached before being destroyed.
+ *
+ * @param[in] window The window to destroy.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @note The context of the specified window must not be current on any other
+ * thread when this function is called.
+ *
+ * @reentrancy This function must not be called from a callback.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_creation
+ * @sa @ref glfwCreateWindow
+ *
+ * @since Added in version 3.0. Replaces `glfwCloseWindow`.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
+
+/*! @brief Checks the close flag of the specified window.
+ *
+ * This function returns the value of the close flag of the specified window.
+ *
+ * @param[in] window The window to query.
+ * @return The value of the close flag.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref window_close
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
+
+/*! @brief Sets the close flag of the specified window.
+ *
+ * This function sets the value of the close flag of the specified window.
+ * This can be used to override the user's attempt to close the window, or
+ * to signal that it should be closed.
+ *
+ * @param[in] window The window whose flag to change.
+ * @param[in] value The new value.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref window_close
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
+
+/*! @brief Sets the title of the specified window.
+ *
+ * This function sets the window title, encoded as UTF-8, of the specified
+ * window.
+ *
+ * @param[in] window The window whose title to change.
+ * @param[in] title The UTF-8 encoded window title.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @macos The window title will not be updated until the next time you
+ * process events.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_title
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
+
+/*! @brief Sets the icon for the specified window.
+ *
+ * This function sets the icon of the specified window. If passed an array of
+ * candidate images, those of or closest to the sizes desired by the system are
+ * selected. If no images are specified, the window reverts to its default
+ * icon.
+ *
+ * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
+ * bits per channel with the red channel first. They are arranged canonically
+ * as packed sequential rows, starting from the top-left corner.
+ *
+ * The desired image sizes varies depending on platform and system settings.
+ * The selected images will be rescaled as needed. Good sizes include 16x16,
+ * 32x32 and 48x48.
+ *
+ * @param[in] window The window whose icon to set.
+ * @param[in] count The number of images in the specified array, or zero to
+ * revert to the default window icon.
+ * @param[in] images The images to create the icon from. This is ignored if
+ * count is zero.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The specified image data is copied before this function
+ * returns.
+ *
+ * @remark @macos The GLFW window has no icon, as it is not a document
+ * window, so this function does nothing. The dock icon will be the same as
+ * the application bundle's icon. For more information on bundles, see the
+ * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
+ * in the Mac Developer Library.
+ *
+ * @remark @wayland There is no existing protocol to change an icon, the
+ * window will thus inherit the one defined in the application's desktop file.
+ * This function always emits @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_icon
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
+
+/*! @brief Retrieves the position of the client area of the specified window.
+ *
+ * This function retrieves the position, in screen coordinates, of the
+ * upper-left corner of the client area of the specified window.
+ *
+ * Any or all of the position arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` position arguments will be set to zero.
+ *
+ * @param[in] window The window to query.
+ * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
+ * the client area, or `NULL`.
+ * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
+ * the client area, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland There is no way for an application to retrieve the global
+ * position of its windows, this function will always emit @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_pos
+ * @sa @ref glfwSetWindowPos
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
+
+/*! @brief Sets the position of the client area of the specified window.
+ *
+ * This function sets the position, in screen coordinates, of the upper-left
+ * corner of the client area of the specified windowed mode window. If the
+ * window is a full screen window, this function does nothing.
+ *
+ * __Do not use this function__ to move an already visible window unless you
+ * have very good reasons for doing so, as it will confuse and annoy the user.
+ *
+ * The window manager may put limits on what positions are allowed. GLFW
+ * cannot and should not override these limits.
+ *
+ * @param[in] window The window to query.
+ * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
+ * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland There is no way for an application to set the global
+ * position of its windows, this function will always emit @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_pos
+ * @sa @ref glfwGetWindowPos
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
+
+/*! @brief Retrieves the size of the client area of the specified window.
+ *
+ * This function retrieves the size, in screen coordinates, of the client area
+ * of the specified window. If you wish to retrieve the size of the
+ * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
+ *
+ * Any or all of the size arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` size arguments will be set to zero.
+ *
+ * @param[in] window The window whose size to retrieve.
+ * @param[out] width Where to store the width, in screen coordinates, of the
+ * client area, or `NULL`.
+ * @param[out] height Where to store the height, in screen coordinates, of the
+ * client area, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_size
+ * @sa @ref glfwSetWindowSize
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
+
+/*! @brief Sets the size limits of the specified window.
+ *
+ * This function sets the size limits of the client area of the specified
+ * window. If the window is full screen, the size limits only take effect
+ * once it is made windowed. If the window is not resizable, this function
+ * does nothing.
+ *
+ * The size limits are applied immediately to a windowed mode window and may
+ * cause it to be resized.
+ *
+ * The maximum dimensions must be greater than or equal to the minimum
+ * dimensions and all must be greater than or equal to zero.
+ *
+ * @param[in] window The window to set limits for.
+ * @param[in] minwidth The minimum width, in screen coordinates, of the client
+ * area, or `GLFW_DONT_CARE`.
+ * @param[in] minheight The minimum height, in screen coordinates, of the
+ * client area, or `GLFW_DONT_CARE`.
+ * @param[in] maxwidth The maximum width, in screen coordinates, of the client
+ * area, or `GLFW_DONT_CARE`.
+ * @param[in] maxheight The maximum height, in screen coordinates, of the
+ * client area, or `GLFW_DONT_CARE`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark If you set size limits and an aspect ratio that conflict, the
+ * results are undefined.
+ *
+ * @remark @wayland The size limits will not be applied until the window is
+ * actually resized, either by the user or by the compositor.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_sizelimits
+ * @sa @ref glfwSetWindowAspectRatio
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
+
+/*! @brief Sets the aspect ratio of the specified window.
+ *
+ * This function sets the required aspect ratio of the client area of the
+ * specified window. If the window is full screen, the aspect ratio only takes
+ * effect once it is made windowed. If the window is not resizable, this
+ * function does nothing.
+ *
+ * The aspect ratio is specified as a numerator and a denominator and both
+ * values must be greater than zero. For example, the common 16:9 aspect ratio
+ * is specified as 16 and 9, respectively.
+ *
+ * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
+ * ratio limit is disabled.
+ *
+ * The aspect ratio is applied immediately to a windowed mode window and may
+ * cause it to be resized.
+ *
+ * @param[in] window The window to set limits for.
+ * @param[in] numer The numerator of the desired aspect ratio, or
+ * `GLFW_DONT_CARE`.
+ * @param[in] denom The denominator of the desired aspect ratio, or
+ * `GLFW_DONT_CARE`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark If you set size limits and an aspect ratio that conflict, the
+ * results are undefined.
+ *
+ * @remark @wayland The aspect ratio will not be applied until the window is
+ * actually resized, either by the user or by the compositor.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_sizelimits
+ * @sa @ref glfwSetWindowSizeLimits
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
+
+/*! @brief Sets the size of the client area of the specified window.
+ *
+ * This function sets the size, in screen coordinates, of the client area of
+ * the specified window.
+ *
+ * For full screen windows, this function updates the resolution of its desired
+ * video mode and switches to the video mode closest to it, without affecting
+ * the window's context. As the context is unaffected, the bit depths of the
+ * framebuffer remain unchanged.
+ *
+ * If you wish to update the refresh rate of the desired video mode in addition
+ * to its resolution, see @ref glfwSetWindowMonitor.
+ *
+ * The window manager may put limits on what sizes are allowed. GLFW cannot
+ * and should not override these limits.
+ *
+ * @param[in] window The window to resize.
+ * @param[in] width The desired width, in screen coordinates, of the window
+ * client area.
+ * @param[in] height The desired height, in screen coordinates, of the window
+ * client area.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland A full screen window will not attempt to change the mode,
+ * no matter what the requested size.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_size
+ * @sa @ref glfwGetWindowSize
+ * @sa @ref glfwSetWindowMonitor
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
+
+/*! @brief Retrieves the size of the framebuffer of the specified window.
+ *
+ * This function retrieves the size, in pixels, of the framebuffer of the
+ * specified window. If you wish to retrieve the size of the window in screen
+ * coordinates, see @ref glfwGetWindowSize.
+ *
+ * Any or all of the size arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` size arguments will be set to zero.
+ *
+ * @param[in] window The window whose framebuffer to query.
+ * @param[out] width Where to store the width, in pixels, of the framebuffer,
+ * or `NULL`.
+ * @param[out] height Where to store the height, in pixels, of the framebuffer,
+ * or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_fbsize
+ * @sa @ref glfwSetFramebufferSizeCallback
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
+
+/*! @brief Retrieves the size of the frame of the window.
+ *
+ * This function retrieves the size, in screen coordinates, of each edge of the
+ * frame of the specified window. This size includes the title bar, if the
+ * window has one. The size of the frame may vary depending on the
+ * [window-related hints](@ref window_hints_wnd) used to create it.
+ *
+ * Because this function retrieves the size of each window frame edge and not
+ * the offset along a particular coordinate axis, the retrieved values will
+ * always be zero or positive.
+ *
+ * Any or all of the size arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` size arguments will be set to zero.
+ *
+ * @param[in] window The window whose frame size to query.
+ * @param[out] left Where to store the size, in screen coordinates, of the left
+ * edge of the window frame, or `NULL`.
+ * @param[out] top Where to store the size, in screen coordinates, of the top
+ * edge of the window frame, or `NULL`.
+ * @param[out] right Where to store the size, in screen coordinates, of the
+ * right edge of the window frame, or `NULL`.
+ * @param[out] bottom Where to store the size, in screen coordinates, of the
+ * bottom edge of the window frame, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_size
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
+
+/*! @brief Retrieves the content scale for the specified window.
+ *
+ * This function retrieves the content scale for the specified window. The
+ * content scale is the ratio between the current DPI and the platform's
+ * default DPI. If you scale all pixel dimensions by this scale then your
+ * content should appear at an appropriate size. This is especially important
+ * for text and any UI elements.
+ *
+ * On systems where each monitors can have its own content scale, the window
+ * content scale will depend on which monitor the system considers the window
+ * to be on.
+ *
+ * @param[in] window The window to query.
+ * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
+ * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_scale
+ * @sa @ref glfwSetWindowContentScaleCallback
+ * @sa @ref glfwGetMonitorContentScale
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
+
+/*! @brief Returns the opacity of the whole window.
+ *
+ * This function returns the opacity of the window, including any decorations.
+ *
+ * The opacity (or alpha) value is a positive finite number between zero and
+ * one, where zero is fully transparent and one is fully opaque. If the system
+ * does not support whole window transparency, this function always returns one.
+ *
+ * The initial opacity value for newly created windows is one.
+ *
+ * @param[in] window The window to query.
+ * @return The opacity value of the specified window.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_transparency
+ * @sa @ref glfwSetWindowOpacity
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
+
+/*! @brief Sets the opacity of the whole window.
+ *
+ * This function sets the opacity of the window, including any decorations.
+ *
+ * The opacity (or alpha) value is a positive finite number between zero and
+ * one, where zero is fully transparent and one is fully opaque.
+ *
+ * The initial opacity value for newly created windows is one.
+ *
+ * A window created with framebuffer transparency may not use whole window
+ * transparency. The results of doing this are undefined.
+ *
+ * @param[in] window The window to set the opacity for.
+ * @param[in] opacity The desired opacity of the specified window.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_transparency
+ * @sa @ref glfwGetWindowOpacity
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
+
+/*! @brief Iconifies the specified window.
+ *
+ * This function iconifies (minimizes) the specified window if it was
+ * previously restored. If the window is already iconified, this function does
+ * nothing.
+ *
+ * If the specified window is a full screen window, the original monitor
+ * resolution is restored until the window is restored.
+ *
+ * @param[in] window The window to iconify.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland There is no concept of iconification in wl_shell, this
+ * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated
+ * protocol.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_iconify
+ * @sa @ref glfwRestoreWindow
+ * @sa @ref glfwMaximizeWindow
+ *
+ * @since Added in version 2.1.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
+
+/*! @brief Restores the specified window.
+ *
+ * This function restores the specified window if it was previously iconified
+ * (minimized) or maximized. If the window is already restored, this function
+ * does nothing.
+ *
+ * If the specified window is a full screen window, the resolution chosen for
+ * the window is restored on the selected monitor.
+ *
+ * @param[in] window The window to restore.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_iconify
+ * @sa @ref glfwIconifyWindow
+ * @sa @ref glfwMaximizeWindow
+ *
+ * @since Added in version 2.1.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
+
+/*! @brief Maximizes the specified window.
+ *
+ * This function maximizes the specified window if it was previously not
+ * maximized. If the window is already maximized, this function does nothing.
+ *
+ * If the specified window is a full screen window, this function does nothing.
+ *
+ * @param[in] window The window to maximize.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @par Thread Safety
+ * This function may only be called from the main thread.
+ *
+ * @sa @ref window_iconify
+ * @sa @ref glfwIconifyWindow
+ * @sa @ref glfwRestoreWindow
+ *
+ * @since Added in GLFW 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
+
+/*! @brief Makes the specified window visible.
+ *
+ * This function makes the specified window visible if it was previously
+ * hidden. If the window is already visible or is in full screen mode, this
+ * function does nothing.
+ *
+ * By default, windowed mode windows are focused when shown
+ * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
+ * to change this behavior for all newly created windows, or change the
+ * behavior for an existing window with @ref glfwSetWindowAttrib.
+ *
+ * @param[in] window The window to make visible.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_hide
+ * @sa @ref glfwHideWindow
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwShowWindow(GLFWwindow* window);
+
+/*! @brief Hides the specified window.
+ *
+ * This function hides the specified window if it was previously visible. If
+ * the window is already hidden or is in full screen mode, this function does
+ * nothing.
+ *
+ * @param[in] window The window to hide.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_hide
+ * @sa @ref glfwShowWindow
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwHideWindow(GLFWwindow* window);
+
+/*! @brief Brings the specified window to front and sets input focus.
+ *
+ * This function brings the specified window to front and sets input focus.
+ * The window should already be visible and not iconified.
+ *
+ * By default, both windowed and full screen mode windows are focused when
+ * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
+ * disable this behavior.
+ *
+ * Also by default, windowed mode windows are focused when shown
+ * with @ref glfwShowWindow. Set the
+ * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
+ *
+ * __Do not use this function__ to steal focus from other applications unless
+ * you are certain that is what the user wants. Focus stealing can be
+ * extremely disruptive.
+ *
+ * For a less disruptive way of getting the user's attention, see
+ * [attention requests](@ref window_attention).
+ *
+ * @param[in] window The window to give input focus.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland It is not possible for an application to bring its windows
+ * to front, this function will always emit @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_focus
+ * @sa @ref window_attention
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwFocusWindow(GLFWwindow* window);
+
+/*! @brief Requests user attention to the specified window.
+ *
+ * This function requests user attention to the specified window. On
+ * platforms where this is not supported, attention is requested to the
+ * application as a whole.
+ *
+ * Once the user has given attention, usually by focusing the window or
+ * application, the system will end the request automatically.
+ *
+ * @param[in] window The window to request attention to.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @macos Attention is requested to the application as a whole, not the
+ * specific window.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_attention
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
+
+/*! @brief Returns the monitor that the window uses for full screen mode.
+ *
+ * This function returns the handle of the monitor that the specified window is
+ * in full screen on.
+ *
+ * @param[in] window The window to query.
+ * @return The monitor, or `NULL` if the window is in windowed mode or an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_monitor
+ * @sa @ref glfwSetWindowMonitor
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
+
+/*! @brief Sets the mode, monitor, video mode and placement of a window.
+ *
+ * This function sets the monitor that the window uses for full screen mode or,
+ * if the monitor is `NULL`, makes it windowed mode.
+ *
+ * When setting a monitor, this function updates the width, height and refresh
+ * rate of the desired video mode and switches to the video mode closest to it.
+ * The window position is ignored when setting a monitor.
+ *
+ * When the monitor is `NULL`, the position, width and height are used to
+ * place the window client area. The refresh rate is ignored when no monitor
+ * is specified.
+ *
+ * If you only wish to update the resolution of a full screen window or the
+ * size of a windowed mode window, see @ref glfwSetWindowSize.
+ *
+ * When a window transitions from full screen to windowed mode, this function
+ * restores any previous window settings such as whether it is decorated,
+ * floating, resizable, has size or aspect ratio limits, etc.
+ *
+ * @param[in] window The window whose monitor, size or video mode to set.
+ * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
+ * @param[in] xpos The desired x-coordinate of the upper-left corner of the
+ * client area.
+ * @param[in] ypos The desired y-coordinate of the upper-left corner of the
+ * client area.
+ * @param[in] width The desired with, in screen coordinates, of the client area
+ * or video mode.
+ * @param[in] height The desired height, in screen coordinates, of the client
+ * area or video mode.
+ * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
+ * or `GLFW_DONT_CARE`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
+ * affected by any resizing or mode switching, although you may need to update
+ * your viewport if the framebuffer size has changed.
+ *
+ * @remark @wayland The desired window position is ignored, as there is no way
+ * for an application to set this property.
+ *
+ * @remark @wayland Setting the window to full screen will not attempt to
+ * change the mode, no matter what the requested size or refresh rate.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_monitor
+ * @sa @ref window_full_screen
+ * @sa @ref glfwGetWindowMonitor
+ * @sa @ref glfwSetWindowSize
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
+
+/*! @brief Returns an attribute of the specified window.
+ *
+ * This function returns the value of an attribute of the specified window or
+ * its OpenGL or OpenGL ES context.
+ *
+ * @param[in] window The window to query.
+ * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
+ * return.
+ * @return The value of the attribute, or zero if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark Framebuffer related hints are not window attributes. See @ref
+ * window_attribs_fb for more information.
+ *
+ * @remark Zero is a valid value for many window and context related
+ * attributes so you cannot use a return value of zero as an indication of
+ * errors. However, this function should not fail as long as it is passed
+ * valid arguments and the library has been [initialized](@ref intro_init).
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_attribs
+ * @sa @ref glfwSetWindowAttrib
+ *
+ * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
+ * `glfwGetGLVersion`.
+ *
+ * @ingroup window
+ */
+GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
+
+/*! @brief Sets an attribute of the specified window.
+ *
+ * This function sets the value of an attribute of the specified window.
+ *
+ * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
+ * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
+ * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
+ * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
+ * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
+ *
+ * Some of these attributes are ignored for full screen windows. The new
+ * value will take effect if the window is later made windowed.
+ *
+ * Some of these attributes are ignored for windowed mode windows. The new
+ * value will take effect if the window is later made full screen.
+ *
+ * @param[in] window The window to set the attribute for.
+ * @param[in] attrib A supported window attribute.
+ * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark Calling @ref glfwGetWindowAttrib will always return the latest
+ * value, even if that value is ignored by the current mode of the window.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_attribs
+ * @sa @ref glfwGetWindowAttrib
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
+
+/*! @brief Sets the user pointer of the specified window.
+ *
+ * This function sets the user-defined pointer of the specified window. The
+ * current value is retained until the window is destroyed. The initial value
+ * is `NULL`.
+ *
+ * @param[in] window The window whose pointer to set.
+ * @param[in] pointer The new value.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref window_userptr
+ * @sa @ref glfwGetWindowUserPointer
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
+
+/*! @brief Returns the user pointer of the specified window.
+ *
+ * This function returns the current value of the user-defined pointer of the
+ * specified window. The initial value is `NULL`.
+ *
+ * @param[in] window The window whose pointer to return.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref window_userptr
+ * @sa @ref glfwSetWindowUserPointer
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
+
+/*! @brief Sets the position callback for the specified window.
+ *
+ * This function sets the position callback of the specified window, which is
+ * called when the window is moved. The callback is provided with the
+ * position, in screen coordinates, of the upper-left corner of the client area
+ * of the window.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @remark @wayland This callback will never be called, as there is no way for
+ * an application to know its global position.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_pos
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
+
+/*! @brief Sets the size callback for the specified window.
+ *
+ * This function sets the size callback of the specified window, which is
+ * called when the window is resized. The callback is provided with the size,
+ * in screen coordinates, of the client area of the window.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_size
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter and return value.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
+
+/*! @brief Sets the close callback for the specified window.
+ *
+ * This function sets the close callback of the specified window, which is
+ * called when the user attempts to close the window, for example by clicking
+ * the close widget in the title bar.
+ *
+ * The close flag is set before this callback is called, but you can modify it
+ * at any time with @ref glfwSetWindowShouldClose.
+ *
+ * The close callback is not triggered by @ref glfwDestroyWindow.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @remark @macos Selecting Quit from the application menu will trigger the
+ * close callback for all windows.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_close
+ *
+ * @since Added in version 2.5.
+ * @glfw3 Added window handle parameter and return value.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
+
+/*! @brief Sets the refresh callback for the specified window.
+ *
+ * This function sets the refresh callback of the specified window, which is
+ * called when the client area of the window needs to be redrawn, for example
+ * if the window has been exposed after having been covered by another window.
+ *
+ * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
+ * the window contents are saved off-screen, this callback may be called only
+ * very infrequently or never at all.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_refresh
+ *
+ * @since Added in version 2.5.
+ * @glfw3 Added window handle parameter and return value.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
+
+/*! @brief Sets the focus callback for the specified window.
+ *
+ * This function sets the focus callback of the specified window, which is
+ * called when the window gains or loses input focus.
+ *
+ * After the focus callback is called for a window that lost input focus,
+ * synthetic key and mouse button release events will be generated for all such
+ * that had been pressed. For more information, see @ref glfwSetKeyCallback
+ * and @ref glfwSetMouseButtonCallback.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_focus
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
+
+/*! @brief Sets the iconify callback for the specified window.
+ *
+ * This function sets the iconification callback of the specified window, which
+ * is called when the window is iconified or restored.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @remark @wayland The wl_shell protocol has no concept of iconification,
+ * this callback will never be called when using this deprecated protocol.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_iconify
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
+
+/*! @brief Sets the maximize callback for the specified window.
+ *
+ * This function sets the maximization callback of the specified window, which
+ * is called when the window is maximized or restored.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_maximize
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun cbfun);
+
+/*! @brief Sets the framebuffer resize callback for the specified window.
+ *
+ * This function sets the framebuffer resize callback of the specified window,
+ * which is called when the framebuffer of the specified window is resized.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_fbsize
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
+
+/*! @brief Sets the window content scale callback for the specified window.
+ *
+ * This function sets the window content scale callback of the specified window,
+ * which is called when the content scale of the specified window changes.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref window_scale
+ * @sa @ref glfwGetWindowContentScale
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup window
+ */
+GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun cbfun);
+
+/*! @brief Processes all pending events.
+ *
+ * This function processes only those events that are already in the event
+ * queue and then returns immediately. Processing events will cause the window
+ * and input callbacks associated with those events to be called.
+ *
+ * On some platforms, a window move, resize or menu operation will cause event
+ * processing to block. This is due to how event processing is designed on
+ * those platforms. You can use the
+ * [window refresh callback](@ref window_refresh) to redraw the contents of
+ * your window when necessary during such operations.
+ *
+ * Do not assume that callbacks you set will _only_ be called in response to
+ * event processing functions like this one. While it is necessary to poll for
+ * events, window systems that require GLFW to register callbacks of its own
+ * can pass events to GLFW in response to many window system function calls.
+ * GLFW will pass those events on to the application callbacks before
+ * returning.
+ *
+ * Event processing is not required for joystick input to work.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @reentrancy This function must not be called from a callback.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref events
+ * @sa @ref glfwWaitEvents
+ * @sa @ref glfwWaitEventsTimeout
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwPollEvents(void);
+
+/*! @brief Waits until events are queued and processes them.
+ *
+ * This function puts the calling thread to sleep until at least one event is
+ * available in the event queue. Once one or more events are available,
+ * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
+ * are processed and the function then returns immediately. Processing events
+ * will cause the window and input callbacks associated with those events to be
+ * called.
+ *
+ * Since not all events are associated with callbacks, this function may return
+ * without a callback having been called even if you are monitoring all
+ * callbacks.
+ *
+ * On some platforms, a window move, resize or menu operation will cause event
+ * processing to block. This is due to how event processing is designed on
+ * those platforms. You can use the
+ * [window refresh callback](@ref window_refresh) to redraw the contents of
+ * your window when necessary during such operations.
+ *
+ * Do not assume that callbacks you set will _only_ be called in response to
+ * event processing functions like this one. While it is necessary to poll for
+ * events, window systems that require GLFW to register callbacks of its own
+ * can pass events to GLFW in response to many window system function calls.
+ * GLFW will pass those events on to the application callbacks before
+ * returning.
+ *
+ * If no windows exist, this function returns immediately. For synchronization
+ * of threads in applications that do not create windows, use your threading
+ * library of choice.
+ *
+ * Event processing is not required for joystick input to work.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @reentrancy This function must not be called from a callback.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref events
+ * @sa @ref glfwPollEvents
+ * @sa @ref glfwWaitEventsTimeout
+ *
+ * @since Added in version 2.5.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwWaitEvents(void);
+
+/*! @brief Waits with timeout until events are queued and processes them.
+ *
+ * This function puts the calling thread to sleep until at least one event is
+ * available in the event queue, or until the specified timeout is reached. If
+ * one or more events are available, it behaves exactly like @ref
+ * glfwPollEvents, i.e. the events in the queue are processed and the function
+ * then returns immediately. Processing events will cause the window and input
+ * callbacks associated with those events to be called.
+ *
+ * The timeout value must be a positive finite number.
+ *
+ * Since not all events are associated with callbacks, this function may return
+ * without a callback having been called even if you are monitoring all
+ * callbacks.
+ *
+ * On some platforms, a window move, resize or menu operation will cause event
+ * processing to block. This is due to how event processing is designed on
+ * those platforms. You can use the
+ * [window refresh callback](@ref window_refresh) to redraw the contents of
+ * your window when necessary during such operations.
+ *
+ * Do not assume that callbacks you set will _only_ be called in response to
+ * event processing functions like this one. While it is necessary to poll for
+ * events, window systems that require GLFW to register callbacks of its own
+ * can pass events to GLFW in response to many window system function calls.
+ * GLFW will pass those events on to the application callbacks before
+ * returning.
+ *
+ * If no windows exist, this function returns immediately. For synchronization
+ * of threads in applications that do not create windows, use your threading
+ * library of choice.
+ *
+ * Event processing is not required for joystick input to work.
+ *
+ * @param[in] timeout The maximum amount of time, in seconds, to wait.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @reentrancy This function must not be called from a callback.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref events
+ * @sa @ref glfwPollEvents
+ * @sa @ref glfwWaitEvents
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwWaitEventsTimeout(double timeout);
+
+/*! @brief Posts an empty event to the event queue.
+ *
+ * This function posts an empty event from the current thread to the event
+ * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
+ *
+ * If no windows exist, this function returns immediately. For synchronization
+ * of threads in applications that do not create windows, use your threading
+ * library of choice.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref events
+ * @sa @ref glfwWaitEvents
+ * @sa @ref glfwWaitEventsTimeout
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwPostEmptyEvent(void);
+
+/*! @brief Returns the value of an input option for the specified window.
+ *
+ * This function returns the value of an input option for the specified window.
+ * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
+ * @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
+ *
+ * @param[in] window The window to query.
+ * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
+ * `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref glfwSetInputMode
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
+
+/*! @brief Sets an input option for the specified window.
+ *
+ * This function sets an input mode option for the specified window. The mode
+ * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
+ * @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
+ *
+ * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
+ * modes:
+ * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
+ * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
+ * area of the window but does not restrict the cursor from leaving.
+ * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
+ * and unlimited cursor movement. This is useful for implementing for
+ * example 3D camera controls.
+ *
+ * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
+ * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
+ * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
+ * the next time it is called even if the key had been released before the
+ * call. This is useful when you are only interested in whether keys have been
+ * pressed but not when or in which order.
+ *
+ * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
+ * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
+ * If sticky mouse buttons are enabled, a mouse button press will ensure that
+ * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
+ * if the mouse button had been released before the call. This is useful when
+ * you are only interested in whether mouse buttons have been pressed but not
+ * when or in which order.
+ *
+ * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
+ * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
+ * callbacks that receive modifier bits will also have the @ref
+ * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
+ * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
+ *
+ * @param[in] window The window whose input mode to set.
+ * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
+ * `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
+ * @param[in] value The new value of the specified input mode.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref glfwGetInputMode
+ *
+ * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
+
+/*! @brief Returns the layout-specific name of the specified printable key.
+ *
+ * This function returns the name of the specified printable key, encoded as
+ * UTF-8. This is typically the character that key would produce without any
+ * modifier keys, intended for displaying key bindings to the user. For dead
+ * keys, it is typically the diacritic it would add to a character.
+ *
+ * __Do not use this function__ for [text input](@ref input_char). You will
+ * break text input for many languages even if it happens to work for yours.
+ *
+ * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
+ * otherwise the scancode is ignored. If you specify a non-printable key, or
+ * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
+ * function returns `NULL` but does not emit an error.
+ *
+ * This behavior allows you to always pass in the arguments in the
+ * [key callback](@ref input_key) without modification.
+ *
+ * The printable keys are:
+ * - `GLFW_KEY_APOSTROPHE`
+ * - `GLFW_KEY_COMMA`
+ * - `GLFW_KEY_MINUS`
+ * - `GLFW_KEY_PERIOD`
+ * - `GLFW_KEY_SLASH`
+ * - `GLFW_KEY_SEMICOLON`
+ * - `GLFW_KEY_EQUAL`
+ * - `GLFW_KEY_LEFT_BRACKET`
+ * - `GLFW_KEY_RIGHT_BRACKET`
+ * - `GLFW_KEY_BACKSLASH`
+ * - `GLFW_KEY_WORLD_1`
+ * - `GLFW_KEY_WORLD_2`
+ * - `GLFW_KEY_0` to `GLFW_KEY_9`
+ * - `GLFW_KEY_A` to `GLFW_KEY_Z`
+ * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
+ * - `GLFW_KEY_KP_DECIMAL`
+ * - `GLFW_KEY_KP_DIVIDE`
+ * - `GLFW_KEY_KP_MULTIPLY`
+ * - `GLFW_KEY_KP_SUBTRACT`
+ * - `GLFW_KEY_KP_ADD`
+ * - `GLFW_KEY_KP_EQUAL`
+ *
+ * Names for printable keys depend on keyboard layout, while names for
+ * non-printable keys are the same across layouts but depend on the application
+ * language and should be localized along with other user interface text.
+ *
+ * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
+ * @param[in] scancode The scancode of the key to query.
+ * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the next call to @ref
+ * glfwGetKeyName, or until the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_key_name
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup input
+ */
+GLFWAPI const char* glfwGetKeyName(int key, int scancode);
+
+/*! @brief Returns the platform-specific scancode of the specified key.
+ *
+ * This function returns the platform-specific scancode of the specified key.
+ *
+ * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
+ * method will return `-1`.
+ *
+ * @param[in] key Any [named key](@ref keys).
+ * @return The platform-specific scancode for the key, or `-1` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref input_key
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwGetKeyScancode(int key);
+
+/*! @brief Returns the last reported state of a keyboard key for the specified
+ * window.
+ *
+ * This function returns the last state reported for the specified key to the
+ * specified window. The returned state is one of `GLFW_PRESS` or
+ * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
+ * the key callback.
+ *
+ * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
+ * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
+ * that key has already been released.
+ *
+ * The key functions deal with physical keys, with [key tokens](@ref keys)
+ * named after their use on the standard US keyboard layout. If you want to
+ * input text, use the Unicode character callback instead.
+ *
+ * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
+ * used with this function.
+ *
+ * __Do not use this function__ to implement [text input](@ref input_char).
+ *
+ * @param[in] window The desired window.
+ * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
+ * not a valid key for this function.
+ * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_key
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
+
+/*! @brief Returns the last reported state of a mouse button for the specified
+ * window.
+ *
+ * This function returns the last state reported for the specified mouse button
+ * to the specified window. The returned state is one of `GLFW_PRESS` or
+ * `GLFW_RELEASE`.
+ *
+ * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
+ * returns `GLFW_PRESS` the first time you call it for a mouse button that was
+ * pressed, even if that mouse button has already been released.
+ *
+ * @param[in] window The desired window.
+ * @param[in] button The desired [mouse button](@ref buttons).
+ * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_mouse_button
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
+
+/*! @brief Retrieves the position of the cursor relative to the client area of
+ * the window.
+ *
+ * This function returns the position of the cursor, in screen coordinates,
+ * relative to the upper-left corner of the client area of the specified
+ * window.
+ *
+ * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
+ * position is unbounded and limited only by the minimum and maximum values of
+ * a `double`.
+ *
+ * The coordinate can be converted to their integer equivalents with the
+ * `floor` function. Casting directly to an integer type works for positive
+ * coordinates, but fails for negative ones.
+ *
+ * Any or all of the position arguments may be `NULL`. If an error occurs, all
+ * non-`NULL` position arguments will be set to zero.
+ *
+ * @param[in] window The desired window.
+ * @param[out] xpos Where to store the cursor x-coordinate, relative to the
+ * left edge of the client area, or `NULL`.
+ * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
+ * top edge of the client area, or `NULL`.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_pos
+ * @sa @ref glfwSetCursorPos
+ *
+ * @since Added in version 3.0. Replaces `glfwGetMousePos`.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
+
+/*! @brief Sets the position of the cursor, relative to the client area of the
+ * window.
+ *
+ * This function sets the position, in screen coordinates, of the cursor
+ * relative to the upper-left corner of the client area of the specified
+ * window. The window must have input focus. If the window does not have
+ * input focus when this function is called, it fails silently.
+ *
+ * __Do not use this function__ to implement things like camera controls. GLFW
+ * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
+ * cursor, transparently re-centers it and provides unconstrained cursor
+ * motion. See @ref glfwSetInputMode for more information.
+ *
+ * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
+ * unconstrained and limited only by the minimum and maximum values of
+ * a `double`.
+ *
+ * @param[in] window The desired window.
+ * @param[in] xpos The desired x-coordinate, relative to the left edge of the
+ * client area.
+ * @param[in] ypos The desired y-coordinate, relative to the top edge of the
+ * client area.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @remark @wayland This function will only work when the cursor mode is
+ * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_pos
+ * @sa @ref glfwGetCursorPos
+ *
+ * @since Added in version 3.0. Replaces `glfwSetMousePos`.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
+
+/*! @brief Creates a custom cursor.
+ *
+ * Creates a new custom cursor image that can be set for a window with @ref
+ * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
+ * Any remaining cursors are destroyed by @ref glfwTerminate.
+ *
+ * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
+ * bits per channel with the red channel first. They are arranged canonically
+ * as packed sequential rows, starting from the top-left corner.
+ *
+ * The cursor hotspot is specified in pixels, relative to the upper-left corner
+ * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
+ * points to the right and the Y-axis points down.
+ *
+ * @param[in] image The desired cursor image.
+ * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
+ * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
+ * @return The handle of the created cursor, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The specified image data is copied before this function
+ * returns.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_object
+ * @sa @ref glfwDestroyCursor
+ * @sa @ref glfwCreateStandardCursor
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
+
+/*! @brief Creates a cursor with a standard shape.
+ *
+ * Returns a cursor with a [standard shape](@ref shapes), that can be set for
+ * a window with @ref glfwSetCursor.
+ *
+ * @param[in] shape One of the [standard shapes](@ref shapes).
+ * @return A new cursor ready to use or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_object
+ * @sa @ref glfwCreateCursor
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
+
+/*! @brief Destroys a cursor.
+ *
+ * This function destroys a cursor previously created with @ref
+ * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
+ * glfwTerminate.
+ *
+ * If the specified cursor is current for any window, that window will be
+ * reverted to the default cursor. This does not affect the cursor mode.
+ *
+ * @param[in] cursor The cursor object to destroy.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @reentrancy This function must not be called from a callback.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_object
+ * @sa @ref glfwCreateCursor
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
+
+/*! @brief Sets the cursor for the window.
+ *
+ * This function sets the cursor image to be used when the cursor is over the
+ * client area of the specified window. The set cursor will only be visible
+ * when the [cursor mode](@ref cursor_mode) of the window is
+ * `GLFW_CURSOR_NORMAL`.
+ *
+ * On some platforms, the set cursor may not be visible unless the window also
+ * has input focus.
+ *
+ * @param[in] window The window to set the cursor for.
+ * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
+ * arrow cursor.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_object
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
+
+/*! @brief Sets the key callback.
+ *
+ * This function sets the key callback of the specified window, which is called
+ * when a key is pressed, repeated or released.
+ *
+ * The key functions deal with physical keys, with layout independent
+ * [key tokens](@ref keys) named after their values in the standard US keyboard
+ * layout. If you want to input text, use the
+ * [character callback](@ref glfwSetCharCallback) instead.
+ *
+ * When a window loses input focus, it will generate synthetic key release
+ * events for all pressed keys. You can tell these events from user-generated
+ * events by the fact that the synthetic ones are generated after the focus
+ * loss event has been processed, i.e. after the
+ * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
+ *
+ * The scancode of a key is specific to that platform or sometimes even to that
+ * machine. Scancodes are intended to allow users to bind keys that don't have
+ * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
+ * state is not saved and so it cannot be queried with @ref glfwGetKey.
+ *
+ * Sometimes GLFW needs to generate synthetic key events, in which case the
+ * scancode may be zero.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new key callback, or `NULL` to remove the currently
+ * set callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_key
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter and return value.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
+
+/*! @brief Sets the Unicode character callback.
+ *
+ * This function sets the character callback of the specified window, which is
+ * called when a Unicode character is input.
+ *
+ * The character callback is intended for Unicode text input. As it deals with
+ * characters, it is keyboard layout dependent, whereas the
+ * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
+ * to physical keys, as a key may produce zero, one or more characters. If you
+ * want to know whether a specific physical key was pressed or released, see
+ * the key callback instead.
+ *
+ * The character callback behaves as system text input normally does and will
+ * not be called if modifier keys are held down that would prevent normal text
+ * input on that platform, for example a Super (Command) key on macOS or Alt key
+ * on Windows.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_char
+ *
+ * @since Added in version 2.4.
+ * @glfw3 Added window handle parameter and return value.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
+
+/*! @brief Sets the Unicode character with modifiers callback.
+ *
+ * This function sets the character with modifiers callback of the specified
+ * window, which is called when a Unicode character is input regardless of what
+ * modifier keys are used.
+ *
+ * The character with modifiers callback is intended for implementing custom
+ * Unicode character input. For regular Unicode text input, see the
+ * [character callback](@ref glfwSetCharCallback). Like the character
+ * callback, the character with modifiers callback deals with characters and is
+ * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
+ * a key may produce zero, one or more characters. If you want to know whether
+ * a specific physical key was pressed or released, see the
+ * [key callback](@ref glfwSetKeyCallback) instead.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or an
+ * [error](@ref error_handling) occurred.
+ *
+ * @deprecated Scheduled for removal in version 4.0.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_char
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
+
+/*! @brief Sets the mouse button callback.
+ *
+ * This function sets the mouse button callback of the specified window, which
+ * is called when a mouse button is pressed or released.
+ *
+ * When a window loses input focus, it will generate synthetic mouse button
+ * release events for all pressed mouse buttons. You can tell these events
+ * from user-generated events by the fact that the synthetic ones are generated
+ * after the focus loss event has been processed, i.e. after the
+ * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref input_mouse_button
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter and return value.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
+
+/*! @brief Sets the cursor position callback.
+ *
+ * This function sets the cursor position callback of the specified window,
+ * which is called when the cursor is moved. The callback is provided with the
+ * position, in screen coordinates, relative to the upper-left corner of the
+ * client area of the window.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_pos
+ *
+ * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
+
+/*! @brief Sets the cursor enter/exit callback.
+ *
+ * This function sets the cursor boundary crossing callback of the specified
+ * window, which is called when the cursor enters or leaves the client area of
+ * the window.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref cursor_enter
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
+
+/*! @brief Sets the scroll callback.
+ *
+ * This function sets the scroll callback of the specified window, which is
+ * called when a scrolling device is used, such as a mouse wheel or scrolling
+ * area of a touchpad.
+ *
+ * The scroll callback receives all scrolling input, like that from a mouse
+ * wheel or a touchpad scrolling area.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
+ * set callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref scrolling
+ *
+ * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
+
+/*! @brief Sets the file drop callback.
+ *
+ * This function sets the file drop callback of the specified window, which is
+ * called when one or more dragged files are dropped on the window.
+ *
+ * Because the path array and its strings may have been generated specifically
+ * for that event, they are not guaranteed to be valid after the callback has
+ * returned. If you wish to use them after the callback returns, you need to
+ * make a deep copy.
+ *
+ * @param[in] window The window whose callback to set.
+ * @param[in] cbfun The new file drop callback, or `NULL` to remove the
+ * currently set callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @remark @wayland File drop is currently unimplemented.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref path_drop
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
+
+/*! @brief Returns whether the specified joystick is present.
+ *
+ * This function returns whether the specified joystick is present.
+ *
+ * There is no need to call this function before other functions that accept
+ * a joystick ID, as they all check for presence before performing any other
+ * work.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref joystick
+ *
+ * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwJoystickPresent(int jid);
+
+/*! @brief Returns the values of all axes of the specified joystick.
+ *
+ * This function returns the values of all axes of the specified joystick.
+ * Each element in the array is a value between -1.0 and 1.0.
+ *
+ * If the specified joystick is not present this function will return `NULL`
+ * but will not generate an error. This can be used instead of first calling
+ * @ref glfwJoystickPresent.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @param[out] count Where to store the number of axis values in the returned
+ * array. This is set to zero if the joystick is not present or an error
+ * occurred.
+ * @return An array of axis values, or `NULL` if the joystick is not present or
+ * an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified joystick is
+ * disconnected or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref joystick_axis
+ *
+ * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
+ *
+ * @ingroup input
+ */
+GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
+
+/*! @brief Returns the state of all buttons of the specified joystick.
+ *
+ * This function returns the state of all buttons of the specified joystick.
+ * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
+ *
+ * For backward compatibility with earlier versions that did not have @ref
+ * glfwGetJoystickHats, the button array also includes all hats, each
+ * represented as four buttons. The hats are in the same order as returned by
+ * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
+ * _left_. To disable these extra buttons, set the @ref
+ * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
+ *
+ * If the specified joystick is not present this function will return `NULL`
+ * but will not generate an error. This can be used instead of first calling
+ * @ref glfwJoystickPresent.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @param[out] count Where to store the number of button states in the returned
+ * array. This is set to zero if the joystick is not present or an error
+ * occurred.
+ * @return An array of button states, or `NULL` if the joystick is not present
+ * or an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified joystick is
+ * disconnected or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref joystick_button
+ *
+ * @since Added in version 2.2.
+ * @glfw3 Changed to return a dynamic array.
+ *
+ * @ingroup input
+ */
+GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
+
+/*! @brief Returns the state of all hats of the specified joystick.
+ *
+ * This function returns the state of all hats of the specified joystick.
+ * Each element in the array is one of the following values:
+ *
+ * Name | Value
+ * ---- | -----
+ * `GLFW_HAT_CENTERED` | 0
+ * `GLFW_HAT_UP` | 1
+ * `GLFW_HAT_RIGHT` | 2
+ * `GLFW_HAT_DOWN` | 4
+ * `GLFW_HAT_LEFT` | 8
+ * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
+ * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
+ * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
+ * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
+ *
+ * The diagonal directions are bitwise combinations of the primary (up, right,
+ * down and left) directions and you can test for these individually by ANDing
+ * it with the corresponding direction.
+ *
+ * @code
+ * if (hats[2] & GLFW_HAT_RIGHT)
+ * {
+ * // State of hat 2 could be right-up, right or right-down
+ * }
+ * @endcode
+ *
+ * If the specified joystick is not present this function will return `NULL`
+ * but will not generate an error. This can be used instead of first calling
+ * @ref glfwJoystickPresent.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @param[out] count Where to store the number of hat states in the returned
+ * array. This is set to zero if the joystick is not present or an error
+ * occurred.
+ * @return An array of hat states, or `NULL` if the joystick is not present
+ * or an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified joystick is
+ * disconnected, this function is called again for that joystick or the library
+ * is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref joystick_hat
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
+
+/*! @brief Returns the name of the specified joystick.
+ *
+ * This function returns the name, encoded as UTF-8, of the specified joystick.
+ * The returned string is allocated and freed by GLFW. You should not free it
+ * yourself.
+ *
+ * If the specified joystick is not present this function will return `NULL`
+ * but will not generate an error. This can be used instead of first calling
+ * @ref glfwJoystickPresent.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
+ * is not present or an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified joystick is
+ * disconnected or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref joystick_name
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup input
+ */
+GLFWAPI const char* glfwGetJoystickName(int jid);
+
+/*! @brief Returns the SDL comaptible GUID of the specified joystick.
+ *
+ * This function returns the SDL compatible GUID, as a UTF-8 encoded
+ * hexadecimal string, of the specified joystick. The returned string is
+ * allocated and freed by GLFW. You should not free it yourself.
+ *
+ * The GUID is what connects a joystick to a gamepad mapping. A connected
+ * joystick will always have a GUID even if there is no gamepad mapping
+ * assigned to it.
+ *
+ * If the specified joystick is not present this function will return `NULL`
+ * but will not generate an error. This can be used instead of first calling
+ * @ref glfwJoystickPresent.
+ *
+ * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
+ * uniquely identify the make and model of a joystick but does not identify
+ * a specific unit, e.g. all wired Xbox 360 controllers will have the same
+ * GUID on that platform. The GUID for a unit may vary between platforms
+ * depending on what hardware information the platform specific APIs provide.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
+ * is not present or an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified joystick is
+ * disconnected or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref gamepad
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI const char* glfwGetJoystickGUID(int jid);
+
+/*! @brief Sets the user pointer of the specified joystick.
+ *
+ * This function sets the user-defined pointer of the specified joystick. The
+ * current value is retained until the joystick is disconnected. The initial
+ * value is `NULL`.
+ *
+ * This function may be called from the joystick callback, even for a joystick
+ * that is being disconnected.
+ *
+ * @param[in] jid The joystick whose pointer to set.
+ * @param[in] pointer The new value.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref joystick_userptr
+ * @sa @ref glfwGetJoystickUserPointer
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
+
+/*! @brief Returns the user pointer of the specified joystick.
+ *
+ * This function returns the current value of the user-defined pointer of the
+ * specified joystick. The initial value is `NULL`.
+ *
+ * This function may be called from the joystick callback, even for a joystick
+ * that is being disconnected.
+ *
+ * @param[in] jid The joystick whose pointer to return.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @sa @ref joystick_userptr
+ * @sa @ref glfwSetJoystickUserPointer
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI void* glfwGetJoystickUserPointer(int jid);
+
+/*! @brief Returns whether the specified joystick has a gamepad mapping.
+ *
+ * This function returns whether the specified joystick is both present and has
+ * a gamepad mapping.
+ *
+ * If the specified joystick is present but does not have a gamepad mapping
+ * this function will return `GLFW_FALSE` but will not generate an error. Call
+ * @ref glfwJoystickPresent to check if a joystick is present regardless of
+ * whether it has a mapping.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
+ * or `GLFW_FALSE` otherwise.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref gamepad
+ * @sa @ref glfwGetGamepadState
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwJoystickIsGamepad(int jid);
+
+/*! @brief Sets the joystick configuration callback.
+ *
+ * This function sets the joystick configuration callback, or removes the
+ * currently set callback. This is called when a joystick is connected to or
+ * disconnected from the system.
+ *
+ * For joystick connection and disconnection events to be delivered on all
+ * platforms, you need to call one of the [event processing](@ref events)
+ * functions. Joystick disconnection may also be detected and the callback
+ * called by joystick functions. The function will then return whatever it
+ * returns if the joystick is not present.
+ *
+ * @param[in] cbfun The new callback, or `NULL` to remove the currently set
+ * callback.
+ * @return The previously set callback, or `NULL` if no callback was set or the
+ * library had not been [initialized](@ref intro_init).
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref joystick_event
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup input
+ */
+GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun);
+
+/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
+ *
+ * This function parses the specified ASCII encoded string and updates the
+ * internal list with any gamepad mappings it finds. This string may
+ * contain either a single gamepad mapping or many mappings separated by
+ * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
+ * source file including empty lines and comments.
+ *
+ * See @ref gamepad_mapping for a description of the format.
+ *
+ * If there is already a gamepad mapping for a given GUID in the internal list,
+ * it will be replaced by the one passed to this function. If the library is
+ * terminated and re-initialized the internal list will revert to the built-in
+ * default.
+ *
+ * @param[in] string The string containing the gamepad mappings.
+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_VALUE.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref gamepad
+ * @sa @ref glfwJoystickIsGamepad
+ * @sa @ref glfwGetGamepadName
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwUpdateGamepadMappings(const char* string);
+
+/*! @brief Returns the human-readable gamepad name for the specified joystick.
+ *
+ * This function returns the human-readable name of the gamepad from the
+ * gamepad mapping assigned to the specified joystick.
+ *
+ * If the specified joystick is not present or does not have a gamepad mapping
+ * this function will return `NULL` but will not generate an error. Call
+ * @ref glfwJoystickPresent to check whether it is present regardless of
+ * whether it has a mapping.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
+ * joystick is not present, does not have a mapping or an
+ * [error](@ref error_handling) occurred.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the specified joystick is
+ * disconnected, the gamepad mappings are updated or the library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref gamepad
+ * @sa @ref glfwJoystickIsGamepad
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI const char* glfwGetGamepadName(int jid);
+
+/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
+ *
+ * This function retrives the state of the specified joystick remapped to
+ * an Xbox-like gamepad.
+ *
+ * If the specified joystick is not present or does not have a gamepad mapping
+ * this function will return `GLFW_FALSE` but will not generate an error. Call
+ * @ref glfwJoystickPresent to check whether it is present regardless of
+ * whether it has a mapping.
+ *
+ * The Guide button may not be available for input as it is often hooked by the
+ * system or the Steam client.
+ *
+ * Not all devices have all the buttons or axes provided by @ref
+ * GLFWgamepadstate. Unavailable buttons and axes will always report
+ * `GLFW_RELEASE` and 0.0 respectively.
+ *
+ * @param[in] jid The [joystick](@ref joysticks) to query.
+ * @param[out] state The gamepad input state of the joystick.
+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
+ * connected, it has no gamepad mapping or an [error](@ref error_handling)
+ * occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_ENUM.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref gamepad
+ * @sa @ref glfwUpdateGamepadMappings
+ * @sa @ref glfwJoystickIsGamepad
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup input
+ */
+GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
+
+/*! @brief Sets the clipboard to the specified string.
+ *
+ * This function sets the system clipboard to the specified, UTF-8 encoded
+ * string.
+ *
+ * @param[in] window Deprecated. Any valid window or `NULL`.
+ * @param[in] string A UTF-8 encoded string.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The specified string is copied before this function
+ * returns.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref clipboard
+ * @sa @ref glfwGetClipboardString
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
+
+/*! @brief Returns the contents of the clipboard as a string.
+ *
+ * This function returns the contents of the system clipboard, if it contains
+ * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
+ * if its contents cannot be converted, `NULL` is returned and a @ref
+ * GLFW_FORMAT_UNAVAILABLE error is generated.
+ *
+ * @param[in] window Deprecated. Any valid window or `NULL`.
+ * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
+ * if an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the next call to @ref
+ * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
+ * is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref clipboard
+ * @sa @ref glfwSetClipboardString
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup input
+ */
+GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
+
+/*! @brief Returns the value of the GLFW timer.
+ *
+ * This function returns the value of the GLFW timer. Unless the timer has
+ * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
+ * was initialized.
+ *
+ * The resolution of the timer is system dependent, but is usually on the order
+ * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
+ * time source on each supported platform.
+ *
+ * @return The current value, in seconds, or zero if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread. Reading and
+ * writing of the internal timer offset is not atomic, so it needs to be
+ * externally synchronized with calls to @ref glfwSetTime.
+ *
+ * @sa @ref time
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup input
+ */
+GLFWAPI double glfwGetTime(void);
+
+/*! @brief Sets the GLFW timer.
+ *
+ * This function sets the value of the GLFW timer. It then continues to count
+ * up from that value. The value must be a positive finite number less than
+ * or equal to 18446744073.0, which is approximately 584.5 years.
+ *
+ * @param[in] time The new value, in seconds.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_INVALID_VALUE.
+ *
+ * @remark The upper limit of the timer is calculated as
+ * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
+ * storing nanoseconds in 64 bits. The limit may be increased in the future.
+ *
+ * @thread_safety This function may be called from any thread. Reading and
+ * writing of the internal timer offset is not atomic, so it needs to be
+ * externally synchronized with calls to @ref glfwGetTime.
+ *
+ * @sa @ref time
+ *
+ * @since Added in version 2.2.
+ *
+ * @ingroup input
+ */
+GLFWAPI void glfwSetTime(double time);
+
+/*! @brief Returns the current value of the raw timer.
+ *
+ * This function returns the current value of the raw timer, measured in
+ * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
+ * glfwGetTimerFrequency.
+ *
+ * @return The value of the timer, or zero if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref time
+ * @sa @ref glfwGetTimerFrequency
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup input
+ */
+GLFWAPI uint64_t glfwGetTimerValue(void);
+
+/*! @brief Returns the frequency, in Hz, of the raw timer.
+ *
+ * This function returns the frequency, in Hz, of the raw timer.
+ *
+ * @return The frequency of the timer, in Hz, or zero if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref time
+ * @sa @ref glfwGetTimerValue
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup input
+ */
+GLFWAPI uint64_t glfwGetTimerFrequency(void);
+
+/*! @brief Makes the context of the specified window current for the calling
+ * thread.
+ *
+ * This function makes the OpenGL or OpenGL ES context of the specified window
+ * current on the calling thread. A context must only be made current on
+ * a single thread at a time and each thread can have only a single current
+ * context at a time.
+ *
+ * When moving a context between threads, you must make it non-current on the
+ * old thread before making it current on the new one.
+ *
+ * By default, making a context non-current implicitly forces a pipeline flush.
+ * On machines that support `GL_KHR_context_flush_control`, you can control
+ * whether a context performs this flush by setting the
+ * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
+ * hint.
+ *
+ * The specified window must have an OpenGL or OpenGL ES context. Specifying
+ * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
+ * error.
+ *
+ * @param[in] window The window whose context to make current, or `NULL` to
+ * detach the current context.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref context_current
+ * @sa @ref glfwGetCurrentContext
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup context
+ */
+GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
+
+/*! @brief Returns the window whose context is current on the calling thread.
+ *
+ * This function returns the window whose OpenGL or OpenGL ES context is
+ * current on the calling thread.
+ *
+ * @return The window whose context is current, or `NULL` if no window's
+ * context is current.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref context_current
+ * @sa @ref glfwMakeContextCurrent
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup context
+ */
+GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
+
+/*! @brief Swaps the front and back buffers of the specified window.
+ *
+ * This function swaps the front and back buffers of the specified window when
+ * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
+ * zero, the GPU driver waits the specified number of screen updates before
+ * swapping the buffers.
+ *
+ * The specified window must have an OpenGL or OpenGL ES context. Specifying
+ * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
+ * error.
+ *
+ * This function does not apply to Vulkan. If you are rendering with Vulkan,
+ * see `vkQueuePresentKHR` instead.
+ *
+ * @param[in] window The window whose buffers to swap.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark __EGL:__ The context of the specified window must be current on the
+ * calling thread.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref buffer_swap
+ * @sa @ref glfwSwapInterval
+ *
+ * @since Added in version 1.0.
+ * @glfw3 Added window handle parameter.
+ *
+ * @ingroup window
+ */
+GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
+
+/*! @brief Sets the swap interval for the current context.
+ *
+ * This function sets the swap interval for the current OpenGL or OpenGL ES
+ * context, i.e. the number of screen updates to wait from the time @ref
+ * glfwSwapBuffers was called before swapping the buffers and returning. This
+ * is sometimes called _vertical synchronization_, _vertical retrace
+ * synchronization_ or just _vsync_.
+ *
+ * A context that supports either of the `WGL_EXT_swap_control_tear` and
+ * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
+ * intervals, which allows the driver to swap immediately even if a frame
+ * arrives a little bit late. You can check for these extensions with @ref
+ * glfwExtensionSupported.
+ *
+ * A context must be current on the calling thread. Calling this function
+ * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
+ *
+ * This function does not apply to Vulkan. If you are rendering with Vulkan,
+ * see the present mode of your swapchain instead.
+ *
+ * @param[in] interval The minimum number of screen updates to wait for
+ * until the buffers are swapped by @ref glfwSwapBuffers.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark This function is not called during context creation, leaving the
+ * swap interval set to whatever is the default on that platform. This is done
+ * because some swap interval extensions used by GLFW do not allow the swap
+ * interval to be reset to zero once it has been set to a non-zero value.
+ *
+ * @remark Some GPU drivers do not honor the requested swap interval, either
+ * because of a user setting that overrides the application's request or due to
+ * bugs in the driver.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref buffer_swap
+ * @sa @ref glfwSwapBuffers
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup context
+ */
+GLFWAPI void glfwSwapInterval(int interval);
+
+/*! @brief Returns whether the specified extension is available.
+ *
+ * This function returns whether the specified
+ * [API extension](@ref context_glext) is supported by the current OpenGL or
+ * OpenGL ES context. It searches both for client API extension and context
+ * creation API extensions.
+ *
+ * A context must be current on the calling thread. Calling this function
+ * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
+ *
+ * As this functions retrieves and searches one or more extension strings each
+ * call, it is recommended that you cache its results if it is going to be used
+ * frequently. The extension strings will not change during the lifetime of
+ * a context, so there is no danger in doing this.
+ *
+ * This function does not apply to Vulkan. If you are using Vulkan, see @ref
+ * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
+ * and `vkEnumerateDeviceExtensionProperties` instead.
+ *
+ * @param[in] extension The ASCII encoded name of the extension.
+ * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
+ * otherwise.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref context_glext
+ * @sa @ref glfwGetProcAddress
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup context
+ */
+GLFWAPI int glfwExtensionSupported(const char* extension);
+
+/*! @brief Returns the address of the specified function for the current
+ * context.
+ *
+ * This function returns the address of the specified OpenGL or OpenGL ES
+ * [core or extension function](@ref context_glext), if it is supported
+ * by the current context.
+ *
+ * A context must be current on the calling thread. Calling this function
+ * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
+ *
+ * This function does not apply to Vulkan. If you are rendering with Vulkan,
+ * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
+ * `vkGetDeviceProcAddr` instead.
+ *
+ * @param[in] procname The ASCII encoded name of the function.
+ * @return The address of the function, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark The address of a given function is not guaranteed to be the same
+ * between contexts.
+ *
+ * @remark This function may return a non-`NULL` address despite the
+ * associated version or extension not being available. Always check the
+ * context version or extension string first.
+ *
+ * @pointer_lifetime The returned function pointer is valid until the context
+ * is destroyed or the library is terminated.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref context_glext
+ * @sa @ref glfwExtensionSupported
+ *
+ * @since Added in version 1.0.
+ *
+ * @ingroup context
+ */
+GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
+
+/*! @brief Returns whether the Vulkan loader and an ICD have been found.
+ *
+ * This function returns whether the Vulkan loader and any minimally functional
+ * ICD have been found.
+ *
+ * The availability of a Vulkan loader and even an ICD does not by itself
+ * guarantee that surface creation or even instance creation is possible.
+ * For example, on Fermi systems Nvidia will install an ICD that provides no
+ * actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
+ * whether the extensions necessary for Vulkan surface creation are available
+ * and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
+ * family of a physical device supports image presentation.
+ *
+ * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
+ * otherwise.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref vulkan_support
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup vulkan
+ */
+GLFWAPI int glfwVulkanSupported(void);
+
+/*! @brief Returns the Vulkan instance extensions required by GLFW.
+ *
+ * This function returns an array of names of Vulkan instance extensions required
+ * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
+ * list will always contains `VK_KHR_surface`, so if you don't require any
+ * additional extensions you can pass this list directly to the
+ * `VkInstanceCreateInfo` struct.
+ *
+ * If Vulkan is not available on the machine, this function returns `NULL` and
+ * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
+ * to check whether Vulkan is at least minimally available.
+ *
+ * If Vulkan is available but no set of extensions allowing window surface
+ * creation was found, this function returns `NULL`. You may still use Vulkan
+ * for off-screen rendering and compute work.
+ *
+ * @param[out] count Where to store the number of extensions in the returned
+ * array. This is set to zero if an error occurred.
+ * @return An array of ASCII encoded extension names, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_API_UNAVAILABLE.
+ *
+ * @remark Additional extensions may be required by future versions of GLFW.
+ * You should check if any extensions you wish to enable are already in the
+ * returned array, as it is an error to specify an extension more than once in
+ * the `VkInstanceCreateInfo` struct.
+ *
+ * @remark @macos This function currently only supports the
+ * `VK_MVK_macos_surface` extension from MoltenVK.
+ *
+ * @pointer_lifetime The returned array is allocated and freed by GLFW. You
+ * should not free it yourself. It is guaranteed to be valid only until the
+ * library is terminated.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref vulkan_ext
+ * @sa @ref glfwCreateWindowSurface
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup vulkan
+ */
+GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
+
+#if defined(VK_VERSION_1_0)
+
+/*! @brief Returns the address of the specified Vulkan instance function.
+ *
+ * This function returns the address of the specified Vulkan core or extension
+ * function for the specified instance. If instance is set to `NULL` it can
+ * return any function exported from the Vulkan loader, including at least the
+ * following functions:
+ *
+ * - `vkEnumerateInstanceExtensionProperties`
+ * - `vkEnumerateInstanceLayerProperties`
+ * - `vkCreateInstance`
+ * - `vkGetInstanceProcAddr`
+ *
+ * If Vulkan is not available on the machine, this function returns `NULL` and
+ * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
+ * to check whether Vulkan is at least minimally available.
+ *
+ * This function is equivalent to calling `vkGetInstanceProcAddr` with
+ * a platform-specific query of the Vulkan loader as a fallback.
+ *
+ * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
+ * functions related to instance creation.
+ * @param[in] procname The ASCII encoded name of the function.
+ * @return The address of the function, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_API_UNAVAILABLE.
+ *
+ * @pointer_lifetime The returned function pointer is valid until the library
+ * is terminated.
+ *
+ * @thread_safety This function may be called from any thread.
+ *
+ * @sa @ref vulkan_proc
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup vulkan
+ */
+GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
+
+/*! @brief Returns whether the specified queue family can present images.
+ *
+ * This function returns whether the specified queue family of the specified
+ * physical device supports presentation to the platform GLFW was built for.
+ *
+ * If Vulkan or the required window surface creation instance extensions are
+ * not available on the machine, or if the specified instance was not created
+ * with the required extensions, this function returns `GLFW_FALSE` and
+ * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
+ * to check whether Vulkan is at least minimally available and @ref
+ * glfwGetRequiredInstanceExtensions to check what instance extensions are
+ * required.
+ *
+ * @param[in] instance The instance that the physical device belongs to.
+ * @param[in] device The physical device that the queue family belongs to.
+ * @param[in] queuefamily The index of the queue family to query.
+ * @return `GLFW_TRUE` if the queue family supports presentation, or
+ * `GLFW_FALSE` otherwise.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
+ *
+ * @remark @macos This function currently always returns `GLFW_TRUE`, as the
+ * `VK_MVK_macos_surface` extension does not provide
+ * a `vkGetPhysicalDevice*PresentationSupport` type function.
+ *
+ * @thread_safety This function may be called from any thread. For
+ * synchronization details of Vulkan objects, see the Vulkan specification.
+ *
+ * @sa @ref vulkan_present
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup vulkan
+ */
+GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
+
+/*! @brief Creates a Vulkan surface for the specified window.
+ *
+ * This function creates a Vulkan surface for the specified window.
+ *
+ * If the Vulkan loader or at least one minimally functional ICD were not found,
+ * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
+ * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
+ * Vulkan is at least minimally available.
+ *
+ * If the required window surface creation instance extensions are not
+ * available or if the specified instance was not created with these extensions
+ * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
+ * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
+ * glfwGetRequiredInstanceExtensions to check what instance extensions are
+ * required.
+ *
+ * The window surface cannot be shared with another API so the window must
+ * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
+ * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
+ * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
+ *
+ * The window surface must be destroyed before the specified Vulkan instance.
+ * It is the responsibility of the caller to destroy the window surface. GLFW
+ * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
+ * surface.
+ *
+ * @param[in] instance The Vulkan instance to create the surface in.
+ * @param[in] window The window to create the surface for.
+ * @param[in] allocator The allocator to use, or `NULL` to use the default
+ * allocator.
+ * @param[out] surface Where to store the handle of the surface. This is set
+ * to `VK_NULL_HANDLE` if an error occurred.
+ * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
+ * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
+ *
+ * @remark If an error occurs before the creation call is made, GLFW returns
+ * the Vulkan error code most appropriate for the error. Appropriate use of
+ * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
+ * eliminate almost all occurrences of these errors.
+ *
+ * @remark @macos This function currently only supports the
+ * `VK_MVK_macos_surface` extension from MoltenVK.
+ *
+ * @remark @macos This function creates and sets a `CAMetalLayer` instance for
+ * the window content view, which is required for MoltenVK to function.
+ *
+ * @thread_safety This function may be called from any thread. For
+ * synchronization details of Vulkan objects, see the Vulkan specification.
+ *
+ * @sa @ref vulkan_surface
+ * @sa @ref glfwGetRequiredInstanceExtensions
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup vulkan
+ */
+GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
+
+#endif /*VK_VERSION_1_0*/
+
+
+/*************************************************************************
+ * Global definition cleanup
+ *************************************************************************/
+
+/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
+
+#ifdef GLFW_WINGDIAPI_DEFINED
+ #undef WINGDIAPI
+ #undef GLFW_WINGDIAPI_DEFINED
+#endif
+
+#ifdef GLFW_CALLBACK_DEFINED
+ #undef CALLBACK
+ #undef GLFW_CALLBACK_DEFINED
+#endif
+
+/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
+ * defined by some gl.h variants (OpenBSD) so define it after if needed.
+ */
+#ifndef GLAPIENTRY
+ #define GLAPIENTRY APIENTRY
+#endif
+
+/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _glfw3_h_ */
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3native.h b/Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3native.h
new file mode 100644
index 0000000..6bddc43
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/include/GLFW/glfw3native.h
@@ -0,0 +1,525 @@
+/*************************************************************************
+ * GLFW 3.3 - www.glfw.org
+ * A library for OpenGL, window and input
+ *------------------------------------------------------------------------
+ * Copyright (c) 2002-2006 Marcus Geelnard
+ * Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would
+ * be appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not
+ * be misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source
+ * distribution.
+ *
+ *************************************************************************/
+
+#ifndef _glfw3_native_h_
+#define _glfw3_native_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*************************************************************************
+ * Doxygen documentation
+ *************************************************************************/
+
+/*! @file glfw3native.h
+ * @brief The header of the native access functions.
+ *
+ * This is the header file of the native access functions. See @ref native for
+ * more information.
+ */
+/*! @defgroup native Native access
+ * @brief Functions related to accessing native handles.
+ *
+ * **By using the native access functions you assert that you know what you're
+ * doing and how to fix problems caused by using them. If you don't, you
+ * shouldn't be using them.**
+ *
+ * Before the inclusion of @ref glfw3native.h, you may define zero or more
+ * window system API macro and zero or more context creation API macros.
+ *
+ * The chosen backends must match those the library was compiled for. Failure
+ * to do this will cause a link-time error.
+ *
+ * The available window API macros are:
+ * * `GLFW_EXPOSE_NATIVE_WIN32`
+ * * `GLFW_EXPOSE_NATIVE_COCOA`
+ * * `GLFW_EXPOSE_NATIVE_X11`
+ * * `GLFW_EXPOSE_NATIVE_WAYLAND`
+ *
+ * The available context API macros are:
+ * * `GLFW_EXPOSE_NATIVE_WGL`
+ * * `GLFW_EXPOSE_NATIVE_NSGL`
+ * * `GLFW_EXPOSE_NATIVE_GLX`
+ * * `GLFW_EXPOSE_NATIVE_EGL`
+ * * `GLFW_EXPOSE_NATIVE_OSMESA`
+ *
+ * These macros select which of the native access functions that are declared
+ * and which platform-specific headers to include. It is then up your (by
+ * definition platform-specific) code to handle which of these should be
+ * defined.
+ */
+
+
+/*************************************************************************
+ * System headers and types
+ *************************************************************************/
+
+#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
+ // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
+ // example to allow applications to correctly declare a GL_ARB_debug_output
+ // callback) but windows.h assumes no one will define APIENTRY before it does
+ #if defined(GLFW_APIENTRY_DEFINED)
+ #undef APIENTRY
+ #undef GLFW_APIENTRY_DEFINED
+ #endif
+ #include <windows.h>
+#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
+ #if defined(__OBJC__)
+ #import <Cocoa/Cocoa.h>
+ #else
+ #include <ApplicationServices/ApplicationServices.h>
+ typedef void* id;
+ #endif
+#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
+ #include <X11/Xlib.h>
+ #include <X11/extensions/Xrandr.h>
+#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
+ #include <wayland-client.h>
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_WGL)
+ /* WGL is declared by windows.h */
+#endif
+#if defined(GLFW_EXPOSE_NATIVE_NSGL)
+ /* NSGL is declared by Cocoa.h */
+#endif
+#if defined(GLFW_EXPOSE_NATIVE_GLX)
+ #include <GL/glx.h>
+#endif
+#if defined(GLFW_EXPOSE_NATIVE_EGL)
+ #include <EGL/egl.h>
+#endif
+#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
+ #include <GL/osmesa.h>
+#endif
+
+
+/*************************************************************************
+ * Functions
+ *************************************************************************/
+
+#if defined(GLFW_EXPOSE_NATIVE_WIN32)
+/*! @brief Returns the adapter device name of the specified monitor.
+ *
+ * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
+ * of the specified monitor, or `NULL` if an [error](@ref error_handling)
+ * occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup native
+ */
+GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
+
+/*! @brief Returns the display device name of the specified monitor.
+ *
+ * @return The UTF-8 encoded display device name (for example
+ * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup native
+ */
+GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
+
+/*! @brief Returns the `HWND` of the specified window.
+ *
+ * @return The `HWND` of the specified window, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_WGL)
+/*! @brief Returns the `HGLRC` of the specified window.
+ *
+ * @return The `HGLRC` of the specified window, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_COCOA)
+/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
+ *
+ * @return The `CGDirectDisplayID` of the specified monitor, or
+ * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup native
+ */
+GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
+
+/*! @brief Returns the `NSWindow` of the specified window.
+ *
+ * @return The `NSWindow` of the specified window, or `nil` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_NSGL)
+/*! @brief Returns the `NSOpenGLContext` of the specified window.
+ *
+ * @return The `NSOpenGLContext` of the specified window, or `nil` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_X11)
+/*! @brief Returns the `Display` used by GLFW.
+ *
+ * @return The `Display` used by GLFW, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI Display* glfwGetX11Display(void);
+
+/*! @brief Returns the `RRCrtc` of the specified monitor.
+ *
+ * @return The `RRCrtc` of the specified monitor, or `None` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup native
+ */
+GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
+
+/*! @brief Returns the `RROutput` of the specified monitor.
+ *
+ * @return The `RROutput` of the specified monitor, or `None` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.1.
+ *
+ * @ingroup native
+ */
+GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
+
+/*! @brief Returns the `Window` of the specified window.
+ *
+ * @return The `Window` of the specified window, or `None` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
+
+/*! @brief Sets the current primary selection to the specified string.
+ *
+ * @param[in] string A UTF-8 encoded string.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The specified string is copied before this function
+ * returns.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref clipboard
+ * @sa glfwGetX11SelectionString
+ * @sa glfwSetClipboardString
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup native
+ */
+GLFWAPI void glfwSetX11SelectionString(const char* string);
+
+/*! @brief Returns the contents of the current primary selection as a string.
+ *
+ * If the selection is empty or if its contents cannot be converted, `NULL`
+ * is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
+ *
+ * @return The contents of the selection as a UTF-8 encoded string, or `NULL`
+ * if an [error](@ref error_handling) occurred.
+ *
+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
+ * GLFW_PLATFORM_ERROR.
+ *
+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
+ * should not free it yourself. It is valid until the next call to @ref
+ * glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
+ * library is terminated.
+ *
+ * @thread_safety This function must only be called from the main thread.
+ *
+ * @sa @ref clipboard
+ * @sa glfwSetX11SelectionString
+ * @sa glfwGetClipboardString
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup native
+ */
+GLFWAPI const char* glfwGetX11SelectionString(void);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_GLX)
+/*! @brief Returns the `GLXContext` of the specified window.
+ *
+ * @return The `GLXContext` of the specified window, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
+
+/*! @brief Returns the `GLXWindow` of the specified window.
+ *
+ * @return The `GLXWindow` of the specified window, or `None` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup native
+ */
+GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
+/*! @brief Returns the `struct wl_display*` used by GLFW.
+ *
+ * @return The `struct wl_display*` used by GLFW, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup native
+ */
+GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
+
+/*! @brief Returns the `struct wl_output*` of the specified monitor.
+ *
+ * @return The `struct wl_output*` of the specified monitor, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup native
+ */
+GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
+
+/*! @brief Returns the main `struct wl_surface*` of the specified window.
+ *
+ * @return The main `struct wl_surface*` of the specified window, or `NULL` if
+ * an [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.2.
+ *
+ * @ingroup native
+ */
+GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_EGL)
+/*! @brief Returns the `EGLDisplay` used by GLFW.
+ *
+ * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
+
+/*! @brief Returns the `EGLContext` of the specified window.
+ *
+ * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
+
+/*! @brief Returns the `EGLSurface` of the specified window.
+ *
+ * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.0.
+ *
+ * @ingroup native
+ */
+GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
+#endif
+
+#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
+/*! @brief Retrieves the color buffer associated with the specified window.
+ *
+ * @param[in] window The window whose color buffer to retrieve.
+ * @param[out] width Where to store the width of the color buffer, or `NULL`.
+ * @param[out] height Where to store the height of the color buffer, or `NULL`.
+ * @param[out] format Where to store the OSMesa pixel format of the color
+ * buffer, or `NULL`.
+ * @param[out] buffer Where to store the address of the color buffer, or
+ * `NULL`.
+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup native
+ */
+GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
+
+/*! @brief Retrieves the depth buffer associated with the specified window.
+ *
+ * @param[in] window The window whose depth buffer to retrieve.
+ * @param[out] width Where to store the width of the depth buffer, or `NULL`.
+ * @param[out] height Where to store the height of the depth buffer, or `NULL`.
+ * @param[out] bytesPerValue Where to store the number of bytes per depth
+ * buffer element, or `NULL`.
+ * @param[out] buffer Where to store the address of the depth buffer, or
+ * `NULL`.
+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup native
+ */
+GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
+
+/*! @brief Returns the `OSMesaContext` of the specified window.
+ *
+ * @return The `OSMesaContext` of the specified window, or `NULL` if an
+ * [error](@ref error_handling) occurred.
+ *
+ * @thread_safety This function may be called from any thread. Access is not
+ * synchronized.
+ *
+ * @since Added in version 3.3.
+ *
+ * @ingroup native
+ */
+GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _glfw3_native_h_ */
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_init.m b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_init.m
new file mode 100644
index 0000000..f3c4795
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_init.m
@@ -0,0 +1,403 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+#include <sys/param.h> // For MAXPATHLEN
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+ #define NSEventMaskKeyUp NSKeyUpMask
+ #define NSEventModifierFlagCommand NSCommandKeyMask
+#endif
+
+// Change to our application bundle's resources directory, if present
+//
+static void changeToResourcesDirectory(void)
+{
+ char resourcesPath[MAXPATHLEN];
+
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if (!bundle)
+ return;
+
+ CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
+
+ CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
+ if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
+ {
+ CFRelease(last);
+ CFRelease(resourcesURL);
+ return;
+ }
+
+ CFRelease(last);
+
+ if (!CFURLGetFileSystemRepresentation(resourcesURL,
+ true,
+ (UInt8*) resourcesPath,
+ MAXPATHLEN))
+ {
+ CFRelease(resourcesURL);
+ return;
+ }
+
+ CFRelease(resourcesURL);
+
+ chdir(resourcesPath);
+}
+
+// Create key code translation tables
+//
+static void createKeyTables(void)
+{
+ int scancode;
+
+ memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
+ memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
+
+ _glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
+ _glfw.ns.keycodes[0x12] = GLFW_KEY_1;
+ _glfw.ns.keycodes[0x13] = GLFW_KEY_2;
+ _glfw.ns.keycodes[0x14] = GLFW_KEY_3;
+ _glfw.ns.keycodes[0x15] = GLFW_KEY_4;
+ _glfw.ns.keycodes[0x17] = GLFW_KEY_5;
+ _glfw.ns.keycodes[0x16] = GLFW_KEY_6;
+ _glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
+ _glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
+ _glfw.ns.keycodes[0x19] = GLFW_KEY_9;
+ _glfw.ns.keycodes[0x00] = GLFW_KEY_A;
+ _glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
+ _glfw.ns.keycodes[0x08] = GLFW_KEY_C;
+ _glfw.ns.keycodes[0x02] = GLFW_KEY_D;
+ _glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
+ _glfw.ns.keycodes[0x03] = GLFW_KEY_F;
+ _glfw.ns.keycodes[0x05] = GLFW_KEY_G;
+ _glfw.ns.keycodes[0x04] = GLFW_KEY_H;
+ _glfw.ns.keycodes[0x22] = GLFW_KEY_I;
+ _glfw.ns.keycodes[0x26] = GLFW_KEY_J;
+ _glfw.ns.keycodes[0x28] = GLFW_KEY_K;
+ _glfw.ns.keycodes[0x25] = GLFW_KEY_L;
+ _glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
+ _glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
+ _glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
+ _glfw.ns.keycodes[0x23] = GLFW_KEY_P;
+ _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
+ _glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
+ _glfw.ns.keycodes[0x01] = GLFW_KEY_S;
+ _glfw.ns.keycodes[0x11] = GLFW_KEY_T;
+ _glfw.ns.keycodes[0x20] = GLFW_KEY_U;
+ _glfw.ns.keycodes[0x09] = GLFW_KEY_V;
+ _glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
+ _glfw.ns.keycodes[0x07] = GLFW_KEY_X;
+ _glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
+ _glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
+
+ _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
+ _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
+ _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
+ _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
+ _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
+ _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
+ _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
+ _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
+ _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
+ _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
+ _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
+ _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
+
+ _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
+ _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
+ _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
+ _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
+ _glfw.ns.keycodes[0x77] = GLFW_KEY_END;
+ _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
+ _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
+ _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
+ _glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
+ _glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
+ _glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
+ _glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
+ _glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
+ _glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
+ _glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
+ _glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
+ _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
+ _glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
+ _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
+ _glfw.ns.keycodes[0x69] = GLFW_KEY_F13;
+ _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
+ _glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
+ _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
+ _glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
+ _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
+ _glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
+ _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
+ _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
+ _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
+ _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
+ _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
+ _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
+ _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
+ _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
+ _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
+ _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
+ _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
+ _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
+ _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
+ _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
+ _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
+ _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
+ _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
+ _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
+ _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
+ _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
+
+ _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
+ _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
+ _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
+ _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
+ _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
+ _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
+ _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
+ _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
+ _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
+ _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
+ _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
+ _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
+ _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
+ _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
+ _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
+ _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
+ _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
+
+ for (scancode = 0; scancode < 256; scancode++)
+ {
+ // Store the reverse translation for faster key name lookup
+ if (_glfw.ns.keycodes[scancode] >= 0)
+ _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
+ }
+}
+
+// Retrieve Unicode data for the current keyboard layout
+//
+static GLFWbool updateUnicodeDataNS(void)
+{
+ if (_glfw.ns.inputSource)
+ {
+ CFRelease(_glfw.ns.inputSource);
+ _glfw.ns.inputSource = NULL;
+ _glfw.ns.unicodeData = nil;
+ }
+
+ _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
+ if (!_glfw.ns.inputSource)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to retrieve keyboard layout input source");
+ return GLFW_FALSE;
+ }
+
+ _glfw.ns.unicodeData =
+ TISGetInputSourceProperty(_glfw.ns.inputSource,
+ kTISPropertyUnicodeKeyLayoutData);
+ if (!_glfw.ns.unicodeData)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to retrieve keyboard layout Unicode data");
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+// Load HIToolbox.framework and the TIS symbols we need from it
+//
+static GLFWbool initializeTIS(void)
+{
+ // This works only because Cocoa has already loaded it properly
+ _glfw.ns.tis.bundle =
+ CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
+ if (!_glfw.ns.tis.bundle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to load HIToolbox.framework");
+ return GLFW_FALSE;
+ }
+
+ CFStringRef* kPropertyUnicodeKeyLayoutData =
+ CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
+ CFSTR("kTISPropertyUnicodeKeyLayoutData"));
+ _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
+ CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
+ CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
+ _glfw.ns.tis.GetInputSourceProperty =
+ CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
+ CFSTR("TISGetInputSourceProperty"));
+ _glfw.ns.tis.GetKbdType =
+ CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
+ CFSTR("LMGetKbdType"));
+
+ if (!kPropertyUnicodeKeyLayoutData ||
+ !TISCopyCurrentKeyboardLayoutInputSource ||
+ !TISGetInputSourceProperty ||
+ !LMGetKbdType)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to load TIS API symbols");
+ return GLFW_FALSE;
+ }
+
+ _glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
+ *kPropertyUnicodeKeyLayoutData;
+
+ return updateUnicodeDataNS();
+}
+
+@interface GLFWHelper : NSObject
+@end
+
+@implementation GLFWHelper
+
+- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
+{
+ updateUnicodeDataNS();
+}
+
+- (void)doNothing:(id)object
+{
+}
+
+@end // GLFWHelper
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformInit(void)
+{
+ _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];
+ _glfw.ns.helper = [[GLFWHelper alloc] init];
+
+ [NSThread detachNewThreadSelector:@selector(doNothing:)
+ toTarget:_glfw.ns.helper
+ withObject:nil];
+
+ [NSApplication sharedApplication];
+
+ NSEvent* (^block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
+ {
+ if ([event modifierFlags] & NSEventModifierFlagCommand)
+ [[NSApp keyWindow] sendEvent:event];
+
+ return event;
+ };
+
+ _glfw.ns.keyUpMonitor =
+ [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp
+ handler:block];
+
+ if (_glfw.hints.init.ns.chdir)
+ changeToResourcesDirectory();
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:_glfw.ns.helper
+ selector:@selector(selectedKeyboardInputSourceChanged:)
+ name:NSTextInputContextKeyboardSelectionDidChangeNotification
+ object:nil];
+
+ createKeyTables();
+
+ _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
+ if (!_glfw.ns.eventSource)
+ return GLFW_FALSE;
+
+ CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
+
+ if (!initializeTIS())
+ return GLFW_FALSE;
+
+ _glfwInitTimerNS();
+ _glfwInitJoysticksNS();
+
+ _glfwPollMonitorsNS();
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformTerminate(void)
+{
+ if (_glfw.ns.inputSource)
+ {
+ CFRelease(_glfw.ns.inputSource);
+ _glfw.ns.inputSource = NULL;
+ _glfw.ns.unicodeData = nil;
+ }
+
+ if (_glfw.ns.eventSource)
+ {
+ CFRelease(_glfw.ns.eventSource);
+ _glfw.ns.eventSource = NULL;
+ }
+
+ if (_glfw.ns.delegate)
+ {
+ [NSApp setDelegate:nil];
+ [_glfw.ns.delegate release];
+ _glfw.ns.delegate = nil;
+ }
+
+ if (_glfw.ns.helper)
+ {
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:_glfw.ns.helper
+ name:NSTextInputContextKeyboardSelectionDidChangeNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:_glfw.ns.helper];
+ [_glfw.ns.helper release];
+ _glfw.ns.helper = nil;
+ }
+
+ if (_glfw.ns.keyUpMonitor)
+ [NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
+
+ free(_glfw.ns.clipboardString);
+
+ _glfwTerminateNSGL();
+ _glfwTerminateJoysticksNS();
+
+ [_glfw.ns.autoreleasePool release];
+ _glfw.ns.autoreleasePool = nil;
+}
+
+const char* _glfwPlatformGetVersionString(void)
+{
+ return _GLFW_VERSION_NUMBER " Cocoa NSGL"
+#if defined(_GLFW_BUILD_DLL)
+ " dynamic"
+#endif
+ ;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.h b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.h
new file mode 100644
index 0000000..d18d032
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.h
@@ -0,0 +1,50 @@
+//========================================================================
+// GLFW 3.3 Cocoa - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <IOKit/IOKitLib.h>
+#include <IOKit/IOCFPlugIn.h>
+#include <IOKit/hid/IOHIDLib.h>
+#include <IOKit/hid/IOHIDKeys.h>
+
+#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
+#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
+
+#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
+
+// Cocoa-specific per-joystick data
+//
+typedef struct _GLFWjoystickNS
+{
+ IOHIDDeviceRef device;
+ CFMutableArrayRef axes;
+ CFMutableArrayRef buttons;
+ CFMutableArrayRef hats;
+} _GLFWjoystickNS;
+
+
+void _glfwInitJoysticksNS(void);
+void _glfwTerminateJoysticksNS(void);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.m b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.m
new file mode 100644
index 0000000..0831809
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_joystick.m
@@ -0,0 +1,462 @@
+//========================================================================
+// GLFW 3.3 Cocoa - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <unistd.h>
+#include <ctype.h>
+#include <string.h>
+
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
+
+
+// Joystick element information
+//
+typedef struct _GLFWjoyelementNS
+{
+ IOHIDElementRef native;
+ uint32_t usage;
+ int index;
+ long minimum;
+ long maximum;
+
+} _GLFWjoyelementNS;
+
+
+// Returns the value of the specified element of the specified joystick
+//
+static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
+{
+ IOHIDValueRef valueRef;
+ long value = 0;
+
+ if (js->ns.device)
+ {
+ if (IOHIDDeviceGetValue(js->ns.device,
+ element->native,
+ &valueRef) == kIOReturnSuccess)
+ {
+ value = IOHIDValueGetIntegerValue(valueRef);
+ }
+ }
+
+ return value;
+}
+
+// Comparison function for matching the SDL element order
+//
+static CFComparisonResult compareElements(const void* fp,
+ const void* sp,
+ void* user)
+{
+ const _GLFWjoyelementNS* fe = fp;
+ const _GLFWjoyelementNS* se = sp;
+ if (fe->usage < se->usage)
+ return kCFCompareLessThan;
+ if (fe->usage > se->usage)
+ return kCFCompareGreaterThan;
+ if (fe->index < se->index)
+ return kCFCompareLessThan;
+ if (fe->index > se->index)
+ return kCFCompareGreaterThan;
+ return kCFCompareEqualTo;
+}
+
+// Removes the specified joystick
+//
+static void closeJoystick(_GLFWjoystick* js)
+{
+ int i;
+
+ if (!js->present)
+ return;
+
+ for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
+ free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
+ CFRelease(js->ns.axes);
+
+ for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
+ free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
+ CFRelease(js->ns.buttons);
+
+ for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
+ free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
+ CFRelease(js->ns.hats);
+
+ _glfwFreeJoystick(js);
+ _glfwInputJoystick(js, GLFW_DISCONNECTED);
+}
+
+// Callback for user-initiated joystick addition
+//
+static void matchCallback(void* context,
+ IOReturn result,
+ void* sender,
+ IOHIDDeviceRef device)
+{
+ int jid;
+ char name[256];
+ char guid[33];
+ CFIndex i;
+ CFTypeRef property;
+ uint32_t vendor = 0, product = 0, version = 0;
+ _GLFWjoystick* js;
+ CFMutableArrayRef axes, buttons, hats;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ if (_glfw.joysticks[jid].ns.device == device)
+ return;
+ }
+
+ axes = CFArrayCreateMutable(NULL, 0, NULL);
+ buttons = CFArrayCreateMutable(NULL, 0, NULL);
+ hats = CFArrayCreateMutable(NULL, 0, NULL);
+
+ property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
+ if (property)
+ {
+ CFStringGetCString(property,
+ name,
+ sizeof(name),
+ kCFStringEncodingUTF8);
+ }
+ else
+ strncpy(name, "Unknown", sizeof(name));
+
+ property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey));
+ if (property)
+ CFNumberGetValue(property, kCFNumberSInt32Type, &vendor);
+
+ property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
+ if (property)
+ CFNumberGetValue(property, kCFNumberSInt32Type, &product);
+
+ property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVersionNumberKey));
+ if (property)
+ CFNumberGetValue(property, kCFNumberSInt32Type, &version);
+
+ // Generate a joystick GUID that matches the SDL 2.0.5+ one
+ if (vendor && product)
+ {
+ sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
+ (uint8_t) vendor, (uint8_t) (vendor >> 8),
+ (uint8_t) product, (uint8_t) (product >> 8),
+ (uint8_t) version, (uint8_t) (version >> 8));
+ }
+ else
+ {
+ sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
+ name[0], name[1], name[2], name[3],
+ name[4], name[5], name[6], name[7],
+ name[8], name[9], name[10]);
+ }
+
+ CFArrayRef elements =
+ IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
+
+ for (i = 0; i < CFArrayGetCount(elements); i++)
+ {
+ IOHIDElementRef native = (IOHIDElementRef)
+ CFArrayGetValueAtIndex(elements, i);
+ if (CFGetTypeID(native) != IOHIDElementGetTypeID())
+ continue;
+
+ const IOHIDElementType type = IOHIDElementGetType(native);
+ if ((type != kIOHIDElementTypeInput_Axis) &&
+ (type != kIOHIDElementTypeInput_Button) &&
+ (type != kIOHIDElementTypeInput_Misc))
+ {
+ continue;
+ }
+
+ CFMutableArrayRef target = NULL;
+
+ const uint32_t usage = IOHIDElementGetUsage(native);
+ const uint32_t page = IOHIDElementGetUsagePage(native);
+ if (page == kHIDPage_GenericDesktop)
+ {
+ switch (usage)
+ {
+ case kHIDUsage_GD_X:
+ case kHIDUsage_GD_Y:
+ case kHIDUsage_GD_Z:
+ case kHIDUsage_GD_Rx:
+ case kHIDUsage_GD_Ry:
+ case kHIDUsage_GD_Rz:
+ case kHIDUsage_GD_Slider:
+ case kHIDUsage_GD_Dial:
+ case kHIDUsage_GD_Wheel:
+ target = axes;
+ break;
+ case kHIDUsage_GD_Hatswitch:
+ target = hats;
+ break;
+ }
+ }
+ else if (page == kHIDPage_Button)
+ target = buttons;
+
+ if (target)
+ {
+ _GLFWjoyelementNS* element = calloc(1, sizeof(_GLFWjoyelementNS));
+ element->native = native;
+ element->usage = usage;
+ element->index = (int) CFArrayGetCount(target);
+ element->minimum = IOHIDElementGetLogicalMin(native);
+ element->maximum = IOHIDElementGetLogicalMax(native);
+ CFArrayAppendValue(target, element);
+ }
+ }
+
+ CFRelease(elements);
+
+ CFArraySortValues(axes, CFRangeMake(0, CFArrayGetCount(axes)),
+ compareElements, NULL);
+ CFArraySortValues(buttons, CFRangeMake(0, CFArrayGetCount(buttons)),
+ compareElements, NULL);
+ CFArraySortValues(hats, CFRangeMake(0, CFArrayGetCount(hats)),
+ compareElements, NULL);
+
+ js = _glfwAllocJoystick(name, guid,
+ (int) CFArrayGetCount(axes),
+ (int) CFArrayGetCount(buttons),
+ (int) CFArrayGetCount(hats));
+
+ js->ns.device = device;
+ js->ns.axes = axes;
+ js->ns.buttons = buttons;
+ js->ns.hats = hats;
+
+ _glfwInputJoystick(js, GLFW_CONNECTED);
+}
+
+// Callback for user-initiated joystick removal
+//
+static void removeCallback(void* context,
+ IOReturn result,
+ void* sender,
+ IOHIDDeviceRef device)
+{
+ int jid;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ if (_glfw.joysticks[jid].ns.device == device)
+ {
+ closeJoystick(_glfw.joysticks + jid);
+ break;
+ }
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize joystick interface
+//
+void _glfwInitJoysticksNS(void)
+{
+ CFMutableArrayRef matching;
+ const long usages[] =
+ {
+ kHIDUsage_GD_Joystick,
+ kHIDUsage_GD_GamePad,
+ kHIDUsage_GD_MultiAxisController
+ };
+
+ _glfw.ns.hidManager = IOHIDManagerCreate(kCFAllocatorDefault,
+ kIOHIDOptionsTypeNone);
+
+ matching = CFArrayCreateMutable(kCFAllocatorDefault,
+ 0,
+ &kCFTypeArrayCallBacks);
+ if (!matching)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
+ return;
+ }
+
+ for (int i = 0; i < sizeof(usages) / sizeof(long); i++)
+ {
+ const long page = kHIDPage_GenericDesktop;
+
+ CFMutableDictionaryRef dict =
+ CFDictionaryCreateMutable(kCFAllocatorDefault,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ if (!dict)
+ continue;
+
+ CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberLongType,
+ &page);
+ CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberLongType,
+ &usages[i]);
+ if (pageRef && usageRef)
+ {
+ CFDictionarySetValue(dict,
+ CFSTR(kIOHIDDeviceUsagePageKey),
+ pageRef);
+ CFDictionarySetValue(dict,
+ CFSTR(kIOHIDDeviceUsageKey),
+ usageRef);
+ CFArrayAppendValue(matching, dict);
+ }
+
+ if (pageRef)
+ CFRelease(pageRef);
+ if (usageRef)
+ CFRelease(usageRef);
+
+ CFRelease(dict);
+ }
+
+ IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns.hidManager, matching);
+ CFRelease(matching);
+
+ IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager,
+ &matchCallback, NULL);
+ IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager,
+ &removeCallback, NULL);
+ IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager,
+ CFRunLoopGetMain(),
+ kCFRunLoopDefaultMode);
+ IOHIDManagerOpen(_glfw.ns.hidManager, kIOHIDOptionsTypeNone);
+
+ // Execute the run loop once in order to register any initially-attached
+ // joysticks
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
+}
+
+// Close all opened joystick handles
+//
+void _glfwTerminateJoysticksNS(void)
+{
+ int jid;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ closeJoystick(_glfw.joysticks + jid);
+
+ CFRelease(_glfw.ns.hidManager);
+ _glfw.ns.hidManager = NULL;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
+{
+ if (mode & _GLFW_POLL_AXES)
+ {
+ CFIndex i;
+
+ for (i = 0; i < CFArrayGetCount(js->ns.axes); i++)
+ {
+ _GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
+ CFArrayGetValueAtIndex(js->ns.axes, i);
+
+ const long raw = getElementValue(js, axis);
+ // Perform auto calibration
+ if (raw < axis->minimum)
+ axis->minimum = raw;
+ if (raw > axis->maximum)
+ axis->maximum = raw;
+
+ const long delta = axis->maximum - axis->minimum;
+ if (delta == 0)
+ _glfwInputJoystickAxis(js, (int) i, 0.f);
+ else
+ {
+ const float value = (2.f * (raw - axis->minimum) / delta) - 1.f;
+ _glfwInputJoystickAxis(js, (int) i, value);
+ }
+ }
+ }
+
+ if (mode & _GLFW_POLL_BUTTONS)
+ {
+ CFIndex i;
+
+ for (i = 0; i < CFArrayGetCount(js->ns.buttons); i++)
+ {
+ _GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
+ CFArrayGetValueAtIndex(js->ns.buttons, i);
+ const char value = getElementValue(js, button) - button->minimum;
+ _glfwInputJoystickButton(js, (int) i, value);
+ }
+
+ for (i = 0; i < CFArrayGetCount(js->ns.hats); i++)
+ {
+ const int states[9] =
+ {
+ GLFW_HAT_UP,
+ GLFW_HAT_RIGHT_UP,
+ GLFW_HAT_RIGHT,
+ GLFW_HAT_RIGHT_DOWN,
+ GLFW_HAT_DOWN,
+ GLFW_HAT_LEFT_DOWN,
+ GLFW_HAT_LEFT,
+ GLFW_HAT_LEFT_UP,
+ GLFW_HAT_CENTERED
+ };
+
+ _GLFWjoyelementNS* hat = (_GLFWjoyelementNS*)
+ CFArrayGetValueAtIndex(js->ns.hats, i);
+ long state = getElementValue(js, hat) - hat->minimum;
+ if (state < 0 || state > 8)
+ state = 8;
+
+ _glfwInputJoystickHat(js, (int) i, states[state]);
+ }
+ }
+
+ return js->present;
+}
+
+void _glfwPlatformUpdateGamepadGUID(char* guid)
+{
+ if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
+ (strncmp(guid + 20, "000000000000", 12) == 0))
+ {
+ char original[33];
+ strcpy(original, guid);
+ sprintf(guid, "03000000%.4s0000%.4s000000000000",
+ original, original + 16);
+ }
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_monitor.m b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_monitor.m
new file mode 100644
index 0000000..39fff6f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_monitor.m
@@ -0,0 +1,527 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdlib.h>
+#include <limits.h>
+
+#include <IOKit/graphics/IOGraphicsLib.h>
+#include <CoreVideo/CVBase.h>
+#include <CoreVideo/CVDisplayLink.h>
+#include <ApplicationServices/ApplicationServices.h>
+
+
+// Get the name of the specified display, or NULL
+//
+static char* getDisplayName(CGDirectDisplayID displayID)
+{
+ io_iterator_t it;
+ io_service_t service;
+ CFDictionaryRef info;
+
+ if (IOServiceGetMatchingServices(kIOMasterPortDefault,
+ IOServiceMatching("IODisplayConnect"),
+ &it) != 0)
+ {
+ // This may happen if a desktop Mac is running headless
+ return NULL;
+ }
+
+ while ((service = IOIteratorNext(it)) != 0)
+ {
+ info = IODisplayCreateInfoDictionary(service,
+ kIODisplayOnlyPreferredName);
+
+ CFNumberRef vendorIDRef =
+ CFDictionaryGetValue(info, CFSTR(kDisplayVendorID));
+ CFNumberRef productIDRef =
+ CFDictionaryGetValue(info, CFSTR(kDisplayProductID));
+ if (!vendorIDRef || !productIDRef)
+ {
+ CFRelease(info);
+ continue;
+ }
+
+ unsigned int vendorID, productID;
+ CFNumberGetValue(vendorIDRef, kCFNumberIntType, &vendorID);
+ CFNumberGetValue(productIDRef, kCFNumberIntType, &productID);
+
+ if (CGDisplayVendorNumber(displayID) == vendorID &&
+ CGDisplayModelNumber(displayID) == productID)
+ {
+ // Info dictionary is used and freed below
+ break;
+ }
+
+ CFRelease(info);
+ }
+
+ IOObjectRelease(it);
+
+ if (!service)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to find service port for display");
+ return NULL;
+ }
+
+ CFDictionaryRef names =
+ CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
+
+ CFStringRef nameRef;
+
+ if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
+ (const void**) &nameRef))
+ {
+ // This may happen if a desktop Mac is running headless
+ CFRelease(info);
+ return NULL;
+ }
+
+ const CFIndex size =
+ CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
+ kCFStringEncodingUTF8);
+ char* name = calloc(size + 1, 1);
+ CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
+
+ CFRelease(info);
+ return name;
+}
+
+// Check whether the display mode should be included in enumeration
+//
+static GLFWbool modeIsGood(CGDisplayModeRef mode)
+{
+ uint32_t flags = CGDisplayModeGetIOFlags(mode);
+
+ if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
+ return GLFW_FALSE;
+ if (flags & kDisplayModeInterlacedFlag)
+ return GLFW_FALSE;
+ if (flags & kDisplayModeStretchedFlag)
+ return GLFW_FALSE;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
+ CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
+ if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
+ CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
+ {
+ CFRelease(format);
+ return GLFW_FALSE;
+ }
+
+ CFRelease(format);
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
+ return GLFW_TRUE;
+}
+
+// Convert Core Graphics display mode to GLFW video mode
+//
+static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
+ CVDisplayLinkRef link)
+{
+ GLFWvidmode result;
+ result.width = (int) CGDisplayModeGetWidth(mode);
+ result.height = (int) CGDisplayModeGetHeight(mode);
+ result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
+
+ if (result.refreshRate == 0)
+ {
+ const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
+ if (!(time.flags & kCVTimeIsIndefinite))
+ result.refreshRate = (int) (time.timeScale / (double) time.timeValue);
+ }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
+ CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
+ if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
+ {
+ result.redBits = 5;
+ result.greenBits = 5;
+ result.blueBits = 5;
+ }
+ else
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
+ {
+ result.redBits = 8;
+ result.greenBits = 8;
+ result.blueBits = 8;
+ }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
+ CFRelease(format);
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
+ return result;
+}
+
+// Starts reservation for display fading
+//
+static CGDisplayFadeReservationToken beginFadeReservation(void)
+{
+ CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;
+
+ if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)
+ {
+ CGDisplayFade(token, 0.3,
+ kCGDisplayBlendNormal,
+ kCGDisplayBlendSolidColor,
+ 0.0, 0.0, 0.0,
+ TRUE);
+ }
+
+ return token;
+}
+
+// Ends reservation for display fading
+//
+static void endFadeReservation(CGDisplayFadeReservationToken token)
+{
+ if (token != kCGDisplayFadeReservationInvalidToken)
+ {
+ CGDisplayFade(token, 0.5,
+ kCGDisplayBlendSolidColor,
+ kCGDisplayBlendNormal,
+ 0.0, 0.0, 0.0,
+ FALSE);
+ CGReleaseDisplayFadeReservation(token);
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Poll for changes in the set of connected monitors
+//
+void _glfwPollMonitorsNS(void)
+{
+ uint32_t i, j, displayCount, disconnectedCount;
+ CGDirectDisplayID* displays;
+ _GLFWmonitor** disconnected = NULL;
+
+ CGGetOnlineDisplayList(0, NULL, &displayCount);
+ displays = calloc(displayCount, sizeof(CGDirectDisplayID));
+ CGGetOnlineDisplayList(displayCount, displays, &displayCount);
+
+ for (i = 0; i < _glfw.monitorCount; i++)
+ _glfw.monitors[i]->ns.screen = nil;
+
+ disconnectedCount = _glfw.monitorCount;
+ if (disconnectedCount)
+ {
+ disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
+ memcpy(disconnected,
+ _glfw.monitors,
+ _glfw.monitorCount * sizeof(_GLFWmonitor*));
+ }
+
+ for (i = 0; i < displayCount; i++)
+ {
+ _GLFWmonitor* monitor;
+ const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
+
+ if (CGDisplayIsAsleep(displays[i]))
+ continue;
+
+ for (j = 0; j < disconnectedCount; j++)
+ {
+ // HACK: Compare unit numbers instead of display IDs to work around
+ // display replacement on machines with automatic graphics
+ // switching
+ if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
+ {
+ disconnected[j] = NULL;
+ break;
+ }
+ }
+
+ const CGSize size = CGDisplayScreenSize(displays[i]);
+ char* name = getDisplayName(displays[i]);
+ if (!name)
+ name = _glfw_strdup("Unknown");
+
+ monitor = _glfwAllocMonitor(name, size.width, size.height);
+ monitor->ns.displayID = displays[i];
+ monitor->ns.unitNumber = unitNumber;
+
+ free(name);
+
+ _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
+ }
+
+ for (i = 0; i < disconnectedCount; i++)
+ {
+ if (disconnected[i])
+ _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
+ }
+
+ free(disconnected);
+ free(displays);
+}
+
+// Change the current video mode
+//
+void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
+{
+ CFArrayRef modes;
+ CFIndex count, i;
+ CVDisplayLinkRef link;
+ CGDisplayModeRef native = NULL;
+ GLFWvidmode current;
+ const GLFWvidmode* best;
+
+ best = _glfwChooseVideoMode(monitor, desired);
+ _glfwPlatformGetVideoMode(monitor, &current);
+ if (_glfwCompareVideoModes(&current, best) == 0)
+ return;
+
+ CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
+
+ modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
+ count = CFArrayGetCount(modes);
+
+ for (i = 0; i < count; i++)
+ {
+ CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
+ if (!modeIsGood(dm))
+ continue;
+
+ const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
+ if (_glfwCompareVideoModes(best, &mode) == 0)
+ {
+ native = dm;
+ break;
+ }
+ }
+
+ if (native)
+ {
+ if (monitor->ns.previousMode == NULL)
+ monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
+
+ CGDisplayFadeReservationToken token = beginFadeReservation();
+ CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
+ endFadeReservation(token);
+ }
+
+ CFRelease(modes);
+ CVDisplayLinkRelease(link);
+}
+
+// Restore the previously saved (original) video mode
+//
+void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
+{
+ if (monitor->ns.previousMode)
+ {
+ CGDisplayFadeReservationToken token = beginFadeReservation();
+ CGDisplaySetDisplayMode(monitor->ns.displayID,
+ monitor->ns.previousMode, NULL);
+ endFadeReservation(token);
+
+ CGDisplayModeRelease(monitor->ns.previousMode);
+ monitor->ns.previousMode = NULL;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
+{
+}
+
+void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
+{
+ const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
+
+ if (xpos)
+ *xpos = (int) bounds.origin.x;
+ if (ypos)
+ *ypos = (int) bounds.origin.y;
+}
+
+void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
+ float* xscale, float* yscale)
+{
+ if (!monitor->ns.screen)
+ {
+ NSUInteger i;
+ NSArray* screens = [NSScreen screens];
+
+ for (i = 0; i < [screens count]; i++)
+ {
+ NSScreen* screen = [screens objectAtIndex:i];
+ NSNumber* displayID =
+ [[screen deviceDescription] objectForKey:@"NSScreenNumber"];
+
+ // HACK: Compare unit numbers instead of display IDs to work around
+ // display replacement on machines with automatic graphics
+ // switching
+ if (monitor->ns.unitNumber ==
+ CGDisplayUnitNumber([displayID unsignedIntValue]))
+ {
+ monitor->ns.screen = screen;
+ break;
+ }
+ }
+
+ if (i == [screens count])
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to find a screen for monitor");
+ return;
+ }
+ }
+
+ const NSRect points = [monitor->ns.screen frame];
+ const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
+
+ if (xscale)
+ *xscale = (float) (pixels.size.width / points.size.width);
+ if (yscale)
+ *yscale = (float) (pixels.size.height / points.size.height);
+}
+
+GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
+{
+ CFArrayRef modes;
+ CFIndex found, i, j;
+ GLFWvidmode* result;
+ CVDisplayLinkRef link;
+
+ *count = 0;
+
+ CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
+
+ modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
+ found = CFArrayGetCount(modes);
+ result = calloc(found, sizeof(GLFWvidmode));
+
+ for (i = 0; i < found; i++)
+ {
+ CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
+ if (!modeIsGood(dm))
+ continue;
+
+ const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
+
+ for (j = 0; j < *count; j++)
+ {
+ if (_glfwCompareVideoModes(result + j, &mode) == 0)
+ break;
+ }
+
+ // Skip duplicate modes
+ if (i < *count)
+ continue;
+
+ (*count)++;
+ result[*count - 1] = mode;
+ }
+
+ CFRelease(modes);
+ CVDisplayLinkRelease(link);
+ return result;
+}
+
+void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
+{
+ CGDisplayModeRef displayMode;
+ CVDisplayLinkRef link;
+
+ CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
+
+ displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
+ *mode = vidmodeFromCGDisplayMode(displayMode, link);
+ CGDisplayModeRelease(displayMode);
+
+ CVDisplayLinkRelease(link);
+}
+
+GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
+{
+ uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
+ CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
+
+ CGGetDisplayTransferByTable(monitor->ns.displayID,
+ size,
+ values,
+ values + size,
+ values + size * 2,
+ &size);
+
+ _glfwAllocGammaArrays(ramp, size);
+
+ for (i = 0; i < size; i++)
+ {
+ ramp->red[i] = (unsigned short) (values[i] * 65535);
+ ramp->green[i] = (unsigned short) (values[i + size] * 65535);
+ ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535);
+ }
+
+ free(values);
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
+{
+ int i;
+ CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
+
+ for (i = 0; i < ramp->size; i++)
+ {
+ values[i] = ramp->red[i] / 65535.f;
+ values[i + ramp->size] = ramp->green[i] / 65535.f;
+ values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
+ }
+
+ CGSetDisplayTransferByTable(monitor->ns.displayID,
+ ramp->size,
+ values,
+ values + ramp->size,
+ values + ramp->size * 2);
+
+ free(values);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
+ return monitor->ns.displayID;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_platform.h b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_platform.h
new file mode 100644
index 0000000..13adaa9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_platform.h
@@ -0,0 +1,169 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <stdint.h>
+#include <dlfcn.h>
+
+#include <Carbon/Carbon.h>
+#if defined(__OBJC__)
+#import <Cocoa/Cocoa.h>
+#else
+typedef void* id;
+#endif
+
+typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
+
+typedef struct VkMacOSSurfaceCreateInfoMVK
+{
+ VkStructureType sType;
+ const void* pNext;
+ VkMacOSSurfaceCreateFlagsMVK flags;
+ const void* pView;
+} VkMacOSSurfaceCreateInfoMVK;
+
+typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
+
+#include "posix_thread.h"
+#include "cocoa_joystick.h"
+#include "nsgl_context.h"
+#include "egl_context.h"
+#include "osmesa_context.h"
+
+#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
+#define _glfw_dlclose(handle) dlclose(handle)
+#define _glfw_dlsym(handle, name) dlsym(handle, name)
+
+#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view)
+#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
+
+#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
+#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
+#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns
+#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns
+#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns
+
+// HIToolbox.framework pointer typedefs
+#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
+typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
+#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
+typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
+#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
+typedef UInt8 (*PFN_LMGetKbdType)(void);
+#define LMGetKbdType _glfw.ns.tis.GetKbdType
+
+
+// Cocoa-specific per-window data
+//
+typedef struct _GLFWwindowNS
+{
+ id object;
+ id delegate;
+ id view;
+ id layer;
+
+ GLFWbool maximized;
+
+ // Cached window properties to filter out duplicate events
+ int width, height;
+ int fbWidth, fbHeight;
+ float xscale, yscale;
+
+ // The total sum of the distances the cursor has been warped
+ // since the last cursor motion event was processed
+ // This is kept to counteract Cocoa doing the same internally
+ double cursorWarpDeltaX, cursorWarpDeltaY;
+
+} _GLFWwindowNS;
+
+// Cocoa-specific global data
+//
+typedef struct _GLFWlibraryNS
+{
+ CGEventSourceRef eventSource;
+ id delegate;
+ id autoreleasePool;
+ GLFWbool cursorHidden;
+ TISInputSourceRef inputSource;
+ IOHIDManagerRef hidManager;
+ id unicodeData;
+ id helper;
+ id keyUpMonitor;
+ id nibObjects;
+
+ char keyName[64];
+ short int keycodes[256];
+ short int scancodes[GLFW_KEY_LAST + 1];
+ char* clipboardString;
+ CGPoint cascadePoint;
+ // Where to place the cursor when re-enabled
+ double restoreCursorPosX, restoreCursorPosY;
+ // The window whose disabled cursor mode is active
+ _GLFWwindow* disabledCursorWindow;
+
+ struct {
+ CFBundleRef bundle;
+ PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
+ PFN_TISGetInputSourceProperty GetInputSourceProperty;
+ PFN_LMGetKbdType GetKbdType;
+ CFStringRef kPropertyUnicodeKeyLayoutData;
+ } tis;
+
+} _GLFWlibraryNS;
+
+// Cocoa-specific per-monitor data
+//
+typedef struct _GLFWmonitorNS
+{
+ CGDirectDisplayID displayID;
+ CGDisplayModeRef previousMode;
+ uint32_t unitNumber;
+ id screen;
+
+} _GLFWmonitorNS;
+
+// Cocoa-specific per-cursor data
+//
+typedef struct _GLFWcursorNS
+{
+ id object;
+
+} _GLFWcursorNS;
+
+// Cocoa-specific global timer data
+//
+typedef struct _GLFWtimerNS
+{
+ uint64_t frequency;
+
+} _GLFWtimerNS;
+
+
+void _glfwInitTimerNS(void);
+
+void _glfwPollMonitorsNS(void);
+void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
+void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_time.c b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_time.c
new file mode 100644
index 0000000..3b27035
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_time.c
@@ -0,0 +1,60 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <mach/mach_time.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialise timer
+//
+void _glfwInitTimerNS(void)
+{
+ mach_timebase_info_data_t info;
+ mach_timebase_info(&info);
+
+ _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+uint64_t _glfwPlatformGetTimerValue(void)
+{
+ return mach_absolute_time();
+}
+
+uint64_t _glfwPlatformGetTimerFrequency(void)
+{
+ return _glfw.timer.ns.frequency;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_window.m b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_window.m
new file mode 100644
index 0000000..db9935c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/cocoa_window.m
@@ -0,0 +1,1855 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <float.h>
+#include <string.h>
+
+// Needed for _NSGetProgname
+#include <crt_externs.h>
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
+ #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
+ #define NSWindowStyleMaskClosable NSClosableWindowMask
+ #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
+ #define NSWindowStyleMaskResizable NSResizableWindowMask
+ #define NSWindowStyleMaskTitled NSTitledWindowMask
+ #define NSEventModifierFlagCommand NSCommandKeyMask
+ #define NSEventModifierFlagControl NSControlKeyMask
+ #define NSEventModifierFlagOption NSAlternateKeyMask
+ #define NSEventModifierFlagShift NSShiftKeyMask
+ #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
+ #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
+ #define NSEventMaskAny NSAnyEventMask
+ #define NSEventTypeApplicationDefined NSApplicationDefined
+ #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
+#endif
+
+// Returns the style mask corresponding to the window settings
+//
+static NSUInteger getStyleMask(_GLFWwindow* window)
+{
+ NSUInteger styleMask = 0;
+
+ if (window->monitor || !window->decorated)
+ styleMask |= NSWindowStyleMaskBorderless;
+ else
+ {
+ styleMask |= NSWindowStyleMaskTitled |
+ NSWindowStyleMaskClosable |
+ NSWindowStyleMaskMiniaturizable;
+
+ if (window->resizable)
+ styleMask |= NSWindowStyleMaskResizable;
+ }
+
+ return styleMask;
+}
+
+// Center the cursor in the view of the window
+//
+static void centerCursor(_GLFWwindow *window)
+{
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
+}
+
+// Returns whether the cursor is in the client area of the specified window
+//
+static GLFWbool cursorInClientArea(_GLFWwindow* window)
+{
+ const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
+ return [window->ns.view mouse:pos inRect:[window->ns.view frame]];
+}
+
+// Hides the cursor if not already hidden
+//
+static void hideCursor(_GLFWwindow* window)
+{
+ if (!_glfw.ns.cursorHidden)
+ {
+ [NSCursor hide];
+ _glfw.ns.cursorHidden = GLFW_TRUE;
+ }
+}
+
+// Shows the cursor if not already shown
+//
+static void showCursor(_GLFWwindow* window)
+{
+ if (_glfw.ns.cursorHidden)
+ {
+ [NSCursor unhide];
+ _glfw.ns.cursorHidden = GLFW_FALSE;
+ }
+}
+
+// Updates the cursor image according to its cursor mode
+//
+static void updateCursorImage(_GLFWwindow* window)
+{
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
+ {
+ showCursor(window);
+
+ if (window->cursor)
+ [(NSCursor*) window->cursor->ns.object set];
+ else
+ [[NSCursor arrowCursor] set];
+ }
+ else
+ hideCursor(window);
+}
+
+// Apply chosen cursor mode to a focused window
+//
+static void updateCursorMode(_GLFWwindow* window)
+{
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ {
+ _glfw.ns.disabledCursorWindow = window;
+ _glfwPlatformGetCursorPos(window,
+ &_glfw.ns.restoreCursorPosX,
+ &_glfw.ns.restoreCursorPosY);
+ centerCursor(window);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ }
+ else if (_glfw.ns.disabledCursorWindow == window)
+ {
+ _glfw.ns.disabledCursorWindow = NULL;
+ CGAssociateMouseAndMouseCursorPosition(true);
+ _glfwPlatformSetCursorPos(window,
+ _glfw.ns.restoreCursorPosX,
+ _glfw.ns.restoreCursorPosY);
+ }
+
+ if (cursorInClientArea(window))
+ updateCursorImage(window);
+}
+
+// Transforms the specified y-coordinate between the CG display and NS screen
+// coordinate systems
+//
+static float transformY(float y)
+{
+ return CGDisplayBounds(CGMainDisplayID()).size.height - y;
+}
+
+// Make the specified window and its video mode active on its monitor
+//
+static void acquireMonitor(_GLFWwindow* window)
+{
+ _glfwSetVideoModeNS(window->monitor, &window->videoMode);
+ const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
+ const NSRect frame = NSMakeRect(bounds.origin.x,
+ transformY(bounds.origin.y + bounds.size.height),
+ bounds.size.width,
+ bounds.size.height);
+
+ [window->ns.object setFrame:frame display:YES];
+
+ _glfwInputMonitorWindow(window->monitor, window);
+}
+
+// Remove the window and restore the original video mode
+//
+static void releaseMonitor(_GLFWwindow* window)
+{
+ if (window->monitor->window != window)
+ return;
+
+ _glfwInputMonitorWindow(window->monitor, NULL);
+ _glfwRestoreVideoModeNS(window->monitor);
+}
+
+// Translates macOS key modifiers into GLFW ones
+//
+static int translateFlags(NSUInteger flags)
+{
+ int mods = 0;
+
+ if (flags & NSEventModifierFlagShift)
+ mods |= GLFW_MOD_SHIFT;
+ if (flags & NSEventModifierFlagControl)
+ mods |= GLFW_MOD_CONTROL;
+ if (flags & NSEventModifierFlagOption)
+ mods |= GLFW_MOD_ALT;
+ if (flags & NSEventModifierFlagCommand)
+ mods |= GLFW_MOD_SUPER;
+ if (flags & NSEventModifierFlagCapsLock)
+ mods |= GLFW_MOD_CAPS_LOCK;
+
+ return mods;
+}
+
+// Translates a macOS keycode to a GLFW keycode
+//
+static int translateKey(unsigned int key)
+{
+ if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0]))
+ return GLFW_KEY_UNKNOWN;
+
+ return _glfw.ns.keycodes[key];
+}
+
+// Translate a GLFW keycode to a Cocoa modifier flag
+//
+static NSUInteger translateKeyToModifierFlag(int key)
+{
+ switch (key)
+ {
+ case GLFW_KEY_LEFT_SHIFT:
+ case GLFW_KEY_RIGHT_SHIFT:
+ return NSEventModifierFlagShift;
+ case GLFW_KEY_LEFT_CONTROL:
+ case GLFW_KEY_RIGHT_CONTROL:
+ return NSEventModifierFlagControl;
+ case GLFW_KEY_LEFT_ALT:
+ case GLFW_KEY_RIGHT_ALT:
+ return NSEventModifierFlagOption;
+ case GLFW_KEY_LEFT_SUPER:
+ case GLFW_KEY_RIGHT_SUPER:
+ return NSEventModifierFlagCommand;
+ case GLFW_KEY_CAPS_LOCK:
+ return NSEventModifierFlagCapsLock;
+ }
+
+ return 0;
+}
+
+// Defines a constant for empty ranges in NSTextInputClient
+//
+static const NSRange kEmptyRange = { NSNotFound, 0 };
+
+
+//------------------------------------------------------------------------
+// Delegate for window related notifications
+//------------------------------------------------------------------------
+
+@interface GLFWWindowDelegate : NSObject
+{
+ _GLFWwindow* window;
+}
+
+- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
+
+@end
+
+@implementation GLFWWindowDelegate
+
+- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
+{
+ self = [super init];
+ if (self != nil)
+ window = initWindow;
+
+ return self;
+}
+
+- (BOOL)windowShouldClose:(id)sender
+{
+ _glfwInputWindowCloseRequest(window);
+ return NO;
+}
+
+- (void)windowDidResize:(NSNotification *)notification
+{
+ if (window->context.client != GLFW_NO_API)
+ [window->context.nsgl.object update];
+
+ if (_glfw.ns.disabledCursorWindow == window)
+ centerCursor(window);
+
+ const int maximized = [window->ns.object isZoomed];
+ if (window->ns.maximized != maximized)
+ {
+ window->ns.maximized = maximized;
+ _glfwInputWindowMaximize(window, maximized);
+ }
+
+ const NSRect contentRect = [window->ns.view frame];
+ const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
+
+ if (fbRect.size.width != window->ns.fbWidth ||
+ fbRect.size.height != window->ns.fbHeight)
+ {
+ window->ns.fbWidth = fbRect.size.width;
+ window->ns.fbHeight = fbRect.size.height;
+ _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
+ }
+
+ if (contentRect.size.width != window->ns.width ||
+ contentRect.size.height != window->ns.height)
+ {
+ window->ns.width = contentRect.size.width;
+ window->ns.height = contentRect.size.height;
+ _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
+ }
+}
+
+- (void)windowDidMove:(NSNotification *)notification
+{
+ if (window->context.client != GLFW_NO_API)
+ [window->context.nsgl.object update];
+
+ if (_glfw.ns.disabledCursorWindow == window)
+ centerCursor(window);
+
+ int x, y;
+ _glfwPlatformGetWindowPos(window, &x, &y);
+ _glfwInputWindowPos(window, x, y);
+}
+
+- (void)windowDidMiniaturize:(NSNotification *)notification
+{
+ if (window->monitor)
+ releaseMonitor(window);
+
+ _glfwInputWindowIconify(window, GLFW_TRUE);
+}
+
+- (void)windowDidDeminiaturize:(NSNotification *)notification
+{
+ if (window->monitor)
+ acquireMonitor(window);
+
+ _glfwInputWindowIconify(window, GLFW_FALSE);
+}
+
+- (void)windowDidBecomeKey:(NSNotification *)notification
+{
+ if (_glfw.ns.disabledCursorWindow == window)
+ centerCursor(window);
+
+ _glfwInputWindowFocus(window, GLFW_TRUE);
+ updateCursorMode(window);
+}
+
+- (void)windowDidResignKey:(NSNotification *)notification
+{
+ if (window->monitor && window->autoIconify)
+ _glfwPlatformIconifyWindow(window);
+
+ _glfwInputWindowFocus(window, GLFW_FALSE);
+}
+
+@end
+
+
+//------------------------------------------------------------------------
+// Delegate for application related notifications
+//------------------------------------------------------------------------
+
+@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
+@end
+
+@implementation GLFWApplicationDelegate
+
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+{
+ _GLFWwindow* window;
+
+ for (window = _glfw.windowListHead; window; window = window->next)
+ _glfwInputWindowCloseRequest(window);
+
+ return NSTerminateCancel;
+}
+
+- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
+{
+ _GLFWwindow* window;
+
+ for (window = _glfw.windowListHead; window; window = window->next)
+ {
+ if (window->context.client != GLFW_NO_API)
+ [window->context.nsgl.object update];
+ }
+
+ _glfwPollMonitorsNS();
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)notification
+{
+ [NSApp stop:nil];
+
+ _glfwPlatformPostEmptyEvent();
+}
+
+- (void)applicationDidHide:(NSNotification *)notification
+{
+ int i;
+
+ for (i = 0; i < _glfw.monitorCount; i++)
+ _glfwRestoreVideoModeNS(_glfw.monitors[i]);
+}
+
+@end
+
+
+//------------------------------------------------------------------------
+// Content view class for the GLFW window
+//------------------------------------------------------------------------
+
+@interface GLFWContentView : NSView <NSTextInputClient>
+{
+ _GLFWwindow* window;
+ NSTrackingArea* trackingArea;
+ NSMutableAttributedString* markedText;
+}
+
+- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
+
+@end
+
+@implementation GLFWContentView
+
+- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
+{
+ self = [super init];
+ if (self != nil)
+ {
+ window = initWindow;
+ trackingArea = nil;
+ markedText = [[NSMutableAttributedString alloc] init];
+
+ [self updateTrackingAreas];
+ // NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available
+ // on 10.7 without having been deprecated yet
+ [self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [trackingArea release];
+ [markedText release];
+ [super dealloc];
+}
+
+- (BOOL)isOpaque
+{
+ return [window->ns.object isOpaque];
+}
+
+- (BOOL)canBecomeKeyView
+{
+ return YES;
+}
+
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
+- (BOOL)wantsUpdateLayer
+{
+ return YES;
+}
+
+- (void)updateLayer
+{
+ if (window->context.client != GLFW_NO_API)
+ [window->context.nsgl.object update];
+
+ _glfwInputWindowDamage(window);
+}
+
+- (id)makeBackingLayer
+{
+ if (window->ns.layer)
+ return window->ns.layer;
+
+ return [super makeBackingLayer];
+}
+
+- (void)cursorUpdate:(NSEvent *)event
+{
+ updateCursorImage(window);
+}
+
+- (BOOL)acceptsFirstMouse:(NSEvent *)event
+{
+ return YES;
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_LEFT,
+ GLFW_PRESS,
+ translateFlags([event modifierFlags]));
+}
+
+- (void)mouseDragged:(NSEvent *)event
+{
+ [self mouseMoved:event];
+}
+
+- (void)mouseUp:(NSEvent *)event
+{
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_LEFT,
+ GLFW_RELEASE,
+ translateFlags([event modifierFlags]));
+}
+
+- (void)mouseMoved:(NSEvent *)event
+{
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ {
+ const double dx = [event deltaX] - window->ns.cursorWarpDeltaX;
+ const double dy = [event deltaY] - window->ns.cursorWarpDeltaY;
+
+ _glfwInputCursorPos(window,
+ window->virtualCursorPosX + dx,
+ window->virtualCursorPosY + dy);
+ }
+ else
+ {
+ const NSRect contentRect = [window->ns.view frame];
+ const NSPoint pos = [event locationInWindow];
+
+ _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
+ }
+
+ window->ns.cursorWarpDeltaX = 0;
+ window->ns.cursorWarpDeltaY = 0;
+}
+
+- (void)rightMouseDown:(NSEvent *)event
+{
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_RIGHT,
+ GLFW_PRESS,
+ translateFlags([event modifierFlags]));
+}
+
+- (void)rightMouseDragged:(NSEvent *)event
+{
+ [self mouseMoved:event];
+}
+
+- (void)rightMouseUp:(NSEvent *)event
+{
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_RIGHT,
+ GLFW_RELEASE,
+ translateFlags([event modifierFlags]));
+}
+
+- (void)otherMouseDown:(NSEvent *)event
+{
+ _glfwInputMouseClick(window,
+ (int) [event buttonNumber],
+ GLFW_PRESS,
+ translateFlags([event modifierFlags]));
+}
+
+- (void)otherMouseDragged:(NSEvent *)event
+{
+ [self mouseMoved:event];
+}
+
+- (void)otherMouseUp:(NSEvent *)event
+{
+ _glfwInputMouseClick(window,
+ (int) [event buttonNumber],
+ GLFW_RELEASE,
+ translateFlags([event modifierFlags]));
+}
+
+- (void)mouseExited:(NSEvent *)event
+{
+ if (window->cursorMode == GLFW_CURSOR_HIDDEN)
+ showCursor(window);
+
+ _glfwInputCursorEnter(window, GLFW_FALSE);
+}
+
+- (void)mouseEntered:(NSEvent *)event
+{
+ if (window->cursorMode == GLFW_CURSOR_HIDDEN)
+ hideCursor(window);
+
+ _glfwInputCursorEnter(window, GLFW_TRUE);
+}
+
+- (void)viewDidChangeBackingProperties
+{
+ const NSRect contentRect = [window->ns.view frame];
+ const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
+
+ if (fbRect.size.width != window->ns.fbWidth ||
+ fbRect.size.height != window->ns.fbHeight)
+ {
+ window->ns.fbWidth = fbRect.size.width;
+ window->ns.fbHeight = fbRect.size.height;
+ _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
+ }
+
+ const float xscale = fbRect.size.width / contentRect.size.width;
+ const float yscale = fbRect.size.height / contentRect.size.height;
+
+ if (xscale != window->ns.xscale || yscale != window->ns.yscale)
+ {
+ window->ns.xscale = xscale;
+ window->ns.yscale = yscale;
+ _glfwInputWindowContentScale(window, xscale, yscale);
+
+ if (window->ns.layer)
+ [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
+ }
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ _glfwInputWindowDamage(window);
+}
+
+- (void)updateTrackingAreas
+{
+ if (trackingArea != nil)
+ {
+ [self removeTrackingArea:trackingArea];
+ [trackingArea release];
+ }
+
+ const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
+ NSTrackingActiveInKeyWindow |
+ NSTrackingEnabledDuringMouseDrag |
+ NSTrackingCursorUpdate |
+ NSTrackingInVisibleRect |
+ NSTrackingAssumeInside;
+
+ trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
+ options:options
+ owner:self
+ userInfo:nil];
+
+ [self addTrackingArea:trackingArea];
+ [super updateTrackingAreas];
+}
+
+- (void)keyDown:(NSEvent *)event
+{
+ const int key = translateKey([event keyCode]);
+ const int mods = translateFlags([event modifierFlags]);
+
+ _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
+
+ [self interpretKeyEvents:@[event]];
+}
+
+- (void)flagsChanged:(NSEvent *)event
+{
+ int action;
+ const unsigned int modifierFlags =
+ [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
+ const int key = translateKey([event keyCode]);
+ const int mods = translateFlags(modifierFlags);
+ const NSUInteger keyFlag = translateKeyToModifierFlag(key);
+
+ if (keyFlag & modifierFlags)
+ {
+ if (window->keys[key] == GLFW_PRESS)
+ action = GLFW_RELEASE;
+ else
+ action = GLFW_PRESS;
+ }
+ else
+ action = GLFW_RELEASE;
+
+ _glfwInputKey(window, key, [event keyCode], action, mods);
+}
+
+- (void)keyUp:(NSEvent *)event
+{
+ const int key = translateKey([event keyCode]);
+ const int mods = translateFlags([event modifierFlags]);
+ _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
+}
+
+- (void)scrollWheel:(NSEvent *)event
+{
+ double deltaX, deltaY;
+
+ deltaX = [event scrollingDeltaX];
+ deltaY = [event scrollingDeltaY];
+
+ if ([event hasPreciseScrollingDeltas])
+ {
+ deltaX *= 0.1;
+ deltaY *= 0.1;
+ }
+
+ if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
+ _glfwInputScroll(window, deltaX, deltaY);
+}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+{
+ // HACK: We don't know what to say here because we don't know what the
+ // application wants to do with the paths
+ return NSDragOperationGeneric;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
+{
+ const NSRect contentRect = [window->ns.view frame];
+ _glfwInputCursorPos(window,
+ [sender draggingLocation].x,
+ contentRect.size.height - [sender draggingLocation].y);
+
+ NSPasteboard* pasteboard = [sender draggingPasteboard];
+ NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
+ NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
+ options:options];
+ const NSUInteger count = [urls count];
+ if (count)
+ {
+ char** paths = calloc(count, sizeof(char*));
+
+ for (NSUInteger i = 0; i < count; i++)
+ paths[i] = _glfw_strdup([[urls objectAtIndex:i] fileSystemRepresentation]);
+
+ _glfwInputDrop(window, (int) count, (const char**) paths);
+
+ for (NSUInteger i = 0; i < count; i++)
+ free(paths[i]);
+ free(paths);
+ }
+
+ return YES;
+}
+
+- (BOOL)hasMarkedText
+{
+ return [markedText length] > 0;
+}
+
+- (NSRange)markedRange
+{
+ if ([markedText length] > 0)
+ return NSMakeRange(0, [markedText length] - 1);
+ else
+ return kEmptyRange;
+}
+
+- (NSRange)selectedRange
+{
+ return kEmptyRange;
+}
+
+- (void)setMarkedText:(id)string
+ selectedRange:(NSRange)selectedRange
+ replacementRange:(NSRange)replacementRange
+{
+ [markedText release];
+ if ([string isKindOfClass:[NSAttributedString class]])
+ markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string];
+ else
+ markedText = [[NSMutableAttributedString alloc] initWithString:string];
+}
+
+- (void)unmarkText
+{
+ [[markedText mutableString] setString:@""];
+}
+
+- (NSArray*)validAttributesForMarkedText
+{
+ return [NSArray array];
+}
+
+- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
+ actualRange:(NSRangePointer)actualRange
+{
+ return nil;
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)point
+{
+ return 0;
+}
+
+- (NSRect)firstRectForCharacterRange:(NSRange)range
+ actualRange:(NSRangePointer)actualRange
+{
+ int xpos, ypos;
+ _glfwPlatformGetWindowPos(window, &xpos, &ypos);
+ const NSRect contentRect = [window->ns.view frame];
+ return NSMakeRect(xpos, transformY(ypos + contentRect.size.height), 0.0, 0.0);
+}
+
+- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
+{
+ NSString* characters;
+ NSEvent* event = [NSApp currentEvent];
+ const int mods = translateFlags([event modifierFlags]);
+ const int plain = !(mods & GLFW_MOD_SUPER);
+
+ if ([string isKindOfClass:[NSAttributedString class]])
+ characters = [string string];
+ else
+ characters = (NSString*) string;
+
+ NSUInteger i, length = [characters length];
+
+ for (i = 0; i < length; i++)
+ {
+ const unichar codepoint = [characters characterAtIndex:i];
+ if ((codepoint & 0xff00) == 0xf700)
+ continue;
+
+ _glfwInputChar(window, codepoint, mods, plain);
+ }
+}
+
+- (void)doCommandBySelector:(SEL)selector
+{
+}
+
+@end
+
+
+//------------------------------------------------------------------------
+// GLFW window class
+//------------------------------------------------------------------------
+
+@interface GLFWWindow : NSWindow {}
+@end
+
+@implementation GLFWWindow
+
+- (BOOL)canBecomeKeyWindow
+{
+ // Required for NSWindowStyleMaskBorderless windows
+ return YES;
+}
+
+- (BOOL)canBecomeMainWindow
+{
+ return YES;
+}
+
+@end
+
+
+// Set up the menu bar (manually)
+// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
+// could go away at any moment, lots of stuff that really should be
+// localize(d|able), etc. Add a nib to save us this horror.
+//
+static void createMenuBar(void)
+{
+ size_t i;
+ NSString* appName = nil;
+ NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
+ NSString* nameKeys[] =
+ {
+ @"CFBundleDisplayName",
+ @"CFBundleName",
+ @"CFBundleExecutable",
+ };
+
+ // Try to figure out what the calling application is called
+
+ for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
+ {
+ id name = [bundleInfo objectForKey:nameKeys[i]];
+ if (name &&
+ [name isKindOfClass:[NSString class]] &&
+ ![name isEqualToString:@""])
+ {
+ appName = name;
+ break;
+ }
+ }
+
+ if (!appName)
+ {
+ char** progname = _NSGetProgname();
+ if (progname && *progname)
+ appName = [NSString stringWithUTF8String:*progname];
+ else
+ appName = @"GLFW Application";
+ }
+
+ NSMenu* bar = [[NSMenu alloc] init];
+ [NSApp setMainMenu:bar];
+
+ NSMenuItem* appMenuItem =
+ [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
+ NSMenu* appMenu = [[NSMenu alloc] init];
+ [appMenuItem setSubmenu:appMenu];
+
+ [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
+ action:@selector(orderFrontStandardAboutPanel:)
+ keyEquivalent:@""];
+ [appMenu addItem:[NSMenuItem separatorItem]];
+ NSMenu* servicesMenu = [[NSMenu alloc] init];
+ [NSApp setServicesMenu:servicesMenu];
+ [[appMenu addItemWithTitle:@"Services"
+ action:NULL
+ keyEquivalent:@""] setSubmenu:servicesMenu];
+ [servicesMenu release];
+ [appMenu addItem:[NSMenuItem separatorItem]];
+ [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
+ action:@selector(hide:)
+ keyEquivalent:@"h"];
+ [[appMenu addItemWithTitle:@"Hide Others"
+ action:@selector(hideOtherApplications:)
+ keyEquivalent:@"h"]
+ setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
+ [appMenu addItemWithTitle:@"Show All"
+ action:@selector(unhideAllApplications:)
+ keyEquivalent:@""];
+ [appMenu addItem:[NSMenuItem separatorItem]];
+ [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
+ action:@selector(terminate:)
+ keyEquivalent:@"q"];
+
+ NSMenuItem* windowMenuItem =
+ [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
+ [bar release];
+ NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
+ [NSApp setWindowsMenu:windowMenu];
+ [windowMenuItem setSubmenu:windowMenu];
+
+ [windowMenu addItemWithTitle:@"Minimize"
+ action:@selector(performMiniaturize:)
+ keyEquivalent:@"m"];
+ [windowMenu addItemWithTitle:@"Zoom"
+ action:@selector(performZoom:)
+ keyEquivalent:@""];
+ [windowMenu addItem:[NSMenuItem separatorItem]];
+ [windowMenu addItemWithTitle:@"Bring All to Front"
+ action:@selector(arrangeInFront:)
+ keyEquivalent:@""];
+
+ // TODO: Make this appear at the bottom of the menu (for consistency)
+ [windowMenu addItem:[NSMenuItem separatorItem]];
+ [[windowMenu addItemWithTitle:@"Enter Full Screen"
+ action:@selector(toggleFullScreen:)
+ keyEquivalent:@"f"]
+ setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
+
+ // Prior to Snow Leopard, we need to use this oddly-named semi-private API
+ // to get the application menu working properly.
+ SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
+ [NSApp performSelector:setAppleMenuSelector withObject:appMenu];
+}
+
+// Initialize the Cocoa Application Kit
+//
+static GLFWbool initializeAppKit(void)
+{
+ if (_glfw.ns.delegate)
+ return GLFW_TRUE;
+
+ // There can only be one application delegate, but we allocate it the
+ // first time a window is created to keep all window code in this file
+ _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
+ if (_glfw.ns.delegate == nil)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to create application delegate");
+ return GLFW_FALSE;
+ }
+
+ [NSApp setDelegate:_glfw.ns.delegate];
+
+ if (_glfw.hints.init.ns.menubar)
+ {
+ // In case we are unbundled, make us a proper UI application
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ // Menu bar setup must go between sharedApplication above and
+ // finishLaunching below, in order to properly emulate the behavior
+ // of NSApplicationMain
+
+ if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+ [[NSBundle mainBundle] loadNibNamed:@"MainMenu"
+ owner:NSApp
+ topLevelObjects:&_glfw.ns.nibObjects];
+#else
+ [[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:NSApp];
+#endif
+ }
+ else
+ createMenuBar();
+ }
+
+ [NSApp run];
+
+ // Press and Hold prevents some keys from emitting repeated characters
+ NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
+ [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
+
+ return GLFW_TRUE;
+}
+
+// Create the Cocoa window
+//
+static GLFWbool createNativeWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
+ if (window->ns.delegate == nil)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to create window delegate");
+ return GLFW_FALSE;
+ }
+
+ NSRect contentRect;
+
+ if (window->monitor)
+ {
+ GLFWvidmode mode;
+ int xpos, ypos;
+
+ _glfwPlatformGetVideoMode(window->monitor, &mode);
+ _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
+
+ contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
+ }
+ else
+ contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
+
+ window->ns.object = [[GLFWWindow alloc]
+ initWithContentRect:contentRect
+ styleMask:getStyleMask(window)
+ backing:NSBackingStoreBuffered
+ defer:NO];
+
+ if (window->ns.object == nil)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window");
+ return GLFW_FALSE;
+ }
+
+ if (window->monitor)
+ [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
+ else
+ {
+ [window->ns.object center];
+ _glfw.ns.cascadePoint =
+ NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
+ NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
+
+ if (wndconfig->resizable)
+ {
+ const NSWindowCollectionBehavior behavior =
+ NSWindowCollectionBehaviorFullScreenPrimary |
+ NSWindowCollectionBehaviorManaged;
+ [window->ns.object setCollectionBehavior:behavior];
+ }
+
+ if (wndconfig->floating)
+ [window->ns.object setLevel:NSFloatingWindowLevel];
+
+ if (wndconfig->maximized)
+ [window->ns.object zoom:nil];
+ }
+
+ if (strlen(wndconfig->ns.frameName))
+ [window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->ns.frameName]];
+
+ window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
+
+ if (wndconfig->ns.retina)
+ [window->ns.view setWantsBestResolutionOpenGLSurface:YES];
+
+ if (fbconfig->transparent)
+ {
+ [window->ns.object setOpaque:NO];
+ [window->ns.object setBackgroundColor:[NSColor clearColor]];
+ }
+
+ [window->ns.object setContentView:window->ns.view];
+ [window->ns.object makeFirstResponder:window->ns.view];
+ [window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
+ [window->ns.object setDelegate:window->ns.delegate];
+ [window->ns.object setAcceptsMouseMovedEvents:YES];
+ [window->ns.object setRestorable:NO];
+
+ _glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height);
+ _glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight);
+
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformCreateWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ if (!initializeAppKit())
+ return GLFW_FALSE;
+
+ if (!createNativeWindow(window, wndconfig, fbconfig))
+ return GLFW_FALSE;
+
+ if (ctxconfig->client != GLFW_NO_API)
+ {
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
+ {
+ if (!_glfwInitNSGL())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
+ {
+ if (!_glfwInitEGL())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ if (!_glfwInitOSMesa())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ }
+
+ if (window->monitor)
+ {
+ _glfwPlatformShowWindow(window);
+ _glfwPlatformFocusWindow(window);
+ acquireMonitor(window);
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyWindow(_GLFWwindow* window)
+{
+ if (_glfw.ns.disabledCursorWindow == window)
+ _glfw.ns.disabledCursorWindow = NULL;
+
+ [window->ns.object orderOut:nil];
+
+ if (window->monitor)
+ releaseMonitor(window);
+
+ if (window->context.destroy)
+ window->context.destroy(window);
+
+ [window->ns.object setDelegate:nil];
+ [window->ns.delegate release];
+ window->ns.delegate = nil;
+
+ [window->ns.view release];
+ window->ns.view = nil;
+
+ [window->ns.object close];
+ window->ns.object = nil;
+
+ [_glfw.ns.autoreleasePool drain];
+ _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];
+}
+
+void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
+{
+ NSString* string = [NSString stringWithUTF8String:title];
+ [window->ns.object setTitle:string];
+ // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
+ // if the window lacks NSWindowStyleMaskTitled
+ [window->ns.object setMiniwindowTitle:string];
+}
+
+void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
+ int count, const GLFWimage* images)
+{
+ // Regular windows do not have icons
+}
+
+void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
+{
+ const NSRect contentRect =
+ [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
+
+ if (xpos)
+ *xpos = contentRect.origin.x;
+ if (ypos)
+ *ypos = transformY(contentRect.origin.y + contentRect.size.height);
+}
+
+void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
+{
+ const NSRect contentRect = [window->ns.view frame];
+ const NSRect dummyRect = NSMakeRect(x, transformY(y + contentRect.size.height), 0, 0);
+ const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
+ [window->ns.object setFrameOrigin:frameRect.origin];
+}
+
+void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
+{
+ const NSRect contentRect = [window->ns.view frame];
+
+ if (width)
+ *width = contentRect.size.width;
+ if (height)
+ *height = contentRect.size.height;
+}
+
+void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
+{
+ if (window->monitor)
+ {
+ if (window->monitor->window == window)
+ acquireMonitor(window);
+ }
+ else
+ [window->ns.object setContentSize:NSMakeSize(width, height)];
+}
+
+void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight)
+{
+ if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
+ [window->ns.object setContentMinSize:NSMakeSize(0, 0)];
+ else
+ [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)];
+
+ if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
+ [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)];
+ else
+ [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)];
+}
+
+void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
+{
+ if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
+ [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)];
+ else
+ [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)];
+}
+
+void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
+{
+ const NSRect contentRect = [window->ns.view frame];
+ const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
+
+ if (width)
+ *width = (int) fbRect.size.width;
+ if (height)
+ *height = (int) fbRect.size.height;
+}
+
+void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
+ int* left, int* top,
+ int* right, int* bottom)
+{
+ const NSRect contentRect = [window->ns.view frame];
+ const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];
+
+ if (left)
+ *left = contentRect.origin.x - frameRect.origin.x;
+ if (top)
+ *top = frameRect.origin.y + frameRect.size.height -
+ contentRect.origin.y - contentRect.size.height;
+ if (right)
+ *right = frameRect.origin.x + frameRect.size.width -
+ contentRect.origin.x - contentRect.size.width;
+ if (bottom)
+ *bottom = contentRect.origin.y - frameRect.origin.y;
+}
+
+void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
+ float* xscale, float* yscale)
+{
+ const NSRect points = [window->ns.view frame];
+ const NSRect pixels = [window->ns.view convertRectToBacking:points];
+
+ if (xscale)
+ *xscale = (float) (pixels.size.width / points.size.width);
+ if (yscale)
+ *yscale = (float) (pixels.size.height / points.size.height);
+}
+
+void _glfwPlatformIconifyWindow(_GLFWwindow* window)
+{
+ [window->ns.object miniaturize:nil];
+}
+
+void _glfwPlatformRestoreWindow(_GLFWwindow* window)
+{
+ if ([window->ns.object isMiniaturized])
+ [window->ns.object deminiaturize:nil];
+ else if ([window->ns.object isZoomed])
+ [window->ns.object zoom:nil];
+}
+
+void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
+{
+ if (![window->ns.object isZoomed])
+ [window->ns.object zoom:nil];
+}
+
+void _glfwPlatformShowWindow(_GLFWwindow* window)
+{
+ [window->ns.object orderFront:nil];
+}
+
+void _glfwPlatformHideWindow(_GLFWwindow* window)
+{
+ [window->ns.object orderOut:nil];
+}
+
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
+{
+ [NSApp requestUserAttention:NSInformationalRequest];
+}
+
+void _glfwPlatformFocusWindow(_GLFWwindow* window)
+{
+ // Make us the active application
+ // HACK: This has been moved here from initializeAppKit to prevent
+ // applications using only hidden windows from being activated, but
+ // should probably not be done every time any window is shown
+ [NSApp activateIgnoringOtherApps:YES];
+
+ [window->ns.object makeKeyAndOrderFront:nil];
+}
+
+void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
+ _GLFWmonitor* monitor,
+ int xpos, int ypos,
+ int width, int height,
+ int refreshRate)
+{
+ if (window->monitor == monitor)
+ {
+ if (monitor)
+ {
+ if (monitor->window == window)
+ acquireMonitor(window);
+ }
+ else
+ {
+ const NSRect contentRect =
+ NSMakeRect(xpos, transformY(ypos + height), width, height);
+ const NSRect frameRect =
+ [window->ns.object frameRectForContentRect:contentRect
+ styleMask:getStyleMask(window)];
+
+ [window->ns.object setFrame:frameRect display:YES];
+ }
+
+ return;
+ }
+
+ if (window->monitor)
+ releaseMonitor(window);
+
+ _glfwInputWindowMonitor(window, monitor);
+
+ // HACK: Allow the state cached in Cocoa to catch up to reality
+ // TODO: Solve this in a less terrible way
+ _glfwPlatformPollEvents();
+
+ const NSUInteger styleMask = getStyleMask(window);
+ [window->ns.object setStyleMask:styleMask];
+ // HACK: Changing the style mask can cause the first responder to be cleared
+ [window->ns.object makeFirstResponder:window->ns.view];
+
+ if (monitor)
+ {
+ [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
+ [window->ns.object setHasShadow:NO];
+
+ acquireMonitor(window);
+ }
+ else
+ {
+ NSRect contentRect = NSMakeRect(xpos, transformY(ypos + height),
+ width, height);
+ NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
+ styleMask:styleMask];
+ [window->ns.object setFrame:frameRect display:YES];
+
+ if (window->numer != GLFW_DONT_CARE &&
+ window->denom != GLFW_DONT_CARE)
+ {
+ [window->ns.object setContentAspectRatio:NSMakeSize(window->numer,
+ window->denom)];
+ }
+
+ if (window->minwidth != GLFW_DONT_CARE &&
+ window->minheight != GLFW_DONT_CARE)
+ {
+ [window->ns.object setContentMinSize:NSMakeSize(window->minwidth,
+ window->minheight)];
+ }
+
+ if (window->maxwidth != GLFW_DONT_CARE &&
+ window->maxheight != GLFW_DONT_CARE)
+ {
+ [window->ns.object setContentMaxSize:NSMakeSize(window->maxwidth,
+ window->maxheight)];
+ }
+
+ if (window->floating)
+ [window->ns.object setLevel:NSFloatingWindowLevel];
+ else
+ [window->ns.object setLevel:NSNormalWindowLevel];
+
+ [window->ns.object setHasShadow:YES];
+ // HACK: Clearing NSWindowStyleMaskTitled resets and disables the window
+ // title property but the miniwindow title property is unaffected
+ [window->ns.object setTitle:[window->ns.object miniwindowTitle]];
+ }
+}
+
+int _glfwPlatformWindowFocused(_GLFWwindow* window)
+{
+ return [window->ns.object isKeyWindow];
+}
+
+int _glfwPlatformWindowIconified(_GLFWwindow* window)
+{
+ return [window->ns.object isMiniaturized];
+}
+
+int _glfwPlatformWindowVisible(_GLFWwindow* window)
+{
+ return [window->ns.object isVisible];
+}
+
+int _glfwPlatformWindowMaximized(_GLFWwindow* window)
+{
+ return [window->ns.object isZoomed];
+}
+
+int _glfwPlatformWindowHovered(_GLFWwindow* window)
+{
+ const NSPoint point = [NSEvent mouseLocation];
+
+ if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] !=
+ [window->ns.object windowNumber])
+ {
+ return GLFW_FALSE;
+ }
+
+ return NSPointInRect(point,
+ [window->ns.object convertRectToScreen:[window->ns.view bounds]]);
+}
+
+int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
+{
+ return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
+}
+
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
+{
+ [window->ns.object setStyleMask:getStyleMask(window)];
+}
+
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
+{
+ [window->ns.object setStyleMask:getStyleMask(window)];
+ [window->ns.object makeFirstResponder:window->ns.view];
+}
+
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
+{
+ if (enabled)
+ [window->ns.object setLevel:NSFloatingWindowLevel];
+ else
+ [window->ns.object setLevel:NSNormalWindowLevel];
+}
+
+float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
+{
+ return (float) [window->ns.object alphaValue];
+}
+
+void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
+{
+ [window->ns.object setAlphaValue:opacity];
+}
+
+void _glfwPlatformPollEvents(void)
+{
+ for (;;)
+ {
+ NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ if (event == nil)
+ break;
+
+ [NSApp sendEvent:event];
+ }
+
+ [_glfw.ns.autoreleasePool drain];
+ _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];
+}
+
+void _glfwPlatformWaitEvents(void)
+{
+ // I wanted to pass NO to dequeue:, and rely on PollEvents to
+ // dequeue and send. For reasons not at all clear to me, passing
+ // NO to dequeue: causes this method never to return.
+ NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny
+ untilDate:[NSDate distantFuture]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ [NSApp sendEvent:event];
+
+ _glfwPlatformPollEvents();
+}
+
+void _glfwPlatformWaitEventsTimeout(double timeout)
+{
+ NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
+ NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
+ untilDate:date
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ if (event)
+ [NSApp sendEvent:event];
+
+ _glfwPlatformPollEvents();
+}
+
+void _glfwPlatformPostEmptyEvent(void)
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
+ location:NSMakePoint(0, 0)
+ modifierFlags:0
+ timestamp:0
+ windowNumber:0
+ context:nil
+ subtype:0
+ data1:0
+ data2:0];
+ [NSApp postEvent:event atStart:YES];
+ [pool drain];
+}
+
+void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
+{
+ const NSRect contentRect = [window->ns.view frame];
+ const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
+
+ if (xpos)
+ *xpos = pos.x;
+ if (ypos)
+ *ypos = contentRect.size.height - pos.y - 1;
+}
+
+void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
+{
+ updateCursorImage(window);
+
+ const NSRect contentRect = [window->ns.view frame];
+ const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
+
+ window->ns.cursorWarpDeltaX += x - pos.x;
+ window->ns.cursorWarpDeltaY += y - contentRect.size.height + pos.y;
+
+ if (window->monitor)
+ {
+ CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,
+ CGPointMake(x, y));
+ }
+ else
+ {
+ const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0);
+ const NSRect globalRect = [window->ns.object convertRectToScreen:localRect];
+ const NSPoint globalPoint = globalRect.origin;
+
+ CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
+ transformY(globalPoint.y)));
+ }
+}
+
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
+{
+ if (_glfwPlatformWindowFocused(window))
+ updateCursorMode(window);
+}
+
+const char* _glfwPlatformGetScancodeName(int scancode)
+{
+ UInt32 deadKeyState = 0;
+ UniChar characters[8];
+ UniCharCount characterCount = 0;
+
+ if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
+ scancode,
+ kUCKeyActionDisplay,
+ 0,
+ LMGetKbdType(),
+ kUCKeyTranslateNoDeadKeysBit,
+ &deadKeyState,
+ sizeof(characters) / sizeof(characters[0]),
+ &characterCount,
+ characters) != noErr)
+ {
+ return NULL;
+ }
+
+ if (!characterCount)
+ return NULL;
+
+ CFStringRef string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
+ characters,
+ characterCount,
+ kCFAllocatorNull);
+ CFStringGetCString(string,
+ _glfw.ns.keyName,
+ sizeof(_glfw.ns.keyName),
+ kCFStringEncodingUTF8);
+ CFRelease(string);
+
+ return _glfw.ns.keyName;
+}
+
+int _glfwPlatformGetKeyScancode(int key)
+{
+ return _glfw.ns.scancodes[key];
+}
+
+int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
+ const GLFWimage* image,
+ int xhot, int yhot)
+{
+ NSImage* native;
+ NSBitmapImageRep* rep;
+
+ rep = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:NULL
+ pixelsWide:image->width
+ pixelsHigh:image->height
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSCalibratedRGBColorSpace
+ bitmapFormat:NSBitmapFormatAlphaNonpremultiplied
+ bytesPerRow:image->width * 4
+ bitsPerPixel:32];
+
+ if (rep == nil)
+ return GLFW_FALSE;
+
+ memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);
+
+ native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
+ [native addRepresentation:rep];
+
+ cursor->ns.object = [[NSCursor alloc] initWithImage:native
+ hotSpot:NSMakePoint(xhot, yhot)];
+
+ [native release];
+ [rep release];
+
+ if (cursor->ns.object == nil)
+ return GLFW_FALSE;
+
+ return GLFW_TRUE;
+}
+
+int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
+{
+ if (shape == GLFW_ARROW_CURSOR)
+ cursor->ns.object = [NSCursor arrowCursor];
+ else if (shape == GLFW_IBEAM_CURSOR)
+ cursor->ns.object = [NSCursor IBeamCursor];
+ else if (shape == GLFW_CROSSHAIR_CURSOR)
+ cursor->ns.object = [NSCursor crosshairCursor];
+ else if (shape == GLFW_HAND_CURSOR)
+ cursor->ns.object = [NSCursor pointingHandCursor];
+ else if (shape == GLFW_HRESIZE_CURSOR)
+ cursor->ns.object = [NSCursor resizeLeftRightCursor];
+ else if (shape == GLFW_VRESIZE_CURSOR)
+ cursor->ns.object = [NSCursor resizeUpDownCursor];
+
+ if (!cursor->ns.object)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to retrieve standard cursor");
+ return GLFW_FALSE;
+ }
+
+ [cursor->ns.object retain];
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
+{
+ if (cursor->ns.object)
+ [(NSCursor*) cursor->ns.object release];
+}
+
+void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
+{
+ if (cursorInClientArea(window))
+ updateCursorImage(window);
+}
+
+void _glfwPlatformSetClipboardString(const char* string)
+{
+ NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
+ [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
+ [pasteboard setString:[NSString stringWithUTF8String:string]
+ forType:NSPasteboardTypeString];
+}
+
+const char* _glfwPlatformGetClipboardString(void)
+{
+ NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
+
+ if (![[pasteboard types] containsObject:NSPasteboardTypeString])
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "Cocoa: Failed to retrieve string from pasteboard");
+ return NULL;
+ }
+
+ NSString* object = [pasteboard stringForType:NSPasteboardTypeString];
+ if (!object)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to retrieve object from pasteboard");
+ return NULL;
+ }
+
+ free(_glfw.ns.clipboardString);
+ _glfw.ns.clipboardString = _glfw_strdup([object UTF8String]);
+
+ return _glfw.ns.clipboardString;
+}
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
+{
+ if (!_glfw.vk.KHR_surface || !_glfw.vk.MVK_macos_surface)
+ return;
+
+ extensions[0] = "VK_KHR_surface";
+ extensions[1] = "VK_MVK_macos_surface";
+}
+
+int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily)
+{
+ return GLFW_TRUE;
+}
+
+VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
+ _GLFWwindow* window,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface)
+{
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
+ VkResult err;
+ VkMacOSSurfaceCreateInfoMVK sci;
+ PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
+
+ vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)
+ vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK");
+ if (!vkCreateMacOSSurfaceMVK)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ // HACK: Dynamically load Core Animation to avoid adding an extra
+ // dependency for the majority who don't use MoltenVK
+ NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
+ if (!bundle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to find QuartzCore.framework");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ // NOTE: Create the layer here as makeBackingLayer should not return nil
+ window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
+ if (!window->ns.layer)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to create layer for view");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
+ [window->ns.view setWantsLayer:YES];
+
+ memset(&sci, 0, sizeof(sci));
+ sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
+ sci.pView = window->ns.view;
+
+ err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface);
+ if (err)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Cocoa: Failed to create Vulkan surface: %s",
+ _glfwGetVulkanResultString(err));
+ }
+
+ return err;
+#else
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+#endif
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(nil);
+ return window->ns.object;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/context.c b/Client/ThirdParty/Box2D/extern/glfw/src/context.c
new file mode 100644
index 0000000..fd344cf
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/context.c
@@ -0,0 +1,758 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Checks whether the desired context attributes are valid
+//
+// This function checks things like whether the specified client API version
+// exists and whether all relevant options have supported and non-conflicting
+// values
+//
+GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
+{
+ if (ctxconfig->share)
+ {
+ if (ctxconfig->client == GLFW_NO_API ||
+ ctxconfig->share->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API &&
+ ctxconfig->source != GLFW_EGL_CONTEXT_API &&
+ ctxconfig->source != GLFW_OSMESA_CONTEXT_API)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid context creation API 0x%08X",
+ ctxconfig->source);
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->client != GLFW_NO_API &&
+ ctxconfig->client != GLFW_OPENGL_API &&
+ ctxconfig->client != GLFW_OPENGL_ES_API)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid client API 0x%08X",
+ ctxconfig->client);
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
+ (ctxconfig->major == 1 && ctxconfig->minor > 5) ||
+ (ctxconfig->major == 2 && ctxconfig->minor > 1) ||
+ (ctxconfig->major == 3 && ctxconfig->minor > 3))
+ {
+ // OpenGL 1.0 is the smallest valid version
+ // OpenGL 1.x series ended with version 1.5
+ // OpenGL 2.x series ended with version 2.1
+ // OpenGL 3.x series ended with version 3.3
+ // For now, let everything else through
+
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid OpenGL version %i.%i",
+ ctxconfig->major, ctxconfig->minor);
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->profile)
+ {
+ if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
+ ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid OpenGL profile 0x%08X",
+ ctxconfig->profile);
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->major <= 2 ||
+ (ctxconfig->major == 3 && ctxconfig->minor < 2))
+ {
+ // Desktop OpenGL context profiles are only defined for version 3.2
+ // and above
+
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Context profiles are only defined for OpenGL version 3.2 and above");
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->forward && ctxconfig->major <= 2)
+ {
+ // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Forward-compatibility is only defined for OpenGL version 3.0 and above");
+ return GLFW_FALSE;
+ }
+ }
+ else if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
+ (ctxconfig->major == 1 && ctxconfig->minor > 1) ||
+ (ctxconfig->major == 2 && ctxconfig->minor > 0))
+ {
+ // OpenGL ES 1.0 is the smallest valid version
+ // OpenGL ES 1.x series ended with version 1.1
+ // OpenGL ES 2.x series ended with version 2.0
+ // For now, let everything else through
+
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid OpenGL ES version %i.%i",
+ ctxconfig->major, ctxconfig->minor);
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->robustness)
+ {
+ if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
+ ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid context robustness mode 0x%08X",
+ ctxconfig->robustness);
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->release)
+ {
+ if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
+ ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid context release behavior 0x%08X",
+ ctxconfig->release);
+ return GLFW_FALSE;
+ }
+ }
+
+ return GLFW_TRUE;
+}
+
+// Chooses the framebuffer config that best matches the desired one
+//
+const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
+ const _GLFWfbconfig* alternatives,
+ unsigned int count)
+{
+ unsigned int i;
+ unsigned int missing, leastMissing = UINT_MAX;
+ unsigned int colorDiff, leastColorDiff = UINT_MAX;
+ unsigned int extraDiff, leastExtraDiff = UINT_MAX;
+ const _GLFWfbconfig* current;
+ const _GLFWfbconfig* closest = NULL;
+
+ for (i = 0; i < count; i++)
+ {
+ current = alternatives + i;
+
+ if (desired->stereo > 0 && current->stereo == 0)
+ {
+ // Stereo is a hard constraint
+ continue;
+ }
+
+ if (desired->doublebuffer != current->doublebuffer)
+ {
+ // Double buffering is a hard constraint
+ continue;
+ }
+
+ // Count number of missing buffers
+ {
+ missing = 0;
+
+ if (desired->alphaBits > 0 && current->alphaBits == 0)
+ missing++;
+
+ if (desired->depthBits > 0 && current->depthBits == 0)
+ missing++;
+
+ if (desired->stencilBits > 0 && current->stencilBits == 0)
+ missing++;
+
+ if (desired->auxBuffers > 0 &&
+ current->auxBuffers < desired->auxBuffers)
+ {
+ missing += desired->auxBuffers - current->auxBuffers;
+ }
+
+ if (desired->samples > 0 && current->samples == 0)
+ {
+ // Technically, several multisampling buffers could be
+ // involved, but that's a lower level implementation detail and
+ // not important to us here, so we count them as one
+ missing++;
+ }
+
+ if (desired->transparent != current->transparent)
+ missing++;
+ }
+
+ // These polynomials make many small channel size differences matter
+ // less than one large channel size difference
+
+ // Calculate color channel size difference value
+ {
+ colorDiff = 0;
+
+ if (desired->redBits != GLFW_DONT_CARE)
+ {
+ colorDiff += (desired->redBits - current->redBits) *
+ (desired->redBits - current->redBits);
+ }
+
+ if (desired->greenBits != GLFW_DONT_CARE)
+ {
+ colorDiff += (desired->greenBits - current->greenBits) *
+ (desired->greenBits - current->greenBits);
+ }
+
+ if (desired->blueBits != GLFW_DONT_CARE)
+ {
+ colorDiff += (desired->blueBits - current->blueBits) *
+ (desired->blueBits - current->blueBits);
+ }
+ }
+
+ // Calculate non-color channel size difference value
+ {
+ extraDiff = 0;
+
+ if (desired->alphaBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->alphaBits - current->alphaBits) *
+ (desired->alphaBits - current->alphaBits);
+ }
+
+ if (desired->depthBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->depthBits - current->depthBits) *
+ (desired->depthBits - current->depthBits);
+ }
+
+ if (desired->stencilBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->stencilBits - current->stencilBits) *
+ (desired->stencilBits - current->stencilBits);
+ }
+
+ if (desired->accumRedBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->accumRedBits - current->accumRedBits) *
+ (desired->accumRedBits - current->accumRedBits);
+ }
+
+ if (desired->accumGreenBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
+ (desired->accumGreenBits - current->accumGreenBits);
+ }
+
+ if (desired->accumBlueBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
+ (desired->accumBlueBits - current->accumBlueBits);
+ }
+
+ if (desired->accumAlphaBits != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
+ (desired->accumAlphaBits - current->accumAlphaBits);
+ }
+
+ if (desired->samples != GLFW_DONT_CARE)
+ {
+ extraDiff += (desired->samples - current->samples) *
+ (desired->samples - current->samples);
+ }
+
+ if (desired->sRGB && !current->sRGB)
+ extraDiff++;
+ }
+
+ // Figure out if the current one is better than the best one found so far
+ // Least number of missing buffers is the most important heuristic,
+ // then color buffer size match and lastly size match for other buffers
+
+ if (missing < leastMissing)
+ closest = current;
+ else if (missing == leastMissing)
+ {
+ if ((colorDiff < leastColorDiff) ||
+ (colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
+ {
+ closest = current;
+ }
+ }
+
+ if (current == closest)
+ {
+ leastMissing = missing;
+ leastColorDiff = colorDiff;
+ leastExtraDiff = extraDiff;
+ }
+ }
+
+ return closest;
+}
+
+// Retrieves the attributes of the current context
+//
+GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig)
+{
+ int i;
+ _GLFWwindow* previous;
+ const char* version;
+ const char* prefixes[] =
+ {
+ "OpenGL ES-CM ",
+ "OpenGL ES-CL ",
+ "OpenGL ES ",
+ NULL
+ };
+
+ window->context.source = ctxconfig->source;
+ window->context.client = GLFW_OPENGL_API;
+
+ previous = _glfwPlatformGetTls(&_glfw.contextSlot);;
+ glfwMakeContextCurrent((GLFWwindow*) window);
+
+ window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
+ window->context.getProcAddress("glGetIntegerv");
+ window->context.GetString = (PFNGLGETSTRINGPROC)
+ window->context.getProcAddress("glGetString");
+ if (!window->context.GetIntegerv || !window->context.GetString)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
+ glfwMakeContextCurrent((GLFWwindow*) previous);
+ return GLFW_FALSE;
+ }
+
+ version = (const char*) window->context.GetString(GL_VERSION);
+ if (!version)
+ {
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "OpenGL version string retrieval is broken");
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "OpenGL ES version string retrieval is broken");
+ }
+
+ glfwMakeContextCurrent((GLFWwindow*) previous);
+ return GLFW_FALSE;
+ }
+
+ for (i = 0; prefixes[i]; i++)
+ {
+ const size_t length = strlen(prefixes[i]);
+
+ if (strncmp(version, prefixes[i], length) == 0)
+ {
+ version += length;
+ window->context.client = GLFW_OPENGL_ES_API;
+ break;
+ }
+ }
+
+ if (!sscanf(version, "%d.%d.%d",
+ &window->context.major,
+ &window->context.minor,
+ &window->context.revision))
+ {
+ if (window->context.client == GLFW_OPENGL_API)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "No version found in OpenGL version string");
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "No version found in OpenGL ES version string");
+ }
+
+ glfwMakeContextCurrent((GLFWwindow*) previous);
+ return GLFW_FALSE;
+ }
+
+ if (window->context.major < ctxconfig->major ||
+ (window->context.major == ctxconfig->major &&
+ window->context.minor < ctxconfig->minor))
+ {
+ // The desired OpenGL version is greater than the actual version
+ // This only happens if the machine lacks {GLX|WGL}_ARB_create_context
+ // /and/ the user has requested an OpenGL version greater than 1.0
+
+ // For API consistency, we emulate the behavior of the
+ // {GLX|WGL}_ARB_create_context extension and fail here
+
+ if (window->context.client == GLFW_OPENGL_API)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "Requested OpenGL version %i.%i, got version %i.%i",
+ ctxconfig->major, ctxconfig->minor,
+ window->context.major, window->context.minor);
+ }
+ else
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "Requested OpenGL ES version %i.%i, got version %i.%i",
+ ctxconfig->major, ctxconfig->minor,
+ window->context.major, window->context.minor);
+ }
+
+ glfwMakeContextCurrent((GLFWwindow*) previous);
+ return GLFW_FALSE;
+ }
+
+ if (window->context.major >= 3)
+ {
+ // OpenGL 3.0+ uses a different function for extension string retrieval
+ // We cache it here instead of in glfwExtensionSupported mostly to alert
+ // users as early as possible that their build may be broken
+
+ window->context.GetStringi = (PFNGLGETSTRINGIPROC)
+ window->context.getProcAddress("glGetStringi");
+ if (!window->context.GetStringi)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Entry point retrieval is broken");
+ glfwMakeContextCurrent((GLFWwindow*) previous);
+ return GLFW_FALSE;
+ }
+ }
+
+ if (window->context.client == GLFW_OPENGL_API)
+ {
+ // Read back context flags (OpenGL 3.0 and above)
+ if (window->context.major >= 3)
+ {
+ GLint flags;
+ window->context.GetIntegerv(GL_CONTEXT_FLAGS, &flags);
+
+ if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
+ window->context.forward = GLFW_TRUE;
+
+ if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
+ window->context.debug = GLFW_TRUE;
+ else if (glfwExtensionSupported("GL_ARB_debug_output") &&
+ ctxconfig->debug)
+ {
+ // HACK: This is a workaround for older drivers (pre KHR_debug)
+ // not setting the debug bit in the context flags for
+ // debug contexts
+ window->context.debug = GLFW_TRUE;
+ }
+
+ if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
+ window->context.noerror = GLFW_TRUE;
+ }
+
+ // Read back OpenGL context profile (OpenGL 3.2 and above)
+ if (window->context.major >= 4 ||
+ (window->context.major == 3 && window->context.minor >= 2))
+ {
+ GLint mask;
+ window->context.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
+
+ if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
+ window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
+ else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
+ window->context.profile = GLFW_OPENGL_CORE_PROFILE;
+ else if (glfwExtensionSupported("GL_ARB_compatibility"))
+ {
+ // HACK: This is a workaround for the compatibility profile bit
+ // not being set in the context flags if an OpenGL 3.2+
+ // context was created without having requested a specific
+ // version
+ window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
+ }
+ }
+
+ // Read back robustness strategy
+ if (glfwExtensionSupported("GL_ARB_robustness"))
+ {
+ // NOTE: We avoid using the context flags for detection, as they are
+ // only present from 3.0 while the extension applies from 1.1
+
+ GLint strategy;
+ window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
+ &strategy);
+
+ if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
+ window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
+ else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
+ window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
+ }
+ }
+ else
+ {
+ // Read back robustness strategy
+ if (glfwExtensionSupported("GL_EXT_robustness"))
+ {
+ // NOTE: The values of these constants match those of the OpenGL ARB
+ // one, so we can reuse them here
+
+ GLint strategy;
+ window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
+ &strategy);
+
+ if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
+ window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
+ else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
+ window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
+ }
+ }
+
+ if (glfwExtensionSupported("GL_KHR_context_flush_control"))
+ {
+ GLint behavior;
+ window->context.GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
+
+ if (behavior == GL_NONE)
+ window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
+ else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
+ window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
+ }
+
+ // Clearing the front buffer to black to avoid garbage pixels left over from
+ // previous uses of our bit of VRAM
+ {
+ PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
+ window->context.getProcAddress("glClear");
+ glClear(GL_COLOR_BUFFER_BIT);
+ window->context.swapBuffers(window);
+ }
+
+ glfwMakeContextCurrent((GLFWwindow*) previous);
+ return GLFW_TRUE;
+}
+
+// Searches an extension string for the specified extension
+//
+GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
+{
+ const char* start = extensions;
+
+ for (;;)
+ {
+ const char* where;
+ const char* terminator;
+
+ where = strstr(start, string);
+ if (!where)
+ return GLFW_FALSE;
+
+ terminator = where + strlen(string);
+ if (where == start || *(where - 1) == ' ')
+ {
+ if (*terminator == ' ' || *terminator == '\0')
+ break;
+ }
+
+ start = terminator;
+ }
+
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW public API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window && window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
+ "Cannot make current with a window that has no OpenGL or OpenGL ES context");
+ return;
+ }
+
+ if (previous)
+ {
+ if (!window || window->context.source != previous->context.source)
+ previous->context.makeCurrent(NULL);
+ }
+
+ if (window)
+ window->context.makeCurrent(window);
+}
+
+GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return _glfwPlatformGetTls(&_glfw.contextSlot);
+}
+
+GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
+ "Cannot swap buffers of a window that has no OpenGL or OpenGL ES context");
+ return;
+ }
+
+ window->context.swapBuffers(window);
+}
+
+GLFWAPI void glfwSwapInterval(int interval)
+{
+ _GLFWwindow* window;
+
+ _GLFW_REQUIRE_INIT();
+
+ window = _glfwPlatformGetTls(&_glfw.contextSlot);
+ if (!window)
+ {
+ _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
+ "Cannot set swap interval without a current OpenGL or OpenGL ES context");
+ return;
+ }
+
+ window->context.swapInterval(interval);
+}
+
+GLFWAPI int glfwExtensionSupported(const char* extension)
+{
+ _GLFWwindow* window;
+ assert(extension != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ window = _glfwPlatformGetTls(&_glfw.contextSlot);
+ if (!window)
+ {
+ _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
+ "Cannot query extension without a current OpenGL or OpenGL ES context");
+ return GLFW_FALSE;
+ }
+
+ if (*extension == '\0')
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string");
+ return GLFW_FALSE;
+ }
+
+ if (window->context.major >= 3)
+ {
+ int i;
+ GLint count;
+
+ // Check if extension is in the modern OpenGL extensions string list
+
+ window->context.GetIntegerv(GL_NUM_EXTENSIONS, &count);
+
+ for (i = 0; i < count; i++)
+ {
+ const char* en = (const char*)
+ window->context.GetStringi(GL_EXTENSIONS, i);
+ if (!en)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Extension string retrieval is broken");
+ return GLFW_FALSE;
+ }
+
+ if (strcmp(en, extension) == 0)
+ return GLFW_TRUE;
+ }
+ }
+ else
+ {
+ // Check if extension is in the old style OpenGL extensions string
+
+ const char* extensions = (const char*)
+ window->context.GetString(GL_EXTENSIONS);
+ if (!extensions)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Extension string retrieval is broken");
+ return GLFW_FALSE;
+ }
+
+ if (_glfwStringInExtensionString(extension, extensions))
+ return GLFW_TRUE;
+ }
+
+ // Check if extension is in the platform-specific string
+ return window->context.extensionSupported(extension);
+}
+
+GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
+{
+ _GLFWwindow* window;
+ assert(procname != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ window = _glfwPlatformGetTls(&_glfw.contextSlot);
+ if (!window)
+ {
+ _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
+ "Cannot query entry point without a current OpenGL or OpenGL ES context");
+ return NULL;
+ }
+
+ return window->context.getProcAddress(procname);
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/egl_context.c b/Client/ThirdParty/Box2D/extern/glfw/src/egl_context.c
new file mode 100644
index 0000000..b2d11a4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/egl_context.c
@@ -0,0 +1,786 @@
+//========================================================================
+// GLFW 3.3 EGL - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+
+// Return a description of the specified EGL error
+//
+static const char* getEGLErrorString(EGLint error)
+{
+ switch (error)
+ {
+ case EGL_SUCCESS:
+ return "Success";
+ case EGL_NOT_INITIALIZED:
+ return "EGL is not or could not be initialized";
+ case EGL_BAD_ACCESS:
+ return "EGL cannot access a requested resource";
+ case EGL_BAD_ALLOC:
+ return "EGL failed to allocate resources for the requested operation";
+ case EGL_BAD_ATTRIBUTE:
+ return "An unrecognized attribute or attribute value was passed in the attribute list";
+ case EGL_BAD_CONTEXT:
+ return "An EGLContext argument does not name a valid EGL rendering context";
+ case EGL_BAD_CONFIG:
+ return "An EGLConfig argument does not name a valid EGL frame buffer configuration";
+ case EGL_BAD_CURRENT_SURFACE:
+ return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid";
+ case EGL_BAD_DISPLAY:
+ return "An EGLDisplay argument does not name a valid EGL display connection";
+ case EGL_BAD_SURFACE:
+ return "An EGLSurface argument does not name a valid surface configured for GL rendering";
+ case EGL_BAD_MATCH:
+ return "Arguments are inconsistent";
+ case EGL_BAD_PARAMETER:
+ return "One or more argument values are invalid";
+ case EGL_BAD_NATIVE_PIXMAP:
+ return "A NativePixmapType argument does not refer to a valid native pixmap";
+ case EGL_BAD_NATIVE_WINDOW:
+ return "A NativeWindowType argument does not refer to a valid native window";
+ case EGL_CONTEXT_LOST:
+ return "The application must destroy all contexts and reinitialise";
+ default:
+ return "ERROR: UNKNOWN EGL ERROR";
+ }
+}
+
+// Returns the specified attribute of the specified EGLConfig
+//
+static int getEGLConfigAttrib(EGLConfig config, int attrib)
+{
+ int value;
+ eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
+ return value;
+}
+
+// Return the EGLConfig most closely matching the specified hints
+//
+static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* desired,
+ EGLConfig* result)
+{
+ EGLConfig* nativeConfigs;
+ _GLFWfbconfig* usableConfigs;
+ const _GLFWfbconfig* closest;
+ int i, nativeCount, usableCount;
+
+ eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
+ if (!nativeCount)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: No EGLConfigs returned");
+ return GLFW_FALSE;
+ }
+
+ nativeConfigs = calloc(nativeCount, sizeof(EGLConfig));
+ eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
+
+ usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
+ usableCount = 0;
+
+ for (i = 0; i < nativeCount; i++)
+ {
+ const EGLConfig n = nativeConfigs[i];
+ _GLFWfbconfig* u = usableConfigs + usableCount;
+
+ // Only consider RGB(A) EGLConfigs
+ if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
+ continue;
+
+ // Only consider window EGLConfigs
+ if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
+ continue;
+
+#if defined(_GLFW_X11)
+ XVisualInfo vi = {0};
+
+ // Only consider EGLConfigs with associated Visuals
+ vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
+ if (!vi.visualid)
+ continue;
+
+ if (desired->transparent)
+ {
+ int count;
+ XVisualInfo* vis = XGetVisualInfo(_glfw.x11.display,
+ VisualIDMask, &vi,
+ &count);
+ if (vis)
+ {
+ u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
+ XFree(vis);
+ }
+ }
+#endif // _GLFW_X11
+
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ if (ctxconfig->major == 1)
+ {
+ if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
+ continue;
+ }
+ else
+ {
+ if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
+ continue;
+ }
+ }
+ else if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
+ continue;
+ }
+
+ u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
+ u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
+ u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
+
+ u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
+ u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
+ u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
+
+ u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
+ u->doublebuffer = GLFW_TRUE;
+
+ u->handle = (uintptr_t) n;
+ usableCount++;
+ }
+
+ closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
+ if (closest)
+ *result = (EGLConfig) closest->handle;
+
+ free(nativeConfigs);
+ free(usableConfigs);
+
+ return closest != NULL;
+}
+
+static void makeContextCurrentEGL(_GLFWwindow* window)
+{
+ if (window)
+ {
+ if (!eglMakeCurrent(_glfw.egl.display,
+ window->context.egl.surface,
+ window->context.egl.surface,
+ window->context.egl.handle))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGL: Failed to make context current: %s",
+ getEGLErrorString(eglGetError()));
+ return;
+ }
+ }
+ else
+ {
+ if (!eglMakeCurrent(_glfw.egl.display,
+ EGL_NO_SURFACE,
+ EGL_NO_SURFACE,
+ EGL_NO_CONTEXT))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGL: Failed to clear current context: %s",
+ getEGLErrorString(eglGetError()));
+ return;
+ }
+ }
+
+ _glfwPlatformSetTls(&_glfw.contextSlot, window);
+}
+
+static void swapBuffersEGL(_GLFWwindow* window)
+{
+ if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGL: The context must be current on the calling thread when swapping buffers");
+ return;
+ }
+
+ eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
+}
+
+static void swapIntervalEGL(int interval)
+{
+ eglSwapInterval(_glfw.egl.display, interval);
+}
+
+static int extensionSupportedEGL(const char* extension)
+{
+ const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
+ if (extensions)
+ {
+ if (_glfwStringInExtensionString(extension, extensions))
+ return GLFW_TRUE;
+ }
+
+ return GLFW_FALSE;
+}
+
+static GLFWglproc getProcAddressEGL(const char* procname)
+{
+ _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
+
+ if (window->context.egl.client)
+ {
+ GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client,
+ procname);
+ if (proc)
+ return proc;
+ }
+
+ return eglGetProcAddress(procname);
+}
+
+static void destroyContextEGL(_GLFWwindow* window)
+{
+#if defined(_GLFW_X11)
+ // NOTE: Do not unload libGL.so.1 while the X11 display is still open,
+ // as it will make XCloseDisplay segfault
+ if (window->context.client != GLFW_OPENGL_API)
+#endif // _GLFW_X11
+ {
+ if (window->context.egl.client)
+ {
+ _glfw_dlclose(window->context.egl.client);
+ window->context.egl.client = NULL;
+ }
+ }
+
+ if (window->context.egl.surface)
+ {
+ eglDestroySurface(_glfw.egl.display, window->context.egl.surface);
+ window->context.egl.surface = EGL_NO_SURFACE;
+ }
+
+ if (window->context.egl.handle)
+ {
+ eglDestroyContext(_glfw.egl.display, window->context.egl.handle);
+ window->context.egl.handle = EGL_NO_CONTEXT;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize EGL
+//
+GLFWbool _glfwInitEGL(void)
+{
+ int i;
+ const char* sonames[] =
+ {
+#if defined(_GLFW_EGL_LIBRARY)
+ _GLFW_EGL_LIBRARY,
+#elif defined(_GLFW_WIN32)
+ "libEGL.dll",
+ "EGL.dll",
+#elif defined(_GLFW_COCOA)
+ "libEGL.dylib",
+#elif defined(__CYGWIN__)
+ "libEGL-1.so",
+#else
+ "libEGL.so.1",
+#endif
+ NULL
+ };
+
+ if (_glfw.egl.handle)
+ return GLFW_TRUE;
+
+ for (i = 0; sonames[i]; i++)
+ {
+ _glfw.egl.handle = _glfw_dlopen(sonames[i]);
+ if (_glfw.egl.handle)
+ break;
+ }
+
+ if (!_glfw.egl.handle)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
+ return GLFW_FALSE;
+ }
+
+ _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
+
+ _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
+ _glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
+ _glfw.egl.GetConfigs = (PFN_eglGetConfigs)
+ _glfw_dlsym(_glfw.egl.handle, "eglGetConfigs");
+ _glfw.egl.GetDisplay = (PFN_eglGetDisplay)
+ _glfw_dlsym(_glfw.egl.handle, "eglGetDisplay");
+ _glfw.egl.GetError = (PFN_eglGetError)
+ _glfw_dlsym(_glfw.egl.handle, "eglGetError");
+ _glfw.egl.Initialize = (PFN_eglInitialize)
+ _glfw_dlsym(_glfw.egl.handle, "eglInitialize");
+ _glfw.egl.Terminate = (PFN_eglTerminate)
+ _glfw_dlsym(_glfw.egl.handle, "eglTerminate");
+ _glfw.egl.BindAPI = (PFN_eglBindAPI)
+ _glfw_dlsym(_glfw.egl.handle, "eglBindAPI");
+ _glfw.egl.CreateContext = (PFN_eglCreateContext)
+ _glfw_dlsym(_glfw.egl.handle, "eglCreateContext");
+ _glfw.egl.DestroySurface = (PFN_eglDestroySurface)
+ _glfw_dlsym(_glfw.egl.handle, "eglDestroySurface");
+ _glfw.egl.DestroyContext = (PFN_eglDestroyContext)
+ _glfw_dlsym(_glfw.egl.handle, "eglDestroyContext");
+ _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
+ _glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface");
+ _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
+ _glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent");
+ _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
+ _glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers");
+ _glfw.egl.SwapInterval = (PFN_eglSwapInterval)
+ _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
+ _glfw.egl.QueryString = (PFN_eglQueryString)
+ _glfw_dlsym(_glfw.egl.handle, "eglQueryString");
+ _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
+ _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
+
+ if (!_glfw.egl.GetConfigAttrib ||
+ !_glfw.egl.GetConfigs ||
+ !_glfw.egl.GetDisplay ||
+ !_glfw.egl.GetError ||
+ !_glfw.egl.Initialize ||
+ !_glfw.egl.Terminate ||
+ !_glfw.egl.BindAPI ||
+ !_glfw.egl.CreateContext ||
+ !_glfw.egl.DestroySurface ||
+ !_glfw.egl.DestroyContext ||
+ !_glfw.egl.CreateWindowSurface ||
+ !_glfw.egl.MakeCurrent ||
+ !_glfw.egl.SwapBuffers ||
+ !_glfw.egl.SwapInterval ||
+ !_glfw.egl.QueryString ||
+ !_glfw.egl.GetProcAddress)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGL: Failed to load required entry points");
+
+ _glfwTerminateEGL();
+ return GLFW_FALSE;
+ }
+
+ _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
+ if (_glfw.egl.display == EGL_NO_DISPLAY)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "EGL: Failed to get EGL display: %s",
+ getEGLErrorString(eglGetError()));
+
+ _glfwTerminateEGL();
+ return GLFW_FALSE;
+ }
+
+ if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "EGL: Failed to initialize EGL: %s",
+ getEGLErrorString(eglGetError()));
+
+ _glfwTerminateEGL();
+ return GLFW_FALSE;
+ }
+
+ _glfw.egl.KHR_create_context =
+ extensionSupportedEGL("EGL_KHR_create_context");
+ _glfw.egl.KHR_create_context_no_error =
+ extensionSupportedEGL("EGL_KHR_create_context_no_error");
+ _glfw.egl.KHR_gl_colorspace =
+ extensionSupportedEGL("EGL_KHR_gl_colorspace");
+ _glfw.egl.KHR_get_all_proc_addresses =
+ extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
+ _glfw.egl.KHR_context_flush_control =
+ extensionSupportedEGL("EGL_KHR_context_flush_control");
+
+ return GLFW_TRUE;
+}
+
+// Terminate EGL
+//
+void _glfwTerminateEGL(void)
+{
+ if (_glfw.egl.display)
+ {
+ eglTerminate(_glfw.egl.display);
+ _glfw.egl.display = EGL_NO_DISPLAY;
+ }
+
+ if (_glfw.egl.handle)
+ {
+ _glfw_dlclose(_glfw.egl.handle);
+ _glfw.egl.handle = NULL;
+ }
+}
+
+#define setAttrib(a, v) \
+{ \
+ assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
+ attribs[index++] = a; \
+ attribs[index++] = v; \
+}
+
+// Create the OpenGL or OpenGL ES context
+//
+GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ EGLint attribs[40];
+ EGLConfig config;
+ EGLContext share = NULL;
+ int index = 0;
+
+ if (!_glfw.egl.display)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: API not available");
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->share)
+ share = ctxconfig->share->context.egl.handle;
+
+ if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "EGL: Failed to find a suitable EGLConfig");
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ if (!eglBindAPI(EGL_OPENGL_ES_API))
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "EGL: Failed to bind OpenGL ES: %s",
+ getEGLErrorString(eglGetError()));
+ return GLFW_FALSE;
+ }
+ }
+ else
+ {
+ if (!eglBindAPI(EGL_OPENGL_API))
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "EGL: Failed to bind OpenGL: %s",
+ getEGLErrorString(eglGetError()));
+ return GLFW_FALSE;
+ }
+ }
+
+ if (_glfw.egl.KHR_create_context)
+ {
+ int mask = 0, flags = 0;
+
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if (ctxconfig->forward)
+ flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
+
+ if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
+ mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+ else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
+ mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
+ }
+
+ if (ctxconfig->debug)
+ flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+
+ if (ctxconfig->robustness)
+ {
+ if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
+ {
+ setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
+ EGL_NO_RESET_NOTIFICATION_KHR);
+ }
+ else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
+ {
+ setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
+ EGL_LOSE_CONTEXT_ON_RESET_KHR);
+ }
+
+ flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
+ }
+
+ if (ctxconfig->noerror)
+ {
+ if (_glfw.egl.KHR_create_context_no_error)
+ setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
+ }
+
+ if (ctxconfig->major != 1 || ctxconfig->minor != 0)
+ {
+ setAttrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
+ setAttrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
+ }
+
+ if (mask)
+ setAttrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
+
+ if (flags)
+ setAttrib(EGL_CONTEXT_FLAGS_KHR, flags);
+ }
+ else
+ {
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ setAttrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
+ }
+
+ if (_glfw.egl.KHR_context_flush_control)
+ {
+ if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
+ {
+ setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
+ EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
+ }
+ else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
+ {
+ setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
+ EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
+ }
+ }
+
+ setAttrib(EGL_NONE, EGL_NONE);
+
+ window->context.egl.handle = eglCreateContext(_glfw.egl.display,
+ config, share, attribs);
+
+ if (window->context.egl.handle == EGL_NO_CONTEXT)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "EGL: Failed to create context: %s",
+ getEGLErrorString(eglGetError()));
+ return GLFW_FALSE;
+ }
+
+ // Set up attributes for surface creation
+ {
+ int index = 0;
+
+ if (fbconfig->sRGB)
+ {
+ if (_glfw.egl.KHR_gl_colorspace)
+ setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
+ }
+
+ setAttrib(EGL_NONE, EGL_NONE);
+ }
+
+ window->context.egl.surface =
+ eglCreateWindowSurface(_glfw.egl.display,
+ config,
+ _GLFW_EGL_NATIVE_WINDOW,
+ attribs);
+ if (window->context.egl.surface == EGL_NO_SURFACE)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGL: Failed to create window surface: %s",
+ getEGLErrorString(eglGetError()));
+ return GLFW_FALSE;
+ }
+
+ window->context.egl.config = config;
+
+ // Load the appropriate client library
+ if (!_glfw.egl.KHR_get_all_proc_addresses)
+ {
+ int i;
+ const char** sonames;
+ const char* es1sonames[] =
+ {
+#if defined(_GLFW_GLESV1_LIBRARY)
+ _GLFW_GLESV1_LIBRARY,
+#elif defined(_GLFW_WIN32)
+ "GLESv1_CM.dll",
+ "libGLES_CM.dll",
+#elif defined(_GLFW_COCOA)
+ "libGLESv1_CM.dylib",
+#else
+ "libGLESv1_CM.so.1",
+ "libGLES_CM.so.1",
+#endif
+ NULL
+ };
+ const char* es2sonames[] =
+ {
+#if defined(_GLFW_GLESV2_LIBRARY)
+ _GLFW_GLESV2_LIBRARY,
+#elif defined(_GLFW_WIN32)
+ "GLESv2.dll",
+ "libGLESv2.dll",
+#elif defined(_GLFW_COCOA)
+ "libGLESv2.dylib",
+#elif defined(__CYGWIN__)
+ "libGLESv2-2.so",
+#else
+ "libGLESv2.so.2",
+#endif
+ NULL
+ };
+ const char* glsonames[] =
+ {
+#if defined(_GLFW_OPENGL_LIBRARY)
+ _GLFW_OPENGL_LIBRARY,
+#elif defined(_GLFW_WIN32)
+#elif defined(_GLFW_COCOA)
+#else
+ "libGL.so.1",
+#endif
+ NULL
+ };
+
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ if (ctxconfig->major == 1)
+ sonames = es1sonames;
+ else
+ sonames = es2sonames;
+ }
+ else
+ sonames = glsonames;
+
+ for (i = 0; sonames[i]; i++)
+ {
+ // HACK: Match presence of lib prefix to increase chance of finding
+ // a matching pair in the jungle that is Win32 EGL/GLES
+ if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
+ continue;
+
+ window->context.egl.client = _glfw_dlopen(sonames[i]);
+ if (window->context.egl.client)
+ break;
+ }
+
+ if (!window->context.egl.client)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "EGL: Failed to load client library");
+ return GLFW_FALSE;
+ }
+ }
+
+ window->context.makeCurrent = makeContextCurrentEGL;
+ window->context.swapBuffers = swapBuffersEGL;
+ window->context.swapInterval = swapIntervalEGL;
+ window->context.extensionSupported = extensionSupportedEGL;
+ window->context.getProcAddress = getProcAddressEGL;
+ window->context.destroy = destroyContextEGL;
+
+ return GLFW_TRUE;
+}
+
+#undef setAttrib
+
+// Returns the Visual and depth of the chosen EGLConfig
+//
+#if defined(_GLFW_X11)
+GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig,
+ Visual** visual, int* depth)
+{
+ XVisualInfo* result;
+ XVisualInfo desired;
+ EGLConfig native;
+ EGLint visualID = 0, count = 0;
+ const long vimask = VisualScreenMask | VisualIDMask;
+
+ if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "EGL: Failed to find a suitable EGLConfig");
+ return GLFW_FALSE;
+ }
+
+ eglGetConfigAttrib(_glfw.egl.display, native,
+ EGL_NATIVE_VISUAL_ID, &visualID);
+
+ desired.screen = _glfw.x11.screen;
+ desired.visualid = visualID;
+
+ result = XGetVisualInfo(_glfw.x11.display, vimask, &desired, &count);
+ if (!result)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGL: Failed to retrieve Visual for EGLConfig");
+ return GLFW_FALSE;
+ }
+
+ *visual = result->visual;
+ *depth = result->depth;
+
+ XFree(result);
+ return GLFW_TRUE;
+}
+#endif // _GLFW_X11
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);
+ return _glfw.egl.display;
+}
+
+GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return EGL_NO_CONTEXT;
+ }
+
+ return window->context.egl.handle;
+}
+
+GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return EGL_NO_SURFACE;
+ }
+
+ return window->context.egl.surface;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/egl_context.h b/Client/ThirdParty/Box2D/extern/glfw/src/egl_context.h
new file mode 100644
index 0000000..8f3d075
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/egl_context.h
@@ -0,0 +1,215 @@
+//========================================================================
+// GLFW 3.3 EGL - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#if defined(_GLFW_USE_EGLPLATFORM_H)
+ #include <EGL/eglplatform.h>
+#elif defined(_GLFW_WIN32)
+ #define EGLAPIENTRY __stdcall
+typedef HDC EGLNativeDisplayType;
+typedef HWND EGLNativeWindowType;
+#elif defined(_GLFW_COCOA)
+ #define EGLAPIENTRY
+typedef void* EGLNativeDisplayType;
+typedef id EGLNativeWindowType;
+#elif defined(_GLFW_X11)
+ #define EGLAPIENTRY
+typedef Display* EGLNativeDisplayType;
+typedef Window EGLNativeWindowType;
+#elif defined(_GLFW_WAYLAND)
+ #define EGLAPIENTRY
+typedef struct wl_display* EGLNativeDisplayType;
+typedef struct wl_egl_window* EGLNativeWindowType;
+#else
+ #error "No supported EGL platform selected"
+#endif
+
+#define EGL_SUCCESS 0x3000
+#define EGL_NOT_INITIALIZED 0x3001
+#define EGL_BAD_ACCESS 0x3002
+#define EGL_BAD_ALLOC 0x3003
+#define EGL_BAD_ATTRIBUTE 0x3004
+#define EGL_BAD_CONFIG 0x3005
+#define EGL_BAD_CONTEXT 0x3006
+#define EGL_BAD_CURRENT_SURFACE 0x3007
+#define EGL_BAD_DISPLAY 0x3008
+#define EGL_BAD_MATCH 0x3009
+#define EGL_BAD_NATIVE_PIXMAP 0x300a
+#define EGL_BAD_NATIVE_WINDOW 0x300b
+#define EGL_BAD_PARAMETER 0x300c
+#define EGL_BAD_SURFACE 0x300d
+#define EGL_CONTEXT_LOST 0x300e
+#define EGL_COLOR_BUFFER_TYPE 0x303f
+#define EGL_RGB_BUFFER 0x308e
+#define EGL_SURFACE_TYPE 0x3033
+#define EGL_WINDOW_BIT 0x0004
+#define EGL_RENDERABLE_TYPE 0x3040
+#define EGL_OPENGL_ES_BIT 0x0001
+#define EGL_OPENGL_ES2_BIT 0x0004
+#define EGL_OPENGL_BIT 0x0008
+#define EGL_ALPHA_SIZE 0x3021
+#define EGL_BLUE_SIZE 0x3022
+#define EGL_GREEN_SIZE 0x3023
+#define EGL_RED_SIZE 0x3024
+#define EGL_DEPTH_SIZE 0x3025
+#define EGL_STENCIL_SIZE 0x3026
+#define EGL_SAMPLES 0x3031
+#define EGL_OPENGL_ES_API 0x30a0
+#define EGL_OPENGL_API 0x30a2
+#define EGL_NONE 0x3038
+#define EGL_EXTENSIONS 0x3055
+#define EGL_CONTEXT_CLIENT_VERSION 0x3098
+#define EGL_NATIVE_VISUAL_ID 0x302e
+#define EGL_NO_SURFACE ((EGLSurface) 0)
+#define EGL_NO_DISPLAY ((EGLDisplay) 0)
+#define EGL_NO_CONTEXT ((EGLContext) 0)
+#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
+
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
+#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
+#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
+#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
+#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
+#define EGL_CONTEXT_FLAGS_KHR 0x30fc
+#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
+#define EGL_GL_COLORSPACE_KHR 0x309d
+#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
+#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
+#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
+#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
+
+typedef int EGLint;
+typedef unsigned int EGLBoolean;
+typedef unsigned int EGLenum;
+typedef void* EGLConfig;
+typedef void* EGLContext;
+typedef void* EGLDisplay;
+typedef void* EGLSurface;
+
+// EGL function pointer typedefs
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
+typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
+typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
+typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
+typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
+typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
+typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
+typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
+#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
+#define eglGetConfigs _glfw.egl.GetConfigs
+#define eglGetDisplay _glfw.egl.GetDisplay
+#define eglGetError _glfw.egl.GetError
+#define eglInitialize _glfw.egl.Initialize
+#define eglTerminate _glfw.egl.Terminate
+#define eglBindAPI _glfw.egl.BindAPI
+#define eglCreateContext _glfw.egl.CreateContext
+#define eglDestroySurface _glfw.egl.DestroySurface
+#define eglDestroyContext _glfw.egl.DestroyContext
+#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
+#define eglMakeCurrent _glfw.egl.MakeCurrent
+#define eglSwapBuffers _glfw.egl.SwapBuffers
+#define eglSwapInterval _glfw.egl.SwapInterval
+#define eglQueryString _glfw.egl.QueryString
+#define eglGetProcAddress _glfw.egl.GetProcAddress
+
+#define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl
+#define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
+
+
+// EGL-specific per-context data
+//
+typedef struct _GLFWcontextEGL
+{
+ EGLConfig config;
+ EGLContext handle;
+ EGLSurface surface;
+
+ void* client;
+
+} _GLFWcontextEGL;
+
+// EGL-specific global data
+//
+typedef struct _GLFWlibraryEGL
+{
+ EGLDisplay display;
+ EGLint major, minor;
+ GLFWbool prefix;
+
+ GLFWbool KHR_create_context;
+ GLFWbool KHR_create_context_no_error;
+ GLFWbool KHR_gl_colorspace;
+ GLFWbool KHR_get_all_proc_addresses;
+ GLFWbool KHR_context_flush_control;
+
+ void* handle;
+
+ PFN_eglGetConfigAttrib GetConfigAttrib;
+ PFN_eglGetConfigs GetConfigs;
+ PFN_eglGetDisplay GetDisplay;
+ PFN_eglGetError GetError;
+ PFN_eglInitialize Initialize;
+ PFN_eglTerminate Terminate;
+ PFN_eglBindAPI BindAPI;
+ PFN_eglCreateContext CreateContext;
+ PFN_eglDestroySurface DestroySurface;
+ PFN_eglDestroyContext DestroyContext;
+ PFN_eglCreateWindowSurface CreateWindowSurface;
+ PFN_eglMakeCurrent MakeCurrent;
+ PFN_eglSwapBuffers SwapBuffers;
+ PFN_eglSwapInterval SwapInterval;
+ PFN_eglQueryString QueryString;
+ PFN_eglGetProcAddress GetProcAddress;
+
+} _GLFWlibraryEGL;
+
+
+GLFWbool _glfwInitEGL(void);
+void _glfwTerminateEGL(void);
+GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig);
+#if defined(_GLFW_X11)
+GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig,
+ Visual** visual, int* depth);
+#endif /*_GLFW_X11*/
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/glfw_config.h b/Client/ThirdParty/Box2D/extern/glfw/src/glfw_config.h
new file mode 100644
index 0000000..96d7b7f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/glfw_config.h
@@ -0,0 +1,45 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+// As glfw_config.h.in, this file is used by CMake to produce the
+// glfw_config.h configuration header file. If you are adding a feature
+// requiring conditional compilation, this is where to add the macro.
+//========================================================================
+// As glfw_config.h, this file defines compile-time option macros for a
+// specific platform and development environment. If you are using the
+// GLFW CMake files, modify glfw_config.h.in instead of this file. If you
+// are using your own build system, make this file define the appropriate
+// macros in whatever way is suitable.
+//========================================================================
+
+// MODIFIED_ERIN
+#ifdef _WIN32
+ #define _GLFW_WIN32
+ #define _CRT_SECURE_NO_WARNINGS
+#elif __APPLE__
+ #define _GLFW_COCOA
+#else
+ #define _GLFW_X11
+#endif
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/glx_context.c b/Client/ThirdParty/Box2D/extern/glfw/src/glx_context.c
new file mode 100644
index 0000000..adace82
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/glx_context.c
@@ -0,0 +1,698 @@
+//========================================================================
+// GLFW 3.3 GLX - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#ifndef GLXBadProfileARB
+ #define GLXBadProfileARB 13
+#endif
+
+
+// Returns the specified attribute of the specified GLXFBConfig
+//
+static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
+{
+ int value;
+ glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
+ return value;
+}
+
+// Return the GLXFBConfig most closely matching the specified hints
+//
+static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
+ GLXFBConfig* result)
+{
+ GLXFBConfig* nativeConfigs;
+ _GLFWfbconfig* usableConfigs;
+ const _GLFWfbconfig* closest;
+ int i, nativeCount, usableCount;
+ const char* vendor;
+ GLFWbool trustWindowBit = GLFW_TRUE;
+
+ // HACK: This is a (hopefully temporary) workaround for Chromium
+ // (VirtualBox GL) not setting the window bit on any GLXFBConfigs
+ vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
+ if (vendor && strcmp(vendor, "Chromium") == 0)
+ trustWindowBit = GLFW_FALSE;
+
+ nativeConfigs =
+ glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
+ if (!nativeConfigs || !nativeCount)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
+ return GLFW_FALSE;
+ }
+
+ usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
+ usableCount = 0;
+
+ for (i = 0; i < nativeCount; i++)
+ {
+ const GLXFBConfig n = nativeConfigs[i];
+ _GLFWfbconfig* u = usableConfigs + usableCount;
+
+ // Only consider RGBA GLXFBConfigs
+ if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
+ continue;
+
+ // Only consider window GLXFBConfigs
+ if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
+ {
+ if (trustWindowBit)
+ continue;
+ }
+
+ if (desired->transparent)
+ {
+ XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
+ if (vi)
+ {
+ u->transparent = _glfwIsVisualTransparentX11(vi->visual);
+ XFree(vi);
+ }
+ }
+
+ u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
+ u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
+ u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
+
+ u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
+ u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
+ u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
+
+ u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
+ u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
+ u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
+ u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
+
+ u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
+
+ if (getGLXFBConfigAttrib(n, GLX_STEREO))
+ u->stereo = GLFW_TRUE;
+ if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
+ u->doublebuffer = GLFW_TRUE;
+
+ if (_glfw.glx.ARB_multisample)
+ u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
+
+ if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
+ u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
+
+ u->handle = (uintptr_t) n;
+ usableCount++;
+ }
+
+ closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
+ if (closest)
+ *result = (GLXFBConfig) closest->handle;
+
+ XFree(nativeConfigs);
+ free(usableConfigs);
+
+ return closest != NULL;
+}
+
+// Create the OpenGL context using legacy API
+//
+static GLXContext createLegacyContextGLX(_GLFWwindow* window,
+ GLXFBConfig fbconfig,
+ GLXContext share)
+{
+ return glXCreateNewContext(_glfw.x11.display,
+ fbconfig,
+ GLX_RGBA_TYPE,
+ share,
+ True);
+}
+
+static void makeContextCurrentGLX(_GLFWwindow* window)
+{
+ if (window)
+ {
+ if (!glXMakeCurrent(_glfw.x11.display,
+ window->context.glx.window,
+ window->context.glx.handle))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "GLX: Failed to make context current");
+ return;
+ }
+ }
+ else
+ {
+ if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "GLX: Failed to clear current context");
+ return;
+ }
+ }
+
+ _glfwPlatformSetTls(&_glfw.contextSlot, window);
+}
+
+static void swapBuffersGLX(_GLFWwindow* window)
+{
+ glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
+}
+
+static void swapIntervalGLX(int interval)
+{
+ _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
+
+ if (_glfw.glx.EXT_swap_control)
+ {
+ _glfw.glx.SwapIntervalEXT(_glfw.x11.display,
+ window->context.glx.window,
+ interval);
+ }
+ else if (_glfw.glx.MESA_swap_control)
+ _glfw.glx.SwapIntervalMESA(interval);
+ else if (_glfw.glx.SGI_swap_control)
+ {
+ if (interval > 0)
+ _glfw.glx.SwapIntervalSGI(interval);
+ }
+}
+
+static int extensionSupportedGLX(const char* extension)
+{
+ const char* extensions =
+ glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
+ if (extensions)
+ {
+ if (_glfwStringInExtensionString(extension, extensions))
+ return GLFW_TRUE;
+ }
+
+ return GLFW_FALSE;
+}
+
+static GLFWglproc getProcAddressGLX(const char* procname)
+{
+ if (_glfw.glx.GetProcAddress)
+ return _glfw.glx.GetProcAddress((const GLubyte*) procname);
+ else if (_glfw.glx.GetProcAddressARB)
+ return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
+ else
+ return _glfw_dlsym(_glfw.glx.handle, procname);
+}
+
+// Destroy the OpenGL context
+//
+static void destroyContextGLX(_GLFWwindow* window)
+{
+ if (window->context.glx.window)
+ {
+ glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
+ window->context.glx.window = None;
+ }
+
+ if (window->context.glx.handle)
+ {
+ glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
+ window->context.glx.handle = NULL;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize GLX
+//
+GLFWbool _glfwInitGLX(void)
+{
+ int i;
+ const char* sonames[] =
+ {
+#if defined(_GLFW_GLX_LIBRARY)
+ _GLFW_GLX_LIBRARY,
+#elif defined(__CYGWIN__)
+ "libGL-1.so",
+#else
+ "libGL.so.1",
+ "libGL.so",
+#endif
+ NULL
+ };
+
+ if (_glfw.glx.handle)
+ return GLFW_TRUE;
+
+ for (i = 0; sonames[i]; i++)
+ {
+ _glfw.glx.handle = _glfw_dlopen(sonames[i]);
+ if (_glfw.glx.handle)
+ break;
+ }
+
+ if (!_glfw.glx.handle)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
+ return GLFW_FALSE;
+ }
+
+ _glfw.glx.GetFBConfigs =
+ _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs");
+ _glfw.glx.GetFBConfigAttrib =
+ _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
+ _glfw.glx.GetClientString =
+ _glfw_dlsym(_glfw.glx.handle, "glXGetClientString");
+ _glfw.glx.QueryExtension =
+ _glfw_dlsym(_glfw.glx.handle, "glXQueryExtension");
+ _glfw.glx.QueryVersion =
+ _glfw_dlsym(_glfw.glx.handle, "glXQueryVersion");
+ _glfw.glx.DestroyContext =
+ _glfw_dlsym(_glfw.glx.handle, "glXDestroyContext");
+ _glfw.glx.MakeCurrent =
+ _glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent");
+ _glfw.glx.SwapBuffers =
+ _glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers");
+ _glfw.glx.QueryExtensionsString =
+ _glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
+ _glfw.glx.CreateNewContext =
+ _glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext");
+ _glfw.glx.CreateWindow =
+ _glfw_dlsym(_glfw.glx.handle, "glXCreateWindow");
+ _glfw.glx.DestroyWindow =
+ _glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow");
+ _glfw.glx.GetProcAddress =
+ _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
+ _glfw.glx.GetProcAddressARB =
+ _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
+ _glfw.glx.GetVisualFromFBConfig =
+ _glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
+
+ if (!_glfw.glx.GetFBConfigs ||
+ !_glfw.glx.GetFBConfigAttrib ||
+ !_glfw.glx.GetClientString ||
+ !_glfw.glx.QueryExtension ||
+ !_glfw.glx.QueryVersion ||
+ !_glfw.glx.DestroyContext ||
+ !_glfw.glx.MakeCurrent ||
+ !_glfw.glx.SwapBuffers ||
+ !_glfw.glx.QueryExtensionsString ||
+ !_glfw.glx.CreateNewContext ||
+ !_glfw.glx.CreateWindow ||
+ !_glfw.glx.DestroyWindow ||
+ !_glfw.glx.GetProcAddress ||
+ !_glfw.glx.GetProcAddressARB ||
+ !_glfw.glx.GetVisualFromFBConfig)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "GLX: Failed to load required entry points");
+ return GLFW_FALSE;
+ }
+
+ if (!glXQueryExtension(_glfw.x11.display,
+ &_glfw.glx.errorBase,
+ &_glfw.glx.eventBase))
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
+ return GLFW_FALSE;
+ }
+
+ if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "GLX: Failed to query GLX version");
+ return GLFW_FALSE;
+ }
+
+ if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "GLX: GLX version 1.3 is required");
+ return GLFW_FALSE;
+ }
+
+ if (extensionSupportedGLX("GLX_EXT_swap_control"))
+ {
+ _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
+ getProcAddressGLX("glXSwapIntervalEXT");
+
+ if (_glfw.glx.SwapIntervalEXT)
+ _glfw.glx.EXT_swap_control = GLFW_TRUE;
+ }
+
+ if (extensionSupportedGLX("GLX_SGI_swap_control"))
+ {
+ _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
+ getProcAddressGLX("glXSwapIntervalSGI");
+
+ if (_glfw.glx.SwapIntervalSGI)
+ _glfw.glx.SGI_swap_control = GLFW_TRUE;
+ }
+
+ if (extensionSupportedGLX("GLX_MESA_swap_control"))
+ {
+ _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
+ getProcAddressGLX("glXSwapIntervalMESA");
+
+ if (_glfw.glx.SwapIntervalMESA)
+ _glfw.glx.MESA_swap_control = GLFW_TRUE;
+ }
+
+ if (extensionSupportedGLX("GLX_ARB_multisample"))
+ _glfw.glx.ARB_multisample = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
+ _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
+ _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_ARB_create_context"))
+ {
+ _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
+ getProcAddressGLX("glXCreateContextAttribsARB");
+
+ if (_glfw.glx.CreateContextAttribsARB)
+ _glfw.glx.ARB_create_context = GLFW_TRUE;
+ }
+
+ if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
+ _glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
+ _glfw.glx.ARB_create_context_profile = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
+ _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
+ _glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
+
+ if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
+ _glfw.glx.ARB_context_flush_control = GLFW_TRUE;
+
+ return GLFW_TRUE;
+}
+
+// Terminate GLX
+//
+void _glfwTerminateGLX(void)
+{
+ // NOTE: This function must not call any X11 functions, as it is called
+ // after XCloseDisplay (see _glfwPlatformTerminate for details)
+
+ if (_glfw.glx.handle)
+ {
+ _glfw_dlclose(_glfw.glx.handle);
+ _glfw.glx.handle = NULL;
+ }
+}
+
+#define setAttrib(a, v) \
+{ \
+ assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
+ attribs[index++] = a; \
+ attribs[index++] = v; \
+}
+
+// Create the OpenGL or OpenGL ES context
+//
+GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ int attribs[40];
+ GLXFBConfig native = NULL;
+ GLXContext share = NULL;
+
+ if (ctxconfig->share)
+ share = ctxconfig->share->context.glx.handle;
+
+ if (!chooseGLXFBConfig(fbconfig, &native))
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "GLX: Failed to find a suitable GLXFBConfig");
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ if (!_glfw.glx.ARB_create_context ||
+ !_glfw.glx.ARB_create_context_profile ||
+ !_glfw.glx.EXT_create_context_es2_profile)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->forward)
+ {
+ if (!_glfw.glx.ARB_create_context)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->profile)
+ {
+ if (!_glfw.glx.ARB_create_context ||
+ !_glfw.glx.ARB_create_context_profile)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
+ return GLFW_FALSE;
+ }
+ }
+
+ _glfwGrabErrorHandlerX11();
+
+ if (_glfw.glx.ARB_create_context)
+ {
+ int index = 0, mask = 0, flags = 0;
+
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if (ctxconfig->forward)
+ flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+
+ if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
+ mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+ else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
+ mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+ }
+ else
+ mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
+
+ if (ctxconfig->debug)
+ flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
+
+ if (ctxconfig->robustness)
+ {
+ if (_glfw.glx.ARB_create_context_robustness)
+ {
+ if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
+ {
+ setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
+ GLX_NO_RESET_NOTIFICATION_ARB);
+ }
+ else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
+ {
+ setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
+ GLX_LOSE_CONTEXT_ON_RESET_ARB);
+ }
+
+ flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
+ }
+ }
+
+ if (ctxconfig->release)
+ {
+ if (_glfw.glx.ARB_context_flush_control)
+ {
+ if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
+ {
+ setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
+ GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
+ }
+ else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
+ {
+ setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
+ GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
+ }
+ }
+ }
+
+ if (ctxconfig->noerror)
+ {
+ if (_glfw.glx.ARB_create_context_no_error)
+ setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
+ }
+
+ // NOTE: Only request an explicitly versioned context when necessary, as
+ // explicitly requesting version 1.0 does not always return the
+ // highest version supported by the driver
+ if (ctxconfig->major != 1 || ctxconfig->minor != 0)
+ {
+ setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
+ setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
+ }
+
+ if (mask)
+ setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
+
+ if (flags)
+ setAttrib(GLX_CONTEXT_FLAGS_ARB, flags);
+
+ setAttrib(None, None);
+
+ window->context.glx.handle =
+ _glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
+ native,
+ share,
+ True,
+ attribs);
+
+ // HACK: This is a fallback for broken versions of the Mesa
+ // implementation of GLX_ARB_create_context_profile that fail
+ // default 1.0 context creation with a GLXBadProfileARB error in
+ // violation of the extension spec
+ if (!window->context.glx.handle)
+ {
+ if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
+ ctxconfig->client == GLFW_OPENGL_API &&
+ ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
+ ctxconfig->forward == GLFW_FALSE)
+ {
+ window->context.glx.handle =
+ createLegacyContextGLX(window, native, share);
+ }
+ }
+ }
+ else
+ {
+ window->context.glx.handle =
+ createLegacyContextGLX(window, native, share);
+ }
+
+ _glfwReleaseErrorHandlerX11();
+
+ if (!window->context.glx.handle)
+ {
+ _glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
+ return GLFW_FALSE;
+ }
+
+ window->context.glx.window =
+ glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
+ if (!window->context.glx.window)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
+ return GLFW_FALSE;
+ }
+
+ window->context.makeCurrent = makeContextCurrentGLX;
+ window->context.swapBuffers = swapBuffersGLX;
+ window->context.swapInterval = swapIntervalGLX;
+ window->context.extensionSupported = extensionSupportedGLX;
+ window->context.getProcAddress = getProcAddressGLX;
+ window->context.destroy = destroyContextGLX;
+
+ return GLFW_TRUE;
+}
+
+#undef setAttrib
+
+// Returns the Visual and depth of the chosen GLXFBConfig
+//
+GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig,
+ Visual** visual, int* depth)
+{
+ GLXFBConfig native;
+ XVisualInfo* result;
+
+ if (!chooseGLXFBConfig(fbconfig, &native))
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "GLX: Failed to find a suitable GLXFBConfig");
+ return GLFW_FALSE;
+ }
+
+ result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
+ if (!result)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "GLX: Failed to retrieve Visual for GLXFBConfig");
+ return GLFW_FALSE;
+ }
+
+ *visual = result->visual;
+ *depth = result->depth;
+
+ XFree(result);
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return NULL;
+ }
+
+ return window->context.glx.handle;
+}
+
+GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(None);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return None;
+ }
+
+ return window->context.glx.window;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/glx_context.h b/Client/ThirdParty/Box2D/extern/glfw/src/glx_context.h
new file mode 100644
index 0000000..f767cb1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/glx_context.h
@@ -0,0 +1,181 @@
+//========================================================================
+// GLFW 3.3 GLX - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define GLX_VENDOR 1
+#define GLX_RGBA_BIT 0x00000001
+#define GLX_WINDOW_BIT 0x00000001
+#define GLX_DRAWABLE_TYPE 0x8010
+#define GLX_RENDER_TYPE 0x8011
+#define GLX_RGBA_TYPE 0x8014
+#define GLX_DOUBLEBUFFER 5
+#define GLX_STEREO 6
+#define GLX_AUX_BUFFERS 7
+#define GLX_RED_SIZE 8
+#define GLX_GREEN_SIZE 9
+#define GLX_BLUE_SIZE 10
+#define GLX_ALPHA_SIZE 11
+#define GLX_DEPTH_SIZE 12
+#define GLX_STENCIL_SIZE 13
+#define GLX_ACCUM_RED_SIZE 14
+#define GLX_ACCUM_GREEN_SIZE 15
+#define GLX_ACCUM_BLUE_SIZE 16
+#define GLX_ACCUM_ALPHA_SIZE 17
+#define GLX_SAMPLES 0x186a1
+#define GLX_VISUAL_ID 0x800b
+
+#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
+#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
+#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
+#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
+#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
+#define GLX_CONTEXT_FLAGS_ARB 0x2094
+#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
+#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
+#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
+#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
+#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
+#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
+#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
+#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
+
+typedef XID GLXWindow;
+typedef XID GLXDrawable;
+typedef struct __GLXFBConfig* GLXFBConfig;
+typedef struct __GLXcontext* GLXContext;
+typedef void (*__GLXextproc)(void);
+
+typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
+typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
+typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
+typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
+typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
+typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
+typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
+typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
+typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
+typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
+typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
+typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
+typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
+typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
+typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
+
+typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
+typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
+typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
+
+// libGL.so function pointer typedefs
+#define glXGetFBConfigs _glfw.glx.GetFBConfigs
+#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
+#define glXGetClientString _glfw.glx.GetClientString
+#define glXQueryExtension _glfw.glx.QueryExtension
+#define glXQueryVersion _glfw.glx.QueryVersion
+#define glXDestroyContext _glfw.glx.DestroyContext
+#define glXMakeCurrent _glfw.glx.MakeCurrent
+#define glXSwapBuffers _glfw.glx.SwapBuffers
+#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
+#define glXCreateNewContext _glfw.glx.CreateNewContext
+#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
+#define glXCreateWindow _glfw.glx.CreateWindow
+#define glXDestroyWindow _glfw.glx.DestroyWindow
+
+#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
+#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx
+
+
+// GLX-specific per-context data
+//
+typedef struct _GLFWcontextGLX
+{
+ GLXContext handle;
+ GLXWindow window;
+
+} _GLFWcontextGLX;
+
+// GLX-specific global data
+//
+typedef struct _GLFWlibraryGLX
+{
+ int major, minor;
+ int eventBase;
+ int errorBase;
+
+ // dlopen handle for libGL.so.1
+ void* handle;
+
+ // GLX 1.3 functions
+ PFNGLXGETFBCONFIGSPROC GetFBConfigs;
+ PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
+ PFNGLXGETCLIENTSTRINGPROC GetClientString;
+ PFNGLXQUERYEXTENSIONPROC QueryExtension;
+ PFNGLXQUERYVERSIONPROC QueryVersion;
+ PFNGLXDESTROYCONTEXTPROC DestroyContext;
+ PFNGLXMAKECURRENTPROC MakeCurrent;
+ PFNGLXSWAPBUFFERSPROC SwapBuffers;
+ PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
+ PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
+ PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
+ PFNGLXCREATEWINDOWPROC CreateWindow;
+ PFNGLXDESTROYWINDOWPROC DestroyWindow;
+
+ // GLX 1.4 and extension functions
+ PFNGLXGETPROCADDRESSPROC GetProcAddress;
+ PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
+ PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
+ PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
+ PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
+ PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
+ GLFWbool SGI_swap_control;
+ GLFWbool EXT_swap_control;
+ GLFWbool MESA_swap_control;
+ GLFWbool ARB_multisample;
+ GLFWbool ARB_framebuffer_sRGB;
+ GLFWbool EXT_framebuffer_sRGB;
+ GLFWbool ARB_create_context;
+ GLFWbool ARB_create_context_profile;
+ GLFWbool ARB_create_context_robustness;
+ GLFWbool EXT_create_context_es2_profile;
+ GLFWbool ARB_create_context_no_error;
+ GLFWbool ARB_context_flush_control;
+
+} _GLFWlibraryGLX;
+
+GLFWbool _glfwInitGLX(void);
+void _glfwTerminateGLX(void);
+GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig);
+void _glfwDestroyContextGLX(_GLFWwindow* window);
+GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig,
+ Visual** visual, int* depth);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/init.c b/Client/ThirdParty/Box2D/extern/glfw/src/init.c
new file mode 100644
index 0000000..4f424c4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/init.c
@@ -0,0 +1,338 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+#include "mappings.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+
+
+// The global variables below comprise all mutable global data in GLFW
+//
+// Any other global variable is a bug
+
+// Global state shared between compilation units of GLFW
+//
+_GLFWlibrary _glfw = { GLFW_FALSE };
+
+// These are outside of _glfw so they can be used before initialization and
+// after termination
+//
+static _GLFWerror _glfwMainThreadError;
+static GLFWerrorfun _glfwErrorCallback;
+static _GLFWinitconfig _glfwInitHints =
+{
+ GLFW_TRUE, // hat buttons
+ {
+ GLFW_TRUE, // macOS menu bar
+ GLFW_TRUE // macOS bundle chdir
+ }
+};
+
+// Terminate the library
+//
+static void terminate(void)
+{
+ int i;
+
+ memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
+
+ while (_glfw.windowListHead)
+ glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
+
+ while (_glfw.cursorListHead)
+ glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);
+
+ for (i = 0; i < _glfw.monitorCount; i++)
+ {
+ _GLFWmonitor* monitor = _glfw.monitors[i];
+ if (monitor->originalRamp.size)
+ _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
+ _glfwFreeMonitor(monitor);
+ }
+
+ free(_glfw.monitors);
+ _glfw.monitors = NULL;
+ _glfw.monitorCount = 0;
+
+ free(_glfw.mappings);
+ _glfw.mappings = NULL;
+ _glfw.mappingCount = 0;
+
+ _glfwTerminateVulkan();
+ _glfwPlatformTerminate();
+
+ _glfw.initialized = GLFW_FALSE;
+
+ while (_glfw.errorListHead)
+ {
+ _GLFWerror* error = _glfw.errorListHead;
+ _glfw.errorListHead = error->next;
+ free(error);
+ }
+
+ _glfwPlatformDestroyTls(&_glfw.contextSlot);
+ _glfwPlatformDestroyTls(&_glfw.errorSlot);
+ _glfwPlatformDestroyMutex(&_glfw.errorLock);
+
+ memset(&_glfw, 0, sizeof(_glfw));
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+char* _glfw_strdup(const char* source)
+{
+ const size_t length = strlen(source);
+ char* result = calloc(length + 1, 1);
+ strcpy(result, source);
+ return result;
+}
+
+float _glfw_fminf(float a, float b)
+{
+ if (a != a)
+ return b;
+ else if (b != b)
+ return a;
+ else if (a < b)
+ return a;
+ else
+ return b;
+}
+
+float _glfw_fmaxf(float a, float b)
+{
+ if (a != a)
+ return b;
+ else if (b != b)
+ return a;
+ else if (a > b)
+ return a;
+ else
+ return b;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW event API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Notifies shared code of an error
+//
+void _glfwInputError(int code, const char* format, ...)
+{
+ _GLFWerror* error;
+ char description[_GLFW_MESSAGE_SIZE];
+
+ if (format)
+ {
+ va_list vl;
+
+ va_start(vl, format);
+ vsnprintf(description, sizeof(description), format, vl);
+ va_end(vl);
+
+ description[sizeof(description) - 1] = '\0';
+ }
+ else
+ {
+ if (code == GLFW_NOT_INITIALIZED)
+ strcpy(description, "The GLFW library is not initialized");
+ else if (code == GLFW_NO_CURRENT_CONTEXT)
+ strcpy(description, "There is no current context");
+ else if (code == GLFW_INVALID_ENUM)
+ strcpy(description, "Invalid argument for enum parameter");
+ else if (code == GLFW_INVALID_VALUE)
+ strcpy(description, "Invalid value for parameter");
+ else if (code == GLFW_OUT_OF_MEMORY)
+ strcpy(description, "Out of memory");
+ else if (code == GLFW_API_UNAVAILABLE)
+ strcpy(description, "The requested API is unavailable");
+ else if (code == GLFW_VERSION_UNAVAILABLE)
+ strcpy(description, "The requested API version is unavailable");
+ else if (code == GLFW_PLATFORM_ERROR)
+ strcpy(description, "A platform-specific error occurred");
+ else if (code == GLFW_FORMAT_UNAVAILABLE)
+ strcpy(description, "The requested format is unavailable");
+ else if (code == GLFW_NO_WINDOW_CONTEXT)
+ strcpy(description, "The specified window has no context");
+ else
+ strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
+ }
+
+ if (_glfw.initialized)
+ {
+ error = _glfwPlatformGetTls(&_glfw.errorSlot);
+ if (!error)
+ {
+ error = calloc(1, sizeof(_GLFWerror));
+ _glfwPlatformSetTls(&_glfw.errorSlot, error);
+ _glfwPlatformLockMutex(&_glfw.errorLock);
+ error->next = _glfw.errorListHead;
+ _glfw.errorListHead = error;
+ _glfwPlatformUnlockMutex(&_glfw.errorLock);
+ }
+ }
+ else
+ error = &_glfwMainThreadError;
+
+ error->code = code;
+ strcpy(error->description, description);
+
+ if (_glfwErrorCallback)
+ _glfwErrorCallback(code, description);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW public API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI int glfwInit(void)
+{
+ if (_glfw.initialized)
+ return GLFW_TRUE;
+
+ memset(&_glfw, 0, sizeof(_glfw));
+ _glfw.hints.init = _glfwInitHints;
+
+ if (!_glfwPlatformInit())
+ {
+ terminate();
+ return GLFW_FALSE;
+ }
+
+ if (!_glfwPlatformCreateMutex(&_glfw.errorLock) ||
+ !_glfwPlatformCreateTls(&_glfw.errorSlot) ||
+ !_glfwPlatformCreateTls(&_glfw.contextSlot))
+ {
+ terminate();
+ return GLFW_FALSE;
+ }
+
+ _glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
+
+ _glfw.initialized = GLFW_TRUE;
+ _glfw.timer.offset = _glfwPlatformGetTimerValue();
+
+ glfwDefaultWindowHints();
+
+ {
+ int i;
+
+ for (i = 0; _glfwDefaultMappings[i]; i++)
+ {
+ if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
+ {
+ terminate();
+ return GLFW_FALSE;
+ }
+ }
+ }
+
+ return GLFW_TRUE;
+}
+
+GLFWAPI void glfwTerminate(void)
+{
+ if (!_glfw.initialized)
+ return;
+
+ terminate();
+}
+
+GLFWAPI void glfwInitHint(int hint, int value)
+{
+ switch (hint)
+ {
+ case GLFW_JOYSTICK_HAT_BUTTONS:
+ _glfwInitHints.hatButtons = value;
+ return;
+ case GLFW_COCOA_CHDIR_RESOURCES:
+ _glfwInitHints.ns.chdir = value;
+ return;
+ case GLFW_COCOA_MENUBAR:
+ _glfwInitHints.ns.menubar = value;
+ return;
+ }
+
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid init hint 0x%08X", hint);
+}
+
+GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
+{
+ if (major != NULL)
+ *major = GLFW_VERSION_MAJOR;
+ if (minor != NULL)
+ *minor = GLFW_VERSION_MINOR;
+ if (rev != NULL)
+ *rev = GLFW_VERSION_REVISION;
+}
+
+GLFWAPI const char* glfwGetVersionString(void)
+{
+ return _glfwPlatformGetVersionString();
+}
+
+GLFWAPI int glfwGetError(const char** description)
+{
+ _GLFWerror* error;
+ int code = GLFW_NO_ERROR;
+
+ if (description)
+ *description = NULL;
+
+ if (_glfw.initialized)
+ error = _glfwPlatformGetTls(&_glfw.errorSlot);
+ else
+ error = &_glfwMainThreadError;
+
+ if (error)
+ {
+ code = error->code;
+ error->code = GLFW_NO_ERROR;
+ if (description && code)
+ *description = error->description;
+ }
+
+ return code;
+}
+
+GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
+{
+ _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);
+ return cbfun;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/input.c b/Client/ThirdParty/Box2D/extern/glfw/src/input.c
new file mode 100644
index 0000000..460e9f3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/input.c
@@ -0,0 +1,1307 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <float.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Internal key state used for sticky keys
+#define _GLFW_STICK 3
+
+// Internal constants for gamepad mapping source types
+#define _GLFW_JOYSTICK_AXIS 1
+#define _GLFW_JOYSTICK_BUTTON 2
+#define _GLFW_JOYSTICK_HATBIT 3
+
+// Finds a mapping based on joystick GUID
+//
+static _GLFWmapping* findMapping(const char* guid)
+{
+ int i;
+
+ for (i = 0; i < _glfw.mappingCount; i++)
+ {
+ if (strcmp(_glfw.mappings[i].guid, guid) == 0)
+ return _glfw.mappings + i;
+ }
+
+ return NULL;
+}
+
+// Checks whether a gamepad mapping element is present in the hardware
+//
+static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
+ const _GLFWjoystick* js)
+{
+ if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount)
+ return GLFW_FALSE;
+ else if (e->type == _GLFW_JOYSTICK_BUTTON && e->index >= js->buttonCount)
+ return GLFW_FALSE;
+ else if (e->type == _GLFW_JOYSTICK_AXIS && e->index >= js->axisCount)
+ return GLFW_FALSE;
+
+ return GLFW_TRUE;
+}
+
+// Finds a mapping based on joystick GUID and verifies element indices
+//
+static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
+{
+ _GLFWmapping* mapping = findMapping(js->guid);
+ if (mapping)
+ {
+ int i;
+
+ for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
+ {
+ if (!isValidElementForJoystick(mapping->buttons + i, js))
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid button in gamepad mapping %s (%s)",
+ mapping->guid,
+ mapping->name);
+ return NULL;
+ }
+ }
+
+ for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
+ {
+ if (!isValidElementForJoystick(mapping->axes + i, js))
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid axis in gamepad mapping %s (%s)",
+ mapping->guid,
+ mapping->name);
+ return NULL;
+ }
+ }
+ }
+
+ return mapping;
+}
+
+// Parses an SDL_GameControllerDB line and adds it to the mapping list
+//
+static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
+{
+ const char* c = string;
+ size_t i, length;
+ struct
+ {
+ const char* name;
+ _GLFWmapelement* element;
+ } fields[] =
+ {
+ { "platform", NULL },
+ { "a", mapping->buttons + GLFW_GAMEPAD_BUTTON_A },
+ { "b", mapping->buttons + GLFW_GAMEPAD_BUTTON_B },
+ { "x", mapping->buttons + GLFW_GAMEPAD_BUTTON_X },
+ { "y", mapping->buttons + GLFW_GAMEPAD_BUTTON_Y },
+ { "back", mapping->buttons + GLFW_GAMEPAD_BUTTON_BACK },
+ { "start", mapping->buttons + GLFW_GAMEPAD_BUTTON_START },
+ { "guide", mapping->buttons + GLFW_GAMEPAD_BUTTON_GUIDE },
+ { "leftshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
+ { "rightshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER },
+ { "leftstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_THUMB },
+ { "rightstick", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB },
+ { "dpup", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_UP },
+ { "dpright", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT },
+ { "dpdown", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_DOWN },
+ { "dpleft", mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_LEFT },
+ { "lefttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER },
+ { "righttrigger", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER },
+ { "leftx", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_X },
+ { "lefty", mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_Y },
+ { "rightx", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_X },
+ { "righty", mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_Y }
+ };
+
+ length = strcspn(c, ",");
+ if (length != 32 || c[length] != ',')
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, NULL);
+ return GLFW_FALSE;
+ }
+
+ memcpy(mapping->guid, c, length);
+ c += length + 1;
+
+ length = strcspn(c, ",");
+ if (length >= sizeof(mapping->name) || c[length] != ',')
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, NULL);
+ return GLFW_FALSE;
+ }
+
+ memcpy(mapping->name, c, length);
+ c += length + 1;
+
+ while (*c)
+ {
+ // TODO: Implement output modifiers
+ if (*c == '+' || *c == '-')
+ return GLFW_FALSE;
+
+ for (i = 0; i < sizeof(fields) / sizeof(fields[0]); i++)
+ {
+ length = strlen(fields[i].name);
+ if (strncmp(c, fields[i].name, length) != 0 || c[length] != ':')
+ continue;
+
+ c += length + 1;
+
+ if (fields[i].element)
+ {
+ _GLFWmapelement* e = fields[i].element;
+ int8_t minimum = -1;
+ int8_t maximum = 1;
+
+ if (*c == '+')
+ {
+ minimum = 0;
+ c += 1;
+ }
+ else if (*c == '-')
+ {
+ maximum = 0;
+ c += 1;
+ }
+
+ if (*c == 'a')
+ e->type = _GLFW_JOYSTICK_AXIS;
+ else if (*c == 'b')
+ e->type = _GLFW_JOYSTICK_BUTTON;
+ else if (*c == 'h')
+ e->type = _GLFW_JOYSTICK_HATBIT;
+ else
+ break;
+
+ if (e->type == _GLFW_JOYSTICK_HATBIT)
+ {
+ const unsigned long hat = strtoul(c + 1, (char**) &c, 10);
+ const unsigned long bit = strtoul(c + 1, (char**) &c, 10);
+ e->index = (uint8_t) ((hat << 4) | bit);
+ }
+ else
+ e->index = (uint8_t) strtoul(c + 1, (char**) &c, 10);
+
+ if (e->type == _GLFW_JOYSTICK_AXIS)
+ {
+ e->axisScale = 2 / (maximum - minimum);
+ e->axisOffset = -(maximum + minimum);
+
+ if (*c == '~')
+ {
+ e->axisScale = -e->axisScale;
+ e->axisOffset = -e->axisOffset;
+ }
+ }
+ }
+ else
+ {
+ length = strlen(_GLFW_PLATFORM_MAPPING_NAME);
+ if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0)
+ return GLFW_FALSE;
+ }
+
+ break;
+ }
+
+ c += strcspn(c, ",");
+ c += strspn(c, ",");
+ }
+
+ for (i = 0; i < 32; i++)
+ {
+ if (mapping->guid[i] >= 'A' && mapping->guid[i] <= 'F')
+ mapping->guid[i] += 'a' - 'A';
+ }
+
+ _glfwPlatformUpdateGamepadGUID(mapping->guid);
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW event API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Notifies shared code of a physical key event
+//
+void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
+{
+ if (key >= 0 && key <= GLFW_KEY_LAST)
+ {
+ GLFWbool repeated = GLFW_FALSE;
+
+ if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)
+ return;
+
+ if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)
+ repeated = GLFW_TRUE;
+
+ if (action == GLFW_RELEASE && window->stickyKeys)
+ window->keys[key] = _GLFW_STICK;
+ else
+ window->keys[key] = (char) action;
+
+ if (repeated)
+ action = GLFW_REPEAT;
+ }
+
+ if (!window->lockKeyMods)
+ mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
+
+ if (window->callbacks.key)
+ window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
+}
+
+// Notifies shared code of a Unicode codepoint input event
+// The 'plain' parameter determines whether to emit a regular character event
+//
+void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWbool plain)
+{
+ if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
+ return;
+
+ if (!window->lockKeyMods)
+ mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
+
+ if (window->callbacks.charmods)
+ window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
+
+ if (plain)
+ {
+ if (window->callbacks.character)
+ window->callbacks.character((GLFWwindow*) window, codepoint);
+ }
+}
+
+// Notifies shared code of a scroll event
+//
+void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
+{
+ if (window->callbacks.scroll)
+ window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
+}
+
+// Notifies shared code of a mouse button click event
+//
+void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
+{
+ if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
+ return;
+
+ if (!window->lockKeyMods)
+ mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
+
+ if (action == GLFW_RELEASE && window->stickyMouseButtons)
+ window->mouseButtons[button] = _GLFW_STICK;
+ else
+ window->mouseButtons[button] = (char) action;
+
+ if (window->callbacks.mouseButton)
+ window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
+}
+
+// Notifies shared code of a cursor motion event
+// The position is specified in client-area relative screen coordinates
+//
+void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
+{
+ if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
+ return;
+
+ window->virtualCursorPosX = xpos;
+ window->virtualCursorPosY = ypos;
+
+ if (window->callbacks.cursorPos)
+ window->callbacks.cursorPos((GLFWwindow*) window, xpos, ypos);
+}
+
+// Notifies shared code of a cursor enter/leave event
+//
+void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
+{
+ if (window->callbacks.cursorEnter)
+ window->callbacks.cursorEnter((GLFWwindow*) window, entered);
+}
+
+// Notifies shared code of files or directories dropped on a window
+//
+void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
+{
+ if (window->callbacks.drop)
+ window->callbacks.drop((GLFWwindow*) window, count, paths);
+}
+
+// Notifies shared code of a joystick connection or disconnection
+//
+void _glfwInputJoystick(_GLFWjoystick* js, int event)
+{
+ const int jid = (int) (js - _glfw.joysticks);
+
+ if (_glfw.callbacks.joystick)
+ _glfw.callbacks.joystick(jid, event);
+}
+
+// Notifies shared code of the new value of a joystick axis
+//
+void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
+{
+ js->axes[axis] = value;
+}
+
+// Notifies shared code of the new value of a joystick button
+//
+void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
+{
+ js->buttons[button] = value;
+}
+
+// Notifies shared code of the new value of a joystick hat
+//
+void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
+{
+ const int base = js->buttonCount + hat * 4;
+
+ js->buttons[base + 0] = (value & 0x01) ? GLFW_PRESS : GLFW_RELEASE;
+ js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
+ js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
+ js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
+
+ js->hats[hat] = value;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Returns an available joystick object with arrays and name allocated
+//
+_GLFWjoystick* _glfwAllocJoystick(const char* name,
+ const char* guid,
+ int axisCount,
+ int buttonCount,
+ int hatCount)
+{
+ int jid;
+ _GLFWjoystick* js;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ if (!_glfw.joysticks[jid].present)
+ break;
+ }
+
+ if (jid > GLFW_JOYSTICK_LAST)
+ return NULL;
+
+ js = _glfw.joysticks + jid;
+ js->present = GLFW_TRUE;
+ js->name = _glfw_strdup(name);
+ js->axes = calloc(axisCount, sizeof(float));
+ js->buttons = calloc(buttonCount + hatCount * 4, 1);
+ js->hats = calloc(hatCount, 1);
+ js->axisCount = axisCount;
+ js->buttonCount = buttonCount;
+ js->hatCount = hatCount;
+
+ strcpy(js->guid, guid);
+ js->mapping = findValidMapping(js);
+
+ return js;
+}
+
+// Frees arrays and name and flags the joystick object as unused
+//
+void _glfwFreeJoystick(_GLFWjoystick* js)
+{
+ free(js->name);
+ free(js->axes);
+ free(js->buttons);
+ free(js->hats);
+ memset(js, 0, sizeof(_GLFWjoystick));
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW public API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(0);
+
+ switch (mode)
+ {
+ case GLFW_CURSOR:
+ return window->cursorMode;
+ case GLFW_STICKY_KEYS:
+ return window->stickyKeys;
+ case GLFW_STICKY_MOUSE_BUTTONS:
+ return window->stickyMouseButtons;
+ case GLFW_LOCK_KEY_MODS:
+ return window->lockKeyMods;
+ }
+
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
+ return 0;
+}
+
+GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (mode == GLFW_CURSOR)
+ {
+ if (value != GLFW_CURSOR_NORMAL &&
+ value != GLFW_CURSOR_HIDDEN &&
+ value != GLFW_CURSOR_DISABLED)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM,
+ "Invalid cursor mode 0x%08X",
+ value);
+ return;
+ }
+
+ if (window->cursorMode == value)
+ return;
+
+ window->cursorMode = value;
+
+ _glfwPlatformGetCursorPos(window,
+ &window->virtualCursorPosX,
+ &window->virtualCursorPosY);
+ _glfwPlatformSetCursorMode(window, value);
+ }
+ else if (mode == GLFW_STICKY_KEYS)
+ {
+ value = value ? GLFW_TRUE : GLFW_FALSE;
+ if (window->stickyKeys == value)
+ return;
+
+ if (!value)
+ {
+ int i;
+
+ // Release all sticky keys
+ for (i = 0; i <= GLFW_KEY_LAST; i++)
+ {
+ if (window->keys[i] == _GLFW_STICK)
+ window->keys[i] = GLFW_RELEASE;
+ }
+ }
+
+ window->stickyKeys = value;
+ }
+ else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
+ {
+ value = value ? GLFW_TRUE : GLFW_FALSE;
+ if (window->stickyMouseButtons == value)
+ return;
+
+ if (!value)
+ {
+ int i;
+
+ // Release all sticky mouse buttons
+ for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
+ {
+ if (window->mouseButtons[i] == _GLFW_STICK)
+ window->mouseButtons[i] = GLFW_RELEASE;
+ }
+ }
+
+ window->stickyMouseButtons = value;
+ }
+ else if (mode == GLFW_LOCK_KEY_MODS)
+ window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
+ else
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
+}
+
+GLFWAPI const char* glfwGetKeyName(int key, int scancode)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (key != GLFW_KEY_UNKNOWN)
+ {
+ if (key != GLFW_KEY_KP_EQUAL &&
+ (key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) &&
+ (key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))
+ {
+ return NULL;
+ }
+
+ scancode = _glfwPlatformGetKeyScancode(key);
+ }
+
+ return _glfwPlatformGetScancodeName(scancode);
+}
+
+GLFWAPI int glfwGetKeyScancode(int key)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(-1);
+
+ if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
+ return GLFW_RELEASE;
+ }
+
+ return _glfwPlatformGetKeyScancode(key);
+}
+
+GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
+
+ if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
+ return GLFW_RELEASE;
+ }
+
+ if (window->keys[key] == _GLFW_STICK)
+ {
+ // Sticky mode: release key now
+ window->keys[key] = GLFW_RELEASE;
+ return GLFW_PRESS;
+ }
+
+ return (int) window->keys[key];
+}
+
+GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
+
+ if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
+ return GLFW_RELEASE;
+ }
+
+ if (window->mouseButtons[button] == _GLFW_STICK)
+ {
+ // Sticky mode: release mouse button now
+ window->mouseButtons[button] = GLFW_RELEASE;
+ return GLFW_PRESS;
+ }
+
+ return (int) window->mouseButtons[button];
+}
+
+GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ if (xpos)
+ *xpos = 0;
+ if (ypos)
+ *ypos = 0;
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ {
+ if (xpos)
+ *xpos = window->virtualCursorPosX;
+ if (ypos)
+ *ypos = window->virtualCursorPosY;
+ }
+ else
+ _glfwPlatformGetCursorPos(window, xpos, ypos);
+}
+
+GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
+ ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid cursor position %f %f",
+ xpos, ypos);
+ return;
+ }
+
+ if (!_glfwPlatformWindowFocused(window))
+ return;
+
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ {
+ // Only update the accumulated position if the cursor is disabled
+ window->virtualCursorPosX = xpos;
+ window->virtualCursorPosY = ypos;
+ }
+ else
+ {
+ // Update system cursor position
+ _glfwPlatformSetCursorPos(window, xpos, ypos);
+ }
+}
+
+GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
+{
+ _GLFWcursor* cursor;
+
+ assert(image != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ cursor = calloc(1, sizeof(_GLFWcursor));
+ cursor->next = _glfw.cursorListHead;
+ _glfw.cursorListHead = cursor;
+
+ if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))
+ {
+ glfwDestroyCursor((GLFWcursor*) cursor);
+ return NULL;
+ }
+
+ return (GLFWcursor*) cursor;
+}
+
+GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
+{
+ _GLFWcursor* cursor;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (shape != GLFW_ARROW_CURSOR &&
+ shape != GLFW_IBEAM_CURSOR &&
+ shape != GLFW_CROSSHAIR_CURSOR &&
+ shape != GLFW_HAND_CURSOR &&
+ shape != GLFW_HRESIZE_CURSOR &&
+ shape != GLFW_VRESIZE_CURSOR)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape);
+ return NULL;
+ }
+
+ cursor = calloc(1, sizeof(_GLFWcursor));
+ cursor->next = _glfw.cursorListHead;
+ _glfw.cursorListHead = cursor;
+
+ if (!_glfwPlatformCreateStandardCursor(cursor, shape))
+ {
+ glfwDestroyCursor((GLFWcursor*) cursor);
+ return NULL;
+ }
+
+ return (GLFWcursor*) cursor;
+}
+
+GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
+{
+ _GLFWcursor* cursor = (_GLFWcursor*) handle;
+
+ _GLFW_REQUIRE_INIT();
+
+ if (cursor == NULL)
+ return;
+
+ // Make sure the cursor is not being used by any window
+ {
+ _GLFWwindow* window;
+
+ for (window = _glfw.windowListHead; window; window = window->next)
+ {
+ if (window->cursor == cursor)
+ glfwSetCursor((GLFWwindow*) window, NULL);
+ }
+ }
+
+ _glfwPlatformDestroyCursor(cursor);
+
+ // Unlink cursor from global linked list
+ {
+ _GLFWcursor** prev = &_glfw.cursorListHead;
+
+ while (*prev != cursor)
+ prev = &((*prev)->next);
+
+ *prev = cursor->next;
+ }
+
+ free(cursor);
+}
+
+GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) windowHandle;
+ _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ window->cursor = cursor;
+
+ _glfwPlatformSetCursor(window, cursor);
+}
+
+GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
+ GLFWmousebuttonfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
+ GLFWcursorposfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
+ GLFWcursorenterfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
+ GLFWscrollfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun);
+ return cbfun;
+}
+
+GLFWAPI int glfwJoystickPresent(int jid)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return GLFW_FALSE;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return GLFW_FALSE;
+
+ return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
+}
+
+GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+ assert(count != NULL);
+
+ *count = 0;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return NULL;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_AXES))
+ return NULL;
+
+ *count = js->axisCount;
+ return js->axes;
+}
+
+GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+ assert(count != NULL);
+
+ *count = 0;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return NULL;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
+ return NULL;
+
+ if (_glfw.hints.init.hatButtons)
+ *count = js->buttonCount + js->hatCount * 4;
+ else
+ *count = js->buttonCount;
+
+ return js->buttons;
+}
+
+GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+ assert(count != NULL);
+
+ *count = 0;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return NULL;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
+ return NULL;
+
+ *count = js->hatCount;
+ return js->hats;
+}
+
+GLFWAPI const char* glfwGetJoystickName(int jid)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return NULL;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
+ return NULL;
+
+ return js->name;
+}
+
+GLFWAPI const char* glfwGetJoystickGUID(int jid)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return NULL;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
+ return NULL;
+
+ return js->guid;
+}
+
+GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT();
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return;
+
+ js->userPointer = pointer;
+}
+
+GLFWAPI void* glfwGetJoystickUserPointer(int jid)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ return js->userPointer;
+}
+
+GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
+ return cbfun;
+}
+
+GLFWAPI int glfwUpdateGamepadMappings(const char* string)
+{
+ int jid;
+ const char* c = string;
+
+ assert(string != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ while (*c)
+ {
+ if ((*c >= '0' && *c <= '9') ||
+ (*c >= 'a' && *c <= 'f') ||
+ (*c >= 'A' && *c <= 'F'))
+ {
+ char line[1024];
+
+ const size_t length = strcspn(c, "\r\n");
+ if (length < sizeof(line))
+ {
+ _GLFWmapping mapping = {{0}};
+
+ memcpy(line, c, length);
+ line[length] = '\0';
+
+ if (parseMapping(&mapping, line))
+ {
+ _GLFWmapping* previous = findMapping(mapping.guid);
+ if (previous)
+ *previous = mapping;
+ else
+ {
+ _glfw.mappingCount++;
+ _glfw.mappings =
+ realloc(_glfw.mappings,
+ sizeof(_GLFWmapping) * _glfw.mappingCount);
+ _glfw.mappings[_glfw.mappingCount - 1] = mapping;
+ }
+ }
+ }
+
+ c += length;
+ }
+ else
+ {
+ c += strcspn(c, "\r\n");
+ c += strspn(c, "\r\n");
+ }
+ }
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ _GLFWjoystick* js = _glfw.joysticks + jid;
+ if (js->present)
+ js->mapping = findValidMapping(js);
+ }
+
+ return GLFW_TRUE;
+}
+
+GLFWAPI int glfwJoystickIsGamepad(int jid)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return GLFW_FALSE;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return GLFW_FALSE;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
+ return GLFW_FALSE;
+
+ return js->mapping != NULL;
+}
+
+GLFWAPI const char* glfwGetGamepadName(int jid)
+{
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return NULL;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return NULL;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
+ return NULL;
+
+ if (!js->mapping)
+ return NULL;
+
+ return js->mapping->name;
+}
+
+GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
+{
+ int i;
+ _GLFWjoystick* js;
+
+ assert(jid >= GLFW_JOYSTICK_1);
+ assert(jid <= GLFW_JOYSTICK_LAST);
+ assert(state != NULL);
+
+ memset(state, 0, sizeof(GLFWgamepadstate));
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
+ {
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
+ return GLFW_FALSE;
+ }
+
+ js = _glfw.joysticks + jid;
+ if (!js->present)
+ return GLFW_FALSE;
+
+ if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL))
+ return GLFW_FALSE;
+
+ if (!js->mapping)
+ return GLFW_FALSE;
+
+ for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
+ {
+ const _GLFWmapelement* e = js->mapping->buttons + i;
+ if (e->type == _GLFW_JOYSTICK_AXIS)
+ {
+ const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
+ if (value > 0.f)
+ state->buttons[i] = GLFW_PRESS;
+ }
+ else if (e->type == _GLFW_JOYSTICK_HATBIT)
+ {
+ const unsigned int hat = e->index >> 4;
+ const unsigned int bit = e->index & 0xf;
+ if (js->hats[hat] & bit)
+ state->buttons[i] = GLFW_PRESS;
+ }
+ else if (e->type == _GLFW_JOYSTICK_BUTTON)
+ state->buttons[i] = js->buttons[e->index];
+ }
+
+ for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
+ {
+ const _GLFWmapelement* e = js->mapping->axes + i;
+ if (e->type == _GLFW_JOYSTICK_AXIS)
+ {
+ const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
+ state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
+ }
+ else if (e->type == _GLFW_JOYSTICK_HATBIT)
+ {
+ const unsigned int hat = e->index >> 4;
+ const unsigned int bit = e->index & 0xf;
+ if (js->hats[hat] & bit)
+ state->axes[i] = 1.f;
+ }
+ else if (e->type == _GLFW_JOYSTICK_BUTTON)
+ state->axes[i] = (float) js->buttons[e->index];
+ }
+
+ return GLFW_TRUE;
+}
+
+GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
+{
+ assert(string != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformSetClipboardString(string);
+}
+
+GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return _glfwPlatformGetClipboardString();
+}
+
+GLFWAPI double glfwGetTime(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(0.0);
+ return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
+ _glfwPlatformGetTimerFrequency();
+}
+
+GLFWAPI void glfwSetTime(double time)
+{
+ _GLFW_REQUIRE_INIT();
+
+ if (time != time || time < 0.0 || time > 18446744073.0)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
+ return;
+ }
+
+ _glfw.timer.offset = _glfwPlatformGetTimerValue() -
+ (uint64_t) (time * _glfwPlatformGetTimerFrequency());
+}
+
+GLFWAPI uint64_t glfwGetTimerValue(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(0);
+ return _glfwPlatformGetTimerValue();
+}
+
+GLFWAPI uint64_t glfwGetTimerFrequency(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(0);
+ return _glfwPlatformGetTimerFrequency();
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/internal.h b/Client/ThirdParty/Box2D/extern/glfw/src/internal.h
new file mode 100644
index 0000000..c80b518
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/internal.h
@@ -0,0 +1,772 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#pragma once
+
+// MODIFIED_ERIN
+//#if defined(_GLFW_USE_CONFIG_H)
+ #include "glfw_config.h"
+//#endif
+
+#if defined(GLFW_INCLUDE_GLCOREARB) || \
+ defined(GLFW_INCLUDE_ES1) || \
+ defined(GLFW_INCLUDE_ES2) || \
+ defined(GLFW_INCLUDE_ES3) || \
+ defined(GLFW_INCLUDE_ES31) || \
+ defined(GLFW_INCLUDE_ES32) || \
+ defined(GLFW_INCLUDE_NONE) || \
+ defined(GLFW_INCLUDE_GLEXT) || \
+ defined(GLFW_INCLUDE_GLU) || \
+ defined(GLFW_INCLUDE_VULKAN) || \
+ defined(GLFW_DLL)
+ #error "You must not define any header option macros when compiling GLFW"
+#endif
+
+#define GLFW_INCLUDE_NONE
+#include "../include/GLFW/glfw3.h"
+
+#define _GLFW_INSERT_FIRST 0
+#define _GLFW_INSERT_LAST 1
+
+#define _GLFW_POLL_PRESENCE 0
+#define _GLFW_POLL_AXES 1
+#define _GLFW_POLL_BUTTONS 2
+#define _GLFW_POLL_ALL (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS)
+
+#define _GLFW_MESSAGE_SIZE 1024
+
+typedef int GLFWbool;
+
+typedef struct _GLFWerror _GLFWerror;
+typedef struct _GLFWinitconfig _GLFWinitconfig;
+typedef struct _GLFWwndconfig _GLFWwndconfig;
+typedef struct _GLFWctxconfig _GLFWctxconfig;
+typedef struct _GLFWfbconfig _GLFWfbconfig;
+typedef struct _GLFWcontext _GLFWcontext;
+typedef struct _GLFWwindow _GLFWwindow;
+typedef struct _GLFWlibrary _GLFWlibrary;
+typedef struct _GLFWmonitor _GLFWmonitor;
+typedef struct _GLFWcursor _GLFWcursor;
+typedef struct _GLFWmapelement _GLFWmapelement;
+typedef struct _GLFWmapping _GLFWmapping;
+typedef struct _GLFWjoystick _GLFWjoystick;
+typedef struct _GLFWtls _GLFWtls;
+typedef struct _GLFWmutex _GLFWmutex;
+
+typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
+typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
+typedef void (* _GLFWswapintervalfun)(int);
+typedef int (* _GLFWextensionsupportedfun)(const char*);
+typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
+typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
+
+#define GL_VERSION 0x1f02
+#define GL_NONE 0
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_EXTENSIONS 0x1f03
+#define GL_NUM_EXTENSIONS 0x821d
+#define GL_CONTEXT_FLAGS 0x821e
+#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
+#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
+#define GL_CONTEXT_PROFILE_MASK 0x9126
+#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
+#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
+#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
+#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
+#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
+
+typedef int GLint;
+typedef unsigned int GLuint;
+typedef unsigned int GLenum;
+typedef unsigned int GLbitfield;
+typedef unsigned char GLubyte;
+
+typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
+typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
+typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
+typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
+
+#define VK_NULL_HANDLE 0
+
+typedef void* VkInstance;
+typedef void* VkPhysicalDevice;
+typedef uint64_t VkSurfaceKHR;
+typedef uint32_t VkFlags;
+typedef uint32_t VkBool32;
+
+typedef enum VkStructureType
+{
+ VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
+ VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
+ VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
+ VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
+ VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
+ VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkStructureType;
+
+typedef enum VkResult
+{
+ VK_SUCCESS = 0,
+ VK_NOT_READY = 1,
+ VK_TIMEOUT = 2,
+ VK_EVENT_SET = 3,
+ VK_EVENT_RESET = 4,
+ VK_INCOMPLETE = 5,
+ VK_ERROR_OUT_OF_HOST_MEMORY = -1,
+ VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
+ VK_ERROR_INITIALIZATION_FAILED = -3,
+ VK_ERROR_DEVICE_LOST = -4,
+ VK_ERROR_MEMORY_MAP_FAILED = -5,
+ VK_ERROR_LAYER_NOT_PRESENT = -6,
+ VK_ERROR_EXTENSION_NOT_PRESENT = -7,
+ VK_ERROR_FEATURE_NOT_PRESENT = -8,
+ VK_ERROR_INCOMPATIBLE_DRIVER = -9,
+ VK_ERROR_TOO_MANY_OBJECTS = -10,
+ VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
+ VK_ERROR_SURFACE_LOST_KHR = -1000000000,
+ VK_SUBOPTIMAL_KHR = 1000001003,
+ VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
+ VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
+ VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
+ VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
+ VK_RESULT_MAX_ENUM = 0x7FFFFFFF
+} VkResult;
+
+typedef struct VkAllocationCallbacks VkAllocationCallbacks;
+
+typedef struct VkExtensionProperties
+{
+ char extensionName[256];
+ uint32_t specVersion;
+} VkExtensionProperties;
+
+typedef void (APIENTRY * PFN_vkVoidFunction)(void);
+
+#if defined(_GLFW_VULKAN_STATIC)
+ PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
+ VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
+#else
+ typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
+ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
+ #define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
+ #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
+#endif
+
+#if defined(_GLFW_COCOA)
+ #include "cocoa_platform.h"
+#elif defined(_GLFW_WIN32)
+ #include "win32_platform.h"
+#elif defined(_GLFW_X11)
+ #include "x11_platform.h"
+#elif defined(_GLFW_WAYLAND)
+ #include "wl_platform.h"
+#elif defined(_GLFW_OSMESA)
+ #include "null_platform.h"
+#else
+ #error "No supported window creation API selected"
+#endif
+
+// Constructs a version number string from the public header macros
+#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
+#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
+#define _GLFW_VERSION_NUMBER _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR, \
+ GLFW_VERSION_MINOR, \
+ GLFW_VERSION_REVISION)
+
+// Checks for whether the library has been initialized
+#define _GLFW_REQUIRE_INIT() \
+ if (!_glfw.initialized) \
+ { \
+ _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
+ return; \
+ }
+#define _GLFW_REQUIRE_INIT_OR_RETURN(x) \
+ if (!_glfw.initialized) \
+ { \
+ _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
+ return x; \
+ }
+
+// Swaps the provided pointers
+#define _GLFW_SWAP_POINTERS(x, y) \
+ { \
+ void* t; \
+ t = x; \
+ x = y; \
+ y = t; \
+ }
+
+// Per-thread error structure
+//
+struct _GLFWerror
+{
+ _GLFWerror* next;
+ int code;
+ char description[_GLFW_MESSAGE_SIZE];
+};
+
+// Initialization configuration
+//
+// Parameters relating to the initialization of the library
+//
+struct _GLFWinitconfig
+{
+ GLFWbool hatButtons;
+ struct {
+ GLFWbool menubar;
+ GLFWbool chdir;
+ } ns;
+};
+
+// Window configuration
+//
+// Parameters relating to the creation of the window but not directly related
+// to the framebuffer. This is used to pass window creation parameters from
+// shared code to the platform API.
+//
+struct _GLFWwndconfig
+{
+ int width;
+ int height;
+ const char* title;
+ GLFWbool resizable;
+ GLFWbool visible;
+ GLFWbool decorated;
+ GLFWbool focused;
+ GLFWbool autoIconify;
+ GLFWbool floating;
+ GLFWbool maximized;
+ GLFWbool centerCursor;
+ GLFWbool focusOnShow;
+ GLFWbool scaleToMonitor;
+ struct {
+ GLFWbool retina;
+ char frameName[256];
+ } ns;
+ struct {
+ char className[256];
+ char instanceName[256];
+ } x11;
+};
+
+// Context configuration
+//
+// Parameters relating to the creation of the context but not directly related
+// to the framebuffer. This is used to pass context creation parameters from
+// shared code to the platform API.
+//
+struct _GLFWctxconfig
+{
+ int client;
+ int source;
+ int major;
+ int minor;
+ GLFWbool forward;
+ GLFWbool debug;
+ GLFWbool noerror;
+ int profile;
+ int robustness;
+ int release;
+ _GLFWwindow* share;
+ struct {
+ GLFWbool offline;
+ } nsgl;
+};
+
+// Framebuffer configuration
+//
+// This describes buffers and their sizes. It also contains
+// a platform-specific ID used to map back to the backend API object.
+//
+// It is used to pass framebuffer parameters from shared code to the platform
+// API and also to enumerate and select available framebuffer configs.
+//
+struct _GLFWfbconfig
+{
+ int redBits;
+ int greenBits;
+ int blueBits;
+ int alphaBits;
+ int depthBits;
+ int stencilBits;
+ int accumRedBits;
+ int accumGreenBits;
+ int accumBlueBits;
+ int accumAlphaBits;
+ int auxBuffers;
+ GLFWbool stereo;
+ int samples;
+ GLFWbool sRGB;
+ GLFWbool doublebuffer;
+ GLFWbool transparent;
+ uintptr_t handle;
+};
+
+// Context structure
+//
+struct _GLFWcontext
+{
+ int client;
+ int source;
+ int major, minor, revision;
+ GLFWbool forward, debug, noerror;
+ int profile;
+ int robustness;
+ int release;
+
+ PFNGLGETSTRINGIPROC GetStringi;
+ PFNGLGETINTEGERVPROC GetIntegerv;
+ PFNGLGETSTRINGPROC GetString;
+
+ _GLFWmakecontextcurrentfun makeCurrent;
+ _GLFWswapbuffersfun swapBuffers;
+ _GLFWswapintervalfun swapInterval;
+ _GLFWextensionsupportedfun extensionSupported;
+ _GLFWgetprocaddressfun getProcAddress;
+ _GLFWdestroycontextfun destroy;
+
+ // This is defined in the context API's context.h
+ _GLFW_PLATFORM_CONTEXT_STATE;
+ // This is defined in egl_context.h
+ _GLFW_EGL_CONTEXT_STATE;
+ // This is defined in osmesa_context.h
+ _GLFW_OSMESA_CONTEXT_STATE;
+};
+
+// Window and context structure
+//
+struct _GLFWwindow
+{
+ struct _GLFWwindow* next;
+
+ // Window settings and state
+ GLFWbool resizable;
+ GLFWbool decorated;
+ GLFWbool autoIconify;
+ GLFWbool floating;
+ GLFWbool focusOnShow;
+ GLFWbool shouldClose;
+ void* userPointer;
+ GLFWvidmode videoMode;
+ _GLFWmonitor* monitor;
+ _GLFWcursor* cursor;
+
+ int minwidth, minheight;
+ int maxwidth, maxheight;
+ int numer, denom;
+
+ GLFWbool stickyKeys;
+ GLFWbool stickyMouseButtons;
+ GLFWbool lockKeyMods;
+ int cursorMode;
+ char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
+ char keys[GLFW_KEY_LAST + 1];
+ // Virtual cursor position when cursor is disabled
+ double virtualCursorPosX, virtualCursorPosY;
+
+ _GLFWcontext context;
+
+ struct {
+ GLFWwindowposfun pos;
+ GLFWwindowsizefun size;
+ GLFWwindowclosefun close;
+ GLFWwindowrefreshfun refresh;
+ GLFWwindowfocusfun focus;
+ GLFWwindowiconifyfun iconify;
+ GLFWwindowmaximizefun maximize;
+ GLFWframebuffersizefun fbsize;
+ GLFWwindowcontentscalefun scale;
+ GLFWmousebuttonfun mouseButton;
+ GLFWcursorposfun cursorPos;
+ GLFWcursorenterfun cursorEnter;
+ GLFWscrollfun scroll;
+ GLFWkeyfun key;
+ GLFWcharfun character;
+ GLFWcharmodsfun charmods;
+ GLFWdropfun drop;
+ } callbacks;
+
+ // This is defined in the window API's platform.h
+ _GLFW_PLATFORM_WINDOW_STATE;
+};
+
+// Monitor structure
+//
+struct _GLFWmonitor
+{
+ char* name;
+ void* userPointer;
+
+ // Physical dimensions in millimeters.
+ int widthMM, heightMM;
+
+ // The window whose video mode is current on this monitor
+ _GLFWwindow* window;
+
+ GLFWvidmode* modes;
+ int modeCount;
+ GLFWvidmode currentMode;
+
+ GLFWgammaramp originalRamp;
+ GLFWgammaramp currentRamp;
+
+ // This is defined in the window API's platform.h
+ _GLFW_PLATFORM_MONITOR_STATE;
+};
+
+// Cursor structure
+//
+struct _GLFWcursor
+{
+ _GLFWcursor* next;
+
+ // This is defined in the window API's platform.h
+ _GLFW_PLATFORM_CURSOR_STATE;
+};
+
+// Gamepad mapping element structure
+//
+struct _GLFWmapelement
+{
+ uint8_t type;
+ uint8_t index;
+ int8_t axisScale;
+ int8_t axisOffset;
+};
+
+// Gamepad mapping structure
+//
+struct _GLFWmapping
+{
+ char name[128];
+ char guid[33];
+ _GLFWmapelement buttons[15];
+ _GLFWmapelement axes[6];
+};
+
+// Joystick structure
+//
+struct _GLFWjoystick
+{
+ GLFWbool present;
+ float* axes;
+ int axisCount;
+ unsigned char* buttons;
+ int buttonCount;
+ unsigned char* hats;
+ int hatCount;
+ char* name;
+ void* userPointer;
+ char guid[33];
+ _GLFWmapping* mapping;
+
+ // This is defined in the joystick API's joystick.h
+ _GLFW_PLATFORM_JOYSTICK_STATE;
+};
+
+// Thread local storage structure
+//
+struct _GLFWtls
+{
+ // This is defined in the platform's thread.h
+ _GLFW_PLATFORM_TLS_STATE;
+};
+
+// Mutex structure
+//
+struct _GLFWmutex
+{
+ // This is defined in the platform's thread.h
+ _GLFW_PLATFORM_MUTEX_STATE;
+};
+
+// Library global data
+//
+struct _GLFWlibrary
+{
+ GLFWbool initialized;
+
+ struct {
+ _GLFWinitconfig init;
+ _GLFWfbconfig framebuffer;
+ _GLFWwndconfig window;
+ _GLFWctxconfig context;
+ int refreshRate;
+ } hints;
+
+ _GLFWerror* errorListHead;
+ _GLFWcursor* cursorListHead;
+ _GLFWwindow* windowListHead;
+
+ _GLFWmonitor** monitors;
+ int monitorCount;
+
+ _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
+ _GLFWmapping* mappings;
+ int mappingCount;
+
+ _GLFWtls errorSlot;
+ _GLFWtls contextSlot;
+ _GLFWmutex errorLock;
+
+ struct {
+ uint64_t offset;
+ // This is defined in the platform's time.h
+ _GLFW_PLATFORM_LIBRARY_TIMER_STATE;
+ } timer;
+
+ struct {
+ GLFWbool available;
+ void* handle;
+ char* extensions[2];
+#if !defined(_GLFW_VULKAN_STATIC)
+ PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
+ PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
+#endif
+ GLFWbool KHR_surface;
+#if defined(_GLFW_WIN32)
+ GLFWbool KHR_win32_surface;
+#elif defined(_GLFW_COCOA)
+ GLFWbool MVK_macos_surface;
+#elif defined(_GLFW_X11)
+ GLFWbool KHR_xlib_surface;
+ GLFWbool KHR_xcb_surface;
+#elif defined(_GLFW_WAYLAND)
+ GLFWbool KHR_wayland_surface;
+#endif
+ } vk;
+
+ struct {
+ GLFWmonitorfun monitor;
+ GLFWjoystickfun joystick;
+ } callbacks;
+
+ // This is defined in the window API's platform.h
+ _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
+ // This is defined in the context API's context.h
+ _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
+ // This is defined in the platform's joystick.h
+ _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
+ // This is defined in egl_context.h
+ _GLFW_EGL_LIBRARY_CONTEXT_STATE;
+ // This is defined in osmesa_context.h
+ _GLFW_OSMESA_LIBRARY_CONTEXT_STATE;
+};
+
+// Global state shared between compilation units of GLFW
+//
+extern _GLFWlibrary _glfw;
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformInit(void);
+void _glfwPlatformTerminate(void);
+const char* _glfwPlatformGetVersionString(void);
+
+void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);
+void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
+int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
+ const GLFWimage* image, int xhot, int yhot);
+int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape);
+void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
+void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
+
+const char* _glfwPlatformGetScancodeName(int scancode);
+int _glfwPlatformGetKeyScancode(int key);
+
+void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
+void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
+void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
+ float* xscale, float* yscale);
+GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
+void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
+GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
+void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
+
+void _glfwPlatformSetClipboardString(const char* string);
+const char* _glfwPlatformGetClipboardString(void);
+
+int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
+void _glfwPlatformUpdateGamepadGUID(char* guid);
+
+uint64_t _glfwPlatformGetTimerValue(void);
+uint64_t _glfwPlatformGetTimerFrequency(void);
+
+int _glfwPlatformCreateWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig);
+void _glfwPlatformDestroyWindow(_GLFWwindow* window);
+void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
+void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
+ int count, const GLFWimage* images);
+void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);
+void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);
+void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
+void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
+void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight);
+void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom);
+void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
+void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
+ int* left, int* top,
+ int* right, int* bottom);
+void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
+ float* xscale, float* yscale);
+void _glfwPlatformIconifyWindow(_GLFWwindow* window);
+void _glfwPlatformRestoreWindow(_GLFWwindow* window);
+void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
+void _glfwPlatformShowWindow(_GLFWwindow* window);
+void _glfwPlatformHideWindow(_GLFWwindow* window);
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
+void _glfwPlatformFocusWindow(_GLFWwindow* window);
+void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
+ int xpos, int ypos, int width, int height,
+ int refreshRate);
+int _glfwPlatformWindowFocused(_GLFWwindow* window);
+int _glfwPlatformWindowIconified(_GLFWwindow* window);
+int _glfwPlatformWindowVisible(_GLFWwindow* window);
+int _glfwPlatformWindowMaximized(_GLFWwindow* window);
+int _glfwPlatformWindowHovered(_GLFWwindow* window);
+int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
+float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
+void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
+
+void _glfwPlatformPollEvents(void);
+void _glfwPlatformWaitEvents(void);
+void _glfwPlatformWaitEventsTimeout(double timeout);
+void _glfwPlatformPostEmptyEvent(void);
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
+int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily);
+VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
+ _GLFWwindow* window,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface);
+
+GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
+void _glfwPlatformDestroyTls(_GLFWtls* tls);
+void* _glfwPlatformGetTls(_GLFWtls* tls);
+void _glfwPlatformSetTls(_GLFWtls* tls, void* value);
+
+GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
+void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
+void _glfwPlatformLockMutex(_GLFWmutex* mutex);
+void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW event API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
+void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
+void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
+void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
+void _glfwInputWindowContentScale(_GLFWwindow* window,
+ float xscale, float yscale);
+void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
+void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
+void _glfwInputWindowDamage(_GLFWwindow* window);
+void _glfwInputWindowCloseRequest(_GLFWwindow* window);
+void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
+
+void _glfwInputKey(_GLFWwindow* window,
+ int key, int scancode, int action, int mods);
+void _glfwInputChar(_GLFWwindow* window,
+ unsigned int codepoint, int mods, GLFWbool plain);
+void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
+void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
+void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
+void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
+void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
+void _glfwInputJoystick(_GLFWjoystick* js, int event);
+void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
+void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
+void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value);
+
+void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement);
+void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window);
+
+#if defined(__GNUC__)
+void _glfwInputError(int code, const char* format, ...)
+ __attribute__((format(printf, 2, 3)));
+#else
+void _glfwInputError(int code, const char* format, ...);
+#endif
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
+const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
+ const _GLFWfbconfig* alternatives,
+ unsigned int count);
+GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig);
+GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
+
+const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
+ const GLFWvidmode* desired);
+int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
+_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
+void _glfwFreeMonitor(_GLFWmonitor* monitor);
+void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
+void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
+void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
+
+_GLFWjoystick* _glfwAllocJoystick(const char* name,
+ const char* guid,
+ int axisCount,
+ int buttonCount,
+ int hatCount);
+void _glfwFreeJoystick(_GLFWjoystick* js);
+
+GLFWbool _glfwInitVulkan(int mode);
+void _glfwTerminateVulkan(void);
+const char* _glfwGetVulkanResultString(VkResult result);
+
+char* _glfw_strdup(const char* source);
+float _glfw_fminf(float a, float b);
+float _glfw_fmaxf(float a, float b);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.c b/Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.c
new file mode 100644
index 0000000..baa3651
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.c
@@ -0,0 +1,434 @@
+//========================================================================
+// GLFW 3.3 Linux - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/inotify.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef SYN_DROPPED // < v2.6.39 kernel headers
+// Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32
+#define SYN_DROPPED 3
+#endif
+
+// Apply an EV_KEY event to the specified joystick
+//
+static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
+{
+ _glfwInputJoystickButton(js,
+ js->linjs.keyMap[code - BTN_MISC],
+ value ? GLFW_PRESS : GLFW_RELEASE);
+}
+
+// Apply an EV_ABS event to the specified joystick
+//
+static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
+{
+ const int index = js->linjs.absMap[code];
+
+ if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
+ {
+ static const char stateMap[3][3] =
+ {
+ { GLFW_HAT_CENTERED, GLFW_HAT_UP, GLFW_HAT_DOWN },
+ { GLFW_HAT_LEFT, GLFW_HAT_LEFT_UP, GLFW_HAT_LEFT_DOWN },
+ { GLFW_HAT_RIGHT, GLFW_HAT_RIGHT_UP, GLFW_HAT_RIGHT_DOWN },
+ };
+
+ const int hat = (code - ABS_HAT0X) / 2;
+ const int axis = (code - ABS_HAT0X) % 2;
+ int* state = js->linjs.hats[hat];
+
+ // NOTE: Looking at several input drivers, it seems all hat events use
+ // -1 for left / up, 0 for centered and 1 for right / down
+ if (value == 0)
+ state[axis] = 0;
+ else if (value < 0)
+ state[axis] = 1;
+ else if (value > 0)
+ state[axis] = 2;
+
+ _glfwInputJoystickHat(js, index, stateMap[state[0]][state[1]]);
+ }
+ else
+ {
+ const struct input_absinfo* info = &js->linjs.absInfo[code];
+ float normalized = value;
+
+ const int range = info->maximum - info->minimum;
+ if (range)
+ {
+ // Normalize to 0.0 -> 1.0
+ normalized = (normalized - info->minimum) / range;
+ // Normalize to -1.0 -> 1.0
+ normalized = normalized * 2.0f - 1.0f;
+ }
+
+ _glfwInputJoystickAxis(js, index, normalized);
+ }
+}
+
+// Poll state of absolute axes
+//
+static void pollAbsState(_GLFWjoystick* js)
+{
+ int code;
+
+ for (code = 0; code < ABS_CNT; code++)
+ {
+ if (js->linjs.absMap[code] < 0)
+ continue;
+
+ struct input_absinfo* info = &js->linjs.absInfo[code];
+
+ if (ioctl(js->linjs.fd, EVIOCGABS(code), info) < 0)
+ continue;
+
+ handleAbsEvent(js, code, info->value);
+ }
+}
+
+#define isBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8)))
+
+// Attempt to open the specified joystick device
+//
+static GLFWbool openJoystickDevice(const char* path)
+{
+ int jid, code;
+ char name[256] = "";
+ char guid[33] = "";
+ char evBits[(EV_CNT + 7) / 8] = {0};
+ char keyBits[(KEY_CNT + 7) / 8] = {0};
+ char absBits[(ABS_CNT + 7) / 8] = {0};
+ int axisCount = 0, buttonCount = 0, hatCount = 0;
+ struct input_id id;
+ _GLFWjoystickLinux linjs = {0};
+ _GLFWjoystick* js = NULL;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ if (!_glfw.joysticks[jid].present)
+ continue;
+ if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
+ return GLFW_FALSE;
+ }
+
+ linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
+ if (linjs.fd == -1)
+ return GLFW_FALSE;
+
+ if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
+ ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
+ ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
+ ioctl(linjs.fd, EVIOCGID, &id) < 0)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Linux: Failed to query input device: %s",
+ strerror(errno));
+ close(linjs.fd);
+ return GLFW_FALSE;
+ }
+
+ // Ensure this device supports the events expected of a joystick
+ if (!isBitSet(EV_KEY, evBits) || !isBitSet(EV_ABS, evBits))
+ {
+ close(linjs.fd);
+ return GLFW_FALSE;
+ }
+
+ if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
+ strncpy(name, "Unknown", sizeof(name));
+
+ // Generate a joystick GUID that matches the SDL 2.0.5+ one
+ if (id.vendor && id.product && id.version)
+ {
+ sprintf(guid, "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000",
+ id.bustype & 0xff, id.bustype >> 8,
+ id.vendor & 0xff, id.vendor >> 8,
+ id.product & 0xff, id.product >> 8,
+ id.version & 0xff, id.version >> 8);
+ }
+ else
+ {
+ sprintf(guid, "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
+ id.bustype & 0xff, id.bustype >> 8,
+ name[0], name[1], name[2], name[3],
+ name[4], name[5], name[6], name[7],
+ name[8], name[9], name[10]);
+ }
+
+ for (code = BTN_MISC; code < KEY_CNT; code++)
+ {
+ if (!isBitSet(code, keyBits))
+ continue;
+
+ linjs.keyMap[code - BTN_MISC] = buttonCount;
+ buttonCount++;
+ }
+
+ for (code = 0; code < ABS_CNT; code++)
+ {
+ linjs.absMap[code] = -1;
+ if (!isBitSet(code, absBits))
+ continue;
+
+ if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
+ {
+ linjs.absMap[code] = hatCount;
+ hatCount++;
+ // Skip the Y axis
+ code++;
+ }
+ else
+ {
+ if (ioctl(linjs.fd, EVIOCGABS(code), &linjs.absInfo[code]) < 0)
+ continue;
+
+ linjs.absMap[code] = axisCount;
+ axisCount++;
+ }
+ }
+
+ js = _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
+ if (!js)
+ {
+ close(linjs.fd);
+ return GLFW_FALSE;
+ }
+
+ strncpy(linjs.path, path, sizeof(linjs.path) - 1);
+ memcpy(&js->linjs, &linjs, sizeof(linjs));
+
+ pollAbsState(js);
+
+ _glfwInputJoystick(js, GLFW_CONNECTED);
+ return GLFW_TRUE;
+}
+
+#undef isBitSet
+
+// Frees all resources associated with the specified joystick
+//
+static void closeJoystick(_GLFWjoystick* js)
+{
+ close(js->linjs.fd);
+ _glfwFreeJoystick(js);
+ _glfwInputJoystick(js, GLFW_DISCONNECTED);
+}
+
+// Lexically compare joysticks by name; used by qsort
+//
+static int compareJoysticks(const void* fp, const void* sp)
+{
+ const _GLFWjoystick* fj = fp;
+ const _GLFWjoystick* sj = sp;
+ return strcmp(fj->linjs.path, sj->linjs.path);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize joystick interface
+//
+GLFWbool _glfwInitJoysticksLinux(void)
+{
+ DIR* dir;
+ int count = 0;
+ const char* dirname = "/dev/input";
+
+ _glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+ if (_glfw.linjs.inotify > 0)
+ {
+ // HACK: Register for IN_ATTRIB to get notified when udev is done
+ // This works well in practice but the true way is libudev
+
+ _glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
+ dirname,
+ IN_CREATE | IN_ATTRIB | IN_DELETE);
+ }
+
+ // Continue without device connection notifications if inotify fails
+
+ if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
+ return GLFW_FALSE;
+ }
+
+ dir = opendir(dirname);
+ if (dir)
+ {
+ struct dirent* entry;
+
+ while ((entry = readdir(dir)))
+ {
+ regmatch_t match;
+
+ if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
+ continue;
+
+ char path[PATH_MAX];
+
+ snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
+
+ if (openJoystickDevice(path))
+ count++;
+ }
+
+ closedir(dir);
+ }
+
+ // Continue with no joysticks if enumeration fails
+
+ qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
+ return GLFW_TRUE;
+}
+
+// Close all opened joystick handles
+//
+void _glfwTerminateJoysticksLinux(void)
+{
+ int jid;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ _GLFWjoystick* js = _glfw.joysticks + jid;
+ if (js->present)
+ closeJoystick(js);
+ }
+
+ regfree(&_glfw.linjs.regex);
+
+ if (_glfw.linjs.inotify > 0)
+ {
+ if (_glfw.linjs.watch > 0)
+ inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
+
+ close(_glfw.linjs.inotify);
+ }
+}
+
+void _glfwDetectJoystickConnectionLinux(void)
+{
+ ssize_t offset = 0;
+ char buffer[16384];
+
+ if (_glfw.linjs.inotify <= 0)
+ return;
+
+ const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
+
+ while (size > offset)
+ {
+ regmatch_t match;
+ const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
+
+ offset += sizeof(struct inotify_event) + e->len;
+
+ if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
+ continue;
+
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), "/dev/input/%s", e->name);
+
+ if (e->mask & (IN_CREATE | IN_ATTRIB))
+ openJoystickDevice(path);
+ else if (e->mask & IN_DELETE)
+ {
+ int jid;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
+ {
+ closeJoystick(_glfw.joysticks + jid);
+ break;
+ }
+ }
+ }
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
+{
+ // Read all queued events (non-blocking)
+ for (;;)
+ {
+ struct input_event e;
+
+ errno = 0;
+ if (read(js->linjs.fd, &e, sizeof(e)) < 0)
+ {
+ // Reset the joystick slot if the device was disconnected
+ if (errno == ENODEV)
+ closeJoystick(js);
+
+ break;
+ }
+
+ if (e.type == EV_SYN)
+ {
+ if (e.code == SYN_DROPPED)
+ _glfw.linjs.dropped = GLFW_TRUE;
+ else if (e.code == SYN_REPORT)
+ {
+ _glfw.linjs.dropped = GLFW_FALSE;
+ pollAbsState(js);
+ }
+ }
+
+ if (_glfw.linjs.dropped)
+ continue;
+
+ if (e.type == EV_KEY)
+ handleKeyEvent(js, e.code, e.value);
+ else if (e.type == EV_ABS)
+ handleAbsEvent(js, e.code, e.value);
+ }
+
+ return js->present;
+}
+
+void _glfwPlatformUpdateGamepadGUID(char* guid)
+{
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.h b/Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.h
new file mode 100644
index 0000000..2eabfa1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/linux_joystick.h
@@ -0,0 +1,62 @@
+//========================================================================
+// GLFW 3.3 Linux - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <linux/input.h>
+#include <linux/limits.h>
+#include <regex.h>
+
+#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs
+#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
+
+#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
+
+// Linux-specific joystick data
+//
+typedef struct _GLFWjoystickLinux
+{
+ int fd;
+ char path[PATH_MAX];
+ int keyMap[KEY_CNT - BTN_MISC];
+ int absMap[ABS_CNT];
+ struct input_absinfo absInfo[ABS_CNT];
+ int hats[4][2];
+} _GLFWjoystickLinux;
+
+// Linux-specific joystick API data
+//
+typedef struct _GLFWlibraryLinux
+{
+ int inotify;
+ int watch;
+ regex_t regex;
+ GLFWbool dropped;
+} _GLFWlibraryLinux;
+
+
+GLFWbool _glfwInitJoysticksLinux(void);
+void _glfwTerminateJoysticksLinux(void);
+void _glfwDetectJoystickConnectionLinux(void);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/mappings.h b/Client/ThirdParty/Box2D/extern/glfw/src/mappings.h
new file mode 100644
index 0000000..97073db
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/mappings.h
@@ -0,0 +1,478 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+// As mappings.h.in, this file is used by CMake to produce the mappings.h
+// header file. If you are adding a GLFW specific gamepad mapping, this is
+// where to put it.
+//========================================================================
+// As mappings.h, this provides all pre-defined gamepad mappings, including
+// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
+// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
+// This file can be re-generated from mappings.h.in and the upstream
+// gamecontrollerdb.txt with the GenerateMappings.cmake script.
+//========================================================================
+
+// All gamepad mappings not labeled GLFW are copied from the
+// SDL_GameControllerDB project under the following license:
+//
+// Simple DirectMedia Layer
+// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the
+// use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+
+const char* _glfwDefaultMappings[] =
+{
+"03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,",
+"03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
+"03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
+"03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
+"03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
+"030000008f0e00001200000000000000,Acme,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows,",
+"030000006b1400000055000000000000,bigben ps3padstreetnew,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows,",
+"03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"030000005e0400008e02000000000000,Controller (XBOX 360 For Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
+"03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows,",
+"03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"030000004f04000023b3000000000000,Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
+"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
+"03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
+"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000451300000010000000000000,Generic USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00004d00000000000000,HORIPAD3 A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,platform:Windows,",
+"030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Windows,",
+"03000000b50700001403000000000000,IMPACT BLACK,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
+"030000006f0e00002401000000000000,INJUSTICE FightStick for PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
+"030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,platform:Windows,",
+"030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008433000000000000,Mad Catz FightStick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008483000000000000,Mad Catz FightStick TE S+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b6,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000008305000031b0000000000000,MaxfireBlaze3,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows,",
+"03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
+"030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,platform:Windows,",
+"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
+"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
+"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,leftx:h0.6,lefty:h0.12,rightshoulder:b5,rightstick:a2,righttrigger:b7,rightx:h0.9,righty:h0.4,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,platform:Windows,",
+"03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
+"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000008f0e00007530000000000000,PS (R) Gamepad,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
+"03000000100800000100000000000000,PS1 USB,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000100800000300000000000000,PS2 USB,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
+"030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Windows,",
+"03000000250900000500000000000000,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,",
+"03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows,",
+"03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
+"03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,platform:Windows,",
+"03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
+"030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
+"0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
+"0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
+"030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000006f0e00001e01000000000000,Rock Candy Gamepad for PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
+"030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
+"03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,x:b0,y:b1,platform:Windows,",
+"03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
+"03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Windows,",
+"03000000300f00001101000000000000,saitek rumble pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
+"0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
+"030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows,",
+"030000008f0e00000800000000000000,SpeedLink Strike FX Wireless,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,platform:Windows,",
+"03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
+"030000004f04000015b3000000000000,Thrustmaster Dual Analog 2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
+"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Windows,",
+"030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
+"03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
+"03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000380700006652000000000000,UnKnown,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
+"03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
+"03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
+"03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,",
+"03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
+"03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
+"03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
+"03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
+"03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
+"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
+"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
+"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,platform:Mac OS X,",
+"03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
+"03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
+"030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X,",
+"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X,",
+"03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
+"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
+"030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
+"030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,platform:Mac OS X,",
+"03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Mac OS X,",
+"030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
+"030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"030000005e0400008e02000001000000,Steam Virtual GamePad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X,",
+"03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
+"03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
+"03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
+"03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
+"030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Mac OS X,",
+"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Mac OS X,",
+"03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
+"03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,platform:Mac OS X,",
+"050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X,",
+"050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X,",
+"030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
+"030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
+"030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
+"030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
+"03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,",
+"03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
+"05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
+"03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
+"05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
+"03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
+"05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
+"05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
+"05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
+"05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
+"030000006f0e00003901000020060000,Afterglow Wired Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
+"05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
+"03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,",
+"03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
+"03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
+"03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
+"030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
+"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:a0,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:a3,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000006f0e00001f01000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
+"030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Linux,",
+"030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
+"030000008f0e00000300000010010000,GreenAsia Inc. USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
+"0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux,",
+"03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux,",
+"030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Linux,",
+"03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
+"050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
+"03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,platform:Linux,",
+"030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Linux,",
+"03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
+"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
+"030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000006d04000015c2000010010000,Logitech Logitech Extreme 3D,a:b0,b:b4,back:b6,guide:b8,leftshoulder:b9,leftstick:h0.8,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:h0.2,start:b7,x:b2,y:b5,platform:Linux,",
+"030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,platform:Linux,",
+"05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700008433000011010000,Mad Catz FightStick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700008483000011010000,Mad Catz FightStick TE S+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
+"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
+"030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
+"05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
+"030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Linux,",
+"050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
+"05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux,",
+"03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
+"05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
+"05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
+"03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
+"030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
+"030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
+"050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
+"030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
+"060000004c0500006802000000010000,PS3 Controller (Bluetooth),a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
+"05000000504c415953544154494f4e00,PS3 Controller (Bluetooth),a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
+"050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
+"030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,",
+"030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux,",
+"030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000008916000000fd000024010000,Razer Onza Tournament,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
+"0300000000f000000300000000010000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
+"0300000000f00000f100000000010000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
+"030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006f0e00001e01000011010000,Rock Candy Gamepad for PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"030000006f0e00004601000001010000,Rock Candy Wired Controller for Xbox One,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,",
+"03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux,",
+"03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,",
+"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux,",
+"03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,platform:Linux,",
+"03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
+"03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
+"030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
+"030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
+"030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
+"030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux,",
+"030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
+"03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
+"03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux,",
+"03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
+"03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
+"03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,platform:Linux,",
+"05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
+"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Linux,",
+"0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
+"050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
+"050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
+"03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
+"05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,",
+"03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,",
+"03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
+"64633436313965656664373634323364,Microsoft X-Box 360 pad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,",
+"61363931656135336130663561616264,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
+"4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
+"37336435666338653565313731303834,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
+"35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
+"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,",
+"5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android,",
+"34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android,",
+"4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS,",
+"4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS,",
+"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,",
+
+"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+NULL
+};
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/mappings.h.in b/Client/ThirdParty/Box2D/extern/glfw/src/mappings.h.in
new file mode 100644
index 0000000..eb6c32f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/mappings.h.in
@@ -0,0 +1,73 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+// As mappings.h.in, this file is used by CMake to produce the mappings.h
+// header file. If you are adding a GLFW specific gamepad mapping, this is
+// where to put it.
+//========================================================================
+// As mappings.h, this provides all pre-defined gamepad mappings, including
+// all available in SDL_GameControllerDB. Do not edit this file. Any gamepad
+// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
+// This file can be re-generated from mappings.h.in and the upstream
+// gamecontrollerdb.txt with the GenerateMappings.cmake script.
+//========================================================================
+
+// All gamepad mappings not labeled GLFW are copied from the
+// SDL_GameControllerDB project under the following license:
+//
+// Simple DirectMedia Layer
+// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the
+// use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+
+const char* _glfwDefaultMappings[] =
+{
+@GLFW_GAMEPAD_MAPPINGS@
+"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
+NULL
+};
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/monitor.c b/Client/ThirdParty/Box2D/extern/glfw/src/monitor.c
new file mode 100644
index 0000000..0ab865e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/monitor.c
@@ -0,0 +1,517 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <math.h>
+#include <float.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+
+
+// Lexically compare video modes, used by qsort
+//
+static int compareVideoModes(const void* fp, const void* sp)
+{
+ const GLFWvidmode* fm = fp;
+ const GLFWvidmode* sm = sp;
+ const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
+ const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
+ const int farea = fm->width * fm->height;
+ const int sarea = sm->width * sm->height;
+
+ // First sort on color bits per pixel
+ if (fbpp != sbpp)
+ return fbpp - sbpp;
+
+ // Then sort on screen area
+ if (farea != sarea)
+ return farea - sarea;
+
+ // Lastly sort on refresh rate
+ return fm->refreshRate - sm->refreshRate;
+}
+
+// Retrieves the available modes for the specified monitor
+//
+static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
+{
+ int modeCount;
+ GLFWvidmode* modes;
+
+ if (monitor->modes)
+ return GLFW_TRUE;
+
+ modes = _glfwPlatformGetVideoModes(monitor, &modeCount);
+ if (!modes)
+ return GLFW_FALSE;
+
+ qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
+
+ free(monitor->modes);
+ monitor->modes = modes;
+ monitor->modeCount = modeCount;
+
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW event API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Notifies shared code of a monitor connection or disconnection
+//
+void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
+{
+ if (action == GLFW_CONNECTED)
+ {
+ _glfw.monitorCount++;
+ _glfw.monitors =
+ realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount);
+
+ if (placement == _GLFW_INSERT_FIRST)
+ {
+ memmove(_glfw.monitors + 1,
+ _glfw.monitors,
+ (_glfw.monitorCount - 1) * sizeof(_GLFWmonitor*));
+ _glfw.monitors[0] = monitor;
+ }
+ else
+ _glfw.monitors[_glfw.monitorCount - 1] = monitor;
+ }
+ else if (action == GLFW_DISCONNECTED)
+ {
+ int i;
+ _GLFWwindow* window;
+
+ for (window = _glfw.windowListHead; window; window = window->next)
+ {
+ if (window->monitor == monitor)
+ {
+ int width, height, xoff, yoff;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ _glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0);
+ _glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
+ _glfwPlatformSetWindowPos(window, xoff, yoff);
+ }
+ }
+
+ for (i = 0; i < _glfw.monitorCount; i++)
+ {
+ if (_glfw.monitors[i] == monitor)
+ {
+ _glfw.monitorCount--;
+ memmove(_glfw.monitors + i,
+ _glfw.monitors + i + 1,
+ (_glfw.monitorCount - i) * sizeof(_GLFWmonitor*));
+ break;
+ }
+ }
+ }
+
+ if (_glfw.callbacks.monitor)
+ _glfw.callbacks.monitor((GLFWmonitor*) monitor, action);
+
+ if (action == GLFW_DISCONNECTED)
+ _glfwFreeMonitor(monitor);
+}
+
+// Notifies shared code that a full screen window has acquired or released
+// a monitor
+//
+void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
+{
+ monitor->window = window;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Allocates and returns a monitor object with the specified name and dimensions
+//
+_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
+{
+ _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));
+ monitor->widthMM = widthMM;
+ monitor->heightMM = heightMM;
+
+ if (name)
+ monitor->name = _glfw_strdup(name);
+
+ return monitor;
+}
+
+// Frees a monitor object and any data associated with it
+//
+void _glfwFreeMonitor(_GLFWmonitor* monitor)
+{
+ if (monitor == NULL)
+ return;
+
+ _glfwPlatformFreeMonitor(monitor);
+
+ _glfwFreeGammaArrays(&monitor->originalRamp);
+ _glfwFreeGammaArrays(&monitor->currentRamp);
+
+ free(monitor->modes);
+ free(monitor->name);
+ free(monitor);
+}
+
+// Allocates red, green and blue value arrays of the specified size
+//
+void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
+{
+ ramp->red = calloc(size, sizeof(unsigned short));
+ ramp->green = calloc(size, sizeof(unsigned short));
+ ramp->blue = calloc(size, sizeof(unsigned short));
+ ramp->size = size;
+}
+
+// Frees the red, green and blue value arrays and clears the struct
+//
+void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
+{
+ free(ramp->red);
+ free(ramp->green);
+ free(ramp->blue);
+
+ memset(ramp, 0, sizeof(GLFWgammaramp));
+}
+
+// Chooses the video mode most closely matching the desired one
+//
+const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
+ const GLFWvidmode* desired)
+{
+ int i;
+ unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
+ unsigned int rateDiff, leastRateDiff = UINT_MAX;
+ unsigned int colorDiff, leastColorDiff = UINT_MAX;
+ const GLFWvidmode* current;
+ const GLFWvidmode* closest = NULL;
+
+ if (!refreshVideoModes(monitor))
+ return NULL;
+
+ for (i = 0; i < monitor->modeCount; i++)
+ {
+ current = monitor->modes + i;
+
+ colorDiff = 0;
+
+ if (desired->redBits != GLFW_DONT_CARE)
+ colorDiff += abs(current->redBits - desired->redBits);
+ if (desired->greenBits != GLFW_DONT_CARE)
+ colorDiff += abs(current->greenBits - desired->greenBits);
+ if (desired->blueBits != GLFW_DONT_CARE)
+ colorDiff += abs(current->blueBits - desired->blueBits);
+
+ sizeDiff = abs((current->width - desired->width) *
+ (current->width - desired->width) +
+ (current->height - desired->height) *
+ (current->height - desired->height));
+
+ if (desired->refreshRate != GLFW_DONT_CARE)
+ rateDiff = abs(current->refreshRate - desired->refreshRate);
+ else
+ rateDiff = UINT_MAX - current->refreshRate;
+
+ if ((colorDiff < leastColorDiff) ||
+ (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||
+ (colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
+ {
+ closest = current;
+ leastSizeDiff = sizeDiff;
+ leastRateDiff = rateDiff;
+ leastColorDiff = colorDiff;
+ }
+ }
+
+ return closest;
+}
+
+// Performs lexical comparison between two @ref GLFWvidmode structures
+//
+int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
+{
+ return compareVideoModes(fm, sm);
+}
+
+// Splits a color depth into red, green and blue bit depths
+//
+void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
+{
+ int delta;
+
+ // We assume that by 32 the user really meant 24
+ if (bpp == 32)
+ bpp = 24;
+
+ // Convert "bits per pixel" to red, green & blue sizes
+
+ *red = *green = *blue = bpp / 3;
+ delta = bpp - (*red * 3);
+ if (delta >= 1)
+ *green = *green + 1;
+
+ if (delta == 2)
+ *red = *red + 1;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW public API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
+{
+ assert(count != NULL);
+
+ *count = 0;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ *count = _glfw.monitorCount;
+ return (GLFWmonitor**) _glfw.monitors;
+}
+
+GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (!_glfw.monitorCount)
+ return NULL;
+
+ return (GLFWmonitor*) _glfw.monitors[0];
+}
+
+GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ if (xpos)
+ *xpos = 0;
+ if (ypos)
+ *ypos = 0;
+
+ _GLFW_REQUIRE_INIT();
+
+ _glfwPlatformGetMonitorPos(monitor, xpos, ypos);
+}
+
+GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ if (widthMM)
+ *widthMM = 0;
+ if (heightMM)
+ *heightMM = 0;
+
+ _GLFW_REQUIRE_INIT();
+
+ if (widthMM)
+ *widthMM = monitor->widthMM;
+ if (heightMM)
+ *heightMM = monitor->heightMM;
+}
+
+GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
+ float* xscale, float* yscale)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ if (xscale)
+ *xscale = 0.f;
+ if (yscale)
+ *yscale = 0.f;
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformGetMonitorContentScale(monitor, xscale, yscale);
+}
+
+GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return monitor->name;
+}
+
+GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ monitor->userPointer = pointer;
+}
+
+GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return monitor->userPointer;
+}
+
+GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
+ return cbfun;
+}
+
+GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+ assert(count != NULL);
+
+ *count = 0;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (!refreshVideoModes(monitor))
+ return NULL;
+
+ *count = monitor->modeCount;
+ return monitor->modes;
+}
+
+GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ _glfwPlatformGetVideoMode(monitor, &monitor->currentMode);
+ return &monitor->currentMode;
+}
+
+GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
+{
+ unsigned int i;
+ unsigned short* values;
+ GLFWgammaramp ramp;
+ const GLFWgammaramp* original;
+ assert(handle != NULL);
+ assert(gamma > 0.f);
+ assert(gamma <= FLT_MAX);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
+ return;
+ }
+
+ original = glfwGetGammaRamp(handle);
+ if (!original)
+ return;
+
+ values = calloc(original->size, sizeof(unsigned short));
+
+ for (i = 0; i < original->size; i++)
+ {
+ float value;
+
+ // Calculate intensity
+ value = i / (float) (original->size - 1);
+ // Apply gamma curve
+ value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
+ // Clamp to value range
+ value = _glfw_fminf(value, 65535.f);
+
+ values[i] = (unsigned short) value;
+ }
+
+ ramp.red = values;
+ ramp.green = values;
+ ramp.blue = values;
+ ramp.size = original->size;
+
+ glfwSetGammaRamp(handle, &ramp);
+ free(values);
+}
+
+GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ _glfwFreeGammaArrays(&monitor->currentRamp);
+ if (!_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp))
+ return NULL;
+
+ return &monitor->currentRamp;
+}
+
+GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ assert(monitor != NULL);
+ assert(ramp != NULL);
+ assert(ramp->size > 0);
+ assert(ramp->red != NULL);
+ assert(ramp->green != NULL);
+ assert(ramp->blue != NULL);
+
+ if (ramp->size <= 0)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid gamma ramp size %i",
+ ramp->size);
+ return;
+ }
+
+ _GLFW_REQUIRE_INIT();
+
+ if (!monitor->originalRamp.size)
+ {
+ if (!_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp))
+ return;
+ }
+
+ _glfwPlatformSetGammaRamp(monitor, ramp);
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.h b/Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.h
new file mode 100644
index 0000000..18042de
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.h
@@ -0,0 +1,56 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl
+#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryNSGL nsgl
+
+
+// NSGL-specific per-context data
+//
+typedef struct _GLFWcontextNSGL
+{
+ id pixelFormat;
+ id object;
+
+} _GLFWcontextNSGL;
+
+// NSGL-specific global data
+//
+typedef struct _GLFWlibraryNSGL
+{
+ // dlopen handle for OpenGL.framework (for glfwGetProcAddress)
+ CFBundleRef framework;
+
+} _GLFWlibraryNSGL;
+
+
+GLFWbool _glfwInitNSGL(void);
+void _glfwTerminateNSGL(void);
+GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig);
+void _glfwDestroyContextNSGL(_GLFWwindow* window);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.m b/Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.m
new file mode 100644
index 0000000..ec1012e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/nsgl_context.m
@@ -0,0 +1,340 @@
+//========================================================================
+// GLFW 3.3 macOS - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
+ #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
+ #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
+#endif
+
+static void makeContextCurrentNSGL(_GLFWwindow* window)
+{
+ if (window)
+ [window->context.nsgl.object makeCurrentContext];
+ else
+ [NSOpenGLContext clearCurrentContext];
+
+ _glfwPlatformSetTls(&_glfw.contextSlot, window);
+}
+
+static void swapBuffersNSGL(_GLFWwindow* window)
+{
+ // ARP appears to be unnecessary, but this is future-proof
+ [window->context.nsgl.object flushBuffer];
+}
+
+static void swapIntervalNSGL(int interval)
+{
+ _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
+
+ GLint sync = interval;
+ [window->context.nsgl.object setValues:&sync
+ forParameter:NSOpenGLContextParameterSwapInterval];
+}
+
+static int extensionSupportedNSGL(const char* extension)
+{
+ // There are no NSGL extensions
+ return GLFW_FALSE;
+}
+
+static GLFWglproc getProcAddressNSGL(const char* procname)
+{
+ CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,
+ procname,
+ kCFStringEncodingASCII);
+
+ GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
+ symbolName);
+
+ CFRelease(symbolName);
+
+ return symbol;
+}
+
+// Destroy the OpenGL context
+//
+static void destroyContextNSGL(_GLFWwindow* window)
+{
+ [window->context.nsgl.pixelFormat release];
+ window->context.nsgl.pixelFormat = nil;
+
+ [window->context.nsgl.object release];
+ window->context.nsgl.object = nil;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize OpenGL support
+//
+GLFWbool _glfwInitNSGL(void)
+{
+ if (_glfw.nsgl.framework)
+ return GLFW_TRUE;
+
+ _glfw.nsgl.framework =
+ CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
+ if (_glfw.nsgl.framework == NULL)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "NSGL: Failed to locate OpenGL framework");
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+// Terminate OpenGL support
+//
+void _glfwTerminateNSGL(void)
+{
+}
+
+// Create the OpenGL context
+//
+GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "NSGL: OpenGL ES is not available on macOS");
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->major > 2)
+ {
+ if (ctxconfig->major == 3 && ctxconfig->minor < 2)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above");
+ return GLFW_FALSE;
+ }
+
+ if (!ctxconfig->forward || ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above");
+ return GLFW_FALSE;
+ }
+ }
+
+ // Context robustness modes (GL_KHR_robustness) are not yet supported by
+ // macOS but are not a hard constraint, so ignore and continue
+
+ // Context release behaviors (GL_KHR_context_flush_control) are not yet
+ // supported by macOS but are not a hard constraint, so ignore and continue
+
+ // Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not
+ // a hard constraint, so ignore and continue
+
+ // No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
+ // are not a hard constraint, so ignore and continue
+
+#define addAttrib(a) \
+{ \
+ assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
+ attribs[index++] = a; \
+}
+#define setAttrib(a, v) { addAttrib(a); addAttrib(v); }
+
+ NSOpenGLPixelFormatAttribute attribs[40];
+ int index = 0;
+
+ addAttrib(NSOpenGLPFAAccelerated);
+ addAttrib(NSOpenGLPFAClosestPolicy);
+
+ if (ctxconfig->nsgl.offline)
+ {
+ addAttrib(NSOpenGLPFAAllowOfflineRenderers);
+ // NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
+ // Info.plist for unbundled applications
+ // HACK: This assumes that NSOpenGLPixelFormat will remain
+ // a straightforward wrapper of its CGL counterpart
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+ addAttrib(kCGLPFASupportsAutomaticGraphicsSwitching);
+#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
+ }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
+ if (ctxconfig->major >= 4)
+ {
+ setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
+ }
+ else
+#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
+ if (ctxconfig->major >= 3)
+ {
+ setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
+ }
+
+ if (ctxconfig->major <= 2)
+ {
+ if (fbconfig->auxBuffers != GLFW_DONT_CARE)
+ setAttrib(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
+
+ if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
+ fbconfig->accumGreenBits != GLFW_DONT_CARE &&
+ fbconfig->accumBlueBits != GLFW_DONT_CARE &&
+ fbconfig->accumAlphaBits != GLFW_DONT_CARE)
+ {
+ const int accumBits = fbconfig->accumRedBits +
+ fbconfig->accumGreenBits +
+ fbconfig->accumBlueBits +
+ fbconfig->accumAlphaBits;
+
+ setAttrib(NSOpenGLPFAAccumSize, accumBits);
+ }
+ }
+
+ if (fbconfig->redBits != GLFW_DONT_CARE &&
+ fbconfig->greenBits != GLFW_DONT_CARE &&
+ fbconfig->blueBits != GLFW_DONT_CARE)
+ {
+ int colorBits = fbconfig->redBits +
+ fbconfig->greenBits +
+ fbconfig->blueBits;
+
+ // macOS needs non-zero color size, so set reasonable values
+ if (colorBits == 0)
+ colorBits = 24;
+ else if (colorBits < 15)
+ colorBits = 15;
+
+ setAttrib(NSOpenGLPFAColorSize, colorBits);
+ }
+
+ if (fbconfig->alphaBits != GLFW_DONT_CARE)
+ setAttrib(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
+
+ if (fbconfig->depthBits != GLFW_DONT_CARE)
+ setAttrib(NSOpenGLPFADepthSize, fbconfig->depthBits);
+
+ if (fbconfig->stencilBits != GLFW_DONT_CARE)
+ setAttrib(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
+
+ if (fbconfig->stereo)
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "NSGL: Stereo rendering is deprecated");
+ return GLFW_FALSE;
+#else
+ addAttrib(NSOpenGLPFAStereo);
+#endif
+ }
+
+ if (fbconfig->doublebuffer)
+ addAttrib(NSOpenGLPFADoubleBuffer);
+
+ if (fbconfig->samples != GLFW_DONT_CARE)
+ {
+ if (fbconfig->samples == 0)
+ {
+ setAttrib(NSOpenGLPFASampleBuffers, 0);
+ }
+ else
+ {
+ setAttrib(NSOpenGLPFASampleBuffers, 1);
+ setAttrib(NSOpenGLPFASamples, fbconfig->samples);
+ }
+ }
+
+ // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
+ // framebuffer, so there's no need (and no way) to request it
+
+ addAttrib(0);
+
+#undef addAttrib
+#undef setAttrib
+
+ window->context.nsgl.pixelFormat =
+ [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
+ if (window->context.nsgl.pixelFormat == nil)
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "NSGL: Failed to find a suitable pixel format");
+ return GLFW_FALSE;
+ }
+
+ NSOpenGLContext* share = NULL;
+
+ if (ctxconfig->share)
+ share = ctxconfig->share->context.nsgl.object;
+
+ window->context.nsgl.object =
+ [[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
+ shareContext:share];
+ if (window->context.nsgl.object == nil)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "NSGL: Failed to create OpenGL context");
+ return GLFW_FALSE;
+ }
+
+ if (fbconfig->transparent)
+ {
+ GLint opaque = 0;
+ [window->context.nsgl.object setValues:&opaque
+ forParameter:NSOpenGLContextParameterSurfaceOpacity];
+ }
+
+ [window->context.nsgl.object setView:window->ns.view];
+
+ window->context.makeCurrent = makeContextCurrentNSGL;
+ window->context.swapBuffers = swapBuffersNSGL;
+ window->context.swapInterval = swapIntervalNSGL;
+ window->context.extensionSupported = extensionSupportedNSGL;
+ window->context.getProcAddress = getProcAddressNSGL;
+ window->context.destroy = destroyContextNSGL;
+
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(nil);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return NULL;
+ }
+
+ return window->context.nsgl.object;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/null_init.c b/Client/ThirdParty/Box2D/extern/glfw/src/null_init.c
new file mode 100644
index 0000000..3414738
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/null_init.c
@@ -0,0 +1,50 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2016 Google Inc.
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformInit(void)
+{
+ _glfwInitTimerPOSIX();
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformTerminate(void)
+{
+ _glfwTerminateOSMesa();
+}
+
+const char* _glfwPlatformGetVersionString(void)
+{
+ return _GLFW_VERSION_NUMBER " null OSMesa";
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.c b/Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.c
new file mode 100644
index 0000000..afd65e1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.c
@@ -0,0 +1,42 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
+{
+ return GLFW_FALSE;
+}
+
+void _glfwPlatformUpdateGamepadGUID(char* guid)
+{
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.h b/Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.h
new file mode 100644
index 0000000..3075815
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/null_joystick.h
@@ -0,0 +1,31 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs
+#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs
+
+#define _GLFW_PLATFORM_MAPPING_NAME ""
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/null_monitor.c b/Client/ThirdParty/Box2D/extern/glfw/src/null_monitor.c
new file mode 100644
index 0000000..45c4a10
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/null_monitor.c
@@ -0,0 +1,69 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2016 Google Inc.
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
+{
+}
+
+void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
+{
+}
+
+void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
+ float* xscale, float* yscale)
+{
+ if (xscale)
+ *xscale = 1.f;
+ if (yscale)
+ *yscale = 1.f;
+}
+
+GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
+{
+ return NULL;
+}
+
+void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
+{
+}
+
+GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
+{
+ return GLFW_FALSE;
+}
+
+void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
+{
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/null_platform.h b/Client/ThirdParty/Box2D/extern/glfw/src/null_platform.h
new file mode 100644
index 0000000..2d67c50
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/null_platform.h
@@ -0,0 +1,62 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2016 Google Inc.
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <dlfcn.h>
+
+#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
+
+#define _GLFW_PLATFORM_CONTEXT_STATE
+#define _GLFW_PLATFORM_MONITOR_STATE
+#define _GLFW_PLATFORM_CURSOR_STATE
+#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE
+#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
+#define _GLFW_EGL_CONTEXT_STATE
+#define _GLFW_EGL_LIBRARY_CONTEXT_STATE
+
+#include "osmesa_context.h"
+#include "posix_time.h"
+#include "posix_thread.h"
+#include "null_joystick.h"
+
+#if defined(_GLFW_WIN32)
+ #define _glfw_dlopen(name) LoadLibraryA(name)
+ #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
+ #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
+#else
+ #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
+ #define _glfw_dlclose(handle) dlclose(handle)
+ #define _glfw_dlsym(handle, name) dlsym(handle, name)
+#endif
+
+// Null-specific per-window data
+//
+typedef struct _GLFWwindowNull
+{
+ int width;
+ int height;
+} _GLFWwindowNull;
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/null_window.c b/Client/ThirdParty/Box2D/extern/glfw/src/null_window.c
new file mode 100644
index 0000000..6a54cfe
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/null_window.c
@@ -0,0 +1,321 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2016 Google Inc.
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+
+static int createNativeWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig)
+{
+ window->null.width = wndconfig->width;
+ window->null.height = wndconfig->height;
+
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformCreateWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ if (!createNativeWindow(window, wndconfig))
+ return GLFW_FALSE;
+
+ if (ctxconfig->client != GLFW_NO_API)
+ {
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
+ ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ if (!_glfwInitOSMesa())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
+ return GLFW_FALSE;
+ }
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyWindow(_GLFWwindow* window)
+{
+ if (window->context.destroy)
+ window->context.destroy(window);
+}
+
+void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
+{
+}
+
+void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
+ const GLFWimage* images)
+{
+}
+
+void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
+ _GLFWmonitor* monitor,
+ int xpos, int ypos,
+ int width, int height,
+ int refreshRate)
+{
+}
+
+void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
+{
+}
+
+void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
+{
+}
+
+void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
+{
+ if (width)
+ *width = window->null.width;
+ if (height)
+ *height = window->null.height;
+}
+
+void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
+{
+ window->null.width = width;
+ window->null.height = height;
+}
+
+void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight)
+{
+}
+
+void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
+{
+}
+
+void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
+{
+ if (width)
+ *width = window->null.width;
+ if (height)
+ *height = window->null.height;
+}
+
+void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
+ int* left, int* top,
+ int* right, int* bottom)
+{
+}
+
+void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
+ float* xscale, float* yscale)
+{
+ if (xscale)
+ *xscale = 1.f;
+ if (yscale)
+ *yscale = 1.f;
+}
+
+void _glfwPlatformIconifyWindow(_GLFWwindow* window)
+{
+}
+
+void _glfwPlatformRestoreWindow(_GLFWwindow* window)
+{
+}
+
+void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
+{
+}
+
+int _glfwPlatformWindowMaximized(_GLFWwindow* window)
+{
+ return GLFW_FALSE;
+}
+
+int _glfwPlatformWindowHovered(_GLFWwindow* window)
+{
+ return GLFW_FALSE;
+}
+
+int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
+{
+ return GLFW_FALSE;
+}
+
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
+{
+}
+
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
+{
+}
+
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
+{
+}
+
+float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
+{
+ return 1.f;
+}
+
+void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
+{
+}
+
+void _glfwPlatformShowWindow(_GLFWwindow* window)
+{
+}
+
+
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
+{
+}
+
+void _glfwPlatformUnhideWindow(_GLFWwindow* window)
+{
+}
+
+void _glfwPlatformHideWindow(_GLFWwindow* window)
+{
+}
+
+void _glfwPlatformFocusWindow(_GLFWwindow* window)
+{
+}
+
+int _glfwPlatformWindowFocused(_GLFWwindow* window)
+{
+ return GLFW_FALSE;
+}
+
+int _glfwPlatformWindowIconified(_GLFWwindow* window)
+{
+ return GLFW_FALSE;
+}
+
+int _glfwPlatformWindowVisible(_GLFWwindow* window)
+{
+ return GLFW_FALSE;
+}
+
+void _glfwPlatformPollEvents(void)
+{
+}
+
+void _glfwPlatformWaitEvents(void)
+{
+}
+
+void _glfwPlatformWaitEventsTimeout(double timeout)
+{
+}
+
+void _glfwPlatformPostEmptyEvent(void)
+{
+}
+
+void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
+{
+}
+
+void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
+{
+}
+
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
+{
+}
+
+int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
+ const GLFWimage* image,
+ int xhot, int yhot)
+{
+ return GLFW_TRUE;
+}
+
+int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
+{
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
+{
+}
+
+void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
+{
+}
+
+void _glfwPlatformSetClipboardString(const char* string)
+{
+}
+
+const char* _glfwPlatformGetClipboardString(void)
+{
+ return NULL;
+}
+
+const char* _glfwPlatformGetScancodeName(int scancode)
+{
+ return "";
+}
+
+int _glfwPlatformGetKeyScancode(int key)
+{
+ return -1;
+}
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
+{
+}
+
+int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily)
+{
+ return GLFW_FALSE;
+}
+
+VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
+ _GLFWwindow* window,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface)
+{
+ // This seems like the most appropriate error to return here
+ return VK_ERROR_INITIALIZATION_FAILED;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.c b/Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.c
new file mode 100644
index 0000000..03651eb
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.c
@@ -0,0 +1,370 @@
+//========================================================================
+// GLFW 3.3 OSMesa - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2016 Google Inc.
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "internal.h"
+
+
+static void makeContextCurrentOSMesa(_GLFWwindow* window)
+{
+ if (window)
+ {
+ int width, height;
+ _glfwPlatformGetFramebufferSize(window, &width, &height);
+
+ // Check to see if we need to allocate a new buffer
+ if ((window->context.osmesa.buffer == NULL) ||
+ (width != window->context.osmesa.width) ||
+ (height != window->context.osmesa.height))
+ {
+ free(window->context.osmesa.buffer);
+
+ // Allocate the new buffer (width * height * 8-bit RGBA)
+ window->context.osmesa.buffer = calloc(4, width * height);
+ window->context.osmesa.width = width;
+ window->context.osmesa.height = height;
+ }
+
+ if (!OSMesaMakeCurrent(window->context.osmesa.handle,
+ window->context.osmesa.buffer,
+ GL_UNSIGNED_BYTE,
+ width, height))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "OSMesa: Failed to make context current");
+ return;
+ }
+ }
+
+ _glfwPlatformSetTls(&_glfw.contextSlot, window);
+}
+
+static GLFWglproc getProcAddressOSMesa(const char* procname)
+{
+ return (GLFWglproc) OSMesaGetProcAddress(procname);
+}
+
+static void destroyContextOSMesa(_GLFWwindow* window)
+{
+ if (window->context.osmesa.handle)
+ {
+ OSMesaDestroyContext(window->context.osmesa.handle);
+ window->context.osmesa.handle = NULL;
+ }
+
+ if (window->context.osmesa.buffer)
+ {
+ free(window->context.osmesa.buffer);
+ window->context.osmesa.width = 0;
+ window->context.osmesa.height = 0;
+ }
+}
+
+static void swapBuffersOSMesa(_GLFWwindow* window)
+{
+ // No double buffering on OSMesa
+}
+
+static void swapIntervalOSMesa(int interval)
+{
+ // No swap interval on OSMesa
+}
+
+static int extensionSupportedOSMesa(const char* extension)
+{
+ // OSMesa does not have extensions
+ return GLFW_FALSE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWbool _glfwInitOSMesa(void)
+{
+ int i;
+ const char* sonames[] =
+ {
+#if defined(_GLFW_OSMESA_LIBRARY)
+ _GLFW_OSMESA_LIBRARY,
+#elif defined(_WIN32)
+ "libOSMesa.dll",
+ "OSMesa.dll",
+#elif defined(__APPLE__)
+ "libOSMesa.8.dylib",
+#elif defined(__CYGWIN__)
+ "libOSMesa-8.so",
+#else
+ "libOSMesa.so.8",
+ "libOSMesa.so.6",
+#endif
+ NULL
+ };
+
+ if (_glfw.osmesa.handle)
+ return GLFW_TRUE;
+
+ for (i = 0; sonames[i]; i++)
+ {
+ _glfw.osmesa.handle = _glfw_dlopen(sonames[i]);
+ if (_glfw.osmesa.handle)
+ break;
+ }
+
+ if (!_glfw.osmesa.handle)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found");
+ return GLFW_FALSE;
+ }
+
+ _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt");
+ _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
+ _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
+ _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
+ _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
+ _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
+ _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
+ _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
+
+ if (!_glfw.osmesa.CreateContextExt ||
+ !_glfw.osmesa.DestroyContext ||
+ !_glfw.osmesa.MakeCurrent ||
+ !_glfw.osmesa.GetColorBuffer ||
+ !_glfw.osmesa.GetDepthBuffer ||
+ !_glfw.osmesa.GetProcAddress)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "OSMesa: Failed to load required entry points");
+
+ _glfwTerminateOSMesa();
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwTerminateOSMesa(void)
+{
+ if (_glfw.osmesa.handle)
+ {
+ _glfw_dlclose(_glfw.osmesa.handle);
+ _glfw.osmesa.handle = NULL;
+ }
+}
+
+#define setAttrib(a, v) \
+{ \
+ assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
+ attribs[index++] = a; \
+ attribs[index++] = v; \
+}
+
+GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ OSMesaContext share = NULL;
+ const int accumBits = fbconfig->accumRedBits +
+ fbconfig->accumGreenBits +
+ fbconfig->accumBlueBits +
+ fbconfig->accumAlphaBits;
+
+ if (ctxconfig->client == GLFW_OPENGL_ES_API)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "OSMesa: OpenGL ES is not available on OSMesa");
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->share)
+ share = ctxconfig->share->context.osmesa.handle;
+
+ if (OSMesaCreateContextAttribs)
+ {
+ int index = 0, attribs[40];
+
+ setAttrib(OSMESA_FORMAT, OSMESA_RGBA);
+ setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits);
+ setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
+ setAttrib(OSMESA_ACCUM_BITS, accumBits);
+
+ if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
+ {
+ setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
+ }
+ else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
+ {
+ setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
+ }
+
+ if (ctxconfig->major != 1 || ctxconfig->minor != 0)
+ {
+ setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
+ setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
+ }
+
+ if (ctxconfig->forward)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "OSMesa: Forward-compatible contexts not supported");
+ return GLFW_FALSE;
+ }
+
+ setAttrib(0, 0);
+
+ window->context.osmesa.handle =
+ OSMesaCreateContextAttribs(attribs, share);
+ }
+ else
+ {
+ if (ctxconfig->profile)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "OSMesa: OpenGL profiles unavailable");
+ return GLFW_FALSE;
+ }
+
+ window->context.osmesa.handle =
+ OSMesaCreateContextExt(OSMESA_RGBA,
+ fbconfig->depthBits,
+ fbconfig->stencilBits,
+ accumBits,
+ share);
+ }
+
+ if (window->context.osmesa.handle == NULL)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "OSMesa: Failed to create context");
+ return GLFW_FALSE;
+ }
+
+ window->context.makeCurrent = makeContextCurrentOSMesa;
+ window->context.swapBuffers = swapBuffersOSMesa;
+ window->context.swapInterval = swapIntervalOSMesa;
+ window->context.extensionSupported = extensionSupportedOSMesa;
+ window->context.getProcAddress = getProcAddressOSMesa;
+ window->context.destroy = destroyContextOSMesa;
+
+ return GLFW_TRUE;
+}
+
+#undef setAttrib
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
+ int* height, int* format, void** buffer)
+{
+ void* mesaBuffer;
+ GLint mesaWidth, mesaHeight, mesaFormat;
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
+ &mesaWidth, &mesaHeight,
+ &mesaFormat, &mesaBuffer))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "OSMesa: Failed to retrieve color buffer");
+ return GLFW_FALSE;
+ }
+
+ if (width)
+ *width = mesaWidth;
+ if (height)
+ *height = mesaHeight;
+ if (format)
+ *format = mesaFormat;
+ if (buffer)
+ *buffer = mesaBuffer;
+
+ return GLFW_TRUE;
+}
+
+GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
+ int* width, int* height,
+ int* bytesPerValue,
+ void** buffer)
+{
+ void* mesaBuffer;
+ GLint mesaWidth, mesaHeight, mesaBytes;
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
+ &mesaWidth, &mesaHeight,
+ &mesaBytes, &mesaBuffer))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "OSMesa: Failed to retrieve depth buffer");
+ return GLFW_FALSE;
+ }
+
+ if (width)
+ *width = mesaWidth;
+ if (height)
+ *height = mesaHeight;
+ if (bytesPerValue)
+ *bytesPerValue = mesaBytes;
+ if (buffer)
+ *buffer = mesaBuffer;
+
+ return GLFW_TRUE;
+}
+
+GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return NULL;
+ }
+
+ return window->context.osmesa.handle;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.h b/Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.h
new file mode 100644
index 0000000..07bb469
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/osmesa_context.h
@@ -0,0 +1,94 @@
+//========================================================================
+// GLFW 3.3 OSMesa - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2016 Google Inc.
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define OSMESA_RGBA 0x1908
+#define OSMESA_FORMAT 0x22
+#define OSMESA_DEPTH_BITS 0x30
+#define OSMESA_STENCIL_BITS 0x31
+#define OSMESA_ACCUM_BITS 0x32
+#define OSMESA_PROFILE 0x33
+#define OSMESA_CORE_PROFILE 0x34
+#define OSMESA_COMPAT_PROFILE 0x35
+#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
+#define OSMESA_CONTEXT_MINOR_VERSION 0x37
+
+typedef void* OSMesaContext;
+typedef void (*OSMESAproc)(void);
+
+typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
+typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
+typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
+typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
+typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
+typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
+typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
+#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
+#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
+#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
+#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
+#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
+#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
+#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
+
+#define _GLFW_OSMESA_CONTEXT_STATE _GLFWcontextOSMesa osmesa
+#define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE _GLFWlibraryOSMesa osmesa
+
+
+// OSMesa-specific per-context data
+//
+typedef struct _GLFWcontextOSMesa
+{
+ OSMesaContext handle;
+ int width;
+ int height;
+ void* buffer;
+
+} _GLFWcontextOSMesa;
+
+// OSMesa-specific global data
+//
+typedef struct _GLFWlibraryOSMesa
+{
+ void* handle;
+
+ PFN_OSMesaCreateContextExt CreateContextExt;
+ PFN_OSMesaCreateContextAttribs CreateContextAttribs;
+ PFN_OSMesaDestroyContext DestroyContext;
+ PFN_OSMesaMakeCurrent MakeCurrent;
+ PFN_OSMesaGetColorBuffer GetColorBuffer;
+ PFN_OSMesaGetDepthBuffer GetDepthBuffer;
+ PFN_OSMesaGetProcAddress GetProcAddress;
+
+} _GLFWlibraryOSMesa;
+
+
+GLFWbool _glfwInitOSMesa(void);
+void _glfwTerminateOSMesa(void);
+GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.c b/Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.c
new file mode 100644
index 0000000..ce0bc39
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.c
@@ -0,0 +1,103 @@
+//========================================================================
+// GLFW 3.3 POSIX - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <string.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
+{
+ assert(tls->posix.allocated == GLFW_FALSE);
+
+ if (pthread_key_create(&tls->posix.key, NULL) != 0)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "POSIX: Failed to create context TLS");
+ return GLFW_FALSE;
+ }
+
+ tls->posix.allocated = GLFW_TRUE;
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyTls(_GLFWtls* tls)
+{
+ if (tls->posix.allocated)
+ pthread_key_delete(tls->posix.key);
+ memset(tls, 0, sizeof(_GLFWtls));
+}
+
+void* _glfwPlatformGetTls(_GLFWtls* tls)
+{
+ assert(tls->posix.allocated == GLFW_TRUE);
+ return pthread_getspecific(tls->posix.key);
+}
+
+void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
+{
+ assert(tls->posix.allocated == GLFW_TRUE);
+ pthread_setspecific(tls->posix.key, value);
+}
+
+GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
+{
+ assert(mutex->posix.allocated == GLFW_FALSE);
+
+ if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex");
+ return GLFW_FALSE;
+ }
+
+ return mutex->posix.allocated = GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
+{
+ if (mutex->posix.allocated)
+ pthread_mutex_destroy(&mutex->posix.handle);
+ memset(mutex, 0, sizeof(_GLFWmutex));
+}
+
+void _glfwPlatformLockMutex(_GLFWmutex* mutex)
+{
+ assert(mutex->posix.allocated == GLFW_TRUE);
+ pthread_mutex_lock(&mutex->posix.handle);
+}
+
+void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
+{
+ assert(mutex->posix.allocated == GLFW_TRUE);
+ pthread_mutex_unlock(&mutex->posix.handle);
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.h b/Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.h
new file mode 100644
index 0000000..bdddf41
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/posix_thread.h
@@ -0,0 +1,51 @@
+//========================================================================
+// GLFW 3.3 POSIX - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <pthread.h>
+
+#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix
+#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix
+
+
+// POSIX-specific thread local storage data
+//
+typedef struct _GLFWtlsPOSIX
+{
+ GLFWbool allocated;
+ pthread_key_t key;
+
+} _GLFWtlsPOSIX;
+
+// POSIX-specific mutex data
+//
+typedef struct _GLFWmutexPOSIX
+{
+ GLFWbool allocated;
+ pthread_mutex_t handle;
+
+} _GLFWmutexPOSIX;
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/posix_time.c b/Client/ThirdParty/Box2D/extern/glfw/src/posix_time.c
new file mode 100644
index 0000000..00b2831
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/posix_time.c
@@ -0,0 +1,85 @@
+//========================================================================
+// GLFW 3.3 POSIX - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <sys/time.h>
+#include <time.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialise timer
+//
+void _glfwInitTimerPOSIX(void)
+{
+#if defined(CLOCK_MONOTONIC)
+ struct timespec ts;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ {
+ _glfw.timer.posix.monotonic = GLFW_TRUE;
+ _glfw.timer.posix.frequency = 1000000000;
+ }
+ else
+#endif
+ {
+ _glfw.timer.posix.monotonic = GLFW_FALSE;
+ _glfw.timer.posix.frequency = 1000000;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+uint64_t _glfwPlatformGetTimerValue(void)
+{
+#if defined(CLOCK_MONOTONIC)
+ if (_glfw.timer.posix.monotonic)
+ {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
+ }
+ else
+#endif
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;
+ }
+}
+
+uint64_t _glfwPlatformGetTimerFrequency(void)
+{
+ return _glfw.timer.posix.frequency;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/posix_time.h b/Client/ThirdParty/Box2D/extern/glfw/src/posix_time.h
new file mode 100644
index 0000000..f1a69eb
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/posix_time.h
@@ -0,0 +1,44 @@
+//========================================================================
+// GLFW 3.3 POSIX - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
+
+#include <stdint.h>
+
+
+// POSIX-specific global timer data
+//
+typedef struct _GLFWtimerPOSIX
+{
+ GLFWbool monotonic;
+ uint64_t frequency;
+
+} _GLFWtimerPOSIX;
+
+
+void _glfwInitTimerPOSIX(void);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/vulkan.c b/Client/ThirdParty/Box2D/extern/glfw/src/vulkan.c
new file mode 100644
index 0000000..b8f752f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/vulkan.c
@@ -0,0 +1,326 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define _GLFW_FIND_LOADER 1
+#define _GLFW_REQUIRE_LOADER 2
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWbool _glfwInitVulkan(int mode)
+{
+ VkResult err;
+ VkExtensionProperties* ep;
+ uint32_t i, count;
+
+ if (_glfw.vk.available)
+ return GLFW_TRUE;
+
+#if !defined(_GLFW_VULKAN_STATIC)
+#if defined(_GLFW_VULKAN_LIBRARY)
+ _glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY);
+#elif defined(_GLFW_WIN32)
+ _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
+#elif defined(_GLFW_COCOA)
+ _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
+#else
+ _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
+#endif
+ if (!_glfw.vk.handle)
+ {
+ if (mode == _GLFW_REQUIRE_LOADER)
+ _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
+
+ return GLFW_FALSE;
+ }
+
+ _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
+ _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
+ if (!_glfw.vk.GetInstanceProcAddr)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Vulkan: Loader does not export vkGetInstanceProcAddr");
+
+ _glfwTerminateVulkan();
+ return GLFW_FALSE;
+ }
+
+ _glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
+ vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
+ if (!_glfw.vk.EnumerateInstanceExtensionProperties)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
+
+ _glfwTerminateVulkan();
+ return GLFW_FALSE;
+ }
+#endif // _GLFW_VULKAN_STATIC
+
+ err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
+ if (err)
+ {
+ // NOTE: This happens on systems with a loader but without any Vulkan ICD
+ if (mode == _GLFW_REQUIRE_LOADER)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Vulkan: Failed to query instance extension count: %s",
+ _glfwGetVulkanResultString(err));
+ }
+
+ _glfwTerminateVulkan();
+ return GLFW_FALSE;
+ }
+
+ ep = calloc(count, sizeof(VkExtensionProperties));
+
+ err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
+ if (err)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Vulkan: Failed to query instance extensions: %s",
+ _glfwGetVulkanResultString(err));
+
+ free(ep);
+ _glfwTerminateVulkan();
+ return GLFW_FALSE;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
+ _glfw.vk.KHR_surface = GLFW_TRUE;
+#if defined(_GLFW_WIN32)
+ else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
+ _glfw.vk.KHR_win32_surface = GLFW_TRUE;
+#elif defined(_GLFW_COCOA)
+ else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
+ _glfw.vk.MVK_macos_surface = GLFW_TRUE;
+#elif defined(_GLFW_X11)
+ else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
+ _glfw.vk.KHR_xlib_surface = GLFW_TRUE;
+ else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
+ _glfw.vk.KHR_xcb_surface = GLFW_TRUE;
+#elif defined(_GLFW_WAYLAND)
+ else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
+ _glfw.vk.KHR_wayland_surface = GLFW_TRUE;
+#endif
+ }
+
+ free(ep);
+
+ _glfw.vk.available = GLFW_TRUE;
+
+ _glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
+
+ return GLFW_TRUE;
+}
+
+void _glfwTerminateVulkan(void)
+{
+#if !defined(_GLFW_VULKAN_STATIC)
+ if (_glfw.vk.handle)
+ _glfw_dlclose(_glfw.vk.handle);
+#endif
+}
+
+const char* _glfwGetVulkanResultString(VkResult result)
+{
+ switch (result)
+ {
+ case VK_SUCCESS:
+ return "Success";
+ case VK_NOT_READY:
+ return "A fence or query has not yet completed";
+ case VK_TIMEOUT:
+ return "A wait operation has not completed in the specified time";
+ case VK_EVENT_SET:
+ return "An event is signaled";
+ case VK_EVENT_RESET:
+ return "An event is unsignaled";
+ case VK_INCOMPLETE:
+ return "A return array was too small for the result";
+ case VK_ERROR_OUT_OF_HOST_MEMORY:
+ return "A host memory allocation has failed";
+ case VK_ERROR_OUT_OF_DEVICE_MEMORY:
+ return "A device memory allocation has failed";
+ case VK_ERROR_INITIALIZATION_FAILED:
+ return "Initialization of an object could not be completed for implementation-specific reasons";
+ case VK_ERROR_DEVICE_LOST:
+ return "The logical or physical device has been lost";
+ case VK_ERROR_MEMORY_MAP_FAILED:
+ return "Mapping of a memory object has failed";
+ case VK_ERROR_LAYER_NOT_PRESENT:
+ return "A requested layer is not present or could not be loaded";
+ case VK_ERROR_EXTENSION_NOT_PRESENT:
+ return "A requested extension is not supported";
+ case VK_ERROR_FEATURE_NOT_PRESENT:
+ return "A requested feature is not supported";
+ case VK_ERROR_INCOMPATIBLE_DRIVER:
+ return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible";
+ case VK_ERROR_TOO_MANY_OBJECTS:
+ return "Too many objects of the type have already been created";
+ case VK_ERROR_FORMAT_NOT_SUPPORTED:
+ return "A requested format is not supported on this device";
+ case VK_ERROR_SURFACE_LOST_KHR:
+ return "A surface is no longer available";
+ case VK_SUBOPTIMAL_KHR:
+ return "A swapchain no longer matches the surface properties exactly, but can still be used";
+ case VK_ERROR_OUT_OF_DATE_KHR:
+ return "A surface has changed in such a way that it is no longer compatible with the swapchain";
+ case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
+ return "The display used by a swapchain does not use the same presentable image layout";
+ case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
+ return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
+ case VK_ERROR_VALIDATION_FAILED_EXT:
+ return "A validation layer found an error";
+ default:
+ return "ERROR: UNKNOWN VULKAN ERROR";
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW public API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI int glfwVulkanSupported(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+ return _glfwInitVulkan(_GLFW_FIND_LOADER);
+}
+
+GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
+{
+ assert(count != NULL);
+
+ *count = 0;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
+ return NULL;
+
+ if (!_glfw.vk.extensions[0])
+ return NULL;
+
+ *count = 2;
+ return (const char**) _glfw.vk.extensions;
+}
+
+GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
+ const char* procname)
+{
+ GLFWvkproc proc;
+ assert(procname != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
+ return NULL;
+
+ proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
+#if defined(_GLFW_VULKAN_STATIC)
+ if (!proc)
+ {
+ if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
+ return (GLFWvkproc) vkGetInstanceProcAddr;
+ }
+#else
+ if (!proc)
+ proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname);
+#endif
+
+ return proc;
+}
+
+GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily)
+{
+ assert(instance != VK_NULL_HANDLE);
+ assert(device != VK_NULL_HANDLE);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
+
+ if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
+ return GLFW_FALSE;
+
+ if (!_glfw.vk.extensions[0])
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Vulkan: Window surface creation extensions not found");
+ return GLFW_FALSE;
+ }
+
+ return _glfwPlatformGetPhysicalDevicePresentationSupport(instance,
+ device,
+ queuefamily);
+}
+
+GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
+ GLFWwindow* handle,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(instance != VK_NULL_HANDLE);
+ assert(window != NULL);
+ assert(surface != NULL);
+
+ *surface = VK_NULL_HANDLE;
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
+
+ if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
+ return VK_ERROR_INITIALIZATION_FAILED;
+
+ if (!_glfw.vk.extensions[0])
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Vulkan: Window surface creation extensions not found");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ if (window->context.client != GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API");
+ return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
+ }
+
+ return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.c b/Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.c
new file mode 100644
index 0000000..06ba8b5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.c
@@ -0,0 +1,732 @@
+//========================================================================
+// GLFW 3.3 WGL - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdlib.h>
+#include <malloc.h>
+#include <assert.h>
+
+
+// Returns the specified attribute of the specified pixel format
+//
+static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib)
+{
+ int value = 0;
+
+ assert(_glfw.wgl.ARB_pixel_format);
+
+ if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc,
+ pixelFormat,
+ 0, 1, &attrib, &value))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to retrieve pixel format attribute");
+ return 0;
+ }
+
+ return value;
+}
+
+// Return a list of available and usable framebuffer configs
+//
+static int choosePixelFormat(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ _GLFWfbconfig* usableConfigs;
+ const _GLFWfbconfig* closest;
+ int i, pixelFormat, nativeCount, usableCount;
+
+ if (_glfw.wgl.ARB_pixel_format)
+ {
+ nativeCount = getPixelFormatAttrib(window,
+ 1,
+ WGL_NUMBER_PIXEL_FORMATS_ARB);
+ }
+ else
+ {
+ nativeCount = DescribePixelFormat(window->context.wgl.dc,
+ 1,
+ sizeof(PIXELFORMATDESCRIPTOR),
+ NULL);
+ }
+
+ usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
+ usableCount = 0;
+
+ for (i = 0; i < nativeCount; i++)
+ {
+ const int n = i + 1;
+ _GLFWfbconfig* u = usableConfigs + usableCount;
+
+ if (_glfw.wgl.ARB_pixel_format)
+ {
+ // Get pixel format attributes through "modern" extension
+
+ if (!getPixelFormatAttrib(window, n, WGL_SUPPORT_OPENGL_ARB) ||
+ !getPixelFormatAttrib(window, n, WGL_DRAW_TO_WINDOW_ARB))
+ {
+ continue;
+ }
+
+ if (getPixelFormatAttrib(window, n, WGL_PIXEL_TYPE_ARB) !=
+ WGL_TYPE_RGBA_ARB)
+ {
+ continue;
+ }
+
+ if (getPixelFormatAttrib(window, n, WGL_ACCELERATION_ARB) ==
+ WGL_NO_ACCELERATION_ARB)
+ {
+ continue;
+ }
+
+ u->redBits = getPixelFormatAttrib(window, n, WGL_RED_BITS_ARB);
+ u->greenBits = getPixelFormatAttrib(window, n, WGL_GREEN_BITS_ARB);
+ u->blueBits = getPixelFormatAttrib(window, n, WGL_BLUE_BITS_ARB);
+ u->alphaBits = getPixelFormatAttrib(window, n, WGL_ALPHA_BITS_ARB);
+
+ u->depthBits = getPixelFormatAttrib(window, n, WGL_DEPTH_BITS_ARB);
+ u->stencilBits = getPixelFormatAttrib(window, n, WGL_STENCIL_BITS_ARB);
+
+ u->accumRedBits = getPixelFormatAttrib(window, n, WGL_ACCUM_RED_BITS_ARB);
+ u->accumGreenBits = getPixelFormatAttrib(window, n, WGL_ACCUM_GREEN_BITS_ARB);
+ u->accumBlueBits = getPixelFormatAttrib(window, n, WGL_ACCUM_BLUE_BITS_ARB);
+ u->accumAlphaBits = getPixelFormatAttrib(window, n, WGL_ACCUM_ALPHA_BITS_ARB);
+
+ u->auxBuffers = getPixelFormatAttrib(window, n, WGL_AUX_BUFFERS_ARB);
+
+ if (getPixelFormatAttrib(window, n, WGL_STEREO_ARB))
+ u->stereo = GLFW_TRUE;
+ if (getPixelFormatAttrib(window, n, WGL_DOUBLE_BUFFER_ARB))
+ u->doublebuffer = GLFW_TRUE;
+
+ if (_glfw.wgl.ARB_multisample)
+ u->samples = getPixelFormatAttrib(window, n, WGL_SAMPLES_ARB);
+
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if (_glfw.wgl.ARB_framebuffer_sRGB ||
+ _glfw.wgl.EXT_framebuffer_sRGB)
+ {
+ if (getPixelFormatAttrib(window, n, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
+ u->sRGB = GLFW_TRUE;
+ }
+ }
+ else
+ {
+ if (_glfw.wgl.EXT_colorspace)
+ {
+ if (getPixelFormatAttrib(window, n, WGL_COLORSPACE_EXT) ==
+ WGL_COLORSPACE_SRGB_EXT)
+ {
+ u->sRGB = GLFW_TRUE;
+ }
+ }
+ }
+ }
+ else
+ {
+ // Get pixel format attributes through legacy PFDs
+
+ PIXELFORMATDESCRIPTOR pfd;
+
+ if (!DescribePixelFormat(window->context.wgl.dc,
+ n,
+ sizeof(PIXELFORMATDESCRIPTOR),
+ &pfd))
+ {
+ continue;
+ }
+
+ if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
+ !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
+ {
+ continue;
+ }
+
+ if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
+ (pfd.dwFlags & PFD_GENERIC_FORMAT))
+ {
+ continue;
+ }
+
+ if (pfd.iPixelType != PFD_TYPE_RGBA)
+ continue;
+
+ u->redBits = pfd.cRedBits;
+ u->greenBits = pfd.cGreenBits;
+ u->blueBits = pfd.cBlueBits;
+ u->alphaBits = pfd.cAlphaBits;
+
+ u->depthBits = pfd.cDepthBits;
+ u->stencilBits = pfd.cStencilBits;
+
+ u->accumRedBits = pfd.cAccumRedBits;
+ u->accumGreenBits = pfd.cAccumGreenBits;
+ u->accumBlueBits = pfd.cAccumBlueBits;
+ u->accumAlphaBits = pfd.cAccumAlphaBits;
+
+ u->auxBuffers = pfd.cAuxBuffers;
+
+ if (pfd.dwFlags & PFD_STEREO)
+ u->stereo = GLFW_TRUE;
+ if (pfd.dwFlags & PFD_DOUBLEBUFFER)
+ u->doublebuffer = GLFW_TRUE;
+ }
+
+ u->handle = n;
+ usableCount++;
+ }
+
+ if (!usableCount)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "WGL: The driver does not appear to support OpenGL");
+
+ free(usableConfigs);
+ return 0;
+ }
+
+ closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
+ if (!closest)
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "WGL: Failed to find a suitable pixel format");
+
+ free(usableConfigs);
+ return 0;
+ }
+
+ pixelFormat = (int) closest->handle;
+ free(usableConfigs);
+
+ return pixelFormat;
+}
+
+static void makeContextCurrentWGL(_GLFWwindow* window)
+{
+ if (window)
+ {
+ if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
+ _glfwPlatformSetTls(&_glfw.contextSlot, window);
+ else
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to make context current");
+ _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
+ }
+ }
+ else
+ {
+ if (!wglMakeCurrent(NULL, NULL))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to clear current context");
+ }
+
+ _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
+ }
+}
+
+static void swapBuffersWGL(_GLFWwindow* window)
+{
+ if (!window->monitor)
+ {
+ if (IsWindowsVistaOrGreater())
+ {
+ BOOL enabled;
+
+ // HACK: Use DwmFlush when desktop composition is enabled
+ if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
+ {
+ int count = abs(window->context.wgl.interval);
+ while (count--)
+ DwmFlush();
+ }
+ }
+ }
+
+ SwapBuffers(window->context.wgl.dc);
+}
+
+static void swapIntervalWGL(int interval)
+{
+ _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
+
+ window->context.wgl.interval = interval;
+
+ if (!window->monitor)
+ {
+ if (IsWindowsVistaOrGreater())
+ {
+ BOOL enabled;
+
+ // HACK: Disable WGL swap interval when desktop composition is enabled to
+ // avoid interfering with DWM vsync
+ if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
+ interval = 0;
+ }
+ }
+
+ if (_glfw.wgl.EXT_swap_control)
+ _glfw.wgl.SwapIntervalEXT(interval);
+}
+
+static int extensionSupportedWGL(const char* extension)
+{
+ const char* extensions = NULL;
+
+ if (_glfw.wgl.GetExtensionsStringARB)
+ extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC());
+ else if (_glfw.wgl.GetExtensionsStringEXT)
+ extensions = _glfw.wgl.GetExtensionsStringEXT();
+
+ if (!extensions)
+ return GLFW_FALSE;
+
+ return _glfwStringInExtensionString(extension, extensions);
+}
+
+static GLFWglproc getProcAddressWGL(const char* procname)
+{
+ const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
+ if (proc)
+ return proc;
+
+ return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
+}
+
+// Destroy the OpenGL context
+//
+static void destroyContextWGL(_GLFWwindow* window)
+{
+ if (window->context.wgl.handle)
+ {
+ wglDeleteContext(window->context.wgl.handle);
+ window->context.wgl.handle = NULL;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize WGL
+//
+GLFWbool _glfwInitWGL(void)
+{
+ PIXELFORMATDESCRIPTOR pfd;
+ HGLRC prc, rc;
+ HDC pdc, dc;
+
+ if (_glfw.wgl.instance)
+ return GLFW_TRUE;
+
+ _glfw.wgl.instance = LoadLibraryA("opengl32.dll");
+ if (!_glfw.wgl.instance)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to load opengl32.dll");
+ return GLFW_FALSE;
+ }
+
+ _glfw.wgl.CreateContext = (PFN_wglCreateContext)
+ GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
+ _glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
+ GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
+ _glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
+ GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
+ _glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
+ GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
+ _glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
+ GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext");
+ _glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
+ GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
+ _glfw.wgl.ShareLists = (PFN_wglShareLists)
+ GetProcAddress(_glfw.wgl.instance, "wglShareLists");
+
+ // NOTE: A dummy context has to be created for opengl32.dll to load the
+ // OpenGL ICD, from which we can then query WGL extensions
+ // NOTE: This code will accept the Microsoft GDI ICD; accelerated context
+ // creation failure occurs during manual pixel format enumeration
+
+ dc = GetDC(_glfw.win32.helperWindowHandle);;
+
+ ZeroMemory(&pfd, sizeof(pfd));
+ pfd.nSize = sizeof(pfd);
+ pfd.nVersion = 1;
+ pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.cColorBits = 24;
+
+ if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to set pixel format for dummy context");
+ return GLFW_FALSE;
+ }
+
+ rc = wglCreateContext(dc);
+ if (!rc)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to create dummy context");
+ return GLFW_FALSE;
+ }
+
+ pdc = wglGetCurrentDC();
+ prc = wglGetCurrentContext();
+
+ if (!wglMakeCurrent(dc, rc))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to make dummy context current");
+ wglMakeCurrent(pdc, prc);
+ wglDeleteContext(rc);
+ return GLFW_FALSE;
+ }
+
+ // NOTE: Functions must be loaded first as they're needed to retrieve the
+ // extension string that tells us whether the functions are supported
+ _glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
+ wglGetProcAddress("wglGetExtensionsStringEXT");
+ _glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
+ wglGetProcAddress("wglGetExtensionsStringARB");
+ _glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
+ wglGetProcAddress("wglCreateContextAttribsARB");
+ _glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
+ wglGetProcAddress("wglSwapIntervalEXT");
+ _glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
+ wglGetProcAddress("wglGetPixelFormatAttribivARB");
+
+ // NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
+ // checked below as we are already using them
+ _glfw.wgl.ARB_multisample =
+ extensionSupportedWGL("WGL_ARB_multisample");
+ _glfw.wgl.ARB_framebuffer_sRGB =
+ extensionSupportedWGL("WGL_ARB_framebuffer_sRGB");
+ _glfw.wgl.EXT_framebuffer_sRGB =
+ extensionSupportedWGL("WGL_EXT_framebuffer_sRGB");
+ _glfw.wgl.ARB_create_context =
+ extensionSupportedWGL("WGL_ARB_create_context");
+ _glfw.wgl.ARB_create_context_profile =
+ extensionSupportedWGL("WGL_ARB_create_context_profile");
+ _glfw.wgl.EXT_create_context_es2_profile =
+ extensionSupportedWGL("WGL_EXT_create_context_es2_profile");
+ _glfw.wgl.ARB_create_context_robustness =
+ extensionSupportedWGL("WGL_ARB_create_context_robustness");
+ _glfw.wgl.ARB_create_context_no_error =
+ extensionSupportedWGL("WGL_ARB_create_context_no_error");
+ _glfw.wgl.EXT_swap_control =
+ extensionSupportedWGL("WGL_EXT_swap_control");
+ _glfw.wgl.EXT_colorspace =
+ extensionSupportedWGL("WGL_EXT_colorspace");
+ _glfw.wgl.ARB_pixel_format =
+ extensionSupportedWGL("WGL_ARB_pixel_format");
+ _glfw.wgl.ARB_context_flush_control =
+ extensionSupportedWGL("WGL_ARB_context_flush_control");
+
+ wglMakeCurrent(pdc, prc);
+ wglDeleteContext(rc);
+ return GLFW_TRUE;
+}
+
+// Terminate WGL
+//
+void _glfwTerminateWGL(void)
+{
+ if (_glfw.wgl.instance)
+ FreeLibrary(_glfw.wgl.instance);
+}
+
+#define setAttrib(a, v) \
+{ \
+ assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
+ attribs[index++] = a; \
+ attribs[index++] = v; \
+}
+
+// Create the OpenGL or OpenGL ES context
+//
+GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ int attribs[40];
+ int pixelFormat;
+ PIXELFORMATDESCRIPTOR pfd;
+ HGLRC share = NULL;
+
+ if (ctxconfig->share)
+ share = ctxconfig->share->context.wgl.handle;
+
+ window->context.wgl.dc = GetDC(window->win32.handle);
+ if (!window->context.wgl.dc)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to retrieve DC for window");
+ return GLFW_FALSE;
+ }
+
+ pixelFormat = choosePixelFormat(window, ctxconfig, fbconfig);
+ if (!pixelFormat)
+ return GLFW_FALSE;
+
+ if (!DescribePixelFormat(window->context.wgl.dc,
+ pixelFormat, sizeof(pfd), &pfd))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to retrieve PFD for selected pixel format");
+ return GLFW_FALSE;
+ }
+
+ if (!SetPixelFormat(window->context.wgl.dc, pixelFormat, &pfd))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to set selected pixel format");
+ return GLFW_FALSE;
+ }
+
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if (ctxconfig->forward)
+ {
+ if (!_glfw.wgl.ARB_create_context)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->profile)
+ {
+ if (!_glfw.wgl.ARB_create_context_profile)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
+ return GLFW_FALSE;
+ }
+ }
+ }
+ else
+ {
+ if (!_glfw.wgl.ARB_create_context ||
+ !_glfw.wgl.ARB_create_context_profile ||
+ !_glfw.wgl.EXT_create_context_es2_profile)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
+ return GLFW_FALSE;
+ }
+ }
+
+ if (_glfw.wgl.ARB_create_context)
+ {
+ int index = 0, mask = 0, flags = 0;
+
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ if (ctxconfig->forward)
+ flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
+
+ if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
+ mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
+ else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
+ mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
+ }
+ else
+ mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
+
+ if (ctxconfig->debug)
+ flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
+
+ if (ctxconfig->robustness)
+ {
+ if (_glfw.wgl.ARB_create_context_robustness)
+ {
+ if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
+ {
+ setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
+ WGL_NO_RESET_NOTIFICATION_ARB);
+ }
+ else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
+ {
+ setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
+ WGL_LOSE_CONTEXT_ON_RESET_ARB);
+ }
+
+ flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
+ }
+ }
+
+ if (ctxconfig->release)
+ {
+ if (_glfw.wgl.ARB_context_flush_control)
+ {
+ if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
+ {
+ setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
+ WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
+ }
+ else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
+ {
+ setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
+ WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
+ }
+ }
+ }
+
+ if (ctxconfig->noerror)
+ {
+ if (_glfw.wgl.ARB_create_context_no_error)
+ setAttrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
+ }
+
+ // NOTE: Only request an explicitly versioned context when necessary, as
+ // explicitly requesting version 1.0 does not always return the
+ // highest version supported by the driver
+ if (ctxconfig->major != 1 || ctxconfig->minor != 0)
+ {
+ setAttrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
+ setAttrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
+ }
+
+ if (flags)
+ setAttrib(WGL_CONTEXT_FLAGS_ARB, flags);
+
+ if (mask)
+ setAttrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
+
+ setAttrib(0, 0);
+
+ window->context.wgl.handle =
+ _glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc,
+ share, attribs);
+ if (!window->context.wgl.handle)
+ {
+ const DWORD error = GetLastError();
+
+ if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB))
+ {
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: Driver does not support OpenGL version %i.%i",
+ ctxconfig->major,
+ ctxconfig->minor);
+ }
+ else
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: Driver does not support OpenGL ES version %i.%i",
+ ctxconfig->major,
+ ctxconfig->minor);
+ }
+ }
+ else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB))
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: Driver does not support the requested OpenGL profile");
+ }
+ else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB))
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "WGL: The share context is not compatible with the requested context");
+ }
+ else
+ {
+ if (ctxconfig->client == GLFW_OPENGL_API)
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: Failed to create OpenGL context");
+ }
+ else
+ {
+ _glfwInputError(GLFW_VERSION_UNAVAILABLE,
+ "WGL: Failed to create OpenGL ES context");
+ }
+ }
+
+ return GLFW_FALSE;
+ }
+ }
+ else
+ {
+ window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
+ if (!window->context.wgl.handle)
+ {
+ _glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
+ "WGL: Failed to create OpenGL context");
+ return GLFW_FALSE;
+ }
+
+ if (share)
+ {
+ if (!wglShareLists(share, window->context.wgl.handle))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "WGL: Failed to enable sharing with specified OpenGL context");
+ return GLFW_FALSE;
+ }
+ }
+ }
+
+ window->context.makeCurrent = makeContextCurrentWGL;
+ window->context.swapBuffers = swapBuffersWGL;
+ window->context.swapInterval = swapIntervalWGL;
+ window->context.extensionSupported = extensionSupportedWGL;
+ window->context.getProcAddress = getProcAddressWGL;
+ window->context.destroy = destroyContextWGL;
+
+ return GLFW_TRUE;
+}
+
+#undef setAttrib
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (window->context.client == GLFW_NO_API)
+ {
+ _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
+ return NULL;
+ }
+
+ return window->context.wgl.handle;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.h b/Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.h
new file mode 100644
index 0000000..c754038
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/wgl_context.h
@@ -0,0 +1,159 @@
+//========================================================================
+// GLFW 3.3 WGL - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
+#define WGL_SUPPORT_OPENGL_ARB 0x2010
+#define WGL_DRAW_TO_WINDOW_ARB 0x2001
+#define WGL_PIXEL_TYPE_ARB 0x2013
+#define WGL_TYPE_RGBA_ARB 0x202b
+#define WGL_ACCELERATION_ARB 0x2003
+#define WGL_NO_ACCELERATION_ARB 0x2025
+#define WGL_RED_BITS_ARB 0x2015
+#define WGL_RED_SHIFT_ARB 0x2016
+#define WGL_GREEN_BITS_ARB 0x2017
+#define WGL_GREEN_SHIFT_ARB 0x2018
+#define WGL_BLUE_BITS_ARB 0x2019
+#define WGL_BLUE_SHIFT_ARB 0x201a
+#define WGL_ALPHA_BITS_ARB 0x201b
+#define WGL_ALPHA_SHIFT_ARB 0x201c
+#define WGL_ACCUM_BITS_ARB 0x201d
+#define WGL_ACCUM_RED_BITS_ARB 0x201e
+#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
+#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
+#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
+#define WGL_DEPTH_BITS_ARB 0x2022
+#define WGL_STENCIL_BITS_ARB 0x2023
+#define WGL_AUX_BUFFERS_ARB 0x2024
+#define WGL_STEREO_ARB 0x2012
+#define WGL_DOUBLE_BUFFER_ARB 0x2011
+#define WGL_SAMPLES_ARB 0x2042
+#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
+#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
+#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
+#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
+#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
+#define WGL_CONTEXT_FLAGS_ARB 0x2094
+#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
+#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
+#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
+#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
+#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
+#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
+#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
+#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
+#define WGL_COLORSPACE_EXT 0x309d
+#define WGL_COLORSPACE_SRGB_EXT 0x3089
+
+#define ERROR_INVALID_VERSION_ARB 0x2095
+#define ERROR_INVALID_PROFILE_ARB 0x2096
+#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
+
+typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
+typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
+typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
+typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
+
+typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
+typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
+typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
+typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
+typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
+typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
+typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
+
+// opengl32.dll function pointer typedefs
+#define wglCreateContext _glfw.wgl.CreateContext
+#define wglDeleteContext _glfw.wgl.DeleteContext
+#define wglGetProcAddress _glfw.wgl.GetProcAddress
+#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
+#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
+#define wglMakeCurrent _glfw.wgl.MakeCurrent
+#define wglShareLists _glfw.wgl.ShareLists
+
+#define _GLFW_RECREATION_NOT_NEEDED 0
+#define _GLFW_RECREATION_REQUIRED 1
+#define _GLFW_RECREATION_IMPOSSIBLE 2
+
+#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl
+#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl
+
+
+// WGL-specific per-context data
+//
+typedef struct _GLFWcontextWGL
+{
+ HDC dc;
+ HGLRC handle;
+ int interval;
+
+} _GLFWcontextWGL;
+
+// WGL-specific global data
+//
+typedef struct _GLFWlibraryWGL
+{
+ HINSTANCE instance;
+ PFN_wglCreateContext CreateContext;
+ PFN_wglDeleteContext DeleteContext;
+ PFN_wglGetProcAddress GetProcAddress;
+ PFN_wglGetCurrentDC GetCurrentDC;
+ PFN_wglGetCurrentContext GetCurrentContext;
+ PFN_wglMakeCurrent MakeCurrent;
+ PFN_wglShareLists ShareLists;
+
+ PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
+ PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
+ PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
+ PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
+ PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
+ GLFWbool EXT_swap_control;
+ GLFWbool EXT_colorspace;
+ GLFWbool ARB_multisample;
+ GLFWbool ARB_framebuffer_sRGB;
+ GLFWbool EXT_framebuffer_sRGB;
+ GLFWbool ARB_pixel_format;
+ GLFWbool ARB_create_context;
+ GLFWbool ARB_create_context_profile;
+ GLFWbool EXT_create_context_es2_profile;
+ GLFWbool ARB_create_context_robustness;
+ GLFWbool ARB_create_context_no_error;
+ GLFWbool ARB_context_flush_control;
+
+} _GLFWlibraryWGL;
+
+
+GLFWbool _glfwInitWGL(void);
+void _glfwTerminateWGL(void);
+GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_init.c b/Client/ThirdParty/Box2D/extern/glfw/src/win32_init.c
new file mode 100644
index 0000000..3ee5eb8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_init.c
@@ -0,0 +1,627 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdlib.h>
+#include <malloc.h>
+
+static const GUID _glfw_GUID_DEVINTERFACE_HID =
+ {0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
+
+#define GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID
+
+#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
+
+// Executables (but not DLLs) exporting this symbol with this value will be
+// automatically directed to the high-performance GPU on Nvidia Optimus systems
+// with up-to-date drivers
+//
+__declspec(dllexport) DWORD NvOptimusEnablement = 1;
+
+// Executables (but not DLLs) exporting this symbol with this value will be
+// automatically directed to the high-performance GPU on AMD PowerXpress systems
+// with up-to-date drivers
+//
+__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
+
+#endif // _GLFW_USE_HYBRID_HPG
+
+#if defined(_GLFW_BUILD_DLL)
+
+// GLFW DLL entry point
+//
+BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
+{
+ return TRUE;
+}
+
+#endif // _GLFW_BUILD_DLL
+
+// Load necessary libraries (DLLs)
+//
+static GLFWbool loadLibraries(void)
+{
+ _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll");
+ if (!_glfw.win32.winmm.instance)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to load winmm.dll");
+ return GLFW_FALSE;
+ }
+
+ _glfw.win32.winmm.GetTime = (PFN_timeGetTime)
+ GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime");
+
+ _glfw.win32.user32.instance = LoadLibraryA("user32.dll");
+ if (!_glfw.win32.user32.instance)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to load user32.dll");
+ return GLFW_FALSE;
+ }
+
+ _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
+ GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
+ _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
+ GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
+ _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
+ GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
+ _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
+ GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
+ _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
+ GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow");
+ _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
+ GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
+
+ _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll");
+ if (_glfw.win32.dinput8.instance)
+ {
+ _glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
+ GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create");
+ }
+
+ {
+ int i;
+ const char* names[] =
+ {
+ "xinput1_4.dll",
+ "xinput1_3.dll",
+ "xinput9_1_0.dll",
+ "xinput1_2.dll",
+ "xinput1_1.dll",
+ NULL
+ };
+
+ for (i = 0; names[i]; i++)
+ {
+ _glfw.win32.xinput.instance = LoadLibraryA(names[i]);
+ if (_glfw.win32.xinput.instance)
+ {
+ _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
+ GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities");
+ _glfw.win32.xinput.GetState = (PFN_XInputGetState)
+ GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState");
+
+ break;
+ }
+ }
+ }
+
+ _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll");
+ if (_glfw.win32.dwmapi.instance)
+ {
+ _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
+ GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
+ _glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
+ GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
+ _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
+ GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
+ }
+
+ _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll");
+ if (_glfw.win32.shcore.instance)
+ {
+ _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
+ GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
+ _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
+ GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor");
+ }
+
+ _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll");
+ if (_glfw.win32.ntdll.instance)
+ {
+ _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
+ GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
+ }
+
+ return GLFW_TRUE;
+}
+
+// Unload used libraries (DLLs)
+//
+static void freeLibraries(void)
+{
+ if (_glfw.win32.xinput.instance)
+ FreeLibrary(_glfw.win32.xinput.instance);
+
+ if (_glfw.win32.dinput8.instance)
+ FreeLibrary(_glfw.win32.dinput8.instance);
+
+ if (_glfw.win32.winmm.instance)
+ FreeLibrary(_glfw.win32.winmm.instance);
+
+ if (_glfw.win32.user32.instance)
+ FreeLibrary(_glfw.win32.user32.instance);
+
+ if (_glfw.win32.dwmapi.instance)
+ FreeLibrary(_glfw.win32.dwmapi.instance);
+
+ if (_glfw.win32.shcore.instance)
+ FreeLibrary(_glfw.win32.shcore.instance);
+
+ if (_glfw.win32.ntdll.instance)
+ FreeLibrary(_glfw.win32.ntdll.instance);
+}
+
+// Create key code translation tables
+//
+static void createKeyTables(void)
+{
+ int scancode;
+
+ memset(_glfw.win32.keycodes, -1, sizeof(_glfw.win32.keycodes));
+ memset(_glfw.win32.scancodes, -1, sizeof(_glfw.win32.scancodes));
+
+ _glfw.win32.keycodes[0x00B] = GLFW_KEY_0;
+ _glfw.win32.keycodes[0x002] = GLFW_KEY_1;
+ _glfw.win32.keycodes[0x003] = GLFW_KEY_2;
+ _glfw.win32.keycodes[0x004] = GLFW_KEY_3;
+ _glfw.win32.keycodes[0x005] = GLFW_KEY_4;
+ _glfw.win32.keycodes[0x006] = GLFW_KEY_5;
+ _glfw.win32.keycodes[0x007] = GLFW_KEY_6;
+ _glfw.win32.keycodes[0x008] = GLFW_KEY_7;
+ _glfw.win32.keycodes[0x009] = GLFW_KEY_8;
+ _glfw.win32.keycodes[0x00A] = GLFW_KEY_9;
+ _glfw.win32.keycodes[0x01E] = GLFW_KEY_A;
+ _glfw.win32.keycodes[0x030] = GLFW_KEY_B;
+ _glfw.win32.keycodes[0x02E] = GLFW_KEY_C;
+ _glfw.win32.keycodes[0x020] = GLFW_KEY_D;
+ _glfw.win32.keycodes[0x012] = GLFW_KEY_E;
+ _glfw.win32.keycodes[0x021] = GLFW_KEY_F;
+ _glfw.win32.keycodes[0x022] = GLFW_KEY_G;
+ _glfw.win32.keycodes[0x023] = GLFW_KEY_H;
+ _glfw.win32.keycodes[0x017] = GLFW_KEY_I;
+ _glfw.win32.keycodes[0x024] = GLFW_KEY_J;
+ _glfw.win32.keycodes[0x025] = GLFW_KEY_K;
+ _glfw.win32.keycodes[0x026] = GLFW_KEY_L;
+ _glfw.win32.keycodes[0x032] = GLFW_KEY_M;
+ _glfw.win32.keycodes[0x031] = GLFW_KEY_N;
+ _glfw.win32.keycodes[0x018] = GLFW_KEY_O;
+ _glfw.win32.keycodes[0x019] = GLFW_KEY_P;
+ _glfw.win32.keycodes[0x010] = GLFW_KEY_Q;
+ _glfw.win32.keycodes[0x013] = GLFW_KEY_R;
+ _glfw.win32.keycodes[0x01F] = GLFW_KEY_S;
+ _glfw.win32.keycodes[0x014] = GLFW_KEY_T;
+ _glfw.win32.keycodes[0x016] = GLFW_KEY_U;
+ _glfw.win32.keycodes[0x02F] = GLFW_KEY_V;
+ _glfw.win32.keycodes[0x011] = GLFW_KEY_W;
+ _glfw.win32.keycodes[0x02D] = GLFW_KEY_X;
+ _glfw.win32.keycodes[0x015] = GLFW_KEY_Y;
+ _glfw.win32.keycodes[0x02C] = GLFW_KEY_Z;
+
+ _glfw.win32.keycodes[0x028] = GLFW_KEY_APOSTROPHE;
+ _glfw.win32.keycodes[0x02B] = GLFW_KEY_BACKSLASH;
+ _glfw.win32.keycodes[0x033] = GLFW_KEY_COMMA;
+ _glfw.win32.keycodes[0x00D] = GLFW_KEY_EQUAL;
+ _glfw.win32.keycodes[0x029] = GLFW_KEY_GRAVE_ACCENT;
+ _glfw.win32.keycodes[0x01A] = GLFW_KEY_LEFT_BRACKET;
+ _glfw.win32.keycodes[0x00C] = GLFW_KEY_MINUS;
+ _glfw.win32.keycodes[0x034] = GLFW_KEY_PERIOD;
+ _glfw.win32.keycodes[0x01B] = GLFW_KEY_RIGHT_BRACKET;
+ _glfw.win32.keycodes[0x027] = GLFW_KEY_SEMICOLON;
+ _glfw.win32.keycodes[0x035] = GLFW_KEY_SLASH;
+ _glfw.win32.keycodes[0x056] = GLFW_KEY_WORLD_2;
+
+ _glfw.win32.keycodes[0x00E] = GLFW_KEY_BACKSPACE;
+ _glfw.win32.keycodes[0x153] = GLFW_KEY_DELETE;
+ _glfw.win32.keycodes[0x14F] = GLFW_KEY_END;
+ _glfw.win32.keycodes[0x01C] = GLFW_KEY_ENTER;
+ _glfw.win32.keycodes[0x001] = GLFW_KEY_ESCAPE;
+ _glfw.win32.keycodes[0x147] = GLFW_KEY_HOME;
+ _glfw.win32.keycodes[0x152] = GLFW_KEY_INSERT;
+ _glfw.win32.keycodes[0x15D] = GLFW_KEY_MENU;
+ _glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
+ _glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
+ _glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
+ _glfw.win32.keycodes[0x146] = GLFW_KEY_PAUSE;
+ _glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
+ _glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
+ _glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
+ _glfw.win32.keycodes[0x145] = GLFW_KEY_NUM_LOCK;
+ _glfw.win32.keycodes[0x046] = GLFW_KEY_SCROLL_LOCK;
+ _glfw.win32.keycodes[0x03B] = GLFW_KEY_F1;
+ _glfw.win32.keycodes[0x03C] = GLFW_KEY_F2;
+ _glfw.win32.keycodes[0x03D] = GLFW_KEY_F3;
+ _glfw.win32.keycodes[0x03E] = GLFW_KEY_F4;
+ _glfw.win32.keycodes[0x03F] = GLFW_KEY_F5;
+ _glfw.win32.keycodes[0x040] = GLFW_KEY_F6;
+ _glfw.win32.keycodes[0x041] = GLFW_KEY_F7;
+ _glfw.win32.keycodes[0x042] = GLFW_KEY_F8;
+ _glfw.win32.keycodes[0x043] = GLFW_KEY_F9;
+ _glfw.win32.keycodes[0x044] = GLFW_KEY_F10;
+ _glfw.win32.keycodes[0x057] = GLFW_KEY_F11;
+ _glfw.win32.keycodes[0x058] = GLFW_KEY_F12;
+ _glfw.win32.keycodes[0x064] = GLFW_KEY_F13;
+ _glfw.win32.keycodes[0x065] = GLFW_KEY_F14;
+ _glfw.win32.keycodes[0x066] = GLFW_KEY_F15;
+ _glfw.win32.keycodes[0x067] = GLFW_KEY_F16;
+ _glfw.win32.keycodes[0x068] = GLFW_KEY_F17;
+ _glfw.win32.keycodes[0x069] = GLFW_KEY_F18;
+ _glfw.win32.keycodes[0x06A] = GLFW_KEY_F19;
+ _glfw.win32.keycodes[0x06B] = GLFW_KEY_F20;
+ _glfw.win32.keycodes[0x06C] = GLFW_KEY_F21;
+ _glfw.win32.keycodes[0x06D] = GLFW_KEY_F22;
+ _glfw.win32.keycodes[0x06E] = GLFW_KEY_F23;
+ _glfw.win32.keycodes[0x076] = GLFW_KEY_F24;
+ _glfw.win32.keycodes[0x038] = GLFW_KEY_LEFT_ALT;
+ _glfw.win32.keycodes[0x01D] = GLFW_KEY_LEFT_CONTROL;
+ _glfw.win32.keycodes[0x02A] = GLFW_KEY_LEFT_SHIFT;
+ _glfw.win32.keycodes[0x15B] = GLFW_KEY_LEFT_SUPER;
+ _glfw.win32.keycodes[0x137] = GLFW_KEY_PRINT_SCREEN;
+ _glfw.win32.keycodes[0x138] = GLFW_KEY_RIGHT_ALT;
+ _glfw.win32.keycodes[0x11D] = GLFW_KEY_RIGHT_CONTROL;
+ _glfw.win32.keycodes[0x036] = GLFW_KEY_RIGHT_SHIFT;
+ _glfw.win32.keycodes[0x15C] = GLFW_KEY_RIGHT_SUPER;
+ _glfw.win32.keycodes[0x150] = GLFW_KEY_DOWN;
+ _glfw.win32.keycodes[0x14B] = GLFW_KEY_LEFT;
+ _glfw.win32.keycodes[0x14D] = GLFW_KEY_RIGHT;
+ _glfw.win32.keycodes[0x148] = GLFW_KEY_UP;
+
+ _glfw.win32.keycodes[0x052] = GLFW_KEY_KP_0;
+ _glfw.win32.keycodes[0x04F] = GLFW_KEY_KP_1;
+ _glfw.win32.keycodes[0x050] = GLFW_KEY_KP_2;
+ _glfw.win32.keycodes[0x051] = GLFW_KEY_KP_3;
+ _glfw.win32.keycodes[0x04B] = GLFW_KEY_KP_4;
+ _glfw.win32.keycodes[0x04C] = GLFW_KEY_KP_5;
+ _glfw.win32.keycodes[0x04D] = GLFW_KEY_KP_6;
+ _glfw.win32.keycodes[0x047] = GLFW_KEY_KP_7;
+ _glfw.win32.keycodes[0x048] = GLFW_KEY_KP_8;
+ _glfw.win32.keycodes[0x049] = GLFW_KEY_KP_9;
+ _glfw.win32.keycodes[0x04E] = GLFW_KEY_KP_ADD;
+ _glfw.win32.keycodes[0x053] = GLFW_KEY_KP_DECIMAL;
+ _glfw.win32.keycodes[0x135] = GLFW_KEY_KP_DIVIDE;
+ _glfw.win32.keycodes[0x11C] = GLFW_KEY_KP_ENTER;
+ _glfw.win32.keycodes[0x059] = GLFW_KEY_KP_EQUAL;
+ _glfw.win32.keycodes[0x037] = GLFW_KEY_KP_MULTIPLY;
+ _glfw.win32.keycodes[0x04A] = GLFW_KEY_KP_SUBTRACT;
+
+ for (scancode = 0; scancode < 512; scancode++)
+ {
+ if (_glfw.win32.keycodes[scancode] > 0)
+ _glfw.win32.scancodes[_glfw.win32.keycodes[scancode]] = scancode;
+ }
+}
+
+// Creates a dummy window for behind-the-scenes work
+//
+static HWND createHelperWindow(void)
+{
+ MSG msg;
+ HWND window = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
+ _GLFW_WNDCLASSNAME,
+ L"GLFW message window",
+ WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ 0, 0, 1, 1,
+ NULL, NULL,
+ GetModuleHandleW(NULL),
+ NULL);
+ if (!window)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create helper window");
+ return NULL;
+ }
+
+ // HACK: The command to the first ShowWindow call is ignored if the parent
+ // process passed along a STARTUPINFO, so clear that with a no-op call
+ ShowWindow(window, SW_HIDE);
+
+ // Register for HID device notifications
+ {
+ DEV_BROADCAST_DEVICEINTERFACE_W dbi;
+ ZeroMemory(&dbi, sizeof(dbi));
+ dbi.dbcc_size = sizeof(dbi);
+ dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
+ dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
+
+ _glfw.win32.deviceNotificationHandle =
+ RegisterDeviceNotificationW(window,
+ (DEV_BROADCAST_HDR*) &dbi,
+ DEVICE_NOTIFY_WINDOW_HANDLE);
+ }
+
+ while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+
+ return window;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Returns a wide string version of the specified UTF-8 string
+//
+WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
+{
+ WCHAR* target;
+ int count;
+
+ count = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
+ if (!count)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to convert string from UTF-8");
+ return NULL;
+ }
+
+ target = calloc(count, sizeof(WCHAR));
+
+ if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to convert string from UTF-8");
+ free(target);
+ return NULL;
+ }
+
+ return target;
+}
+
+// Returns a UTF-8 string version of the specified wide string
+//
+char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
+{
+ char* target;
+ int size;
+
+ size = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
+ if (!size)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to convert string to UTF-8");
+ return NULL;
+ }
+
+ target = calloc(size, 1);
+
+ if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to convert string to UTF-8");
+ free(target);
+ return NULL;
+ }
+
+ return target;
+}
+
+// Reports the specified error, appending information about the last Win32 error
+//
+void _glfwInputErrorWin32(int error, const char* description)
+{
+ WCHAR buffer[_GLFW_MESSAGE_SIZE] = L"";
+ char message[_GLFW_MESSAGE_SIZE] = "";
+
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS |
+ FORMAT_MESSAGE_MAX_WIDTH_MASK,
+ NULL,
+ GetLastError() & 0xffff,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ buffer,
+ sizeof(buffer),
+ NULL);
+ WideCharToMultiByte(CP_UTF8, 0, buffer, -1, message, sizeof(message), NULL, NULL);
+
+ _glfwInputError(error, "%s: %s", description, message);
+}
+
+// Updates key names according to the current keyboard layout
+//
+void _glfwUpdateKeyNamesWin32(void)
+{
+ int key;
+ BYTE state[256] = {0};
+
+ memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames));
+
+ for (key = GLFW_KEY_SPACE; key <= GLFW_KEY_LAST; key++)
+ {
+ UINT vk;
+ int scancode, length;
+ WCHAR chars[16];
+
+ scancode = _glfw.win32.scancodes[key];
+ if (scancode == -1)
+ continue;
+
+ if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD)
+ {
+ const UINT vks[] = {
+ VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
+ VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
+ VK_NUMPAD8, VK_NUMPAD9, VK_DECIMAL, VK_DIVIDE,
+ VK_MULTIPLY, VK_SUBTRACT, VK_ADD
+ };
+
+ vk = vks[key - GLFW_KEY_KP_0];
+ }
+ else
+ vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
+
+ length = ToUnicode(vk, scancode, state,
+ chars, sizeof(chars) / sizeof(WCHAR),
+ 0);
+
+ if (length == -1)
+ {
+ length = ToUnicode(vk, scancode, state,
+ chars, sizeof(chars) / sizeof(WCHAR),
+ 0);
+ }
+
+ if (length < 1)
+ continue;
+
+ WideCharToMultiByte(CP_UTF8, 0, chars, 1,
+ _glfw.win32.keynames[key],
+ sizeof(_glfw.win32.keynames[key]),
+ NULL, NULL);
+ }
+}
+
+// Replacement for IsWindowsVersionOrGreater as MinGW lacks versionhelpers.h
+//
+BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
+{
+ OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, {0}, sp };
+ DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
+ ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
+ cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
+ // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
+ // latter lies unless the user knew to embedd a non-default manifest
+ // announcing support for Windows 10 via supportedOS GUID
+ return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
+}
+
+// Checks whether we are on at least the specified build of Windows 10
+//
+BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
+{
+ OSVERSIONINFOEXW osvi = { sizeof(osvi), 10, 0, build };
+ DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER;
+ ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
+ cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
+ // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
+ // latter lies unless the user knew to embedd a non-default manifest
+ // announcing support for Windows 10 via supportedOS GUID
+ return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformInit(void)
+{
+ // To make SetForegroundWindow work as we want, we need to fiddle
+ // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
+ // as possible in the hope of still being the foreground process)
+ SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
+ &_glfw.win32.foregroundLockTimeout, 0);
+ SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
+ SPIF_SENDCHANGE);
+
+ if (!loadLibraries())
+ return GLFW_FALSE;
+
+ createKeyTables();
+ _glfwUpdateKeyNamesWin32();
+
+ if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
+ SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
+ else if (IsWindows8Point1OrGreater())
+ SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
+ else if (IsWindowsVistaOrGreater())
+ SetProcessDPIAware();
+
+ if (!_glfwRegisterWindowClassWin32())
+ return GLFW_FALSE;
+
+ _glfw.win32.helperWindowHandle = createHelperWindow();
+ if (!_glfw.win32.helperWindowHandle)
+ return GLFW_FALSE;
+
+ _glfwInitTimerWin32();
+ _glfwInitJoysticksWin32();
+
+ _glfwPollMonitorsWin32();
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformTerminate(void)
+{
+ if (_glfw.win32.deviceNotificationHandle)
+ UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
+
+ if (_glfw.win32.helperWindowHandle)
+ DestroyWindow(_glfw.win32.helperWindowHandle);
+
+ _glfwUnregisterWindowClassWin32();
+
+ // Restore previous foreground lock timeout system setting
+ SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
+ UIntToPtr(_glfw.win32.foregroundLockTimeout),
+ SPIF_SENDCHANGE);
+
+ free(_glfw.win32.clipboardString);
+ free(_glfw.win32.rawInput);
+
+ _glfwTerminateWGL();
+ _glfwTerminateEGL();
+
+ _glfwTerminateJoysticksWin32();
+
+ freeLibraries();
+}
+
+const char* _glfwPlatformGetVersionString(void)
+{
+ return _GLFW_VERSION_NUMBER " Win32 WGL EGL"
+#if defined(__MINGW32__)
+ " MinGW"
+#elif defined(_MSC_VER)
+ " VisualC"
+#endif
+#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
+ " hybrid-GPU"
+#endif
+#if defined(_GLFW_BUILD_DLL)
+ " DLL"
+#endif
+ ;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.c b/Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.c
new file mode 100644
index 0000000..5812396
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.c
@@ -0,0 +1,753 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdio.h>
+#include <math.h>
+
+#define _GLFW_TYPE_AXIS 0
+#define _GLFW_TYPE_SLIDER 1
+#define _GLFW_TYPE_BUTTON 2
+#define _GLFW_TYPE_POV 3
+
+// Data produced with DirectInput device object enumeration
+//
+typedef struct _GLFWobjenumWin32
+{
+ IDirectInputDevice8W* device;
+ _GLFWjoyobjectWin32* objects;
+ int objectCount;
+ int axisCount;
+ int sliderCount;
+ int buttonCount;
+ int povCount;
+} _GLFWobjenumWin32;
+
+// Define local copies of the necessary GUIDs
+//
+static const GUID _glfw_IID_IDirectInput8W =
+ {0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
+static const GUID _glfw_GUID_XAxis =
+ {0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_YAxis =
+ {0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_ZAxis =
+ {0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_RxAxis =
+ {0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_RyAxis =
+ {0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_RzAxis =
+ {0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_Slider =
+ {0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+static const GUID _glfw_GUID_POV =
+ {0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
+
+#define IID_IDirectInput8W _glfw_IID_IDirectInput8W
+#define GUID_XAxis _glfw_GUID_XAxis
+#define GUID_YAxis _glfw_GUID_YAxis
+#define GUID_ZAxis _glfw_GUID_ZAxis
+#define GUID_RxAxis _glfw_GUID_RxAxis
+#define GUID_RyAxis _glfw_GUID_RyAxis
+#define GUID_RzAxis _glfw_GUID_RzAxis
+#define GUID_Slider _glfw_GUID_Slider
+#define GUID_POV _glfw_GUID_POV
+
+// Object data array for our clone of c_dfDIJoystick
+// Generated with https://github.com/elmindreda/c_dfDIJoystick2
+//
+static DIOBJECTDATAFORMAT _glfwObjectDataFormats[] =
+{
+ { &GUID_XAxis,DIJOFS_X,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_YAxis,DIJOFS_Y,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_ZAxis,DIJOFS_Z,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_RxAxis,DIJOFS_RX,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_RyAxis,DIJOFS_RY,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_RzAxis,DIJOFS_RZ,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
+ { &GUID_POV,DIJOFS_POV(0),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { &GUID_POV,DIJOFS_POV(1),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { &GUID_POV,DIJOFS_POV(2),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { &GUID_POV,DIJOFS_POV(3),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(0),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(1),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(2),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(3),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(4),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(5),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(6),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(7),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(8),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(9),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(10),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(11),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(12),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(13),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(14),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(15),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(16),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(17),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(18),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(19),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(20),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(21),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(22),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(23),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(24),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(25),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(26),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(27),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(28),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(29),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(30),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+ { NULL,DIJOFS_BUTTON(31),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
+};
+
+// Our clone of c_dfDIJoystick
+//
+static const DIDATAFORMAT _glfwDataFormat =
+{
+ sizeof(DIDATAFORMAT),
+ sizeof(DIOBJECTDATAFORMAT),
+ DIDFT_ABSAXIS,
+ sizeof(DIJOYSTATE),
+ sizeof(_glfwObjectDataFormats) / sizeof(DIOBJECTDATAFORMAT),
+ _glfwObjectDataFormats
+};
+
+// Returns a description fitting the specified XInput capabilities
+//
+static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
+{
+ switch (xic->SubType)
+ {
+ case XINPUT_DEVSUBTYPE_WHEEL:
+ return "XInput Wheel";
+ case XINPUT_DEVSUBTYPE_ARCADE_STICK:
+ return "XInput Arcade Stick";
+ case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
+ return "XInput Flight Stick";
+ case XINPUT_DEVSUBTYPE_DANCE_PAD:
+ return "XInput Dance Pad";
+ case XINPUT_DEVSUBTYPE_GUITAR:
+ return "XInput Guitar";
+ case XINPUT_DEVSUBTYPE_DRUM_KIT:
+ return "XInput Drum Kit";
+ case XINPUT_DEVSUBTYPE_GAMEPAD:
+ {
+ if (xic->Flags & XINPUT_CAPS_WIRELESS)
+ return "Wireless Xbox Controller";
+ else
+ return "Xbox Controller";
+ }
+ }
+
+ return "Unknown XInput Device";
+}
+
+// Lexically compare device objects
+//
+static int compareJoystickObjects(const void* first, const void* second)
+{
+ const _GLFWjoyobjectWin32* fo = first;
+ const _GLFWjoyobjectWin32* so = second;
+
+ if (fo->type != so->type)
+ return fo->type - so->type;
+
+ return fo->offset - so->offset;
+}
+
+// Checks whether the specified device supports XInput
+// Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom
+//
+static GLFWbool supportsXInput(const GUID* guid)
+{
+ UINT i, count = 0;
+ RAWINPUTDEVICELIST* ridl;
+ GLFWbool result = GLFW_FALSE;
+
+ if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
+ return GLFW_FALSE;
+
+ ridl = calloc(count, sizeof(RAWINPUTDEVICELIST));
+
+ if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
+ {
+ free(ridl);
+ return GLFW_FALSE;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ RID_DEVICE_INFO rdi;
+ char name[256];
+ UINT size;
+
+ if (ridl[i].dwType != RIM_TYPEHID)
+ continue;
+
+ ZeroMemory(&rdi, sizeof(rdi));
+ rdi.cbSize = sizeof(rdi);
+ size = sizeof(rdi);
+
+ if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
+ RIDI_DEVICEINFO,
+ &rdi, &size) == -1)
+ {
+ continue;
+ }
+
+ if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
+ continue;
+
+ memset(name, 0, sizeof(name));
+ size = sizeof(name);
+
+ if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
+ RIDI_DEVICENAME,
+ name, &size) == -1)
+ {
+ break;
+ }
+
+ name[sizeof(name) - 1] = '\0';
+ if (strstr(name, "IG_"))
+ {
+ result = GLFW_TRUE;
+ break;
+ }
+ }
+
+ free(ridl);
+ return result;
+}
+
+// Frees all resources associated with the specified joystick
+//
+static void closeJoystick(_GLFWjoystick* js)
+{
+ if (js->win32.device)
+ {
+ IDirectInputDevice8_Unacquire(js->win32.device);
+ IDirectInputDevice8_Release(js->win32.device);
+ }
+
+ free(js->win32.objects);
+
+ _glfwFreeJoystick(js);
+ _glfwInputJoystick(js, GLFW_DISCONNECTED);
+}
+
+// DirectInput device object enumeration callback
+// Insights gleaned from SDL
+//
+static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
+ void* user)
+{
+ _GLFWobjenumWin32* data = user;
+ _GLFWjoyobjectWin32* object = data->objects + data->objectCount;
+
+ if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
+ {
+ DIPROPRANGE dipr;
+
+ if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_SLIDER(data->sliderCount);
+ else if (memcmp(&doi->guidType, &GUID_XAxis, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_X;
+ else if (memcmp(&doi->guidType, &GUID_YAxis, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_Y;
+ else if (memcmp(&doi->guidType, &GUID_ZAxis, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_Z;
+ else if (memcmp(&doi->guidType, &GUID_RxAxis, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_RX;
+ else if (memcmp(&doi->guidType, &GUID_RyAxis, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_RY;
+ else if (memcmp(&doi->guidType, &GUID_RzAxis, sizeof(GUID)) == 0)
+ object->offset = DIJOFS_RZ;
+ else
+ return DIENUM_CONTINUE;
+
+ ZeroMemory(&dipr, sizeof(dipr));
+ dipr.diph.dwSize = sizeof(dipr);
+ dipr.diph.dwHeaderSize = sizeof(dipr.diph);
+ dipr.diph.dwObj = doi->dwType;
+ dipr.diph.dwHow = DIPH_BYID;
+ dipr.lMin = -32768;
+ dipr.lMax = 32767;
+
+ if (FAILED(IDirectInputDevice8_SetProperty(data->device,
+ DIPROP_RANGE,
+ &dipr.diph)))
+ {
+ return DIENUM_CONTINUE;
+ }
+
+ if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
+ {
+ object->type = _GLFW_TYPE_SLIDER;
+ data->sliderCount++;
+ }
+ else
+ {
+ object->type = _GLFW_TYPE_AXIS;
+ data->axisCount++;
+ }
+ }
+ else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_BUTTON)
+ {
+ object->offset = DIJOFS_BUTTON(data->buttonCount);
+ object->type = _GLFW_TYPE_BUTTON;
+ data->buttonCount++;
+ }
+ else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_POV)
+ {
+ object->offset = DIJOFS_POV(data->povCount);
+ object->type = _GLFW_TYPE_POV;
+ data->povCount++;
+ }
+
+ data->objectCount++;
+ return DIENUM_CONTINUE;
+}
+
+// DirectInput device enumeration callback
+//
+static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
+{
+ int jid = 0;
+ DIDEVCAPS dc;
+ DIPROPDWORD dipd;
+ IDirectInputDevice8* device;
+ _GLFWobjenumWin32 data;
+ _GLFWjoystick* js;
+ char guid[33];
+ char name[256];
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ _GLFWjoystick* js = _glfw.joysticks + jid;
+ if (js->present)
+ {
+ if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
+ return DIENUM_CONTINUE;
+ }
+ }
+
+ if (supportsXInput(&di->guidProduct))
+ return DIENUM_CONTINUE;
+
+ if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api,
+ &di->guidInstance,
+ &device,
+ NULL)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create device");
+ return DIENUM_CONTINUE;
+ }
+
+ if (FAILED(IDirectInputDevice8_SetDataFormat(device, &_glfwDataFormat)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to set device data format");
+
+ IDirectInputDevice8_Release(device);
+ return DIENUM_CONTINUE;
+ }
+
+ ZeroMemory(&dc, sizeof(dc));
+ dc.dwSize = sizeof(dc);
+
+ if (FAILED(IDirectInputDevice8_GetCapabilities(device, &dc)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to query device capabilities");
+
+ IDirectInputDevice8_Release(device);
+ return DIENUM_CONTINUE;
+ }
+
+ ZeroMemory(&dipd, sizeof(dipd));
+ dipd.diph.dwSize = sizeof(dipd);
+ dipd.diph.dwHeaderSize = sizeof(dipd.diph);
+ dipd.diph.dwHow = DIPH_DEVICE;
+ dipd.dwData = DIPROPAXISMODE_ABS;
+
+ if (FAILED(IDirectInputDevice8_SetProperty(device,
+ DIPROP_AXISMODE,
+ &dipd.diph)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to set device axis mode");
+
+ IDirectInputDevice8_Release(device);
+ return DIENUM_CONTINUE;
+ }
+
+ memset(&data, 0, sizeof(data));
+ data.device = device;
+ data.objects = calloc(dc.dwAxes + dc.dwButtons + dc.dwPOVs,
+ sizeof(_GLFWjoyobjectWin32));
+
+ if (FAILED(IDirectInputDevice8_EnumObjects(device,
+ deviceObjectCallback,
+ &data,
+ DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to enumerate device objects");
+
+ IDirectInputDevice8_Release(device);
+ free(data.objects);
+ return DIENUM_CONTINUE;
+ }
+
+ qsort(data.objects, data.objectCount,
+ sizeof(_GLFWjoyobjectWin32),
+ compareJoystickObjects);
+
+ if (!WideCharToMultiByte(CP_UTF8, 0,
+ di->tszInstanceName, -1,
+ name, sizeof(name),
+ NULL, NULL))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to convert joystick name to UTF-8");
+
+ IDirectInputDevice8_Release(device);
+ free(data.objects);
+ return DIENUM_STOP;
+ }
+
+ // Generate a joystick GUID that matches the SDL 2.0.5+ one
+ if (memcmp(&di->guidProduct.Data4[2], "PIDVID", 6) == 0)
+ {
+ sprintf(guid, "03000000%02x%02x0000%02x%02x000000000000",
+ (uint8_t) di->guidProduct.Data1,
+ (uint8_t) (di->guidProduct.Data1 >> 8),
+ (uint8_t) (di->guidProduct.Data1 >> 16),
+ (uint8_t) (di->guidProduct.Data1 >> 24));
+ }
+ else
+ {
+ sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
+ name[0], name[1], name[2], name[3],
+ name[4], name[5], name[6], name[7],
+ name[8], name[9], name[10]);
+ }
+
+ js = _glfwAllocJoystick(name, guid,
+ data.axisCount + data.sliderCount,
+ data.buttonCount,
+ data.povCount);
+ if (!js)
+ {
+ IDirectInputDevice8_Release(device);
+ free(data.objects);
+ return DIENUM_STOP;
+ }
+
+ js->win32.device = device;
+ js->win32.guid = di->guidInstance;
+ js->win32.objects = data.objects;
+ js->win32.objectCount = data.objectCount;
+
+ _glfwInputJoystick(js, GLFW_CONNECTED);
+ return DIENUM_CONTINUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialize joystick interface
+//
+void _glfwInitJoysticksWin32(void)
+{
+ if (_glfw.win32.dinput8.instance)
+ {
+ if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
+ DIRECTINPUT_VERSION,
+ &IID_IDirectInput8W,
+ (void**) &_glfw.win32.dinput8.api,
+ NULL)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create interface");
+ }
+ }
+
+ _glfwDetectJoystickConnectionWin32();
+}
+
+// Close all opened joystick handles
+//
+void _glfwTerminateJoysticksWin32(void)
+{
+ int jid;
+
+ for (jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
+ closeJoystick(_glfw.joysticks + jid);
+
+ if (_glfw.win32.dinput8.api)
+ IDirectInput8_Release(_glfw.win32.dinput8.api);
+}
+
+// Checks for new joysticks after DBT_DEVICEARRIVAL
+//
+void _glfwDetectJoystickConnectionWin32(void)
+{
+ if (_glfw.win32.xinput.instance)
+ {
+ DWORD index;
+
+ for (index = 0; index < XUSER_MAX_COUNT; index++)
+ {
+ int jid;
+ char guid[33];
+ XINPUT_CAPABILITIES xic;
+ _GLFWjoystick* js;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ if (_glfw.joysticks[jid].present &&
+ _glfw.joysticks[jid].win32.device == NULL &&
+ _glfw.joysticks[jid].win32.index == index)
+ {
+ break;
+ }
+ }
+
+ if (jid <= GLFW_JOYSTICK_LAST)
+ continue;
+
+ if (XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
+ continue;
+
+ // Generate a joystick GUID that matches the SDL 2.0.5+ one
+ sprintf(guid, "78696e707574%02x000000000000000000",
+ xic.SubType & 0xff);
+
+ js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1);
+ if (!js)
+ continue;
+
+ js->win32.index = index;
+
+ _glfwInputJoystick(js, GLFW_CONNECTED);
+ }
+ }
+
+ if (_glfw.win32.dinput8.api)
+ {
+ if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api,
+ DI8DEVCLASS_GAMECTRL,
+ deviceCallback,
+ NULL,
+ DIEDFL_ALLDEVICES)))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Failed to enumerate DirectInput8 devices");
+ return;
+ }
+ }
+}
+
+// Checks for joystick disconnection after DBT_DEVICEREMOVECOMPLETE
+//
+void _glfwDetectJoystickDisconnectionWin32(void)
+{
+ int jid;
+
+ for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
+ {
+ _GLFWjoystick* js = _glfw.joysticks + jid;
+ if (js->present)
+ _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
+{
+ if (js->win32.device)
+ {
+ int i, ai = 0, bi = 0, pi = 0;
+ HRESULT result;
+ DIJOYSTATE state;
+
+ IDirectInputDevice8_Poll(js->win32.device);
+ result = IDirectInputDevice8_GetDeviceState(js->win32.device,
+ sizeof(state),
+ &state);
+ if (result == DIERR_NOTACQUIRED || result == DIERR_INPUTLOST)
+ {
+ IDirectInputDevice8_Acquire(js->win32.device);
+ IDirectInputDevice8_Poll(js->win32.device);
+ result = IDirectInputDevice8_GetDeviceState(js->win32.device,
+ sizeof(state),
+ &state);
+ }
+
+ if (FAILED(result))
+ {
+ closeJoystick(js);
+ return GLFW_FALSE;
+ }
+
+ if (mode == _GLFW_POLL_PRESENCE)
+ return GLFW_TRUE;
+
+ for (i = 0; i < js->win32.objectCount; i++)
+ {
+ const void* data = (char*) &state + js->win32.objects[i].offset;
+
+ switch (js->win32.objects[i].type)
+ {
+ case _GLFW_TYPE_AXIS:
+ case _GLFW_TYPE_SLIDER:
+ {
+ const float value = (*((LONG*) data) + 0.5f) / 32767.5f;
+ _glfwInputJoystickAxis(js, ai, value);
+ ai++;
+ break;
+ }
+
+ case _GLFW_TYPE_BUTTON:
+ {
+ const char value = (*((BYTE*) data) & 0x80) != 0;
+ _glfwInputJoystickButton(js, bi, value);
+ bi++;
+ break;
+ }
+
+ case _GLFW_TYPE_POV:
+ {
+ const int states[9] =
+ {
+ GLFW_HAT_UP,
+ GLFW_HAT_RIGHT_UP,
+ GLFW_HAT_RIGHT,
+ GLFW_HAT_RIGHT_DOWN,
+ GLFW_HAT_DOWN,
+ GLFW_HAT_LEFT_DOWN,
+ GLFW_HAT_LEFT,
+ GLFW_HAT_LEFT_UP,
+ GLFW_HAT_CENTERED
+ };
+
+ // Screams of horror are appropriate at this point
+ int state = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
+ if (state < 0 || state > 8)
+ state = 8;
+
+ _glfwInputJoystickHat(js, pi, states[state]);
+ pi++;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ int i, dpad = 0;
+ DWORD result;
+ XINPUT_STATE xis;
+ const WORD buttons[10] =
+ {
+ XINPUT_GAMEPAD_A,
+ XINPUT_GAMEPAD_B,
+ XINPUT_GAMEPAD_X,
+ XINPUT_GAMEPAD_Y,
+ XINPUT_GAMEPAD_LEFT_SHOULDER,
+ XINPUT_GAMEPAD_RIGHT_SHOULDER,
+ XINPUT_GAMEPAD_BACK,
+ XINPUT_GAMEPAD_START,
+ XINPUT_GAMEPAD_LEFT_THUMB,
+ XINPUT_GAMEPAD_RIGHT_THUMB
+ };
+
+ result = XInputGetState(js->win32.index, &xis);
+ if (result != ERROR_SUCCESS)
+ {
+ if (result == ERROR_DEVICE_NOT_CONNECTED)
+ closeJoystick(js);
+
+ return GLFW_FALSE;
+ }
+
+ if (mode == _GLFW_POLL_PRESENCE)
+ return GLFW_TRUE;
+
+ _glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.5f);
+ _glfwInputJoystickAxis(js, 1, -(xis.Gamepad.sThumbLY + 0.5f) / 32767.5f);
+ _glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.5f);
+ _glfwInputJoystickAxis(js, 3, -(xis.Gamepad.sThumbRY + 0.5f) / 32767.5f);
+ _glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f);
+ _glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f);
+
+ for (i = 0; i < 10; i++)
+ {
+ const char value = (xis.Gamepad.wButtons & buttons[i]) ? 1 : 0;
+ _glfwInputJoystickButton(js, i, value);
+ }
+
+ if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
+ dpad |= GLFW_HAT_UP;
+ if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
+ dpad |= GLFW_HAT_RIGHT;
+ if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
+ dpad |= GLFW_HAT_DOWN;
+ if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
+ dpad |= GLFW_HAT_LEFT;
+
+ _glfwInputJoystickHat(js, 0, dpad);
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformUpdateGamepadGUID(char* guid)
+{
+ if (strcmp(guid + 20, "504944564944") == 0)
+ {
+ char original[33];
+ strcpy(original, guid);
+ sprintf(guid, "03000000%.4s0000%.4s000000000000",
+ original, original + 4);
+ }
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.h b/Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.h
new file mode 100644
index 0000000..9156f6c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_joystick.h
@@ -0,0 +1,56 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
+#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy
+
+#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
+
+// Joystick element (axis, button or slider)
+//
+typedef struct _GLFWjoyobjectWin32
+{
+ int offset;
+ int type;
+} _GLFWjoyobjectWin32;
+
+// Win32-specific per-joystick data
+//
+typedef struct _GLFWjoystickWin32
+{
+ _GLFWjoyobjectWin32* objects;
+ int objectCount;
+ IDirectInputDevice8W* device;
+ DWORD index;
+ GUID guid;
+} _GLFWjoystickWin32;
+
+
+void _glfwInitJoysticksWin32(void);
+void _glfwTerminateJoysticksWin32(void);
+void _glfwDetectJoystickConnectionWin32(void);
+void _glfwDetectJoystickDisconnectionWin32(void);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_monitor.c b/Client/ThirdParty/Box2D/extern/glfw/src/win32_monitor.c
new file mode 100644
index 0000000..07b3614
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_monitor.c
@@ -0,0 +1,515 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <malloc.h>
+
+
+// Callback for EnumDisplayMonitors in createMonitor
+//
+static BOOL CALLBACK monitorCallback(HMONITOR handle,
+ HDC dc,
+ RECT* rect,
+ LPARAM data)
+{
+ MONITORINFOEXW mi;
+ ZeroMemory(&mi, sizeof(mi));
+ mi.cbSize = sizeof(mi);
+
+ if (GetMonitorInfoW(handle, (MONITORINFO*) &mi))
+ {
+ _GLFWmonitor* monitor = (_GLFWmonitor*) data;
+ if (wcscmp(mi.szDevice, monitor->win32.adapterName) == 0)
+ monitor->win32.handle = handle;
+ }
+
+ return TRUE;
+}
+
+// Create monitor from an adapter and (optionally) a display
+//
+static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter,
+ DISPLAY_DEVICEW* display)
+{
+ _GLFWmonitor* monitor;
+ int widthMM, heightMM;
+ char* name;
+ HDC dc;
+ DEVMODEW dm;
+ RECT rect;
+
+ if (display)
+ name = _glfwCreateUTF8FromWideStringWin32(display->DeviceString);
+ else
+ name = _glfwCreateUTF8FromWideStringWin32(adapter->DeviceString);
+ if (!name)
+ return NULL;
+
+ ZeroMemory(&dm, sizeof(dm));
+ dm.dmSize = sizeof(dm);
+ EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &dm);
+
+ dc = CreateDCW(L"DISPLAY", adapter->DeviceName, NULL, NULL);
+
+ if (IsWindows8Point1OrGreater())
+ {
+ widthMM = GetDeviceCaps(dc, HORZSIZE);
+ heightMM = GetDeviceCaps(dc, VERTSIZE);
+ }
+ else
+ {
+ widthMM = (int) (dm.dmPelsWidth * 25.4f / GetDeviceCaps(dc, LOGPIXELSX));
+ heightMM = (int) (dm.dmPelsHeight * 25.4f / GetDeviceCaps(dc, LOGPIXELSY));
+ }
+
+ DeleteDC(dc);
+
+ monitor = _glfwAllocMonitor(name, widthMM, heightMM);
+ free(name);
+
+ if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED)
+ monitor->win32.modesPruned = GLFW_TRUE;
+
+ wcscpy(monitor->win32.adapterName, adapter->DeviceName);
+ WideCharToMultiByte(CP_UTF8, 0,
+ adapter->DeviceName, -1,
+ monitor->win32.publicAdapterName,
+ sizeof(monitor->win32.publicAdapterName),
+ NULL, NULL);
+
+ if (display)
+ {
+ wcscpy(monitor->win32.displayName, display->DeviceName);
+ WideCharToMultiByte(CP_UTF8, 0,
+ display->DeviceName, -1,
+ monitor->win32.publicDisplayName,
+ sizeof(monitor->win32.publicDisplayName),
+ NULL, NULL);
+ }
+
+ rect.left = dm.dmPosition.x;
+ rect.top = dm.dmPosition.y;
+ rect.right = dm.dmPosition.x + dm.dmPelsWidth;
+ rect.bottom = dm.dmPosition.y + dm.dmPelsHeight;
+
+ EnumDisplayMonitors(NULL, &rect, monitorCallback, (LPARAM) monitor);
+ return monitor;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Poll for changes in the set of connected monitors
+//
+void _glfwPollMonitorsWin32(void)
+{
+ int i, disconnectedCount;
+ _GLFWmonitor** disconnected = NULL;
+ DWORD adapterIndex, displayIndex;
+ DISPLAY_DEVICEW adapter, display;
+ _GLFWmonitor* monitor;
+
+ disconnectedCount = _glfw.monitorCount;
+ if (disconnectedCount)
+ {
+ disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
+ memcpy(disconnected,
+ _glfw.monitors,
+ _glfw.monitorCount * sizeof(_GLFWmonitor*));
+ }
+
+ for (adapterIndex = 0; ; adapterIndex++)
+ {
+ int type = _GLFW_INSERT_LAST;
+
+ ZeroMemory(&adapter, sizeof(adapter));
+ adapter.cb = sizeof(adapter);
+
+ if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
+ break;
+
+ if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
+ continue;
+
+ if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
+ type = _GLFW_INSERT_FIRST;
+
+ for (displayIndex = 0; ; displayIndex++)
+ {
+ ZeroMemory(&display, sizeof(display));
+ display.cb = sizeof(display);
+
+ if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
+ break;
+
+ if (!(display.StateFlags & DISPLAY_DEVICE_ACTIVE))
+ continue;
+
+ for (i = 0; i < disconnectedCount; i++)
+ {
+ if (disconnected[i] &&
+ wcscmp(disconnected[i]->win32.displayName,
+ display.DeviceName) == 0)
+ {
+ disconnected[i] = NULL;
+ break;
+ }
+ }
+
+ if (i < disconnectedCount)
+ continue;
+
+ monitor = createMonitor(&adapter, &display);
+ if (!monitor)
+ {
+ free(disconnected);
+ return;
+ }
+
+ _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
+
+ type = _GLFW_INSERT_LAST;
+ }
+
+ // HACK: If an active adapter does not have any display devices
+ // (as sometimes happens), add it directly as a monitor
+ if (displayIndex == 0)
+ {
+ for (i = 0; i < disconnectedCount; i++)
+ {
+ if (disconnected[i] &&
+ wcscmp(disconnected[i]->win32.adapterName,
+ adapter.DeviceName) == 0)
+ {
+ disconnected[i] = NULL;
+ break;
+ }
+ }
+
+ if (i < disconnectedCount)
+ continue;
+
+ monitor = createMonitor(&adapter, NULL);
+ if (!monitor)
+ {
+ free(disconnected);
+ return;
+ }
+
+ _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
+ }
+ }
+
+ for (i = 0; i < disconnectedCount; i++)
+ {
+ if (disconnected[i])
+ _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
+ }
+
+ free(disconnected);
+}
+
+// Change the current video mode
+//
+void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
+{
+ GLFWvidmode current;
+ const GLFWvidmode* best;
+ DEVMODEW dm;
+ LONG result;
+
+ best = _glfwChooseVideoMode(monitor, desired);
+ _glfwPlatformGetVideoMode(monitor, &current);
+ if (_glfwCompareVideoModes(&current, best) == 0)
+ return;
+
+ ZeroMemory(&dm, sizeof(dm));
+ dm.dmSize = sizeof(dm);
+ dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
+ DM_DISPLAYFREQUENCY;
+ dm.dmPelsWidth = best->width;
+ dm.dmPelsHeight = best->height;
+ dm.dmBitsPerPel = best->redBits + best->greenBits + best->blueBits;
+ dm.dmDisplayFrequency = best->refreshRate;
+
+ if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
+ dm.dmBitsPerPel = 32;
+
+ result = ChangeDisplaySettingsExW(monitor->win32.adapterName,
+ &dm,
+ NULL,
+ CDS_FULLSCREEN,
+ NULL);
+ if (result == DISP_CHANGE_SUCCESSFUL)
+ monitor->win32.modeChanged = GLFW_TRUE;
+ else
+ {
+ const char* description = "Unknown error";
+
+ if (result == DISP_CHANGE_BADDUALVIEW)
+ description = "The system uses DualView";
+ else if (result == DISP_CHANGE_BADFLAGS)
+ description = "Invalid flags";
+ else if (result == DISP_CHANGE_BADMODE)
+ description = "Graphics mode not supported";
+ else if (result == DISP_CHANGE_BADPARAM)
+ description = "Invalid parameter";
+ else if (result == DISP_CHANGE_FAILED)
+ description = "Graphics mode failed";
+ else if (result == DISP_CHANGE_NOTUPDATED)
+ description = "Failed to write to registry";
+ else if (result == DISP_CHANGE_RESTART)
+ description = "Computer restart required";
+
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to set video mode: %s",
+ description);
+ }
+}
+
+// Restore the previously saved (original) video mode
+//
+void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
+{
+ if (monitor->win32.modeChanged)
+ {
+ ChangeDisplaySettingsExW(monitor->win32.adapterName,
+ NULL, NULL, CDS_FULLSCREEN, NULL);
+ monitor->win32.modeChanged = GLFW_FALSE;
+ }
+}
+
+void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
+{
+ UINT xdpi, ydpi;
+
+ if (IsWindows8Point1OrGreater())
+ GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
+ else
+ {
+ const HDC dc = GetDC(NULL);
+ xdpi = GetDeviceCaps(dc, LOGPIXELSX);
+ ydpi = GetDeviceCaps(dc, LOGPIXELSY);
+ ReleaseDC(NULL, dc);
+ }
+
+ if (xscale)
+ *xscale = xdpi / (float) USER_DEFAULT_SCREEN_DPI;
+ if (yscale)
+ *yscale = ydpi / (float) USER_DEFAULT_SCREEN_DPI;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
+{
+}
+
+void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
+{
+ DEVMODEW dm;
+ ZeroMemory(&dm, sizeof(dm));
+ dm.dmSize = sizeof(dm);
+
+ EnumDisplaySettingsExW(monitor->win32.adapterName,
+ ENUM_CURRENT_SETTINGS,
+ &dm,
+ EDS_ROTATEDMODE);
+
+ if (xpos)
+ *xpos = dm.dmPosition.x;
+ if (ypos)
+ *ypos = dm.dmPosition.y;
+}
+
+void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
+ float* xscale, float* yscale)
+{
+ _glfwGetMonitorContentScaleWin32(monitor->win32.handle, xscale, yscale);
+}
+
+GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
+{
+ int modeIndex = 0, size = 0;
+ GLFWvidmode* result = NULL;
+
+ *count = 0;
+
+ for (;;)
+ {
+ int i;
+ GLFWvidmode mode;
+ DEVMODEW dm;
+
+ ZeroMemory(&dm, sizeof(dm));
+ dm.dmSize = sizeof(dm);
+
+ if (!EnumDisplaySettingsW(monitor->win32.adapterName, modeIndex, &dm))
+ break;
+
+ modeIndex++;
+
+ // Skip modes with less than 15 BPP
+ if (dm.dmBitsPerPel < 15)
+ continue;
+
+ mode.width = dm.dmPelsWidth;
+ mode.height = dm.dmPelsHeight;
+ mode.refreshRate = dm.dmDisplayFrequency;
+ _glfwSplitBPP(dm.dmBitsPerPel,
+ &mode.redBits,
+ &mode.greenBits,
+ &mode.blueBits);
+
+ for (i = 0; i < *count; i++)
+ {
+ if (_glfwCompareVideoModes(result + i, &mode) == 0)
+ break;
+ }
+
+ // Skip duplicate modes
+ if (i < *count)
+ continue;
+
+ if (monitor->win32.modesPruned)
+ {
+ // Skip modes not supported by the connected displays
+ if (ChangeDisplaySettingsExW(monitor->win32.adapterName,
+ &dm,
+ NULL,
+ CDS_TEST,
+ NULL) != DISP_CHANGE_SUCCESSFUL)
+ {
+ continue;
+ }
+ }
+
+ if (*count == size)
+ {
+ size += 128;
+ result = (GLFWvidmode*) realloc(result, size * sizeof(GLFWvidmode));
+ }
+
+ (*count)++;
+ result[*count - 1] = mode;
+ }
+
+ if (!*count)
+ {
+ // HACK: Report the current mode if no valid modes were found
+ result = calloc(1, sizeof(GLFWvidmode));
+ _glfwPlatformGetVideoMode(monitor, result);
+ *count = 1;
+ }
+
+ return result;
+}
+
+void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
+{
+ DEVMODEW dm;
+ ZeroMemory(&dm, sizeof(dm));
+ dm.dmSize = sizeof(dm);
+
+ EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm);
+
+ mode->width = dm.dmPelsWidth;
+ mode->height = dm.dmPelsHeight;
+ mode->refreshRate = dm.dmDisplayFrequency;
+ _glfwSplitBPP(dm.dmBitsPerPel,
+ &mode->redBits,
+ &mode->greenBits,
+ &mode->blueBits);
+}
+
+GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
+{
+ HDC dc;
+ WORD values[768];
+
+ dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
+ GetDeviceGammaRamp(dc, values);
+ DeleteDC(dc);
+
+ _glfwAllocGammaArrays(ramp, 256);
+
+ memcpy(ramp->red, values + 0, 256 * sizeof(unsigned short));
+ memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short));
+ memcpy(ramp->blue, values + 512, 256 * sizeof(unsigned short));
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
+{
+ HDC dc;
+ WORD values[768];
+
+ if (ramp->size != 256)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Gamma ramp size must be 256");
+ return;
+ }
+
+ memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short));
+ memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short));
+ memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short));
+
+ dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
+ SetDeviceGammaRamp(dc, values);
+ DeleteDC(dc);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return monitor->win32.publicAdapterName;
+}
+
+GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return monitor->win32.publicDisplayName;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_platform.h b/Client/ThirdParty/Box2D/extern/glfw/src/win32_platform.h
new file mode 100644
index 0000000..712de7f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_platform.h
@@ -0,0 +1,449 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+// We don't need all the fancy stuff
+#ifndef NOMINMAX
+ #define NOMINMAX
+#endif
+
+#ifndef VC_EXTRALEAN
+ #define VC_EXTRALEAN
+#endif
+
+#ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+#endif
+
+// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
+// example to allow applications to correctly declare a GL_ARB_debug_output
+// callback) but windows.h assumes no one will define APIENTRY before it does
+#undef APIENTRY
+
+// GLFW on Windows is Unicode only and does not work in MBCS mode
+#ifndef UNICODE
+ #define UNICODE
+#endif
+
+// GLFW requires Windows XP or later
+#if WINVER < 0x0501
+ #undef WINVER
+ #define WINVER 0x0501
+#endif
+#if _WIN32_WINNT < 0x0501
+ #undef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0501
+#endif
+
+// GLFW uses DirectInput8 interfaces
+#define DIRECTINPUT_VERSION 0x0800
+
+#include <wctype.h>
+#include <windows.h>
+#include <dinput.h>
+#include <xinput.h>
+#include <dbt.h>
+
+// HACK: Define macros that some windows.h variants don't
+#ifndef WM_MOUSEHWHEEL
+ #define WM_MOUSEHWHEEL 0x020E
+#endif
+#ifndef WM_DWMCOMPOSITIONCHANGED
+ #define WM_DWMCOMPOSITIONCHANGED 0x031E
+#endif
+#ifndef WM_COPYGLOBALDATA
+ #define WM_COPYGLOBALDATA 0x0049
+#endif
+#ifndef WM_UNICHAR
+ #define WM_UNICHAR 0x0109
+#endif
+#ifndef UNICODE_NOCHAR
+ #define UNICODE_NOCHAR 0xFFFF
+#endif
+#ifndef WM_DPICHANGED
+ #define WM_DPICHANGED 0x02E0
+#endif
+#ifndef GET_XBUTTON_WPARAM
+ #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
+#endif
+#ifndef EDS_ROTATEDMODE
+ #define EDS_ROTATEDMODE 0x00000004
+#endif
+#ifndef DISPLAY_DEVICE_ACTIVE
+ #define DISPLAY_DEVICE_ACTIVE 0x00000001
+#endif
+#ifndef _WIN32_WINNT_WINBLUE
+ #define _WIN32_WINNT_WINBLUE 0x0602
+#endif
+#ifndef WM_GETDPISCALEDSIZE
+ #define WM_GETDPISCALEDSIZE 0x02e4
+#endif
+#ifndef USER_DEFAULT_SCREEN_DPI
+ #define USER_DEFAULT_SCREEN_DPI 96
+#endif
+
+#if WINVER < 0x0601
+typedef struct
+{
+ DWORD cbSize;
+ DWORD ExtStatus;
+} CHANGEFILTERSTRUCT;
+#ifndef MSGFLT_ALLOW
+ #define MSGFLT_ALLOW 1
+#endif
+#endif /*Windows 7*/
+
+#if WINVER < 0x0600
+#define DWM_BB_ENABLE 0x00000001
+#define DWM_BB_BLURREGION 0x00000002
+typedef struct
+{
+ DWORD dwFlags;
+ BOOL fEnable;
+ HRGN hRgnBlur;
+ BOOL fTransitionOnMaximized;
+} DWM_BLURBEHIND;
+#else
+ #include <dwmapi.h>
+#endif /*Windows Vista*/
+
+#ifndef DPI_ENUMS_DECLARED
+typedef enum
+{
+ PROCESS_DPI_UNAWARE = 0,
+ PROCESS_SYSTEM_DPI_AWARE = 1,
+ PROCESS_PER_MONITOR_DPI_AWARE = 2
+} PROCESS_DPI_AWARENESS;
+typedef enum
+{
+ MDT_EFFECTIVE_DPI = 0,
+ MDT_ANGULAR_DPI = 1,
+ MDT_RAW_DPI = 2,
+ MDT_DEFAULT = MDT_EFFECTIVE_DPI
+} MONITOR_DPI_TYPE;
+#endif /*DPI_ENUMS_DECLARED*/
+
+#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
+#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
+#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
+
+// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
+#define IsWindowsXPOrGreater() \
+ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINXP), \
+ LOBYTE(_WIN32_WINNT_WINXP), 0)
+#define IsWindowsVistaOrGreater() \
+ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
+ LOBYTE(_WIN32_WINNT_VISTA), 0)
+#define IsWindows7OrGreater() \
+ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \
+ LOBYTE(_WIN32_WINNT_WIN7), 0)
+#define IsWindows8OrGreater() \
+ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
+ LOBYTE(_WIN32_WINNT_WIN8), 0)
+#define IsWindows8Point1OrGreater() \
+ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
+ LOBYTE(_WIN32_WINNT_WINBLUE), 0)
+
+#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \
+ _glfwIsWindows10BuildOrGreaterWin32(14393)
+#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \
+ _glfwIsWindows10BuildOrGreaterWin32(15063)
+
+// HACK: Define macros that some xinput.h variants don't
+#ifndef XINPUT_CAPS_WIRELESS
+ #define XINPUT_CAPS_WIRELESS 0x0002
+#endif
+#ifndef XINPUT_DEVSUBTYPE_WHEEL
+ #define XINPUT_DEVSUBTYPE_WHEEL 0x02
+#endif
+#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
+ #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
+#endif
+#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
+ #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
+#endif
+#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
+ #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
+#endif
+#ifndef XINPUT_DEVSUBTYPE_GUITAR
+ #define XINPUT_DEVSUBTYPE_GUITAR 0x06
+#endif
+#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
+ #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
+#endif
+#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
+ #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
+#endif
+#ifndef XUSER_MAX_COUNT
+ #define XUSER_MAX_COUNT 4
+#endif
+
+// HACK: Define macros that some dinput.h variants don't
+#ifndef DIDFT_OPTIONAL
+ #define DIDFT_OPTIONAL 0x80000000
+#endif
+
+// winmm.dll function pointer typedefs
+typedef DWORD (WINAPI * PFN_timeGetTime)(void);
+#define timeGetTime _glfw.win32.winmm.GetTime
+
+// xinput.dll function pointer typedefs
+typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
+typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
+#define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities
+#define XInputGetState _glfw.win32.xinput.GetState
+
+// dinput8.dll function pointer typedefs
+typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*,LPUNKNOWN);
+#define DirectInput8Create _glfw.win32.dinput8.Create
+
+// user32.dll function pointer typedefs
+typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
+typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
+typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
+typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
+typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
+typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
+#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
+#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
+#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
+#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
+#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
+#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
+
+// dwmapi.dll function pointer typedefs
+typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
+typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
+typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
+#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
+#define DwmFlush _glfw.win32.dwmapi.Flush
+#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
+
+// shcore.dll function pointer typedefs
+typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
+typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
+#define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness_
+#define GetDpiForMonitor _glfw.win32.shcore.GetDpiForMonitor_
+
+// ntdll.dll function pointer typedefs
+typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
+#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
+
+typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
+
+typedef struct VkWin32SurfaceCreateInfoKHR
+{
+ VkStructureType sType;
+ const void* pNext;
+ VkWin32SurfaceCreateFlagsKHR flags;
+ HINSTANCE hinstance;
+ HWND hwnd;
+} VkWin32SurfaceCreateInfoKHR;
+
+typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
+typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
+
+#include "win32_joystick.h"
+#include "wgl_context.h"
+#include "egl_context.h"
+#include "osmesa_context.h"
+
+#if !defined(_GLFW_WNDCLASSNAME)
+ #define _GLFW_WNDCLASSNAME L"GLFW30"
+#endif
+
+#define _glfw_dlopen(name) LoadLibraryA(name)
+#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
+#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
+
+#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->win32.handle)
+#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
+
+#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
+#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
+#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32
+#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
+#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32
+#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32
+#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32
+
+
+// Win32-specific per-window data
+//
+typedef struct _GLFWwindowWin32
+{
+ HWND handle;
+ HICON bigIcon;
+ HICON smallIcon;
+
+ GLFWbool cursorTracked;
+ GLFWbool frameAction;
+ GLFWbool iconified;
+ GLFWbool maximized;
+ // Whether to enable framebuffer transparency on DWM
+ GLFWbool transparent;
+ GLFWbool scaleToMonitor;
+
+ // The last received cursor position, regardless of source
+ int lastCursorPosX, lastCursorPosY;
+
+} _GLFWwindowWin32;
+
+// Win32-specific global data
+//
+typedef struct _GLFWlibraryWin32
+{
+ HWND helperWindowHandle;
+ HDEVNOTIFY deviceNotificationHandle;
+ DWORD foregroundLockTimeout;
+ int acquiredMonitorCount;
+ char* clipboardString;
+ short int keycodes[512];
+ short int scancodes[GLFW_KEY_LAST + 1];
+ char keynames[GLFW_KEY_LAST + 1][5];
+ // Where to place the cursor when re-enabled
+ double restoreCursorPosX, restoreCursorPosY;
+ // The window whose disabled cursor mode is active
+ _GLFWwindow* disabledCursorWindow;
+ RAWINPUT* rawInput;
+ int rawInputSize;
+ UINT mouseTrailSize;
+
+ struct {
+ HINSTANCE instance;
+ PFN_timeGetTime GetTime;
+ } winmm;
+
+ struct {
+ HINSTANCE instance;
+ PFN_DirectInput8Create Create;
+ IDirectInput8W* api;
+ } dinput8;
+
+ struct {
+ HINSTANCE instance;
+ PFN_XInputGetCapabilities GetCapabilities;
+ PFN_XInputGetState GetState;
+ } xinput;
+
+ struct {
+ HINSTANCE instance;
+ PFN_SetProcessDPIAware SetProcessDPIAware_;
+ PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
+ PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_;
+ PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
+ PFN_GetDpiForWindow GetDpiForWindow_;
+ PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_;
+ } user32;
+
+ struct {
+ HINSTANCE instance;
+ PFN_DwmIsCompositionEnabled IsCompositionEnabled;
+ PFN_DwmFlush Flush;
+ PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow;
+ } dwmapi;
+
+ struct {
+ HINSTANCE instance;
+ PFN_SetProcessDpiAwareness SetProcessDpiAwareness_;
+ PFN_GetDpiForMonitor GetDpiForMonitor_;
+ } shcore;
+
+ struct {
+ HINSTANCE instance;
+ PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_;
+ } ntdll;
+
+} _GLFWlibraryWin32;
+
+// Win32-specific per-monitor data
+//
+typedef struct _GLFWmonitorWin32
+{
+ HMONITOR handle;
+ // This size matches the static size of DISPLAY_DEVICE.DeviceName
+ WCHAR adapterName[32];
+ WCHAR displayName[32];
+ char publicAdapterName[32];
+ char publicDisplayName[32];
+ GLFWbool modesPruned;
+ GLFWbool modeChanged;
+
+} _GLFWmonitorWin32;
+
+// Win32-specific per-cursor data
+//
+typedef struct _GLFWcursorWin32
+{
+ HCURSOR handle;
+
+} _GLFWcursorWin32;
+
+// Win32-specific global timer data
+//
+typedef struct _GLFWtimerWin32
+{
+ GLFWbool hasPC;
+ uint64_t frequency;
+
+} _GLFWtimerWin32;
+
+// Win32-specific thread local storage data
+//
+typedef struct _GLFWtlsWin32
+{
+ GLFWbool allocated;
+ DWORD index;
+
+} _GLFWtlsWin32;
+
+// Win32-specific mutex data
+//
+typedef struct _GLFWmutexWin32
+{
+ GLFWbool allocated;
+ CRITICAL_SECTION section;
+
+} _GLFWmutexWin32;
+
+
+GLFWbool _glfwRegisterWindowClassWin32(void);
+void _glfwUnregisterWindowClassWin32(void);
+
+WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
+char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
+BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
+BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
+void _glfwInputErrorWin32(int error, const char* description);
+void _glfwUpdateKeyNamesWin32(void);
+
+void _glfwInitTimerWin32(void);
+
+void _glfwPollMonitorsWin32(void);
+void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
+void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
+void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_thread.c b/Client/ThirdParty/Box2D/extern/glfw/src/win32_thread.c
new file mode 100644
index 0000000..98231c1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_thread.c
@@ -0,0 +1,97 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
+{
+ assert(tls->win32.allocated == GLFW_FALSE);
+
+ tls->win32.index = TlsAlloc();
+ if (tls->win32.index == TLS_OUT_OF_INDEXES)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to allocate TLS index");
+ return GLFW_FALSE;
+ }
+
+ tls->win32.allocated = GLFW_TRUE;
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyTls(_GLFWtls* tls)
+{
+ if (tls->win32.allocated)
+ TlsFree(tls->win32.index);
+ memset(tls, 0, sizeof(_GLFWtls));
+}
+
+void* _glfwPlatformGetTls(_GLFWtls* tls)
+{
+ assert(tls->win32.allocated == GLFW_TRUE);
+ return TlsGetValue(tls->win32.index);
+}
+
+void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
+{
+ assert(tls->win32.allocated == GLFW_TRUE);
+ TlsSetValue(tls->win32.index, value);
+}
+
+GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
+{
+ assert(mutex->win32.allocated == GLFW_FALSE);
+ InitializeCriticalSection(&mutex->win32.section);
+ return mutex->win32.allocated = GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
+{
+ if (mutex->win32.allocated)
+ DeleteCriticalSection(&mutex->win32.section);
+ memset(mutex, 0, sizeof(_GLFWmutex));
+}
+
+void _glfwPlatformLockMutex(_GLFWmutex* mutex)
+{
+ assert(mutex->win32.allocated == GLFW_TRUE);
+ EnterCriticalSection(&mutex->win32.section);
+}
+
+void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
+{
+ assert(mutex->win32.allocated == GLFW_TRUE);
+ LeaveCriticalSection(&mutex->win32.section);
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_time.c b/Client/ThirdParty/Box2D/extern/glfw/src/win32_time.c
new file mode 100644
index 0000000..f333cd4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_time.c
@@ -0,0 +1,74 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Initialise timer
+//
+void _glfwInitTimerWin32(void)
+{
+ uint64_t frequency;
+
+ if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
+ {
+ _glfw.timer.win32.hasPC = GLFW_TRUE;
+ _glfw.timer.win32.frequency = frequency;
+ }
+ else
+ {
+ _glfw.timer.win32.hasPC = GLFW_FALSE;
+ _glfw.timer.win32.frequency = 1000;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+uint64_t _glfwPlatformGetTimerValue(void)
+{
+ if (_glfw.timer.win32.hasPC)
+ {
+ uint64_t value;
+ QueryPerformanceCounter((LARGE_INTEGER*) &value);
+ return value;
+ }
+ else
+ return (uint64_t) timeGetTime();
+}
+
+uint64_t _glfwPlatformGetTimerFrequency(void)
+{
+ return _glfw.timer.win32.frequency;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/win32_window.c b/Client/ThirdParty/Box2D/extern/glfw/src/win32_window.c
new file mode 100644
index 0000000..a0abca0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/win32_window.c
@@ -0,0 +1,2205 @@
+//========================================================================
+// GLFW 3.3 Win32 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <limits.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <string.h>
+#include <windowsx.h>
+#include <shellapi.h>
+
+#define _GLFW_KEY_INVALID -2
+
+// Returns the window style for the specified window
+//
+static DWORD getWindowStyle(const _GLFWwindow* window)
+{
+ DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
+
+ if (window->monitor)
+ style |= WS_POPUP;
+ else
+ {
+ style |= WS_SYSMENU | WS_MINIMIZEBOX;
+
+ if (window->decorated)
+ {
+ style |= WS_CAPTION;
+
+ if (window->resizable)
+ style |= WS_MAXIMIZEBOX | WS_THICKFRAME;
+ }
+ else
+ style |= WS_POPUP;
+ }
+
+ return style;
+}
+
+// Returns the extended window style for the specified window
+//
+static DWORD getWindowExStyle(const _GLFWwindow* window)
+{
+ DWORD style = WS_EX_APPWINDOW;
+
+ if (window->monitor || window->floating)
+ style |= WS_EX_TOPMOST;
+
+ return style;
+}
+
+// Returns the image whose area most closely matches the desired one
+//
+static const GLFWimage* chooseImage(int count, const GLFWimage* images,
+ int width, int height)
+{
+ int i, leastDiff = INT_MAX;
+ const GLFWimage* closest = NULL;
+
+ for (i = 0; i < count; i++)
+ {
+ const int currDiff = abs(images[i].width * images[i].height -
+ width * height);
+ if (currDiff < leastDiff)
+ {
+ closest = images + i;
+ leastDiff = currDiff;
+ }
+ }
+
+ return closest;
+}
+
+// Creates an RGBA icon or cursor
+//
+static HICON createIcon(const GLFWimage* image,
+ int xhot, int yhot, GLFWbool icon)
+{
+ int i;
+ HDC dc;
+ HICON handle;
+ HBITMAP color, mask;
+ BITMAPV5HEADER bi;
+ ICONINFO ii;
+ unsigned char* target = NULL;
+ unsigned char* source = image->pixels;
+
+ ZeroMemory(&bi, sizeof(bi));
+ bi.bV5Size = sizeof(bi);
+ bi.bV5Width = image->width;
+ bi.bV5Height = -image->height;
+ bi.bV5Planes = 1;
+ bi.bV5BitCount = 32;
+ bi.bV5Compression = BI_BITFIELDS;
+ bi.bV5RedMask = 0x00ff0000;
+ bi.bV5GreenMask = 0x0000ff00;
+ bi.bV5BlueMask = 0x000000ff;
+ bi.bV5AlphaMask = 0xff000000;
+
+ dc = GetDC(NULL);
+ color = CreateDIBSection(dc,
+ (BITMAPINFO*) &bi,
+ DIB_RGB_COLORS,
+ (void**) &target,
+ NULL,
+ (DWORD) 0);
+ ReleaseDC(NULL, dc);
+
+ if (!color)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create RGBA bitmap");
+ return NULL;
+ }
+
+ mask = CreateBitmap(image->width, image->height, 1, 1, NULL);
+ if (!mask)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create mask bitmap");
+ DeleteObject(color);
+ return NULL;
+ }
+
+ for (i = 0; i < image->width * image->height; i++)
+ {
+ target[0] = source[2];
+ target[1] = source[1];
+ target[2] = source[0];
+ target[3] = source[3];
+ target += 4;
+ source += 4;
+ }
+
+ ZeroMemory(&ii, sizeof(ii));
+ ii.fIcon = icon;
+ ii.xHotspot = xhot;
+ ii.yHotspot = yhot;
+ ii.hbmMask = mask;
+ ii.hbmColor = color;
+
+ handle = CreateIconIndirect(&ii);
+
+ DeleteObject(color);
+ DeleteObject(mask);
+
+ if (!handle)
+ {
+ if (icon)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create icon");
+ }
+ else
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create cursor");
+ }
+ }
+
+ return handle;
+}
+
+// Translate client window size to full window size according to styles and DPI
+//
+static void getFullWindowSize(DWORD style, DWORD exStyle,
+ int clientWidth, int clientHeight,
+ int* fullWidth, int* fullHeight,
+ UINT dpi)
+{
+ RECT rect = { 0, 0, clientWidth, clientHeight };
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
+ else
+ AdjustWindowRectEx(&rect, style, FALSE, exStyle);
+
+ *fullWidth = rect.right - rect.left;
+ *fullHeight = rect.bottom - rect.top;
+}
+
+// Enforce the client rect aspect ratio based on which edge is being dragged
+//
+static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
+{
+ int xoff, yoff;
+ UINT dpi = USER_DEFAULT_SCREEN_DPI;
+ const float ratio = (float) window->numer / (float) window->denom;
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ dpi = GetDpiForWindow(window->win32.handle);
+
+ getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
+ 0, 0, &xoff, &yoff, dpi);
+
+ if (edge == WMSZ_LEFT || edge == WMSZ_BOTTOMLEFT ||
+ edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
+ {
+ area->bottom = area->top + yoff +
+ (int) ((area->right - area->left - xoff) / ratio);
+ }
+ else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
+ {
+ area->top = area->bottom - yoff -
+ (int) ((area->right - area->left - xoff) / ratio);
+ }
+ else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
+ {
+ area->right = area->left + xoff +
+ (int) ((area->bottom - area->top - yoff) * ratio);
+ }
+}
+
+// Centers the cursor over the window client area
+//
+static void centerCursor(_GLFWwindow* window)
+{
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
+}
+
+// Updates the cursor image according to its cursor mode
+//
+static void updateCursorImage(_GLFWwindow* window)
+{
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
+ {
+ if (window->cursor)
+ SetCursor(window->cursor->win32.handle);
+ else
+ SetCursor(LoadCursorW(NULL, IDC_ARROW));
+ }
+ else
+ SetCursor(NULL);
+}
+
+// Updates the cursor clip rect
+//
+static void updateClipRect(_GLFWwindow* window)
+{
+ if (window)
+ {
+ RECT clipRect;
+ GetClientRect(window->win32.handle, &clipRect);
+ ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
+ ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
+ ClipCursor(&clipRect);
+ }
+ else
+ ClipCursor(NULL);
+}
+
+// Apply disabled cursor mode to a focused window
+//
+static void disableCursor(_GLFWwindow* window)
+{
+ const RAWINPUTDEVICE rid = { 0x01, 0x02, 0, window->win32.handle };
+
+ _glfw.win32.disabledCursorWindow = window;
+ _glfwPlatformGetCursorPos(window,
+ &_glfw.win32.restoreCursorPosX,
+ &_glfw.win32.restoreCursorPosY);
+ updateCursorImage(window);
+ centerCursor(window);
+ updateClipRect(window);
+
+ if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to register raw input device");
+ }
+}
+
+// Exit disabled cursor mode for the specified window
+//
+static void enableCursor(_GLFWwindow* window)
+{
+ const RAWINPUTDEVICE rid = { 0x01, 0x02, RIDEV_REMOVE, NULL };
+
+ _glfw.win32.disabledCursorWindow = NULL;
+ updateClipRect(NULL);
+ _glfwPlatformSetCursorPos(window,
+ _glfw.win32.restoreCursorPosX,
+ _glfw.win32.restoreCursorPosY);
+ updateCursorImage(window);
+
+ if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to remove raw input device");
+ }
+}
+
+// Returns whether the cursor is in the client area of the specified window
+//
+static GLFWbool cursorInClientArea(_GLFWwindow* window)
+{
+ RECT area;
+ POINT pos;
+
+ if (!GetCursorPos(&pos))
+ return GLFW_FALSE;
+
+ if (WindowFromPoint(pos) != window->win32.handle)
+ return GLFW_FALSE;
+
+ GetClientRect(window->win32.handle, &area);
+ ClientToScreen(window->win32.handle, (POINT*) &area.left);
+ ClientToScreen(window->win32.handle, (POINT*) &area.right);
+
+ return PtInRect(&area, pos);
+}
+
+// Update native window styles to match attributes
+//
+static void updateWindowStyles(const _GLFWwindow* window)
+{
+ RECT rect;
+ DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
+ style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP);
+ style |= getWindowStyle(window);
+
+ GetClientRect(window->win32.handle, &rect);
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, style, FALSE,
+ getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window));
+
+ ClientToScreen(window->win32.handle, (POINT*) &rect.left);
+ ClientToScreen(window->win32.handle, (POINT*) &rect.right);
+ SetWindowLongW(window->win32.handle, GWL_STYLE, style);
+ SetWindowPos(window->win32.handle, HWND_TOP,
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER);
+}
+
+// Update window framebuffer transparency
+//
+static void updateFramebufferTransparency(const _GLFWwindow* window)
+{
+ BOOL enabled;
+
+ if (!IsWindowsVistaOrGreater())
+ return;
+
+ if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
+ {
+ HRGN region = CreateRectRgn(0, 0, -1, -1);
+ DWM_BLURBEHIND bb = {0};
+ bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
+ bb.hRgnBlur = region;
+ bb.fEnable = TRUE;
+
+ if (SUCCEEDED(DwmEnableBlurBehindWindow(window->win32.handle, &bb)))
+ {
+ // Decorated windows don't repaint the transparent background
+ // leaving a trail behind animations
+ // HACK: Making the window layered with a transparency color key
+ // seems to fix this. Normally, when specifying
+ // a transparency color key to be used when composing the
+ // layered window, all pixels painted by the window in this
+ // color will be transparent. That doesn't seem to be the
+ // case anymore, at least when used with blur behind window
+ // plus negative region.
+ LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
+ exStyle |= WS_EX_LAYERED;
+ SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
+
+ // Using a color key not equal to black to fix the trailing
+ // issue. When set to black, something is making the hit test
+ // not resize with the window frame.
+ SetLayeredWindowAttributes(window->win32.handle,
+ RGB(0, 193, 48), 255, LWA_COLORKEY);
+ }
+
+ DeleteObject(region);
+ }
+ else
+ {
+ LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
+ exStyle &= ~WS_EX_LAYERED;
+ SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
+ RedrawWindow(window->win32.handle, NULL, NULL,
+ RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
+ }
+}
+
+// Retrieves and translates modifier keys
+//
+static int getKeyMods(void)
+{
+ int mods = 0;
+
+ if (GetKeyState(VK_SHIFT) & 0x8000)
+ mods |= GLFW_MOD_SHIFT;
+ if (GetKeyState(VK_CONTROL) & 0x8000)
+ mods |= GLFW_MOD_CONTROL;
+ if (GetKeyState(VK_MENU) & 0x8000)
+ mods |= GLFW_MOD_ALT;
+ if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
+ mods |= GLFW_MOD_SUPER;
+ if (GetKeyState(VK_CAPITAL) & 1)
+ mods |= GLFW_MOD_CAPS_LOCK;
+ if (GetKeyState(VK_NUMLOCK) & 1)
+ mods |= GLFW_MOD_NUM_LOCK;
+
+ return mods;
+}
+
+// Retrieves and translates modifier keys
+//
+static int getAsyncKeyMods(void)
+{
+ int mods = 0;
+
+ if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
+ mods |= GLFW_MOD_SHIFT;
+ if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
+ mods |= GLFW_MOD_CONTROL;
+ if (GetAsyncKeyState(VK_MENU) & 0x8000)
+ mods |= GLFW_MOD_ALT;
+ if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000)
+ mods |= GLFW_MOD_SUPER;
+ if (GetAsyncKeyState(VK_CAPITAL) & 1)
+ mods |= GLFW_MOD_CAPS_LOCK;
+ if (GetAsyncKeyState(VK_NUMLOCK) & 1)
+ mods |= GLFW_MOD_NUM_LOCK;
+
+ return mods;
+}
+
+// Translates a Windows key to the corresponding GLFW key
+//
+static int translateKey(WPARAM wParam, LPARAM lParam)
+{
+ // The Ctrl keys require special handling
+ if (wParam == VK_CONTROL)
+ {
+ MSG next;
+ DWORD time;
+
+ // Right side keys have the extended key bit set
+ if (lParam & 0x01000000)
+ return GLFW_KEY_RIGHT_CONTROL;
+
+ // HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence
+ // We only want the Right Alt message, so if the next message is
+ // Right Alt we ignore this (synthetic) Left Ctrl message
+ time = GetMessageTime();
+
+ if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))
+ {
+ if (next.message == WM_KEYDOWN ||
+ next.message == WM_SYSKEYDOWN ||
+ next.message == WM_KEYUP ||
+ next.message == WM_SYSKEYUP)
+ {
+ if (next.wParam == VK_MENU &&
+ (next.lParam & 0x01000000) &&
+ next.time == time)
+ {
+ // Next message is Right Alt down so discard this
+ return _GLFW_KEY_INVALID;
+ }
+ }
+ }
+
+ return GLFW_KEY_LEFT_CONTROL;
+ }
+
+ if (wParam == VK_PROCESSKEY)
+ {
+ // IME notifies that keys have been filtered by setting the virtual
+ // key-code to VK_PROCESSKEY
+ return _GLFW_KEY_INVALID;
+ }
+
+ return _glfw.win32.keycodes[HIWORD(lParam) & 0x1FF];
+}
+
+static void fitToMonitor(_GLFWwindow* window)
+{
+ MONITORINFO mi = { sizeof(mi) };
+ GetMonitorInfo(window->monitor->win32.handle, &mi);
+ SetWindowPos(window->win32.handle, HWND_TOPMOST,
+ mi.rcMonitor.left,
+ mi.rcMonitor.top,
+ mi.rcMonitor.right - mi.rcMonitor.left,
+ mi.rcMonitor.bottom - mi.rcMonitor.top,
+ SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
+}
+
+// Make the specified window and its video mode active on its monitor
+//
+static void acquireMonitor(_GLFWwindow* window)
+{
+ if (!_glfw.win32.acquiredMonitorCount)
+ {
+ SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
+
+ // HACK: When mouse trails are enabled the cursor becomes invisible when
+ // the OpenGL ICD switches to page flipping
+ if (IsWindowsXPOrGreater())
+ {
+ SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
+ SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0);
+ }
+ }
+
+ if (!window->monitor->window)
+ _glfw.win32.acquiredMonitorCount++;
+
+ _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
+ _glfwInputMonitorWindow(window->monitor, window);
+}
+
+// Remove the window and restore the original video mode
+//
+static void releaseMonitor(_GLFWwindow* window)
+{
+ if (window->monitor->window != window)
+ return;
+
+ _glfw.win32.acquiredMonitorCount--;
+ if (!_glfw.win32.acquiredMonitorCount)
+ {
+ SetThreadExecutionState(ES_CONTINUOUS);
+
+ // HACK: Restore mouse trail length saved in acquireMonitor
+ if (IsWindowsXPOrGreater())
+ SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
+ }
+
+ _glfwInputMonitorWindow(window->monitor, NULL);
+ _glfwRestoreVideoModeWin32(window->monitor);
+}
+
+// Window callback function (handles window messages)
+//
+static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ _GLFWwindow* window = GetPropW(hWnd, L"GLFW");
+ if (!window)
+ {
+ // This is the message handling for the hidden helper window
+ // and for a regular window during its initial creation
+
+ switch (uMsg)
+ {
+ case WM_NCCREATE:
+ {
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ EnableNonClientDpiScaling(hWnd);
+
+ break;
+ }
+
+ case WM_DISPLAYCHANGE:
+ _glfwPollMonitorsWin32();
+ break;
+
+ case WM_DEVICECHANGE:
+ {
+ if (wParam == DBT_DEVICEARRIVAL)
+ {
+ DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
+ if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
+ _glfwDetectJoystickConnectionWin32();
+ }
+ else if (wParam == DBT_DEVICEREMOVECOMPLETE)
+ {
+ DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
+ if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
+ _glfwDetectJoystickDisconnectionWin32();
+ }
+
+ break;
+ }
+ }
+
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+ }
+
+ switch (uMsg)
+ {
+ case WM_MOUSEACTIVATE:
+ {
+ // HACK: Postpone cursor disabling when the window was activated by
+ // clicking a caption button
+ if (HIWORD(lParam) == WM_LBUTTONDOWN)
+ {
+ if (LOWORD(lParam) == HTCLOSE ||
+ LOWORD(lParam) == HTMINBUTTON ||
+ LOWORD(lParam) == HTMAXBUTTON)
+ {
+ window->win32.frameAction = GLFW_TRUE;
+ }
+ }
+
+ break;
+ }
+
+ case WM_CAPTURECHANGED:
+ {
+ // HACK: Disable the cursor once the caption button action has been
+ // completed or cancelled
+ if (lParam == 0 && window->win32.frameAction)
+ {
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ disableCursor(window);
+
+ window->win32.frameAction = GLFW_FALSE;
+ }
+
+ break;
+ }
+
+ case WM_SETFOCUS:
+ {
+ _glfwInputWindowFocus(window, GLFW_TRUE);
+
+ // HACK: Do not disable cursor while the user is interacting with
+ // a caption button
+ if (window->win32.frameAction)
+ break;
+
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ disableCursor(window);
+
+ return 0;
+ }
+
+ case WM_KILLFOCUS:
+ {
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ enableCursor(window);
+
+ if (window->monitor && window->autoIconify)
+ _glfwPlatformIconifyWindow(window);
+
+ _glfwInputWindowFocus(window, GLFW_FALSE);
+ return 0;
+ }
+
+ case WM_SYSCOMMAND:
+ {
+ switch (wParam & 0xfff0)
+ {
+ case SC_SCREENSAVE:
+ case SC_MONITORPOWER:
+ {
+ if (window->monitor)
+ {
+ // We are running in full screen mode, so disallow
+ // screen saver and screen blanking
+ return 0;
+ }
+ else
+ break;
+ }
+
+ // User trying to access application menu using ALT?
+ case SC_KEYMENU:
+ return 0;
+ }
+ break;
+ }
+
+ case WM_CLOSE:
+ {
+ _glfwInputWindowCloseRequest(window);
+ return 0;
+ }
+
+ case WM_INPUTLANGCHANGE:
+ {
+ _glfwUpdateKeyNamesWin32();
+ break;
+ }
+
+ case WM_CHAR:
+ case WM_SYSCHAR:
+ case WM_UNICHAR:
+ {
+ const GLFWbool plain = (uMsg != WM_SYSCHAR);
+
+ if (uMsg == WM_UNICHAR && wParam == UNICODE_NOCHAR)
+ {
+ // WM_UNICHAR is not sent by Windows, but is sent by some
+ // third-party input method engine
+ // Returning TRUE here announces support for this message
+ return TRUE;
+ }
+
+ _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain);
+ return 0;
+ }
+
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN:
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ {
+ const int key = translateKey(wParam, lParam);
+ const int scancode = (lParam >> 16) & 0x1ff;
+ const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS;
+ const int mods = getKeyMods();
+
+ if (key == _GLFW_KEY_INVALID)
+ break;
+
+ if (action == GLFW_RELEASE && wParam == VK_SHIFT)
+ {
+ // HACK: Release both Shift keys on Shift up event, as when both
+ // are pressed the first release does not emit any event
+ // NOTE: The other half of this is in _glfwPlatformPollEvents
+ _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods);
+ _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods);
+ }
+ else if (wParam == VK_SNAPSHOT)
+ {
+ // HACK: Key down is not reported for the Print Screen key
+ _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
+ _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
+ }
+ else
+ _glfwInputKey(window, key, scancode, action, mods);
+
+ break;
+ }
+
+ case WM_LBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_XBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_XBUTTONUP:
+ {
+ int i, button, action;
+
+ if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
+ button = GLFW_MOUSE_BUTTON_LEFT;
+ else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP)
+ button = GLFW_MOUSE_BUTTON_RIGHT;
+ else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP)
+ button = GLFW_MOUSE_BUTTON_MIDDLE;
+ else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1)
+ button = GLFW_MOUSE_BUTTON_4;
+ else
+ button = GLFW_MOUSE_BUTTON_5;
+
+ if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN ||
+ uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN)
+ {
+ action = GLFW_PRESS;
+ }
+ else
+ action = GLFW_RELEASE;
+
+ for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
+ {
+ if (window->mouseButtons[i] == GLFW_PRESS)
+ break;
+ }
+
+ if (i > GLFW_MOUSE_BUTTON_LAST)
+ SetCapture(hWnd);
+
+ _glfwInputMouseClick(window, button, action, getKeyMods());
+
+ for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
+ {
+ if (window->mouseButtons[i] == GLFW_PRESS)
+ break;
+ }
+
+ if (i > GLFW_MOUSE_BUTTON_LAST)
+ ReleaseCapture();
+
+ if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP)
+ return TRUE;
+
+ return 0;
+ }
+
+ case WM_MOUSEMOVE:
+ {
+ const int x = GET_X_LPARAM(lParam);
+ const int y = GET_Y_LPARAM(lParam);
+
+ // Disabled cursor motion input is provided by WM_INPUT
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ break;
+
+ _glfwInputCursorPos(window, x, y);
+
+ window->win32.lastCursorPosX = x;
+ window->win32.lastCursorPosY = y;
+
+ if (!window->win32.cursorTracked)
+ {
+ TRACKMOUSEEVENT tme;
+ ZeroMemory(&tme, sizeof(tme));
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = window->win32.handle;
+ TrackMouseEvent(&tme);
+
+ window->win32.cursorTracked = GLFW_TRUE;
+ _glfwInputCursorEnter(window, GLFW_TRUE);
+ }
+
+ return 0;
+ }
+
+ case WM_INPUT:
+ {
+ UINT size;
+ HRAWINPUT ri = (HRAWINPUT) lParam;
+ RAWINPUT* data;
+ int dx, dy;
+
+ // Only process input when disabled cursor mode is applied
+ if (_glfw.win32.disabledCursorWindow != window)
+ break;
+
+ GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
+ if (size > (UINT) _glfw.win32.rawInputSize)
+ {
+ free(_glfw.win32.rawInput);
+ _glfw.win32.rawInput = calloc(size, 1);
+ _glfw.win32.rawInputSize = size;
+ }
+
+ size = _glfw.win32.rawInputSize;
+ if (GetRawInputData(ri, RID_INPUT,
+ _glfw.win32.rawInput, &size,
+ sizeof(RAWINPUTHEADER)) == (UINT) -1)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to retrieve raw input data");
+ break;
+ }
+
+ data = _glfw.win32.rawInput;
+ if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
+ {
+ dx = data->data.mouse.lLastX - window->win32.lastCursorPosX;
+ dy = data->data.mouse.lLastY - window->win32.lastCursorPosY;
+ }
+ else
+ {
+ dx = data->data.mouse.lLastX;
+ dy = data->data.mouse.lLastY;
+ }
+
+ _glfwInputCursorPos(window,
+ window->virtualCursorPosX + dx,
+ window->virtualCursorPosY + dy);
+
+ window->win32.lastCursorPosX += dx;
+ window->win32.lastCursorPosY += dy;
+ break;
+ }
+
+ case WM_MOUSELEAVE:
+ {
+ window->win32.cursorTracked = GLFW_FALSE;
+ _glfwInputCursorEnter(window, GLFW_FALSE);
+ return 0;
+ }
+
+ case WM_MOUSEWHEEL:
+ {
+ _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
+ return 0;
+ }
+
+ case WM_MOUSEHWHEEL:
+ {
+ // This message is only sent on Windows Vista and later
+ // NOTE: The X-axis is inverted for consistency with macOS and X11
+ _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
+ return 0;
+ }
+
+ case WM_ENTERSIZEMOVE:
+ case WM_ENTERMENULOOP:
+ {
+ // HACK: Enable the cursor while the user is moving or
+ // resizing the window or using the window menu
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ enableCursor(window);
+
+ break;
+ }
+
+ case WM_EXITSIZEMOVE:
+ case WM_EXITMENULOOP:
+ {
+ // HACK: Disable the cursor once the user is done moving or
+ // resizing the window or using the menu
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ disableCursor(window);
+
+ break;
+ }
+
+ case WM_SIZE:
+ {
+ const GLFWbool iconified = wParam == SIZE_MINIMIZED;
+ const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
+ (window->win32.maximized &&
+ wParam != SIZE_RESTORED);
+
+ if (_glfw.win32.disabledCursorWindow == window)
+ updateClipRect(window);
+
+ if (window->win32.iconified != iconified)
+ _glfwInputWindowIconify(window, iconified);
+
+ if (window->win32.maximized != maximized)
+ _glfwInputWindowMaximize(window, maximized);
+
+ _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
+ _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
+
+ if (window->monitor && window->win32.iconified != iconified)
+ {
+ if (iconified)
+ releaseMonitor(window);
+ else
+ {
+ acquireMonitor(window);
+ fitToMonitor(window);
+ }
+ }
+
+ window->win32.iconified = iconified;
+ window->win32.maximized = maximized;
+ return 0;
+ }
+
+ case WM_MOVE:
+ {
+ if (_glfw.win32.disabledCursorWindow == window)
+ updateClipRect(window);
+
+ // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
+ // those macros do not handle negative window positions correctly
+ _glfwInputWindowPos(window,
+ GET_X_LPARAM(lParam),
+ GET_Y_LPARAM(lParam));
+ return 0;
+ }
+
+ case WM_SIZING:
+ {
+ if (window->numer == GLFW_DONT_CARE ||
+ window->denom == GLFW_DONT_CARE)
+ {
+ break;
+ }
+
+ applyAspectRatio(window, (int) wParam, (RECT*) lParam);
+ return TRUE;
+ }
+
+ case WM_GETMINMAXINFO:
+ {
+ int xoff, yoff;
+ UINT dpi = USER_DEFAULT_SCREEN_DPI;
+ MINMAXINFO* mmi = (MINMAXINFO*) lParam;
+
+ if (window->monitor)
+ break;
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ dpi = GetDpiForWindow(window->win32.handle);
+
+ getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
+ 0, 0, &xoff, &yoff, dpi);
+
+ if (window->minwidth != GLFW_DONT_CARE &&
+ window->minheight != GLFW_DONT_CARE)
+ {
+ mmi->ptMinTrackSize.x = window->minwidth + xoff;
+ mmi->ptMinTrackSize.y = window->minheight + yoff;
+ }
+
+ if (window->maxwidth != GLFW_DONT_CARE &&
+ window->maxheight != GLFW_DONT_CARE)
+ {
+ mmi->ptMaxTrackSize.x = window->maxwidth + xoff;
+ mmi->ptMaxTrackSize.y = window->maxheight + yoff;
+ }
+
+ if (!window->decorated)
+ {
+ MONITORINFO mi;
+ const HMONITOR mh = MonitorFromWindow(window->win32.handle,
+ MONITOR_DEFAULTTONEAREST);
+
+ ZeroMemory(&mi, sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(mh, &mi);
+
+ mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
+ mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
+ mmi->ptMaxSize.x = mi.rcWork.right - mi.rcWork.left;
+ mmi->ptMaxSize.y = mi.rcWork.bottom - mi.rcWork.top;
+ }
+
+ return 0;
+ }
+
+ case WM_PAINT:
+ {
+ _glfwInputWindowDamage(window);
+ break;
+ }
+
+ case WM_ERASEBKGND:
+ {
+ return TRUE;
+ }
+
+ case WM_NCACTIVATE:
+ case WM_NCPAINT:
+ {
+ // Prevent title bar from being drawn after restoring a minimized
+ // undecorated window
+ if (!window->decorated)
+ return TRUE;
+
+ break;
+ }
+
+ case WM_DWMCOMPOSITIONCHANGED:
+ {
+ if (window->win32.transparent)
+ updateFramebufferTransparency(window);
+ return 0;
+ }
+
+ case WM_GETDPISCALEDSIZE:
+ {
+ if (window->win32.scaleToMonitor)
+ break;
+
+ // Adjust the window size to keep the client area size constant
+ if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
+ {
+ RECT source = {0}, target = {0};
+ SIZE* size = (SIZE*) lParam;
+
+ AdjustWindowRectExForDpi(&source, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ AdjustWindowRectExForDpi(&target, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ LOWORD(wParam));
+
+ size->cx += (target.right - target.left) -
+ (source.right - source.left);
+ size->cy += (target.bottom - target.top) -
+ (source.bottom - source.top);
+ return TRUE;
+ }
+
+ break;
+ }
+
+ case WM_DPICHANGED:
+ {
+ const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
+ const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
+
+ // Only apply the suggested size if the OS is new enough to have
+ // sent a WM_GETDPISCALEDSIZE before this
+ if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
+ {
+ RECT* suggested = (RECT*) lParam;
+ SetWindowPos(window->win32.handle, HWND_TOP,
+ suggested->left,
+ suggested->top,
+ suggested->right - suggested->left,
+ suggested->bottom - suggested->top,
+ SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+
+ _glfwInputWindowContentScale(window, xscale, yscale);
+ break;
+ }
+
+ case WM_SETCURSOR:
+ {
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ updateCursorImage(window);
+ return TRUE;
+ }
+
+ break;
+ }
+
+ case WM_DROPFILES:
+ {
+ HDROP drop = (HDROP) wParam;
+ POINT pt;
+ int i;
+
+ const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
+ char** paths = calloc(count, sizeof(char*));
+
+ // Move the mouse to the position of the drop
+ DragQueryPoint(drop, &pt);
+ _glfwInputCursorPos(window, pt.x, pt.y);
+
+ for (i = 0; i < count; i++)
+ {
+ const UINT length = DragQueryFileW(drop, i, NULL, 0);
+ WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
+
+ DragQueryFileW(drop, i, buffer, length + 1);
+ paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
+
+ free(buffer);
+ }
+
+ _glfwInputDrop(window, count, (const char**) paths);
+
+ for (i = 0; i < count; i++)
+ free(paths[i]);
+ free(paths);
+
+ DragFinish(drop);
+ return 0;
+ }
+ }
+
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+}
+
+// Creates the GLFW window
+//
+static int createNativeWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ int xpos, ypos, fullWidth, fullHeight;
+ WCHAR* wideTitle;
+ DWORD style = getWindowStyle(window);
+ DWORD exStyle = getWindowExStyle(window);
+
+ if (window->monitor)
+ {
+ GLFWvidmode mode;
+
+ // NOTE: This window placement is temporary and approximate, as the
+ // correct position and size cannot be known until the monitor
+ // video mode has been picked in _glfwSetVideoModeWin32
+ _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
+ _glfwPlatformGetVideoMode(window->monitor, &mode);
+ fullWidth = mode.width;
+ fullHeight = mode.height;
+ }
+ else
+ {
+ xpos = CW_USEDEFAULT;
+ ypos = CW_USEDEFAULT;
+
+ if (wndconfig->maximized)
+ style |= WS_MAXIMIZE;
+
+ getFullWindowSize(style, exStyle,
+ wndconfig->width, wndconfig->height,
+ &fullWidth, &fullHeight,
+ USER_DEFAULT_SCREEN_DPI);
+ }
+
+ wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
+ if (!wideTitle)
+ return GLFW_FALSE;
+
+ window->win32.handle = CreateWindowExW(exStyle,
+ _GLFW_WNDCLASSNAME,
+ wideTitle,
+ style,
+ xpos, ypos,
+ fullWidth, fullHeight,
+ NULL, // No parent window
+ NULL, // No window menu
+ GetModuleHandleW(NULL),
+ NULL);
+
+ free(wideTitle);
+
+ if (!window->win32.handle)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create window");
+ return GLFW_FALSE;
+ }
+
+ SetPropW(window->win32.handle, L"GLFW", window);
+
+ if (IsWindows7OrGreater())
+ {
+ ChangeWindowMessageFilterEx(window->win32.handle,
+ WM_DROPFILES, MSGFLT_ALLOW, NULL);
+ ChangeWindowMessageFilterEx(window->win32.handle,
+ WM_COPYDATA, MSGFLT_ALLOW, NULL);
+ ChangeWindowMessageFilterEx(window->win32.handle,
+ WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
+ }
+
+ window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
+
+ // Adjust window size to account for DPI scaling of the window frame and
+ // optionally DPI scaling of the client area
+ // This cannot be done until we know what monitor it was placed on
+ if (!window->monitor)
+ {
+ RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
+
+ if (wndconfig->scaleToMonitor)
+ {
+ float xscale, yscale;
+ _glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
+ rect.right = (int) (rect.right * xscale);
+ rect.bottom = (int) (rect.bottom * yscale);
+ }
+
+ ClientToScreen(window->win32.handle, (POINT*) &rect.left);
+ ClientToScreen(window->win32.handle, (POINT*) &rect.right);
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle,
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ AdjustWindowRectEx(&rect, style, FALSE, exStyle);
+
+ SetWindowPos(window->win32.handle, NULL,
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+
+ DragAcceptFiles(window->win32.handle, TRUE);
+
+ if (fbconfig->transparent)
+ {
+ updateFramebufferTransparency(window);
+ window->win32.transparent = GLFW_TRUE;
+ }
+
+ return GLFW_TRUE;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Registers the GLFW window class
+//
+GLFWbool _glfwRegisterWindowClassWin32(void)
+{
+ WNDCLASSEXW wc;
+
+ ZeroMemory(&wc, sizeof(wc));
+ wc.cbSize = sizeof(wc);
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ wc.lpfnWndProc = (WNDPROC) windowProc;
+ wc.hInstance = GetModuleHandleW(NULL);
+ wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
+ wc.lpszClassName = _GLFW_WNDCLASSNAME;
+
+ // Load user-provided icon if available
+ wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
+ L"GLFW_ICON", IMAGE_ICON,
+ 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+ if (!wc.hIcon)
+ {
+ // No user-provided icon found, load default icon
+ wc.hIcon = LoadImageW(NULL,
+ IDI_APPLICATION, IMAGE_ICON,
+ 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+ }
+
+ if (!RegisterClassExW(&wc))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to register window class");
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+// Unregisters the GLFW window class
+//
+void _glfwUnregisterWindowClassWin32(void)
+{
+ UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformCreateWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ if (!createNativeWindow(window, wndconfig, fbconfig))
+ return GLFW_FALSE;
+
+ if (ctxconfig->client != GLFW_NO_API)
+ {
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
+ {
+ if (!_glfwInitWGL())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
+ {
+ if (!_glfwInitEGL())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ if (!_glfwInitOSMesa())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ }
+
+ if (window->monitor)
+ {
+ _glfwPlatformShowWindow(window);
+ _glfwPlatformFocusWindow(window);
+ acquireMonitor(window);
+ fitToMonitor(window);
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyWindow(_GLFWwindow* window)
+{
+ if (window->monitor)
+ releaseMonitor(window);
+
+ if (window->context.destroy)
+ window->context.destroy(window);
+
+ if (_glfw.win32.disabledCursorWindow == window)
+ _glfw.win32.disabledCursorWindow = NULL;
+
+ if (window->win32.handle)
+ {
+ RemovePropW(window->win32.handle, L"GLFW");
+ DestroyWindow(window->win32.handle);
+ window->win32.handle = NULL;
+ }
+
+ if (window->win32.bigIcon)
+ DestroyIcon(window->win32.bigIcon);
+
+ if (window->win32.smallIcon)
+ DestroyIcon(window->win32.smallIcon);
+}
+
+void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
+{
+ WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
+ if (!wideTitle)
+ return;
+
+ SetWindowTextW(window->win32.handle, wideTitle);
+ free(wideTitle);
+}
+
+void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
+ int count, const GLFWimage* images)
+{
+ HICON bigIcon = NULL, smallIcon = NULL;
+
+ if (count)
+ {
+ const GLFWimage* bigImage = chooseImage(count, images,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON));
+ const GLFWimage* smallImage = chooseImage(count, images,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON));
+
+ bigIcon = createIcon(bigImage, 0, 0, GLFW_TRUE);
+ smallIcon = createIcon(smallImage, 0, 0, GLFW_TRUE);
+ }
+ else
+ {
+ bigIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICON);
+ smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
+ }
+
+ SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
+ SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
+
+ if (window->win32.bigIcon)
+ DestroyIcon(window->win32.bigIcon);
+
+ if (window->win32.smallIcon)
+ DestroyIcon(window->win32.smallIcon);
+
+ if (count)
+ {
+ window->win32.bigIcon = bigIcon;
+ window->win32.smallIcon = smallIcon;
+ }
+}
+
+void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
+{
+ POINT pos = { 0, 0 };
+ ClientToScreen(window->win32.handle, &pos);
+
+ if (xpos)
+ *xpos = pos.x;
+ if (ypos)
+ *ypos = pos.y;
+}
+
+void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
+{
+ RECT rect = { xpos, ypos, xpos, ypos };
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ {
+ AdjustWindowRectEx(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window));
+ }
+
+ SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,
+ SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
+}
+
+void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
+{
+ RECT area;
+ GetClientRect(window->win32.handle, &area);
+
+ if (width)
+ *width = area.right;
+ if (height)
+ *height = area.bottom;
+}
+
+void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
+{
+ if (window->monitor)
+ {
+ if (window->monitor->window == window)
+ {
+ acquireMonitor(window);
+ fitToMonitor(window);
+ }
+ }
+ else
+ {
+ RECT rect = { 0, 0, width, height };
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ {
+ AdjustWindowRectEx(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window));
+ }
+
+ SetWindowPos(window->win32.handle, HWND_TOP,
+ 0, 0, rect.right - rect.left, rect.bottom - rect.top,
+ SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
+ }
+}
+
+void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight)
+{
+ RECT area;
+
+ if ((minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) &&
+ (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE))
+ {
+ return;
+ }
+
+ GetWindowRect(window->win32.handle, &area);
+ MoveWindow(window->win32.handle,
+ area.left, area.top,
+ area.right - area.left,
+ area.bottom - area.top, TRUE);
+}
+
+void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
+{
+ RECT area;
+
+ if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
+ return;
+
+ GetWindowRect(window->win32.handle, &area);
+ applyAspectRatio(window, WMSZ_BOTTOMRIGHT, &area);
+ MoveWindow(window->win32.handle,
+ area.left, area.top,
+ area.right - area.left,
+ area.bottom - area.top, TRUE);
+}
+
+void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
+{
+ _glfwPlatformGetWindowSize(window, width, height);
+}
+
+void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
+ int* left, int* top,
+ int* right, int* bottom)
+{
+ RECT rect;
+ int width, height;
+
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ SetRect(&rect, 0, 0, width, height);
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ {
+ AdjustWindowRectEx(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window));
+ }
+
+ if (left)
+ *left = -rect.left;
+ if (top)
+ *top = -rect.top;
+ if (right)
+ *right = rect.right - width;
+ if (bottom)
+ *bottom = rect.bottom - height;
+}
+
+void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
+ float* xscale, float* yscale)
+{
+ const HANDLE handle = MonitorFromWindow(window->win32.handle,
+ MONITOR_DEFAULTTONEAREST);
+ _glfwGetMonitorContentScaleWin32(handle, xscale, yscale);
+}
+
+void _glfwPlatformIconifyWindow(_GLFWwindow* window)
+{
+ ShowWindow(window->win32.handle, SW_MINIMIZE);
+}
+
+void _glfwPlatformRestoreWindow(_GLFWwindow* window)
+{
+ ShowWindow(window->win32.handle, SW_RESTORE);
+}
+
+void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
+{
+ ShowWindow(window->win32.handle, SW_MAXIMIZE);
+}
+
+void _glfwPlatformShowWindow(_GLFWwindow* window)
+{
+ ShowWindow(window->win32.handle, SW_SHOWNA);
+}
+
+void _glfwPlatformHideWindow(_GLFWwindow* window)
+{
+ ShowWindow(window->win32.handle, SW_HIDE);
+}
+
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
+{
+ FlashWindow(window->win32.handle, TRUE);
+}
+
+void _glfwPlatformFocusWindow(_GLFWwindow* window)
+{
+ BringWindowToTop(window->win32.handle);
+ SetForegroundWindow(window->win32.handle);
+ SetFocus(window->win32.handle);
+}
+
+void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
+ _GLFWmonitor* monitor,
+ int xpos, int ypos,
+ int width, int height,
+ int refreshRate)
+{
+ if (window->monitor == monitor)
+ {
+ if (monitor)
+ {
+ if (monitor->window == window)
+ {
+ acquireMonitor(window);
+ fitToMonitor(window);
+ }
+ }
+ else
+ {
+ RECT rect = { xpos, ypos, xpos + width, ypos + height };
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ {
+ AdjustWindowRectEx(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window));
+ }
+
+ SetWindowPos(window->win32.handle, HWND_TOP,
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ SWP_NOCOPYBITS | SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+
+ return;
+ }
+
+ if (window->monitor)
+ releaseMonitor(window);
+
+ _glfwInputWindowMonitor(window, monitor);
+
+ if (monitor)
+ {
+ MONITORINFO mi = { sizeof(mi) };
+ UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
+
+ if (window->decorated)
+ {
+ DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
+ style &= ~WS_OVERLAPPEDWINDOW;
+ style |= getWindowStyle(window);
+ SetWindowLongW(window->win32.handle, GWL_STYLE, style);
+ flags |= SWP_FRAMECHANGED;
+ }
+
+ acquireMonitor(window);
+
+ GetMonitorInfo(window->monitor->win32.handle, &mi);
+ SetWindowPos(window->win32.handle, HWND_TOPMOST,
+ mi.rcMonitor.left,
+ mi.rcMonitor.top,
+ mi.rcMonitor.right - mi.rcMonitor.left,
+ mi.rcMonitor.bottom - mi.rcMonitor.top,
+ flags);
+ }
+ else
+ {
+ HWND after;
+ RECT rect = { xpos, ypos, xpos + width, ypos + height };
+ DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
+ UINT flags = SWP_NOACTIVATE | SWP_NOCOPYBITS;
+
+ if (window->decorated)
+ {
+ style &= ~WS_POPUP;
+ style |= getWindowStyle(window);
+ SetWindowLongW(window->win32.handle, GWL_STYLE, style);
+
+ flags |= SWP_FRAMECHANGED;
+ }
+
+ if (window->floating)
+ after = HWND_TOPMOST;
+ else
+ after = HWND_NOTOPMOST;
+
+ if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
+ {
+ AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window),
+ GetDpiForWindow(window->win32.handle));
+ }
+ else
+ {
+ AdjustWindowRectEx(&rect, getWindowStyle(window),
+ FALSE, getWindowExStyle(window));
+ }
+
+ SetWindowPos(window->win32.handle, after,
+ rect.left, rect.top,
+ rect.right - rect.left, rect.bottom - rect.top,
+ flags);
+ }
+}
+
+int _glfwPlatformWindowFocused(_GLFWwindow* window)
+{
+ return window->win32.handle == GetActiveWindow();
+}
+
+int _glfwPlatformWindowIconified(_GLFWwindow* window)
+{
+ return IsIconic(window->win32.handle);
+}
+
+int _glfwPlatformWindowVisible(_GLFWwindow* window)
+{
+ return IsWindowVisible(window->win32.handle);
+}
+
+int _glfwPlatformWindowMaximized(_GLFWwindow* window)
+{
+ return IsZoomed(window->win32.handle);
+}
+
+int _glfwPlatformWindowHovered(_GLFWwindow* window)
+{
+ return cursorInClientArea(window);
+}
+
+int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
+{
+ BOOL enabled;
+
+ if (!window->win32.transparent)
+ return GLFW_FALSE;
+
+ if (!IsWindowsVistaOrGreater())
+ return GLFW_FALSE;
+
+ return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled;
+}
+
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
+{
+ updateWindowStyles(window);
+}
+
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
+{
+ updateWindowStyles(window);
+}
+
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
+{
+ const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
+ SetWindowPos(window->win32.handle, after, 0, 0, 0, 0,
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+}
+
+float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
+{
+ BYTE alpha;
+ DWORD flags;
+
+ if ((GetWindowLongW(window->win32.handle, GWL_EXSTYLE) & WS_EX_LAYERED) &&
+ GetLayeredWindowAttributes(window->win32.handle, NULL, &alpha, &flags))
+ {
+ if (flags & LWA_ALPHA)
+ return alpha / 255.f;
+ }
+
+ return 1.f;
+}
+
+void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
+{
+ if (opacity < 1.f)
+ {
+ const BYTE alpha = (BYTE) (255 * opacity);
+ DWORD style = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
+ style |= WS_EX_LAYERED;
+ SetWindowLongW(window->win32.handle, GWL_EXSTYLE, style);
+ SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA);
+ }
+ else
+ {
+ DWORD style = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
+ style &= ~WS_EX_LAYERED;
+ SetWindowLongW(window->win32.handle, GWL_EXSTYLE, style);
+ }
+}
+
+void _glfwPlatformPollEvents(void)
+{
+ MSG msg;
+ HWND handle;
+ _GLFWwindow* window;
+
+ while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (msg.message == WM_QUIT)
+ {
+ // NOTE: While GLFW does not itself post WM_QUIT, other processes
+ // may post it to this one, for example Task Manager
+ // HACK: Treat WM_QUIT as a close on all windows
+
+ window = _glfw.windowListHead;
+ while (window)
+ {
+ _glfwInputWindowCloseRequest(window);
+ window = window->next;
+ }
+ }
+ else
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ }
+
+ handle = GetActiveWindow();
+ if (handle)
+ {
+ // NOTE: Shift keys on Windows tend to "stick" when both are pressed as
+ // no key up message is generated by the first key release
+ // The other half of this is in the handling of WM_KEYUP
+ // HACK: Query actual key state and synthesize release events as needed
+ window = GetPropW(handle, L"GLFW");
+ if (window)
+ {
+ const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;
+ const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;
+
+ if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
+ {
+ const int mods = getAsyncKeyMods();
+ const int scancode = _glfw.win32.scancodes[GLFW_KEY_LEFT_SHIFT];
+ _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods);
+ }
+ else if (!rshift && window->keys[GLFW_KEY_RIGHT_SHIFT] == GLFW_PRESS)
+ {
+ const int mods = getAsyncKeyMods();
+ const int scancode = _glfw.win32.scancodes[GLFW_KEY_RIGHT_SHIFT];
+ _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods);
+ }
+ }
+ }
+
+ window = _glfw.win32.disabledCursorWindow;
+ if (window)
+ {
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+
+ // NOTE: Re-center the cursor only if it has moved since the last call,
+ // to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
+ if (window->win32.lastCursorPosX != width / 2 ||
+ window->win32.lastCursorPosY != height / 2)
+ {
+ _glfwPlatformSetCursorPos(window, width / 2, height / 2);
+ }
+ }
+}
+
+void _glfwPlatformWaitEvents(void)
+{
+ WaitMessage();
+
+ _glfwPlatformPollEvents();
+}
+
+void _glfwPlatformWaitEventsTimeout(double timeout)
+{
+ MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
+
+ _glfwPlatformPollEvents();
+}
+
+void _glfwPlatformPostEmptyEvent(void)
+{
+ PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
+}
+
+void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
+{
+ POINT pos;
+
+ if (GetCursorPos(&pos))
+ {
+ ScreenToClient(window->win32.handle, &pos);
+
+ if (xpos)
+ *xpos = pos.x;
+ if (ypos)
+ *ypos = pos.y;
+ }
+}
+
+void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
+{
+ POINT pos = { (int) xpos, (int) ypos };
+
+ // Store the new position so it can be recognized later
+ window->win32.lastCursorPosX = pos.x;
+ window->win32.lastCursorPosY = pos.y;
+
+ ClientToScreen(window->win32.handle, &pos);
+ SetCursorPos(pos.x, pos.y);
+}
+
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
+{
+ if (mode == GLFW_CURSOR_DISABLED)
+ {
+ if (_glfwPlatformWindowFocused(window))
+ disableCursor(window);
+ }
+ else if (_glfw.win32.disabledCursorWindow == window)
+ enableCursor(window);
+ else if (cursorInClientArea(window))
+ updateCursorImage(window);
+}
+
+const char* _glfwPlatformGetScancodeName(int scancode)
+{
+ return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
+}
+
+int _glfwPlatformGetKeyScancode(int key)
+{
+ return _glfw.win32.scancodes[key];
+}
+
+int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
+ const GLFWimage* image,
+ int xhot, int yhot)
+{
+ cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
+ if (!cursor->win32.handle)
+ return GLFW_FALSE;
+
+ return GLFW_TRUE;
+}
+
+int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
+{
+ LPCWSTR name = NULL;
+
+ if (shape == GLFW_ARROW_CURSOR)
+ name = IDC_ARROW;
+ else if (shape == GLFW_IBEAM_CURSOR)
+ name = IDC_IBEAM;
+ else if (shape == GLFW_CROSSHAIR_CURSOR)
+ name = IDC_CROSS;
+ else if (shape == GLFW_HAND_CURSOR)
+ name = IDC_HAND;
+ else if (shape == GLFW_HRESIZE_CURSOR)
+ name = IDC_SIZEWE;
+ else if (shape == GLFW_VRESIZE_CURSOR)
+ name = IDC_SIZENS;
+ else
+ return GLFW_FALSE;
+
+ cursor->win32.handle = CopyCursor(LoadCursorW(NULL, name));
+ if (!cursor->win32.handle)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create standard cursor");
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
+{
+ if (cursor->win32.handle)
+ DestroyIcon((HICON) cursor->win32.handle);
+}
+
+void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
+{
+ if (cursorInClientArea(window))
+ updateCursorImage(window);
+}
+
+void _glfwPlatformSetClipboardString(const char* string)
+{
+ int characterCount;
+ HANDLE object;
+ WCHAR* buffer;
+
+ characterCount = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
+ if (!characterCount)
+ return;
+
+ object = GlobalAlloc(GMEM_MOVEABLE, characterCount * sizeof(WCHAR));
+ if (!object)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to allocate global handle for clipboard");
+ return;
+ }
+
+ buffer = GlobalLock(object);
+ if (!buffer)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to lock global handle");
+ GlobalFree(object);
+ return;
+ }
+
+ MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount);
+ GlobalUnlock(object);
+
+ if (!OpenClipboard(_glfw.win32.helperWindowHandle))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to open clipboard");
+ GlobalFree(object);
+ return;
+ }
+
+ EmptyClipboard();
+ SetClipboardData(CF_UNICODETEXT, object);
+ CloseClipboard();
+}
+
+const char* _glfwPlatformGetClipboardString(void)
+{
+ HANDLE object;
+ WCHAR* buffer;
+
+ if (!OpenClipboard(_glfw.win32.helperWindowHandle))
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to open clipboard");
+ return NULL;
+ }
+
+ object = GetClipboardData(CF_UNICODETEXT);
+ if (!object)
+ {
+ _glfwInputErrorWin32(GLFW_FORMAT_UNAVAILABLE,
+ "Win32: Failed to convert clipboard to string");
+ CloseClipboard();
+ return NULL;
+ }
+
+ buffer = GlobalLock(object);
+ if (!buffer)
+ {
+ _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to lock global handle");
+ CloseClipboard();
+ return NULL;
+ }
+
+ free(_glfw.win32.clipboardString);
+ _glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer);
+
+ GlobalUnlock(object);
+ CloseClipboard();
+
+ return _glfw.win32.clipboardString;
+}
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
+{
+ if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
+ return;
+
+ extensions[0] = "VK_KHR_surface";
+ extensions[1] = "VK_KHR_win32_surface";
+}
+
+int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily)
+{
+ PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
+ vkGetPhysicalDeviceWin32PresentationSupportKHR =
+ (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)
+ vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
+ if (!vkGetPhysicalDeviceWin32PresentationSupportKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
+ return GLFW_FALSE;
+ }
+
+ return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
+}
+
+VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
+ _GLFWwindow* window,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface)
+{
+ VkResult err;
+ VkWin32SurfaceCreateInfoKHR sci;
+ PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
+
+ vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
+ vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR");
+ if (!vkCreateWin32SurfaceKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ memset(&sci, 0, sizeof(sci));
+ sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
+ sci.hinstance = GetModuleHandle(NULL);
+ sci.hwnd = window->win32.handle;
+
+ err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface);
+ if (err)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Win32: Failed to create Vulkan surface: %s",
+ _glfwGetVulkanResultString(err));
+ }
+
+ return err;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return window->win32.handle;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/window.c b/Client/ThirdParty/Box2D/extern/glfw/src/window.c
new file mode 100644
index 0000000..4e365cb
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/window.c
@@ -0,0 +1,1113 @@
+//========================================================================
+// GLFW 3.3 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <float.h>
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW event API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Notifies shared code that a window has lost or received input focus
+//
+void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
+{
+ if (window->callbacks.focus)
+ window->callbacks.focus((GLFWwindow*) window, focused);
+
+ if (!focused)
+ {
+ int key, button;
+
+ for (key = 0; key <= GLFW_KEY_LAST; key++)
+ {
+ if (window->keys[key] == GLFW_PRESS)
+ {
+ const int scancode = _glfwPlatformGetKeyScancode(key);
+ _glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
+ }
+ }
+
+ for (button = 0; button <= GLFW_MOUSE_BUTTON_LAST; button++)
+ {
+ if (window->mouseButtons[button] == GLFW_PRESS)
+ _glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
+ }
+ }
+}
+
+// Notifies shared code that a window has moved
+// The position is specified in client-area relative screen coordinates
+//
+void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
+{
+ if (window->callbacks.pos)
+ window->callbacks.pos((GLFWwindow*) window, x, y);
+}
+
+// Notifies shared code that a window has been resized
+// The size is specified in screen coordinates
+//
+void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
+{
+ if (window->callbacks.size)
+ window->callbacks.size((GLFWwindow*) window, width, height);
+}
+
+// Notifies shared code that a window has been iconified or restored
+//
+void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
+{
+ if (window->callbacks.iconify)
+ window->callbacks.iconify((GLFWwindow*) window, iconified);
+}
+
+// Notifies shared code that a window has been maximized or restored
+//
+void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
+{
+ if (window->callbacks.maximize)
+ window->callbacks.maximize((GLFWwindow*) window, maximized);
+}
+
+// Notifies shared code that a window framebuffer has been resized
+// The size is specified in pixels
+//
+void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
+{
+ if (window->callbacks.fbsize)
+ window->callbacks.fbsize((GLFWwindow*) window, width, height);
+}
+
+// Notifies shared code that a window content scale has changed
+// The scale is specified as the ratio between the current and default DPI
+//
+void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
+{
+ if (window->callbacks.scale)
+ window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
+}
+
+// Notifies shared code that the window contents needs updating
+//
+void _glfwInputWindowDamage(_GLFWwindow* window)
+{
+ if (window->callbacks.refresh)
+ window->callbacks.refresh((GLFWwindow*) window);
+}
+
+// Notifies shared code that the user wishes to close a window
+//
+void _glfwInputWindowCloseRequest(_GLFWwindow* window)
+{
+ window->shouldClose = GLFW_TRUE;
+
+ if (window->callbacks.close)
+ window->callbacks.close((GLFWwindow*) window);
+}
+
+// Notifies shared code that a window has changed its desired monitor
+//
+void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
+{
+ window->monitor = monitor;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW public API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
+ const char* title,
+ GLFWmonitor* monitor,
+ GLFWwindow* share)
+{
+ _GLFWfbconfig fbconfig;
+ _GLFWctxconfig ctxconfig;
+ _GLFWwndconfig wndconfig;
+ _GLFWwindow* window;
+
+ assert(title != NULL);
+ assert(width >= 0);
+ assert(height >= 0);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+
+ if (width <= 0 || height <= 0)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid window size %ix%i",
+ width, height);
+
+ return NULL;
+ }
+
+ fbconfig = _glfw.hints.framebuffer;
+ ctxconfig = _glfw.hints.context;
+ wndconfig = _glfw.hints.window;
+
+ wndconfig.width = width;
+ wndconfig.height = height;
+ wndconfig.title = title;
+ ctxconfig.share = (_GLFWwindow*) share;
+
+ if (!_glfwIsValidContextConfig(&ctxconfig))
+ return NULL;
+
+ window = calloc(1, sizeof(_GLFWwindow));
+ window->next = _glfw.windowListHead;
+ _glfw.windowListHead = window;
+
+ window->videoMode.width = width;
+ window->videoMode.height = height;
+ window->videoMode.redBits = fbconfig.redBits;
+ window->videoMode.greenBits = fbconfig.greenBits;
+ window->videoMode.blueBits = fbconfig.blueBits;
+ window->videoMode.refreshRate = _glfw.hints.refreshRate;
+
+ window->monitor = (_GLFWmonitor*) monitor;
+ window->resizable = wndconfig.resizable;
+ window->decorated = wndconfig.decorated;
+ window->autoIconify = wndconfig.autoIconify;
+ window->floating = wndconfig.floating;
+ window->focusOnShow = wndconfig.focusOnShow;
+ window->cursorMode = GLFW_CURSOR_NORMAL;
+
+ window->minwidth = GLFW_DONT_CARE;
+ window->minheight = GLFW_DONT_CARE;
+ window->maxwidth = GLFW_DONT_CARE;
+ window->maxheight = GLFW_DONT_CARE;
+ window->numer = GLFW_DONT_CARE;
+ window->denom = GLFW_DONT_CARE;
+
+ // Open the actual window and create its context
+ if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
+ {
+ glfwDestroyWindow((GLFWwindow*) window);
+ return NULL;
+ }
+
+ if (ctxconfig.client != GLFW_NO_API)
+ {
+ if (!_glfwRefreshContextAttribs(window, &ctxconfig))
+ {
+ glfwDestroyWindow((GLFWwindow*) window);
+ return NULL;
+ }
+ }
+
+ if (window->monitor)
+ {
+ if (wndconfig.centerCursor)
+ {
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
+ }
+ }
+ else
+ {
+ if (wndconfig.visible)
+ {
+ _glfwPlatformShowWindow(window);
+ if (wndconfig.focused)
+ _glfwPlatformFocusWindow(window);
+ }
+ }
+
+ return (GLFWwindow*) window;
+}
+
+void glfwDefaultWindowHints(void)
+{
+ _GLFW_REQUIRE_INIT();
+
+ // The default is OpenGL with minimum version 1.0
+ memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
+ _glfw.hints.context.client = GLFW_OPENGL_API;
+ _glfw.hints.context.source = GLFW_NATIVE_CONTEXT_API;
+ _glfw.hints.context.major = 1;
+ _glfw.hints.context.minor = 0;
+
+ // The default is a focused, visible, resizable window with decorations
+ memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
+ _glfw.hints.window.resizable = GLFW_TRUE;
+ _glfw.hints.window.visible = GLFW_TRUE;
+ _glfw.hints.window.decorated = GLFW_TRUE;
+ _glfw.hints.window.focused = GLFW_TRUE;
+ _glfw.hints.window.autoIconify = GLFW_TRUE;
+ _glfw.hints.window.centerCursor = GLFW_TRUE;
+ _glfw.hints.window.focusOnShow = GLFW_TRUE;
+
+ // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
+ // double buffered
+ memset(&_glfw.hints.framebuffer, 0, sizeof(_glfw.hints.framebuffer));
+ _glfw.hints.framebuffer.redBits = 8;
+ _glfw.hints.framebuffer.greenBits = 8;
+ _glfw.hints.framebuffer.blueBits = 8;
+ _glfw.hints.framebuffer.alphaBits = 8;
+ _glfw.hints.framebuffer.depthBits = 24;
+ _glfw.hints.framebuffer.stencilBits = 8;
+ _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
+
+ // The default is to select the highest available refresh rate
+ _glfw.hints.refreshRate = GLFW_DONT_CARE;
+
+ // The default is to use full Retina resolution framebuffers
+ _glfw.hints.window.ns.retina = GLFW_TRUE;
+}
+
+GLFWAPI void glfwWindowHint(int hint, int value)
+{
+ _GLFW_REQUIRE_INIT();
+
+ switch (hint)
+ {
+ case GLFW_RED_BITS:
+ _glfw.hints.framebuffer.redBits = value;
+ return;
+ case GLFW_GREEN_BITS:
+ _glfw.hints.framebuffer.greenBits = value;
+ return;
+ case GLFW_BLUE_BITS:
+ _glfw.hints.framebuffer.blueBits = value;
+ return;
+ case GLFW_ALPHA_BITS:
+ _glfw.hints.framebuffer.alphaBits = value;
+ return;
+ case GLFW_DEPTH_BITS:
+ _glfw.hints.framebuffer.depthBits = value;
+ return;
+ case GLFW_STENCIL_BITS:
+ _glfw.hints.framebuffer.stencilBits = value;
+ return;
+ case GLFW_ACCUM_RED_BITS:
+ _glfw.hints.framebuffer.accumRedBits = value;
+ return;
+ case GLFW_ACCUM_GREEN_BITS:
+ _glfw.hints.framebuffer.accumGreenBits = value;
+ return;
+ case GLFW_ACCUM_BLUE_BITS:
+ _glfw.hints.framebuffer.accumBlueBits = value;
+ return;
+ case GLFW_ACCUM_ALPHA_BITS:
+ _glfw.hints.framebuffer.accumAlphaBits = value;
+ return;
+ case GLFW_AUX_BUFFERS:
+ _glfw.hints.framebuffer.auxBuffers = value;
+ return;
+ case GLFW_STEREO:
+ _glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_DOUBLEBUFFER:
+ _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_TRANSPARENT_FRAMEBUFFER:
+ _glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_SAMPLES:
+ _glfw.hints.framebuffer.samples = value;
+ return;
+ case GLFW_SRGB_CAPABLE:
+ _glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_RESIZABLE:
+ _glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_DECORATED:
+ _glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_FOCUSED:
+ _glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_AUTO_ICONIFY:
+ _glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_FLOATING:
+ _glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_MAXIMIZED:
+ _glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_VISIBLE:
+ _glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_COCOA_RETINA_FRAMEBUFFER:
+ _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_COCOA_GRAPHICS_SWITCHING:
+ _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_SCALE_TO_MONITOR:
+ _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_CENTER_CURSOR:
+ _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_FOCUS_ON_SHOW:
+ _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_CLIENT_API:
+ _glfw.hints.context.client = value;
+ return;
+ case GLFW_CONTEXT_CREATION_API:
+ _glfw.hints.context.source = value;
+ return;
+ case GLFW_CONTEXT_VERSION_MAJOR:
+ _glfw.hints.context.major = value;
+ return;
+ case GLFW_CONTEXT_VERSION_MINOR:
+ _glfw.hints.context.minor = value;
+ return;
+ case GLFW_CONTEXT_ROBUSTNESS:
+ _glfw.hints.context.robustness = value;
+ return;
+ case GLFW_OPENGL_FORWARD_COMPAT:
+ _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_OPENGL_DEBUG_CONTEXT:
+ _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_CONTEXT_NO_ERROR:
+ _glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE;
+ return;
+ case GLFW_OPENGL_PROFILE:
+ _glfw.hints.context.profile = value;
+ return;
+ case GLFW_CONTEXT_RELEASE_BEHAVIOR:
+ _glfw.hints.context.release = value;
+ return;
+ case GLFW_REFRESH_RATE:
+ _glfw.hints.refreshRate = value;
+ return;
+ }
+
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
+}
+
+GLFWAPI void glfwWindowHintString(int hint, const char* value)
+{
+ assert(value != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ switch (hint)
+ {
+ case GLFW_COCOA_FRAME_NAME:
+ strncpy(_glfw.hints.window.ns.frameName, value,
+ sizeof(_glfw.hints.window.ns.frameName) - 1);
+ return;
+ case GLFW_X11_CLASS_NAME:
+ strncpy(_glfw.hints.window.x11.className, value,
+ sizeof(_glfw.hints.window.x11.className) - 1);
+ return;
+ case GLFW_X11_INSTANCE_NAME:
+ strncpy(_glfw.hints.window.x11.instanceName, value,
+ sizeof(_glfw.hints.window.x11.instanceName) - 1);
+ return;
+ }
+
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
+}
+
+GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+
+ _GLFW_REQUIRE_INIT();
+
+ // Allow closing of NULL (to match the behavior of free)
+ if (window == NULL)
+ return;
+
+ // Clear all callbacks to avoid exposing a half torn-down window object
+ memset(&window->callbacks, 0, sizeof(window->callbacks));
+
+ // The window's context must not be current on another thread when the
+ // window is destroyed
+ if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
+ glfwMakeContextCurrent(NULL);
+
+ _glfwPlatformDestroyWindow(window);
+
+ // Unlink window from global linked list
+ {
+ _GLFWwindow** prev = &_glfw.windowListHead;
+
+ while (*prev != window)
+ prev = &((*prev)->next);
+
+ *prev = window->next;
+ }
+
+ free(window);
+}
+
+GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(0);
+ return window->shouldClose;
+}
+
+GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ window->shouldClose = value;
+}
+
+GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+ assert(title != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformSetWindowTitle(window, title);
+}
+
+GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
+ int count, const GLFWimage* images)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+ assert(count >= 0);
+ assert(count == 0 || images != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformSetWindowIcon(window, count, images);
+}
+
+GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ if (xpos)
+ *xpos = 0;
+ if (ypos)
+ *ypos = 0;
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformGetWindowPos(window, xpos, ypos);
+}
+
+GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window->monitor)
+ return;
+
+ _glfwPlatformSetWindowPos(window, xpos, ypos);
+}
+
+GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ if (width)
+ *width = 0;
+ if (height)
+ *height = 0;
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformGetWindowSize(window, width, height);
+}
+
+GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+ assert(width >= 0);
+ assert(height >= 0);
+
+ _GLFW_REQUIRE_INIT();
+
+ window->videoMode.width = width;
+ window->videoMode.height = height;
+
+ _glfwPlatformSetWindowSize(window, width, height);
+}
+
+GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE)
+ {
+ if (minwidth < 0 || minheight < 0)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid window minimum size %ix%i",
+ minwidth, minheight);
+ return;
+ }
+ }
+
+ if (maxwidth != GLFW_DONT_CARE && maxheight != GLFW_DONT_CARE)
+ {
+ if (maxwidth < 0 || maxheight < 0 ||
+ maxwidth < minwidth || maxheight < minheight)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid window maximum size %ix%i",
+ maxwidth, maxheight);
+ return;
+ }
+ }
+
+ window->minwidth = minwidth;
+ window->minheight = minheight;
+ window->maxwidth = maxwidth;
+ window->maxheight = maxheight;
+
+ if (window->monitor || !window->resizable)
+ return;
+
+ _glfwPlatformSetWindowSizeLimits(window,
+ minwidth, minheight,
+ maxwidth, maxheight);
+}
+
+GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+ assert(numer != 0);
+ assert(denom != 0);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
+ {
+ if (numer <= 0 || denom <= 0)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid window aspect ratio %i:%i",
+ numer, denom);
+ return;
+ }
+ }
+
+ window->numer = numer;
+ window->denom = denom;
+
+ if (window->monitor || !window->resizable)
+ return;
+
+ _glfwPlatformSetWindowAspectRatio(window, numer, denom);
+}
+
+GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ if (width)
+ *width = 0;
+ if (height)
+ *height = 0;
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformGetFramebufferSize(window, width, height);
+}
+
+GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
+ int* left, int* top,
+ int* right, int* bottom)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ if (left)
+ *left = 0;
+ if (top)
+ *top = 0;
+ if (right)
+ *right = 0;
+ if (bottom)
+ *bottom = 0;
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
+}
+
+GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
+ float* xscale, float* yscale)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ if (xscale)
+ *xscale = 0.f;
+ if (yscale)
+ *yscale = 0.f;
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformGetWindowContentScale(window, xscale, yscale);
+}
+
+GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(1.f);
+ return _glfwPlatformGetWindowOpacity(window);
+}
+
+GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+ assert(opacity == opacity);
+ assert(opacity >= 0.f);
+ assert(opacity <= 1.f);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (opacity != opacity || opacity < 0.f || opacity > 1.f)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity);
+ return;
+ }
+
+ _glfwPlatformSetWindowOpacity(window, opacity);
+}
+
+GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformIconifyWindow(window);
+}
+
+GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformRestoreWindow(window);
+}
+
+GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window->monitor)
+ return;
+
+ _glfwPlatformMaximizeWindow(window);
+}
+
+GLFWAPI void glfwShowWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window->monitor)
+ return;
+
+ _glfwPlatformShowWindow(window);
+
+ if (window->focusOnShow)
+ _glfwPlatformFocusWindow(window);
+}
+
+GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ _glfwPlatformRequestWindowAttention(window);
+}
+
+GLFWAPI void glfwHideWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (window->monitor)
+ return;
+
+ _glfwPlatformHideWindow(window);
+}
+
+GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ _glfwPlatformFocusWindow(window);
+}
+
+GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(0);
+
+ switch (attrib)
+ {
+ case GLFW_FOCUSED:
+ return _glfwPlatformWindowFocused(window);
+ case GLFW_ICONIFIED:
+ return _glfwPlatformWindowIconified(window);
+ case GLFW_VISIBLE:
+ return _glfwPlatformWindowVisible(window);
+ case GLFW_MAXIMIZED:
+ return _glfwPlatformWindowMaximized(window);
+ case GLFW_HOVERED:
+ return _glfwPlatformWindowHovered(window);
+ case GLFW_FOCUS_ON_SHOW:
+ return window->focusOnShow;
+ case GLFW_TRANSPARENT_FRAMEBUFFER:
+ return _glfwPlatformFramebufferTransparent(window);
+ case GLFW_RESIZABLE:
+ return window->resizable;
+ case GLFW_DECORATED:
+ return window->decorated;
+ case GLFW_FLOATING:
+ return window->floating;
+ case GLFW_AUTO_ICONIFY:
+ return window->autoIconify;
+ case GLFW_CLIENT_API:
+ return window->context.client;
+ case GLFW_CONTEXT_CREATION_API:
+ return window->context.source;
+ case GLFW_CONTEXT_VERSION_MAJOR:
+ return window->context.major;
+ case GLFW_CONTEXT_VERSION_MINOR:
+ return window->context.minor;
+ case GLFW_CONTEXT_REVISION:
+ return window->context.revision;
+ case GLFW_CONTEXT_ROBUSTNESS:
+ return window->context.robustness;
+ case GLFW_OPENGL_FORWARD_COMPAT:
+ return window->context.forward;
+ case GLFW_OPENGL_DEBUG_CONTEXT:
+ return window->context.debug;
+ case GLFW_OPENGL_PROFILE:
+ return window->context.profile;
+ case GLFW_CONTEXT_RELEASE_BEHAVIOR:
+ return window->context.release;
+ case GLFW_CONTEXT_NO_ERROR:
+ return window->context.noerror;
+ }
+
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
+ return 0;
+}
+
+GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+
+ value = value ? GLFW_TRUE : GLFW_FALSE;
+
+ if (attrib == GLFW_AUTO_ICONIFY)
+ window->autoIconify = value;
+ else if (attrib == GLFW_RESIZABLE)
+ {
+ if (window->resizable == value)
+ return;
+
+ window->resizable = value;
+ if (!window->monitor)
+ _glfwPlatformSetWindowResizable(window, value);
+ }
+ else if (attrib == GLFW_DECORATED)
+ {
+ if (window->decorated == value)
+ return;
+
+ window->decorated = value;
+ if (!window->monitor)
+ _glfwPlatformSetWindowDecorated(window, value);
+ }
+ else if (attrib == GLFW_FLOATING)
+ {
+ if (window->floating == value)
+ return;
+
+ window->floating = value;
+ if (!window->monitor)
+ _glfwPlatformSetWindowFloating(window, value);
+ }
+ else if (attrib == GLFW_FOCUS_ON_SHOW)
+ window->focusOnShow = value;
+ else
+ _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
+}
+
+GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return (GLFWmonitor*) window->monitor;
+}
+
+GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
+ GLFWmonitor* mh,
+ int xpos, int ypos,
+ int width, int height,
+ int refreshRate)
+{
+ _GLFWwindow* window = (_GLFWwindow*) wh;
+ _GLFWmonitor* monitor = (_GLFWmonitor*) mh;
+ assert(window != NULL);
+ assert(width >= 0);
+ assert(height >= 0);
+
+ _GLFW_REQUIRE_INIT();
+
+ if (width <= 0 || height <= 0)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid window size %ix%i",
+ width, height);
+ return;
+ }
+
+ if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE,
+ "Invalid refresh rate %i",
+ refreshRate);
+ return;
+ }
+
+ window->videoMode.width = width;
+ window->videoMode.height = height;
+ window->videoMode.refreshRate = refreshRate;
+
+ _glfwPlatformSetWindowMonitor(window, monitor,
+ xpos, ypos, width, height,
+ refreshRate);
+}
+
+GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT();
+ window->userPointer = pointer;
+}
+
+GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return window->userPointer;
+}
+
+GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
+ GLFWwindowposfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
+ GLFWwindowsizefun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
+ GLFWwindowclosefun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
+ GLFWwindowrefreshfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
+ GLFWwindowfocusfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
+ GLFWwindowiconifyfun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
+ GLFWwindowmaximizefun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
+ GLFWframebuffersizefun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
+ return cbfun;
+}
+
+GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle,
+ GLFWwindowcontentscalefun cbfun)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ assert(window != NULL);
+
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ _GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
+ return cbfun;
+}
+
+GLFWAPI void glfwPollEvents(void)
+{
+ _GLFW_REQUIRE_INIT();
+ _glfwPlatformPollEvents();
+}
+
+GLFWAPI void glfwWaitEvents(void)
+{
+ _GLFW_REQUIRE_INIT();
+
+ if (!_glfw.windowListHead)
+ return;
+
+ _glfwPlatformWaitEvents();
+}
+
+GLFWAPI void glfwWaitEventsTimeout(double timeout)
+{
+ _GLFW_REQUIRE_INIT();
+ assert(timeout == timeout);
+ assert(timeout >= 0.0);
+ assert(timeout <= DBL_MAX);
+
+ if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
+ {
+ _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout);
+ return;
+ }
+
+ _glfwPlatformWaitEventsTimeout(timeout);
+}
+
+GLFWAPI void glfwPostEmptyEvent(void)
+{
+ _GLFW_REQUIRE_INIT();
+
+ if (!_glfw.windowListHead)
+ return;
+
+ _glfwPlatformPostEmptyEvent();
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/wl_init.c b/Client/ThirdParty/Box2D/extern/glfw/src/wl_init.c
new file mode 100644
index 0000000..c6b209b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/wl_init.c
@@ -0,0 +1,1318 @@
+//========================================================================
+// GLFW 3.3 Wayland - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <linux/input.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/timerfd.h>
+#include <unistd.h>
+#include <wayland-client.h>
+
+
+static inline int min(int n1, int n2)
+{
+ return n1 < n2 ? n1 : n2;
+}
+
+static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
+ int* which)
+{
+ int focus;
+ _GLFWwindow* window = _glfw.windowListHead;
+ if (!which)
+ which = &focus;
+ while (window)
+ {
+ if (surface == window->wl.decorations.top.surface)
+ {
+ *which = topDecoration;
+ break;
+ }
+ if (surface == window->wl.decorations.left.surface)
+ {
+ *which = leftDecoration;
+ break;
+ }
+ if (surface == window->wl.decorations.right.surface)
+ {
+ *which = rightDecoration;
+ break;
+ }
+ if (surface == window->wl.decorations.bottom.surface)
+ {
+ *which = bottomDecoration;
+ break;
+ }
+ window = window->next;
+ }
+ return window;
+}
+
+static void pointerHandleEnter(void* data,
+ struct wl_pointer* pointer,
+ uint32_t serial,
+ struct wl_surface* surface,
+ wl_fixed_t sx,
+ wl_fixed_t sy)
+{
+ // Happens in the case we just destroyed the surface.
+ if (!surface)
+ return;
+
+ int focus = 0;
+ _GLFWwindow* window = wl_surface_get_user_data(surface);
+ if (!window)
+ {
+ window = findWindowFromDecorationSurface(surface, &focus);
+ if (!window)
+ return;
+ }
+
+ window->wl.decorations.focus = focus;
+ _glfw.wl.serial = serial;
+ _glfw.wl.pointerFocus = window;
+
+ window->wl.hovered = GLFW_TRUE;
+
+ _glfwPlatformSetCursor(window, window->wl.currentCursor);
+ _glfwInputCursorEnter(window, GLFW_TRUE);
+}
+
+static void pointerHandleLeave(void* data,
+ struct wl_pointer* pointer,
+ uint32_t serial,
+ struct wl_surface* surface)
+{
+ _GLFWwindow* window = _glfw.wl.pointerFocus;
+
+ if (!window)
+ return;
+
+ window->wl.hovered = GLFW_FALSE;
+
+ _glfw.wl.serial = serial;
+ _glfw.wl.pointerFocus = NULL;
+ _glfwInputCursorEnter(window, GLFW_FALSE);
+}
+
+static void setCursor(_GLFWwindow* window, const char* name)
+{
+ struct wl_buffer* buffer;
+ struct wl_cursor* cursor;
+ struct wl_cursor_image* image;
+ struct wl_surface* surface = _glfw.wl.cursorSurface;
+ struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
+ int scale = 1;
+
+ if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI)
+ {
+ // We only support up to scale=2 for now, since libwayland-cursor
+ // requires us to load a different theme for each size.
+ scale = 2;
+ theme = _glfw.wl.cursorThemeHiDPI;
+ }
+
+ cursor = wl_cursor_theme_get_cursor(theme, name);
+ if (!cursor)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Standard cursor not found");
+ return;
+ }
+ // TODO: handle animated cursors too.
+ image = cursor->images[0];
+
+ if (!image)
+ return;
+
+ buffer = wl_cursor_image_get_buffer(image);
+ if (!buffer)
+ return;
+ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
+ surface,
+ image->hotspot_x / scale,
+ image->hotspot_y / scale);
+ wl_surface_set_buffer_scale(surface, scale);
+ wl_surface_attach(surface, buffer, 0, 0);
+ wl_surface_damage(surface, 0, 0,
+ image->width, image->height);
+ wl_surface_commit(surface);
+}
+
+static void pointerHandleMotion(void* data,
+ struct wl_pointer* pointer,
+ uint32_t time,
+ wl_fixed_t sx,
+ wl_fixed_t sy)
+{
+ _GLFWwindow* window = _glfw.wl.pointerFocus;
+ const char* cursorName;
+
+ if (!window)
+ return;
+
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ return;
+ else
+ {
+ window->wl.cursorPosX = wl_fixed_to_double(sx);
+ window->wl.cursorPosY = wl_fixed_to_double(sy);
+ }
+
+ switch (window->wl.decorations.focus)
+ {
+ case mainWindow:
+ _glfwInputCursorPos(window,
+ wl_fixed_to_double(sx),
+ wl_fixed_to_double(sy));
+ return;
+ case topDecoration:
+ if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
+ cursorName = "n-resize";
+ else
+ cursorName = "left_ptr";
+ break;
+ case leftDecoration:
+ if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
+ cursorName = "nw-resize";
+ else
+ cursorName = "w-resize";
+ break;
+ case rightDecoration:
+ if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
+ cursorName = "ne-resize";
+ else
+ cursorName = "e-resize";
+ break;
+ case bottomDecoration:
+ if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
+ cursorName = "sw-resize";
+ else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
+ cursorName = "se-resize";
+ else
+ cursorName = "s-resize";
+ break;
+ default:
+ assert(0);
+ }
+ setCursor(window, cursorName);
+}
+
+static void pointerHandleButton(void* data,
+ struct wl_pointer* pointer,
+ uint32_t serial,
+ uint32_t time,
+ uint32_t button,
+ uint32_t state)
+{
+ _GLFWwindow* window = _glfw.wl.pointerFocus;
+ int glfwButton;
+
+ // Both xdg-shell and wl_shell use the same values.
+ uint32_t edges = WL_SHELL_SURFACE_RESIZE_NONE;
+
+ if (!window)
+ return;
+ if (button == BTN_LEFT)
+ {
+ switch (window->wl.decorations.focus)
+ {
+ case mainWindow:
+ break;
+ case topDecoration:
+ if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
+ edges = WL_SHELL_SURFACE_RESIZE_TOP;
+ else
+ {
+ if (window->wl.xdg.toplevel)
+ xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
+ else
+ wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
+ }
+ break;
+ case leftDecoration:
+ if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
+ edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
+ else
+ edges = WL_SHELL_SURFACE_RESIZE_LEFT;
+ break;
+ case rightDecoration:
+ if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
+ edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
+ else
+ edges = WL_SHELL_SURFACE_RESIZE_RIGHT;
+ break;
+ case bottomDecoration:
+ if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
+ edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
+ else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
+ edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
+ else
+ edges = WL_SHELL_SURFACE_RESIZE_BOTTOM;
+ break;
+ default:
+ assert(0);
+ }
+ if (edges != WL_SHELL_SURFACE_RESIZE_NONE)
+ {
+ if (window->wl.xdg.toplevel)
+ xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
+ serial, edges);
+ else
+ wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
+ serial, edges);
+ }
+ }
+ else if (button == BTN_RIGHT)
+ {
+ if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
+ {
+ xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
+ _glfw.wl.seat, serial,
+ window->wl.cursorPosX,
+ window->wl.cursorPosY);
+ return;
+ }
+ }
+
+ // Don’t pass the button to the user if it was related to a decoration.
+ if (window->wl.decorations.focus != mainWindow)
+ return;
+
+ _glfw.wl.serial = serial;
+
+ /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
+ * codes. */
+ glfwButton = button - BTN_LEFT;
+
+ _glfwInputMouseClick(window,
+ glfwButton,
+ state == WL_POINTER_BUTTON_STATE_PRESSED
+ ? GLFW_PRESS
+ : GLFW_RELEASE,
+ _glfw.wl.xkb.modifiers);
+}
+
+static void pointerHandleAxis(void* data,
+ struct wl_pointer* pointer,
+ uint32_t time,
+ uint32_t axis,
+ wl_fixed_t value)
+{
+ _GLFWwindow* window = _glfw.wl.pointerFocus;
+ double x = 0.0, y = 0.0;
+ // Wayland scroll events are in pointer motion coordinate space (think two
+ // finger scroll). The factor 10 is commonly used to convert to "scroll
+ // step means 1.0.
+ const double scrollFactor = 1.0 / 10.0;
+
+ if (!window)
+ return;
+
+ assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
+ axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
+
+ if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
+ x = wl_fixed_to_double(value) * scrollFactor;
+ else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
+ y = wl_fixed_to_double(value) * scrollFactor;
+
+ _glfwInputScroll(window, x, y);
+}
+
+static const struct wl_pointer_listener pointerListener = {
+ pointerHandleEnter,
+ pointerHandleLeave,
+ pointerHandleMotion,
+ pointerHandleButton,
+ pointerHandleAxis,
+};
+
+static void keyboardHandleKeymap(void* data,
+ struct wl_keyboard* keyboard,
+ uint32_t format,
+ int fd,
+ uint32_t size)
+{
+ struct xkb_keymap* keymap;
+ struct xkb_state* state;
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ struct xkb_compose_table* composeTable;
+ struct xkb_compose_state* composeState;
+#endif
+
+ char* mapStr;
+ const char* locale;
+
+ if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
+ {
+ close(fd);
+ return;
+ }
+
+ mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
+ if (mapStr == MAP_FAILED) {
+ close(fd);
+ return;
+ }
+
+ keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context,
+ mapStr,
+ XKB_KEYMAP_FORMAT_TEXT_V1,
+ 0);
+ munmap(mapStr, size);
+ close(fd);
+
+ if (!keymap)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to compile keymap");
+ return;
+ }
+
+ state = xkb_state_new(keymap);
+ if (!state)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to create XKB state");
+ xkb_keymap_unref(keymap);
+ return;
+ }
+
+ // Look up the preferred locale, falling back to "C" as default.
+ locale = getenv("LC_ALL");
+ if (!locale)
+ locale = getenv("LC_CTYPE");
+ if (!locale)
+ locale = getenv("LANG");
+ if (!locale)
+ locale = "C";
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ composeTable =
+ xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ if (composeTable)
+ {
+ composeState =
+ xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
+ xkb_compose_table_unref(composeTable);
+ if (composeState)
+ _glfw.wl.xkb.composeState = composeState;
+ else
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to create XKB compose state");
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to create XKB compose table");
+ }
+#endif
+
+ xkb_keymap_unref(_glfw.wl.xkb.keymap);
+ xkb_state_unref(_glfw.wl.xkb.state);
+ _glfw.wl.xkb.keymap = keymap;
+ _glfw.wl.xkb.state = state;
+
+ _glfw.wl.xkb.controlMask =
+ 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
+ _glfw.wl.xkb.altMask =
+ 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
+ _glfw.wl.xkb.shiftMask =
+ 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
+ _glfw.wl.xkb.superMask =
+ 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
+ _glfw.wl.xkb.capsLockMask =
+ 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
+ _glfw.wl.xkb.numLockMask =
+ 1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
+}
+
+static void keyboardHandleEnter(void* data,
+ struct wl_keyboard* keyboard,
+ uint32_t serial,
+ struct wl_surface* surface,
+ struct wl_array* keys)
+{
+ // Happens in the case we just destroyed the surface.
+ if (!surface)
+ return;
+
+ _GLFWwindow* window = wl_surface_get_user_data(surface);
+ if (!window)
+ {
+ window = findWindowFromDecorationSurface(surface, NULL);
+ if (!window)
+ return;
+ }
+
+ _glfw.wl.serial = serial;
+ _glfw.wl.keyboardFocus = window;
+ _glfwInputWindowFocus(window, GLFW_TRUE);
+}
+
+static void keyboardHandleLeave(void* data,
+ struct wl_keyboard* keyboard,
+ uint32_t serial,
+ struct wl_surface* surface)
+{
+ _GLFWwindow* window = _glfw.wl.keyboardFocus;
+
+ if (!window)
+ return;
+
+ _glfw.wl.serial = serial;
+ _glfw.wl.keyboardFocus = NULL;
+ _glfwInputWindowFocus(window, GLFW_FALSE);
+}
+
+static int toGLFWKeyCode(uint32_t key)
+{
+ if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
+ return _glfw.wl.keycodes[key];
+
+ return GLFW_KEY_UNKNOWN;
+}
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
+{
+ if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
+ return sym;
+ if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym)
+ != XKB_COMPOSE_FEED_ACCEPTED)
+ return sym;
+ switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState))
+ {
+ case XKB_COMPOSE_COMPOSED:
+ return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState);
+ case XKB_COMPOSE_COMPOSING:
+ case XKB_COMPOSE_CANCELLED:
+ return XKB_KEY_NoSymbol;
+ case XKB_COMPOSE_NOTHING:
+ default:
+ return sym;
+ }
+}
+#endif
+
+static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
+{
+ uint32_t code, numSyms;
+ long cp;
+ const xkb_keysym_t *syms;
+ xkb_keysym_t sym;
+
+ code = key + 8;
+ numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms);
+
+ if (numSyms == 1)
+ {
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ sym = composeSymbol(syms[0]);
+#else
+ sym = syms[0];
+#endif
+ cp = _glfwKeySym2Unicode(sym);
+ if (cp != -1)
+ {
+ const int mods = _glfw.wl.xkb.modifiers;
+ const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
+ _glfwInputChar(window, cp, mods, plain);
+ }
+ }
+
+ return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]);
+}
+
+static void keyboardHandleKey(void* data,
+ struct wl_keyboard* keyboard,
+ uint32_t serial,
+ uint32_t time,
+ uint32_t key,
+ uint32_t state)
+{
+ int keyCode;
+ int action;
+ _GLFWwindow* window = _glfw.wl.keyboardFocus;
+ GLFWbool shouldRepeat;
+ struct itimerspec timer = {};
+
+ if (!window)
+ return;
+
+ keyCode = toGLFWKeyCode(key);
+ action = state == WL_KEYBOARD_KEY_STATE_PRESSED
+ ? GLFW_PRESS : GLFW_RELEASE;
+
+ _glfw.wl.serial = serial;
+ _glfwInputKey(window, keyCode, key, action,
+ _glfw.wl.xkb.modifiers);
+
+ if (action == GLFW_PRESS)
+ {
+ shouldRepeat = inputChar(window, key);
+
+ if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
+ {
+ _glfw.wl.keyboardLastKey = keyCode;
+ _glfw.wl.keyboardLastScancode = key;
+ timer.it_interval.tv_sec = _glfw.wl.keyboardRepeatRate / 1000;
+ timer.it_interval.tv_nsec = (_glfw.wl.keyboardRepeatRate % 1000) * 1000000;
+ timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
+ timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
+ }
+ }
+ timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
+}
+
+static void keyboardHandleModifiers(void* data,
+ struct wl_keyboard* keyboard,
+ uint32_t serial,
+ uint32_t modsDepressed,
+ uint32_t modsLatched,
+ uint32_t modsLocked,
+ uint32_t group)
+{
+ xkb_mod_mask_t mask;
+ unsigned int modifiers = 0;
+
+ _glfw.wl.serial = serial;
+
+ if (!_glfw.wl.xkb.keymap)
+ return;
+
+ xkb_state_update_mask(_glfw.wl.xkb.state,
+ modsDepressed,
+ modsLatched,
+ modsLocked,
+ 0,
+ 0,
+ group);
+
+ mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
+ XKB_STATE_MODS_DEPRESSED |
+ XKB_STATE_LAYOUT_DEPRESSED |
+ XKB_STATE_MODS_LATCHED |
+ XKB_STATE_LAYOUT_LATCHED);
+ if (mask & _glfw.wl.xkb.controlMask)
+ modifiers |= GLFW_MOD_CONTROL;
+ if (mask & _glfw.wl.xkb.altMask)
+ modifiers |= GLFW_MOD_ALT;
+ if (mask & _glfw.wl.xkb.shiftMask)
+ modifiers |= GLFW_MOD_SHIFT;
+ if (mask & _glfw.wl.xkb.superMask)
+ modifiers |= GLFW_MOD_SUPER;
+ if (mask & _glfw.wl.xkb.capsLockMask)
+ modifiers |= GLFW_MOD_CAPS_LOCK;
+ if (mask & _glfw.wl.xkb.numLockMask)
+ modifiers |= GLFW_MOD_NUM_LOCK;
+ _glfw.wl.xkb.modifiers = modifiers;
+}
+
+#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
+static void keyboardHandleRepeatInfo(void* data,
+ struct wl_keyboard* keyboard,
+ int32_t rate,
+ int32_t delay)
+{
+ if (keyboard != _glfw.wl.keyboard)
+ return;
+
+ _glfw.wl.keyboardRepeatRate = rate;
+ _glfw.wl.keyboardRepeatDelay = delay;
+}
+#endif
+
+static const struct wl_keyboard_listener keyboardListener = {
+ keyboardHandleKeymap,
+ keyboardHandleEnter,
+ keyboardHandleLeave,
+ keyboardHandleKey,
+ keyboardHandleModifiers,
+#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
+ keyboardHandleRepeatInfo,
+#endif
+};
+
+static void seatHandleCapabilities(void* data,
+ struct wl_seat* seat,
+ enum wl_seat_capability caps)
+{
+ if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)
+ {
+ _glfw.wl.pointer = wl_seat_get_pointer(seat);
+ wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
+ }
+ else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
+ {
+ wl_pointer_destroy(_glfw.wl.pointer);
+ _glfw.wl.pointer = NULL;
+ }
+
+ if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)
+ {
+ _glfw.wl.keyboard = wl_seat_get_keyboard(seat);
+ wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);
+ }
+ else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
+ {
+ wl_keyboard_destroy(_glfw.wl.keyboard);
+ _glfw.wl.keyboard = NULL;
+ }
+}
+
+static void seatHandleName(void* data,
+ struct wl_seat* seat,
+ const char* name)
+{
+}
+
+static const struct wl_seat_listener seatListener = {
+ seatHandleCapabilities,
+ seatHandleName,
+};
+
+static void dataOfferHandleOffer(void* data,
+ struct wl_data_offer* dataOffer,
+ const char* mimeType)
+{
+}
+
+static const struct wl_data_offer_listener dataOfferListener = {
+ dataOfferHandleOffer,
+};
+
+static void dataDeviceHandleDataOffer(void* data,
+ struct wl_data_device* dataDevice,
+ struct wl_data_offer* id)
+{
+ if (_glfw.wl.dataOffer)
+ wl_data_offer_destroy(_glfw.wl.dataOffer);
+
+ _glfw.wl.dataOffer = id;
+ wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL);
+}
+
+static void dataDeviceHandleEnter(void* data,
+ struct wl_data_device* dataDevice,
+ uint32_t serial,
+ struct wl_surface *surface,
+ wl_fixed_t x,
+ wl_fixed_t y,
+ struct wl_data_offer *id)
+{
+}
+
+static void dataDeviceHandleLeave(void* data,
+ struct wl_data_device* dataDevice)
+{
+}
+
+static void dataDeviceHandleMotion(void* data,
+ struct wl_data_device* dataDevice,
+ uint32_t time,
+ wl_fixed_t x,
+ wl_fixed_t y)
+{
+}
+
+static void dataDeviceHandleDrop(void* data,
+ struct wl_data_device* dataDevice)
+{
+}
+
+static void dataDeviceHandleSelection(void* data,
+ struct wl_data_device* dataDevice,
+ struct wl_data_offer* id)
+{
+}
+
+static const struct wl_data_device_listener dataDeviceListener = {
+ dataDeviceHandleDataOffer,
+ dataDeviceHandleEnter,
+ dataDeviceHandleLeave,
+ dataDeviceHandleMotion,
+ dataDeviceHandleDrop,
+ dataDeviceHandleSelection,
+};
+
+static void wmBaseHandlePing(void* data,
+ struct xdg_wm_base* wmBase,
+ uint32_t serial)
+{
+ xdg_wm_base_pong(wmBase, serial);
+}
+
+static const struct xdg_wm_base_listener wmBaseListener = {
+ wmBaseHandlePing
+};
+
+static void registryHandleGlobal(void* data,
+ struct wl_registry* registry,
+ uint32_t name,
+ const char* interface,
+ uint32_t version)
+{
+ if (strcmp(interface, "wl_compositor") == 0)
+ {
+ _glfw.wl.compositorVersion = min(3, version);
+ _glfw.wl.compositor =
+ wl_registry_bind(registry, name, &wl_compositor_interface,
+ _glfw.wl.compositorVersion);
+ }
+ else if (strcmp(interface, "wl_subcompositor") == 0)
+ {
+ _glfw.wl.subcompositor =
+ wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
+ }
+ else if (strcmp(interface, "wl_shm") == 0)
+ {
+ _glfw.wl.shm =
+ wl_registry_bind(registry, name, &wl_shm_interface, 1);
+ }
+ else if (strcmp(interface, "wl_shell") == 0)
+ {
+ _glfw.wl.shell =
+ wl_registry_bind(registry, name, &wl_shell_interface, 1);
+ }
+ else if (strcmp(interface, "wl_output") == 0)
+ {
+ _glfwAddOutputWayland(name, version);
+ }
+ else if (strcmp(interface, "wl_seat") == 0)
+ {
+ if (!_glfw.wl.seat)
+ {
+ _glfw.wl.seatVersion = min(4, version);
+ _glfw.wl.seat =
+ wl_registry_bind(registry, name, &wl_seat_interface,
+ _glfw.wl.seatVersion);
+ wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL);
+ }
+ }
+ else if (strcmp(interface, "wl_data_device_manager") == 0)
+ {
+ if (!_glfw.wl.dataDeviceManager)
+ {
+ _glfw.wl.dataDeviceManager =
+ wl_registry_bind(registry, name,
+ &wl_data_device_manager_interface, 1);
+ }
+ }
+ else if (strcmp(interface, "xdg_wm_base") == 0)
+ {
+ _glfw.wl.wmBase =
+ wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
+ xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL);
+ }
+ else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0)
+ {
+ _glfw.wl.decorationManager =
+ wl_registry_bind(registry, name,
+ &zxdg_decoration_manager_v1_interface,
+ 1);
+ }
+ else if (strcmp(interface, "wp_viewporter") == 0)
+ {
+ _glfw.wl.viewporter =
+ wl_registry_bind(registry, name, &wp_viewporter_interface, 1);
+ }
+ else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0)
+ {
+ _glfw.wl.relativePointerManager =
+ wl_registry_bind(registry, name,
+ &zwp_relative_pointer_manager_v1_interface,
+ 1);
+ }
+ else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0)
+ {
+ _glfw.wl.pointerConstraints =
+ wl_registry_bind(registry, name,
+ &zwp_pointer_constraints_v1_interface,
+ 1);
+ }
+ else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
+ {
+ _glfw.wl.idleInhibitManager =
+ wl_registry_bind(registry, name,
+ &zwp_idle_inhibit_manager_v1_interface,
+ 1);
+ }
+}
+
+static void registryHandleGlobalRemove(void *data,
+ struct wl_registry *registry,
+ uint32_t name)
+{
+ int i;
+ _GLFWmonitor* monitor;
+
+ for (i = 0; i < _glfw.monitorCount; ++i)
+ {
+ monitor = _glfw.monitors[i];
+ if (monitor->wl.name == name)
+ {
+ _glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
+ return;
+ }
+ }
+}
+
+
+static const struct wl_registry_listener registryListener = {
+ registryHandleGlobal,
+ registryHandleGlobalRemove
+};
+
+// Create key code translation tables
+//
+static void createKeyTables(void)
+{
+ int scancode;
+
+ memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
+ memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
+
+ _glfw.wl.keycodes[KEY_GRAVE] = GLFW_KEY_GRAVE_ACCENT;
+ _glfw.wl.keycodes[KEY_1] = GLFW_KEY_1;
+ _glfw.wl.keycodes[KEY_2] = GLFW_KEY_2;
+ _glfw.wl.keycodes[KEY_3] = GLFW_KEY_3;
+ _glfw.wl.keycodes[KEY_4] = GLFW_KEY_4;
+ _glfw.wl.keycodes[KEY_5] = GLFW_KEY_5;
+ _glfw.wl.keycodes[KEY_6] = GLFW_KEY_6;
+ _glfw.wl.keycodes[KEY_7] = GLFW_KEY_7;
+ _glfw.wl.keycodes[KEY_8] = GLFW_KEY_8;
+ _glfw.wl.keycodes[KEY_9] = GLFW_KEY_9;
+ _glfw.wl.keycodes[KEY_0] = GLFW_KEY_0;
+ _glfw.wl.keycodes[KEY_SPACE] = GLFW_KEY_SPACE;
+ _glfw.wl.keycodes[KEY_MINUS] = GLFW_KEY_MINUS;
+ _glfw.wl.keycodes[KEY_EQUAL] = GLFW_KEY_EQUAL;
+ _glfw.wl.keycodes[KEY_Q] = GLFW_KEY_Q;
+ _glfw.wl.keycodes[KEY_W] = GLFW_KEY_W;
+ _glfw.wl.keycodes[KEY_E] = GLFW_KEY_E;
+ _glfw.wl.keycodes[KEY_R] = GLFW_KEY_R;
+ _glfw.wl.keycodes[KEY_T] = GLFW_KEY_T;
+ _glfw.wl.keycodes[KEY_Y] = GLFW_KEY_Y;
+ _glfw.wl.keycodes[KEY_U] = GLFW_KEY_U;
+ _glfw.wl.keycodes[KEY_I] = GLFW_KEY_I;
+ _glfw.wl.keycodes[KEY_O] = GLFW_KEY_O;
+ _glfw.wl.keycodes[KEY_P] = GLFW_KEY_P;
+ _glfw.wl.keycodes[KEY_LEFTBRACE] = GLFW_KEY_LEFT_BRACKET;
+ _glfw.wl.keycodes[KEY_RIGHTBRACE] = GLFW_KEY_RIGHT_BRACKET;
+ _glfw.wl.keycodes[KEY_A] = GLFW_KEY_A;
+ _glfw.wl.keycodes[KEY_S] = GLFW_KEY_S;
+ _glfw.wl.keycodes[KEY_D] = GLFW_KEY_D;
+ _glfw.wl.keycodes[KEY_F] = GLFW_KEY_F;
+ _glfw.wl.keycodes[KEY_G] = GLFW_KEY_G;
+ _glfw.wl.keycodes[KEY_H] = GLFW_KEY_H;
+ _glfw.wl.keycodes[KEY_J] = GLFW_KEY_J;
+ _glfw.wl.keycodes[KEY_K] = GLFW_KEY_K;
+ _glfw.wl.keycodes[KEY_L] = GLFW_KEY_L;
+ _glfw.wl.keycodes[KEY_SEMICOLON] = GLFW_KEY_SEMICOLON;
+ _glfw.wl.keycodes[KEY_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
+ _glfw.wl.keycodes[KEY_Z] = GLFW_KEY_Z;
+ _glfw.wl.keycodes[KEY_X] = GLFW_KEY_X;
+ _glfw.wl.keycodes[KEY_C] = GLFW_KEY_C;
+ _glfw.wl.keycodes[KEY_V] = GLFW_KEY_V;
+ _glfw.wl.keycodes[KEY_B] = GLFW_KEY_B;
+ _glfw.wl.keycodes[KEY_N] = GLFW_KEY_N;
+ _glfw.wl.keycodes[KEY_M] = GLFW_KEY_M;
+ _glfw.wl.keycodes[KEY_COMMA] = GLFW_KEY_COMMA;
+ _glfw.wl.keycodes[KEY_DOT] = GLFW_KEY_PERIOD;
+ _glfw.wl.keycodes[KEY_SLASH] = GLFW_KEY_SLASH;
+ _glfw.wl.keycodes[KEY_BACKSLASH] = GLFW_KEY_BACKSLASH;
+ _glfw.wl.keycodes[KEY_ESC] = GLFW_KEY_ESCAPE;
+ _glfw.wl.keycodes[KEY_TAB] = GLFW_KEY_TAB;
+ _glfw.wl.keycodes[KEY_LEFTSHIFT] = GLFW_KEY_LEFT_SHIFT;
+ _glfw.wl.keycodes[KEY_RIGHTSHIFT] = GLFW_KEY_RIGHT_SHIFT;
+ _glfw.wl.keycodes[KEY_LEFTCTRL] = GLFW_KEY_LEFT_CONTROL;
+ _glfw.wl.keycodes[KEY_RIGHTCTRL] = GLFW_KEY_RIGHT_CONTROL;
+ _glfw.wl.keycodes[KEY_LEFTALT] = GLFW_KEY_LEFT_ALT;
+ _glfw.wl.keycodes[KEY_RIGHTALT] = GLFW_KEY_RIGHT_ALT;
+ _glfw.wl.keycodes[KEY_LEFTMETA] = GLFW_KEY_LEFT_SUPER;
+ _glfw.wl.keycodes[KEY_RIGHTMETA] = GLFW_KEY_RIGHT_SUPER;
+ _glfw.wl.keycodes[KEY_MENU] = GLFW_KEY_MENU;
+ _glfw.wl.keycodes[KEY_NUMLOCK] = GLFW_KEY_NUM_LOCK;
+ _glfw.wl.keycodes[KEY_CAPSLOCK] = GLFW_KEY_CAPS_LOCK;
+ _glfw.wl.keycodes[KEY_PRINT] = GLFW_KEY_PRINT_SCREEN;
+ _glfw.wl.keycodes[KEY_SCROLLLOCK] = GLFW_KEY_SCROLL_LOCK;
+ _glfw.wl.keycodes[KEY_PAUSE] = GLFW_KEY_PAUSE;
+ _glfw.wl.keycodes[KEY_DELETE] = GLFW_KEY_DELETE;
+ _glfw.wl.keycodes[KEY_BACKSPACE] = GLFW_KEY_BACKSPACE;
+ _glfw.wl.keycodes[KEY_ENTER] = GLFW_KEY_ENTER;
+ _glfw.wl.keycodes[KEY_HOME] = GLFW_KEY_HOME;
+ _glfw.wl.keycodes[KEY_END] = GLFW_KEY_END;
+ _glfw.wl.keycodes[KEY_PAGEUP] = GLFW_KEY_PAGE_UP;
+ _glfw.wl.keycodes[KEY_PAGEDOWN] = GLFW_KEY_PAGE_DOWN;
+ _glfw.wl.keycodes[KEY_INSERT] = GLFW_KEY_INSERT;
+ _glfw.wl.keycodes[KEY_LEFT] = GLFW_KEY_LEFT;
+ _glfw.wl.keycodes[KEY_RIGHT] = GLFW_KEY_RIGHT;
+ _glfw.wl.keycodes[KEY_DOWN] = GLFW_KEY_DOWN;
+ _glfw.wl.keycodes[KEY_UP] = GLFW_KEY_UP;
+ _glfw.wl.keycodes[KEY_F1] = GLFW_KEY_F1;
+ _glfw.wl.keycodes[KEY_F2] = GLFW_KEY_F2;
+ _glfw.wl.keycodes[KEY_F3] = GLFW_KEY_F3;
+ _glfw.wl.keycodes[KEY_F4] = GLFW_KEY_F4;
+ _glfw.wl.keycodes[KEY_F5] = GLFW_KEY_F5;
+ _glfw.wl.keycodes[KEY_F6] = GLFW_KEY_F6;
+ _glfw.wl.keycodes[KEY_F7] = GLFW_KEY_F7;
+ _glfw.wl.keycodes[KEY_F8] = GLFW_KEY_F8;
+ _glfw.wl.keycodes[KEY_F9] = GLFW_KEY_F9;
+ _glfw.wl.keycodes[KEY_F10] = GLFW_KEY_F10;
+ _glfw.wl.keycodes[KEY_F11] = GLFW_KEY_F11;
+ _glfw.wl.keycodes[KEY_F12] = GLFW_KEY_F12;
+ _glfw.wl.keycodes[KEY_F13] = GLFW_KEY_F13;
+ _glfw.wl.keycodes[KEY_F14] = GLFW_KEY_F14;
+ _glfw.wl.keycodes[KEY_F15] = GLFW_KEY_F15;
+ _glfw.wl.keycodes[KEY_F16] = GLFW_KEY_F16;
+ _glfw.wl.keycodes[KEY_F17] = GLFW_KEY_F17;
+ _glfw.wl.keycodes[KEY_F18] = GLFW_KEY_F18;
+ _glfw.wl.keycodes[KEY_F19] = GLFW_KEY_F19;
+ _glfw.wl.keycodes[KEY_F20] = GLFW_KEY_F20;
+ _glfw.wl.keycodes[KEY_F21] = GLFW_KEY_F21;
+ _glfw.wl.keycodes[KEY_F22] = GLFW_KEY_F22;
+ _glfw.wl.keycodes[KEY_F23] = GLFW_KEY_F23;
+ _glfw.wl.keycodes[KEY_F24] = GLFW_KEY_F24;
+ _glfw.wl.keycodes[KEY_KPSLASH] = GLFW_KEY_KP_DIVIDE;
+ _glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_MULTIPLY;
+ _glfw.wl.keycodes[KEY_KPMINUS] = GLFW_KEY_KP_SUBTRACT;
+ _glfw.wl.keycodes[KEY_KPPLUS] = GLFW_KEY_KP_ADD;
+ _glfw.wl.keycodes[KEY_KP0] = GLFW_KEY_KP_0;
+ _glfw.wl.keycodes[KEY_KP1] = GLFW_KEY_KP_1;
+ _glfw.wl.keycodes[KEY_KP2] = GLFW_KEY_KP_2;
+ _glfw.wl.keycodes[KEY_KP3] = GLFW_KEY_KP_3;
+ _glfw.wl.keycodes[KEY_KP4] = GLFW_KEY_KP_4;
+ _glfw.wl.keycodes[KEY_KP5] = GLFW_KEY_KP_5;
+ _glfw.wl.keycodes[KEY_KP6] = GLFW_KEY_KP_6;
+ _glfw.wl.keycodes[KEY_KP7] = GLFW_KEY_KP_7;
+ _glfw.wl.keycodes[KEY_KP8] = GLFW_KEY_KP_8;
+ _glfw.wl.keycodes[KEY_KP9] = GLFW_KEY_KP_9;
+ _glfw.wl.keycodes[KEY_KPCOMMA] = GLFW_KEY_KP_DECIMAL;
+ _glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
+ _glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
+
+ for (scancode = 0; scancode < 256; scancode++)
+ {
+ if (_glfw.wl.keycodes[scancode] > 0)
+ _glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformInit(void)
+{
+ const char *cursorTheme;
+ const char *cursorSizeStr;
+ char *cursorSizeEnd;
+ long cursorSizeLong;
+ int cursorSize;
+
+ _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
+ if (!_glfw.wl.cursor.handle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to open libwayland-cursor");
+ return GLFW_FALSE;
+ }
+
+ _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
+ _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
+ _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
+ _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
+ _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
+ _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
+ _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
+ _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
+
+ _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
+ if (!_glfw.wl.egl.handle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to open libwayland-egl");
+ return GLFW_FALSE;
+ }
+
+ _glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
+ _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create");
+ _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
+ _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy");
+ _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
+ _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize");
+
+ _glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0");
+ if (!_glfw.wl.xkb.handle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to open libxkbcommon");
+ return GLFW_FALSE;
+ }
+
+ _glfw.wl.xkb.context_new = (PFN_xkb_context_new)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new");
+ _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref");
+ _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
+ _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref");
+ _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
+ _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
+ _glfw.wl.xkb.state_new = (PFN_xkb_state_new)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new");
+ _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref");
+ _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
+ _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
+ _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
+ _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
+ _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new");
+ _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
+ _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
+ _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
+ _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
+ _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
+#endif
+
+ _glfw.wl.display = wl_display_connect(NULL);
+ if (!_glfw.wl.display)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to connect to display");
+ return GLFW_FALSE;
+ }
+
+ _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
+ wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
+
+ createKeyTables();
+
+ _glfw.wl.xkb.context = xkb_context_new(0);
+ if (!_glfw.wl.xkb.context)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to initialize xkb context");
+ return GLFW_FALSE;
+ }
+
+ // Sync so we got all registry objects
+ wl_display_roundtrip(_glfw.wl.display);
+
+ // Sync so we got all initial output events
+ wl_display_roundtrip(_glfw.wl.display);
+
+#ifdef __linux__
+ if (!_glfwInitJoysticksLinux())
+ return GLFW_FALSE;
+#endif
+
+ _glfwInitTimerPOSIX();
+
+ _glfw.wl.timerfd = -1;
+ if (_glfw.wl.seatVersion >= 4)
+ _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
+
+ if (_glfw.wl.pointer && _glfw.wl.shm)
+ {
+ cursorTheme = getenv("XCURSOR_THEME");
+ cursorSizeStr = getenv("XCURSOR_SIZE");
+ cursorSize = 32;
+ if (cursorSizeStr)
+ {
+ errno = 0;
+ cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
+ if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
+ cursorSize = (int)cursorSizeLong;
+ }
+ _glfw.wl.cursorTheme =
+ wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
+ if (!_glfw.wl.cursorTheme)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Unable to load default cursor theme");
+ return GLFW_FALSE;
+ }
+ // If this happens to be NULL, we just fallback to the scale=1 version.
+ _glfw.wl.cursorThemeHiDPI =
+ wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
+ _glfw.wl.cursorSurface =
+ wl_compositor_create_surface(_glfw.wl.compositor);
+ _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
+ }
+
+ if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
+ {
+ _glfw.wl.dataDevice =
+ wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
+ _glfw.wl.seat);
+ wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
+ _glfw.wl.clipboardString = malloc(4096);
+ if (!_glfw.wl.clipboardString)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Unable to allocate clipboard memory");
+ return GLFW_FALSE;
+ }
+ _glfw.wl.clipboardSize = 4096;
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformTerminate(void)
+{
+#ifdef __linux__
+ _glfwTerminateJoysticksLinux();
+#endif
+ _glfwTerminateEGL();
+ if (_glfw.wl.egl.handle)
+ {
+ _glfw_dlclose(_glfw.wl.egl.handle);
+ _glfw.wl.egl.handle = NULL;
+ }
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ if (_glfw.wl.xkb.composeState)
+ xkb_compose_state_unref(_glfw.wl.xkb.composeState);
+#endif
+ if (_glfw.wl.xkb.keymap)
+ xkb_keymap_unref(_glfw.wl.xkb.keymap);
+ if (_glfw.wl.xkb.state)
+ xkb_state_unref(_glfw.wl.xkb.state);
+ if (_glfw.wl.xkb.context)
+ xkb_context_unref(_glfw.wl.xkb.context);
+ if (_glfw.wl.xkb.handle)
+ {
+ _glfw_dlclose(_glfw.wl.xkb.handle);
+ _glfw.wl.xkb.handle = NULL;
+ }
+
+ if (_glfw.wl.cursorTheme)
+ wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
+ if (_glfw.wl.cursorThemeHiDPI)
+ wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
+ if (_glfw.wl.cursor.handle)
+ {
+ _glfw_dlclose(_glfw.wl.cursor.handle);
+ _glfw.wl.cursor.handle = NULL;
+ }
+
+ if (_glfw.wl.cursorSurface)
+ wl_surface_destroy(_glfw.wl.cursorSurface);
+ if (_glfw.wl.subcompositor)
+ wl_subcompositor_destroy(_glfw.wl.subcompositor);
+ if (_glfw.wl.compositor)
+ wl_compositor_destroy(_glfw.wl.compositor);
+ if (_glfw.wl.shm)
+ wl_shm_destroy(_glfw.wl.shm);
+ if (_glfw.wl.shell)
+ wl_shell_destroy(_glfw.wl.shell);
+ if (_glfw.wl.viewporter)
+ wp_viewporter_destroy(_glfw.wl.viewporter);
+ if (_glfw.wl.decorationManager)
+ zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager);
+ if (_glfw.wl.wmBase)
+ xdg_wm_base_destroy(_glfw.wl.wmBase);
+ if (_glfw.wl.dataSource)
+ wl_data_source_destroy(_glfw.wl.dataSource);
+ if (_glfw.wl.dataDevice)
+ wl_data_device_destroy(_glfw.wl.dataDevice);
+ if (_glfw.wl.dataOffer)
+ wl_data_offer_destroy(_glfw.wl.dataOffer);
+ if (_glfw.wl.dataDeviceManager)
+ wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager);
+ if (_glfw.wl.pointer)
+ wl_pointer_destroy(_glfw.wl.pointer);
+ if (_glfw.wl.keyboard)
+ wl_keyboard_destroy(_glfw.wl.keyboard);
+ if (_glfw.wl.seat)
+ wl_seat_destroy(_glfw.wl.seat);
+ if (_glfw.wl.relativePointerManager)
+ zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
+ if (_glfw.wl.pointerConstraints)
+ zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
+ if (_glfw.wl.idleInhibitManager)
+ zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
+ if (_glfw.wl.registry)
+ wl_registry_destroy(_glfw.wl.registry);
+ if (_glfw.wl.display)
+ {
+ wl_display_flush(_glfw.wl.display);
+ wl_display_disconnect(_glfw.wl.display);
+ }
+
+ if (_glfw.wl.timerfd >= 0)
+ close(_glfw.wl.timerfd);
+ if (_glfw.wl.cursorTimerfd >= 0)
+ close(_glfw.wl.cursorTimerfd);
+
+ if (_glfw.wl.clipboardString)
+ free(_glfw.wl.clipboardString);
+ if (_glfw.wl.clipboardSendString)
+ free(_glfw.wl.clipboardSendString);
+}
+
+const char* _glfwPlatformGetVersionString(void)
+{
+ return _GLFW_VERSION_NUMBER " Wayland EGL"
+#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
+ " clock_gettime"
+#else
+ " gettimeofday"
+#endif
+ " evdev"
+#if defined(_GLFW_BUILD_DLL)
+ " shared"
+#endif
+ ;
+}
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/wl_monitor.c b/Client/ThirdParty/Box2D/extern/glfw/src/wl_monitor.c
new file mode 100644
index 0000000..588f8b0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/wl_monitor.c
@@ -0,0 +1,208 @@
+//========================================================================
+// GLFW 3.3 Wayland - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+
+static void outputHandleGeometry(void* data,
+ struct wl_output* output,
+ int32_t x,
+ int32_t y,
+ int32_t physicalWidth,
+ int32_t physicalHeight,
+ int32_t subpixel,
+ const char* make,
+ const char* model,
+ int32_t transform)
+{
+ struct _GLFWmonitor *monitor = data;
+ char name[1024];
+
+ monitor->wl.x = x;
+ monitor->wl.y = y;
+ monitor->widthMM = physicalWidth;
+ monitor->heightMM = physicalHeight;
+
+ snprintf(name, sizeof(name), "%s %s", make, model);
+ monitor->name = _glfw_strdup(name);
+}
+
+static void outputHandleMode(void* data,
+ struct wl_output* output,
+ uint32_t flags,
+ int32_t width,
+ int32_t height,
+ int32_t refresh)
+{
+ struct _GLFWmonitor *monitor = data;
+ GLFWvidmode mode;
+
+ mode.width = width;
+ mode.height = height;
+ mode.redBits = 8;
+ mode.greenBits = 8;
+ mode.blueBits = 8;
+ mode.refreshRate = refresh / 1000;
+
+ monitor->modeCount++;
+ monitor->modes =
+ realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
+ monitor->modes[monitor->modeCount - 1] = mode;
+
+ if (flags & WL_OUTPUT_MODE_CURRENT)
+ monitor->wl.currentMode = monitor->modeCount - 1;
+}
+
+static void outputHandleDone(void* data, struct wl_output* output)
+{
+ struct _GLFWmonitor *monitor = data;
+
+ _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
+}
+
+static void outputHandleScale(void* data,
+ struct wl_output* output,
+ int32_t factor)
+{
+ struct _GLFWmonitor *monitor = data;
+
+ monitor->wl.scale = factor;
+}
+
+static const struct wl_output_listener outputListener = {
+ outputHandleGeometry,
+ outputHandleMode,
+ outputHandleDone,
+ outputHandleScale,
+};
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwAddOutputWayland(uint32_t name, uint32_t version)
+{
+ _GLFWmonitor *monitor;
+ struct wl_output *output;
+
+ if (version < 2)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Unsupported output interface version");
+ return;
+ }
+
+ // The actual name of this output will be set in the geometry handler.
+ monitor = _glfwAllocMonitor(NULL, 0, 0);
+
+ output = wl_registry_bind(_glfw.wl.registry,
+ name,
+ &wl_output_interface,
+ 2);
+ if (!output)
+ {
+ _glfwFreeMonitor(monitor);
+ return;
+ }
+
+ monitor->wl.scale = 1;
+ monitor->wl.output = output;
+ monitor->wl.name = name;
+
+ wl_output_add_listener(output, &outputListener, monitor);
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
+{
+ if (monitor->wl.output)
+ wl_output_destroy(monitor->wl.output);
+}
+
+void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
+{
+ if (xpos)
+ *xpos = monitor->wl.x;
+ if (ypos)
+ *ypos = monitor->wl.y;
+}
+
+void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
+ float* xscale, float* yscale)
+{
+ if (xscale)
+ *xscale = (float) monitor->wl.scale;
+ if (yscale)
+ *yscale = (float) monitor->wl.scale;
+}
+
+GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
+{
+ *found = monitor->modeCount;
+ return monitor->modes;
+}
+
+void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
+{
+ *mode = monitor->modes[monitor->wl.currentMode];
+}
+
+GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Gamma ramp access it not available");
+ return GLFW_FALSE;
+}
+
+void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
+ const GLFWgammaramp* ramp)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Gamma ramp access is not available");
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return monitor->wl.output;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/wl_platform.h b/Client/ThirdParty/Box2D/extern/glfw/src/wl_platform.h
new file mode 100644
index 0000000..c17ebe8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/wl_platform.h
@@ -0,0 +1,359 @@
+//========================================================================
+// GLFW 3.3 Wayland - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <wayland-client.h>
+#include <xkbcommon/xkbcommon.h>
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+#include <xkbcommon/xkbcommon-compose.h>
+#endif
+#include <dlfcn.h>
+
+typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
+
+typedef struct VkWaylandSurfaceCreateInfoKHR
+{
+ VkStructureType sType;
+ const void* pNext;
+ VkWaylandSurfaceCreateFlagsKHR flags;
+ struct wl_display* display;
+ struct wl_surface* surface;
+} VkWaylandSurfaceCreateInfoKHR;
+
+typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
+typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
+
+#include "posix_thread.h"
+#include "posix_time.h"
+#ifdef __linux__
+#include "linux_joystick.h"
+#else
+#include "null_joystick.h"
+#endif
+#include "xkb_unicode.h"
+#include "egl_context.h"
+#include "osmesa_context.h"
+
+#include "wayland-xdg-shell-client-protocol.h"
+#include "wayland-xdg-decoration-client-protocol.h"
+#include "wayland-viewporter-client-protocol.h"
+#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
+#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
+#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
+
+#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
+#define _glfw_dlclose(handle) dlclose(handle)
+#define _glfw_dlsym(handle, name) dlsym(handle, name)
+
+#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->wl.native)
+#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.wl.display)
+
+#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
+#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
+#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
+#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
+
+#define _GLFW_PLATFORM_CONTEXT_STATE
+#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
+
+struct wl_cursor_image {
+ uint32_t width;
+ uint32_t height;
+ uint32_t hotspot_x;
+ uint32_t hotspot_y;
+ uint32_t delay;
+};
+struct wl_cursor {
+ unsigned int image_count;
+ struct wl_cursor_image** images;
+ char* name;
+};
+typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*);
+typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*);
+typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*);
+typedef struct wl_buffer* (* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image*);
+#define wl_cursor_theme_load _glfw.wl.cursor.theme_load
+#define wl_cursor_theme_destroy _glfw.wl.cursor.theme_destroy
+#define wl_cursor_theme_get_cursor _glfw.wl.cursor.theme_get_cursor
+#define wl_cursor_image_get_buffer _glfw.wl.cursor.image_get_buffer
+
+typedef struct wl_egl_window* (* PFN_wl_egl_window_create)(struct wl_surface*, int, int);
+typedef void (* PFN_wl_egl_window_destroy)(struct wl_egl_window*);
+typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, int);
+#define wl_egl_window_create _glfw.wl.egl.window_create
+#define wl_egl_window_destroy _glfw.wl.egl.window_destroy
+#define wl_egl_window_resize _glfw.wl.egl.window_resize
+
+typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags);
+typedef void (* PFN_xkb_context_unref)(struct xkb_context*);
+typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
+typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
+typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
+typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
+typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
+typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
+typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
+typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
+typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
+#define xkb_context_new _glfw.wl.xkb.context_new
+#define xkb_context_unref _glfw.wl.xkb.context_unref
+#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
+#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
+#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
+#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
+#define xkb_state_new _glfw.wl.xkb.state_new
+#define xkb_state_unref _glfw.wl.xkb.state_unref
+#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
+#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
+#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
+typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
+typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
+typedef void (* PFN_xkb_compose_state_unref)(struct xkb_compose_state*);
+typedef enum xkb_compose_feed_result (* PFN_xkb_compose_state_feed)(struct xkb_compose_state*, xkb_keysym_t);
+typedef enum xkb_compose_status (* PFN_xkb_compose_state_get_status)(struct xkb_compose_state*);
+typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_state*);
+#define xkb_compose_table_new_from_locale _glfw.wl.xkb.compose_table_new_from_locale
+#define xkb_compose_table_unref _glfw.wl.xkb.compose_table_unref
+#define xkb_compose_state_new _glfw.wl.xkb.compose_state_new
+#define xkb_compose_state_unref _glfw.wl.xkb.compose_state_unref
+#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
+#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
+#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
+#endif
+
+#define _GLFW_DECORATION_WIDTH 4
+#define _GLFW_DECORATION_TOP 24
+#define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH)
+#define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH)
+
+typedef enum _GLFWdecorationSideWayland
+{
+ mainWindow,
+ topDecoration,
+ leftDecoration,
+ rightDecoration,
+ bottomDecoration,
+
+} _GLFWdecorationSideWayland;
+
+typedef struct _GLFWdecorationWayland
+{
+ struct wl_surface* surface;
+ struct wl_subsurface* subsurface;
+ struct wp_viewport* viewport;
+
+} _GLFWdecorationWayland;
+
+// Wayland-specific per-window data
+//
+typedef struct _GLFWwindowWayland
+{
+ int width, height;
+ GLFWbool visible;
+ GLFWbool maximized;
+ GLFWbool hovered;
+ GLFWbool transparent;
+ struct wl_surface* surface;
+ struct wl_egl_window* native;
+ struct wl_shell_surface* shellSurface;
+ struct wl_callback* callback;
+
+ struct {
+ struct xdg_surface* surface;
+ struct xdg_toplevel* toplevel;
+ struct zxdg_toplevel_decoration_v1* decoration;
+ } xdg;
+
+ _GLFWcursor* currentCursor;
+ double cursorPosX, cursorPosY;
+
+ char* title;
+
+ // We need to track the monitors the window spans on to calculate the
+ // optimal scaling factor.
+ int scale;
+ _GLFWmonitor** monitors;
+ int monitorsCount;
+ int monitorsSize;
+
+ struct {
+ struct zwp_relative_pointer_v1* relativePointer;
+ struct zwp_locked_pointer_v1* lockedPointer;
+ } pointerLock;
+
+ struct zwp_idle_inhibitor_v1* idleInhibitor;
+
+ // This is a hack to prevent auto-iconification on creation.
+ GLFWbool justCreated;
+
+ struct {
+ GLFWbool serverSide;
+ struct wl_buffer* buffer;
+ _GLFWdecorationWayland top, left, right, bottom;
+ int focus;
+ } decorations;
+
+} _GLFWwindowWayland;
+
+// Wayland-specific global data
+//
+typedef struct _GLFWlibraryWayland
+{
+ struct wl_display* display;
+ struct wl_registry* registry;
+ struct wl_compositor* compositor;
+ struct wl_subcompositor* subcompositor;
+ struct wl_shell* shell;
+ struct wl_shm* shm;
+ struct wl_seat* seat;
+ struct wl_pointer* pointer;
+ struct wl_keyboard* keyboard;
+ struct wl_data_device_manager* dataDeviceManager;
+ struct wl_data_device* dataDevice;
+ struct wl_data_offer* dataOffer;
+ struct wl_data_source* dataSource;
+ struct xdg_wm_base* wmBase;
+ struct zxdg_decoration_manager_v1* decorationManager;
+ struct wp_viewporter* viewporter;
+ struct zwp_relative_pointer_manager_v1* relativePointerManager;
+ struct zwp_pointer_constraints_v1* pointerConstraints;
+ struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
+
+ int compositorVersion;
+ int seatVersion;
+
+ struct wl_cursor_theme* cursorTheme;
+ struct wl_cursor_theme* cursorThemeHiDPI;
+ struct wl_surface* cursorSurface;
+ int cursorTimerfd;
+ uint32_t serial;
+
+ int32_t keyboardRepeatRate;
+ int32_t keyboardRepeatDelay;
+ int keyboardLastKey;
+ int keyboardLastScancode;
+ char* clipboardString;
+ size_t clipboardSize;
+ char* clipboardSendString;
+ size_t clipboardSendSize;
+ int timerfd;
+ short int keycodes[256];
+ short int scancodes[GLFW_KEY_LAST + 1];
+
+ struct {
+ void* handle;
+ struct xkb_context* context;
+ struct xkb_keymap* keymap;
+ struct xkb_state* state;
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ struct xkb_compose_state* composeState;
+#endif
+
+ xkb_mod_mask_t controlMask;
+ xkb_mod_mask_t altMask;
+ xkb_mod_mask_t shiftMask;
+ xkb_mod_mask_t superMask;
+ xkb_mod_mask_t capsLockMask;
+ xkb_mod_mask_t numLockMask;
+ unsigned int modifiers;
+
+ PFN_xkb_context_new context_new;
+ PFN_xkb_context_unref context_unref;
+ PFN_xkb_keymap_new_from_string keymap_new_from_string;
+ PFN_xkb_keymap_unref keymap_unref;
+ PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
+ PFN_xkb_keymap_key_repeats keymap_key_repeats;
+ PFN_xkb_state_new state_new;
+ PFN_xkb_state_unref state_unref;
+ PFN_xkb_state_key_get_syms state_key_get_syms;
+ PFN_xkb_state_update_mask state_update_mask;
+ PFN_xkb_state_serialize_mods state_serialize_mods;
+
+#ifdef HAVE_XKBCOMMON_COMPOSE_H
+ PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
+ PFN_xkb_compose_table_unref compose_table_unref;
+ PFN_xkb_compose_state_new compose_state_new;
+ PFN_xkb_compose_state_unref compose_state_unref;
+ PFN_xkb_compose_state_feed compose_state_feed;
+ PFN_xkb_compose_state_get_status compose_state_get_status;
+ PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
+#endif
+ } xkb;
+
+ _GLFWwindow* pointerFocus;
+ _GLFWwindow* keyboardFocus;
+
+ struct {
+ void* handle;
+
+ PFN_wl_cursor_theme_load theme_load;
+ PFN_wl_cursor_theme_destroy theme_destroy;
+ PFN_wl_cursor_theme_get_cursor theme_get_cursor;
+ PFN_wl_cursor_image_get_buffer image_get_buffer;
+ } cursor;
+
+ struct {
+ void* handle;
+
+ PFN_wl_egl_window_create window_create;
+ PFN_wl_egl_window_destroy window_destroy;
+ PFN_wl_egl_window_resize window_resize;
+ } egl;
+
+} _GLFWlibraryWayland;
+
+// Wayland-specific per-monitor data
+//
+typedef struct _GLFWmonitorWayland
+{
+ struct wl_output* output;
+ int name;
+ int currentMode;
+
+ int x;
+ int y;
+ int scale;
+
+} _GLFWmonitorWayland;
+
+// Wayland-specific per-cursor data
+//
+typedef struct _GLFWcursorWayland
+{
+ struct wl_cursor* cursor;
+ struct wl_cursor* cursorHiDPI;
+ struct wl_buffer* buffer;
+ int width, height;
+ int xhot, yhot;
+ int currentImage;
+} _GLFWcursorWayland;
+
+
+void _glfwAddOutputWayland(uint32_t name, uint32_t version);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/wl_window.c b/Client/ThirdParty/Box2D/extern/glfw/src/wl_window.c
new file mode 100644
index 0000000..98a6465
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/wl_window.c
@@ -0,0 +1,1857 @@
+//========================================================================
+// GLFW 3.3 Wayland - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#define _GNU_SOURCE
+
+#include "internal.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/timerfd.h>
+#include <poll.h>
+
+
+static void shellSurfaceHandlePing(void* data,
+ struct wl_shell_surface* shellSurface,
+ uint32_t serial)
+{
+ wl_shell_surface_pong(shellSurface, serial);
+}
+
+static void shellSurfaceHandleConfigure(void* data,
+ struct wl_shell_surface* shellSurface,
+ uint32_t edges,
+ int32_t width,
+ int32_t height)
+{
+ _GLFWwindow* window = data;
+ float aspectRatio;
+ float targetRatio;
+
+ if (!window->monitor)
+ {
+ if (_glfw.wl.viewporter && window->decorated)
+ {
+ width -= _GLFW_DECORATION_HORIZONTAL;
+ height -= _GLFW_DECORATION_VERTICAL;
+ }
+ if (width < 1)
+ width = 1;
+ if (height < 1)
+ height = 1;
+
+ if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
+ {
+ aspectRatio = (float)width / (float)height;
+ targetRatio = (float)window->numer / (float)window->denom;
+ if (aspectRatio < targetRatio)
+ height = width / targetRatio;
+ else if (aspectRatio > targetRatio)
+ width = height * targetRatio;
+ }
+
+ if (window->minwidth != GLFW_DONT_CARE && width < window->minwidth)
+ width = window->minwidth;
+ else if (window->maxwidth != GLFW_DONT_CARE && width > window->maxwidth)
+ width = window->maxwidth;
+
+ if (window->minheight != GLFW_DONT_CARE && height < window->minheight)
+ height = window->minheight;
+ else if (window->maxheight != GLFW_DONT_CARE && height > window->maxheight)
+ height = window->maxheight;
+ }
+
+ _glfwInputWindowSize(window, width, height);
+ _glfwPlatformSetWindowSize(window, width, height);
+ _glfwInputWindowDamage(window);
+}
+
+static void shellSurfaceHandlePopupDone(void* data,
+ struct wl_shell_surface* shellSurface)
+{
+}
+
+static const struct wl_shell_surface_listener shellSurfaceListener = {
+ shellSurfaceHandlePing,
+ shellSurfaceHandleConfigure,
+ shellSurfaceHandlePopupDone
+};
+
+static int createTmpfileCloexec(char* tmpname)
+{
+ int fd;
+
+ fd = mkostemp(tmpname, O_CLOEXEC);
+ if (fd >= 0)
+ unlink(tmpname);
+
+ return fd;
+}
+
+/*
+ * Create a new, unique, anonymous file of the given size, and
+ * return the file descriptor for it. The file descriptor is set
+ * CLOEXEC. The file is immediately suitable for mmap()'ing
+ * the given size at offset zero.
+ *
+ * The file should not have a permanent backing store like a disk,
+ * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
+ *
+ * The file name is deleted from the file system.
+ *
+ * The file is suitable for buffer sharing between processes by
+ * transmitting the file descriptor over Unix sockets using the
+ * SCM_RIGHTS methods.
+ *
+ * posix_fallocate() is used to guarantee that disk space is available
+ * for the file at the given size. If disk space is insufficent, errno
+ * is set to ENOSPC. If posix_fallocate() is not supported, program may
+ * receive SIGBUS on accessing mmap()'ed file contents instead.
+ */
+static int createAnonymousFile(off_t size)
+{
+ static const char template[] = "/glfw-shared-XXXXXX";
+ const char* path;
+ char* name;
+ int fd;
+ int ret;
+
+#ifdef HAVE_MEMFD_CREATE
+ fd = memfd_create("glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
+ if (fd >= 0)
+ {
+ // We can add this seal before calling posix_fallocate(), as the file
+ // is currently zero-sized anyway.
+ //
+ // There is also no need to check for the return value, we couldn’t do
+ // anything with it anyway.
+ fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ }
+ else
+#endif
+ {
+ path = getenv("XDG_RUNTIME_DIR");
+ if (!path)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ name = calloc(strlen(path) + sizeof(template), 1);
+ strcpy(name, path);
+ strcat(name, template);
+
+ fd = createTmpfileCloexec(name);
+ free(name);
+ if (fd < 0)
+ return -1;
+ }
+
+ ret = posix_fallocate(fd, 0, size);
+ if (ret != 0)
+ {
+ close(fd);
+ errno = ret;
+ return -1;
+ }
+ return fd;
+}
+
+static struct wl_buffer* createShmBuffer(const GLFWimage* image)
+{
+ struct wl_shm_pool* pool;
+ struct wl_buffer* buffer;
+ int stride = image->width * 4;
+ int length = image->width * image->height * 4;
+ void* data;
+ int fd, i;
+
+ fd = createAnonymousFile(length);
+ if (fd < 0)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Creating a buffer file for %d B failed: %m",
+ length);
+ return NULL;
+ }
+
+ data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (data == MAP_FAILED)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: mmap failed: %m");
+ close(fd);
+ return NULL;
+ }
+
+ pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);
+
+ close(fd);
+ unsigned char* source = (unsigned char*) image->pixels;
+ unsigned char* target = data;
+ for (i = 0; i < image->width * image->height; i++, source += 4)
+ {
+ unsigned int alpha = source[3];
+
+ *target++ = (unsigned char) ((source[2] * alpha) / 255);
+ *target++ = (unsigned char) ((source[1] * alpha) / 255);
+ *target++ = (unsigned char) ((source[0] * alpha) / 255);
+ *target++ = (unsigned char) alpha;
+ }
+
+ buffer =
+ wl_shm_pool_create_buffer(pool, 0,
+ image->width,
+ image->height,
+ stride, WL_SHM_FORMAT_ARGB8888);
+ munmap(data, length);
+ wl_shm_pool_destroy(pool);
+
+ return buffer;
+}
+
+static void createDecoration(_GLFWdecorationWayland* decoration,
+ struct wl_surface* parent,
+ struct wl_buffer* buffer, GLFWbool opaque,
+ int x, int y,
+ int width, int height)
+{
+ struct wl_region* region;
+
+ decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor);
+ decoration->subsurface =
+ wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
+ decoration->surface, parent);
+ wl_subsurface_set_position(decoration->subsurface, x, y);
+ decoration->viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter,
+ decoration->surface);
+ wp_viewport_set_destination(decoration->viewport, width, height);
+ wl_surface_attach(decoration->surface, buffer, 0, 0);
+
+ if (opaque)
+ {
+ region = wl_compositor_create_region(_glfw.wl.compositor);
+ wl_region_add(region, 0, 0, width, height);
+ wl_surface_set_opaque_region(decoration->surface, region);
+ wl_surface_commit(decoration->surface);
+ wl_region_destroy(region);
+ }
+ else
+ wl_surface_commit(decoration->surface);
+}
+
+static void createDecorations(_GLFWwindow* window)
+{
+ unsigned char data[] = { 224, 224, 224, 255 };
+ const GLFWimage image = { 1, 1, data };
+ GLFWbool opaque = (data[3] == 255);
+
+ if (!_glfw.wl.viewporter || !window->decorated || window->wl.decorations.serverSide)
+ return;
+
+ if (!window->wl.decorations.buffer)
+ window->wl.decorations.buffer = createShmBuffer(&image);
+ if (!window->wl.decorations.buffer)
+ return;
+
+ createDecoration(&window->wl.decorations.top, window->wl.surface,
+ window->wl.decorations.buffer, opaque,
+ 0, -_GLFW_DECORATION_TOP,
+ window->wl.width, _GLFW_DECORATION_TOP);
+ createDecoration(&window->wl.decorations.left, window->wl.surface,
+ window->wl.decorations.buffer, opaque,
+ -_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP,
+ _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
+ createDecoration(&window->wl.decorations.right, window->wl.surface,
+ window->wl.decorations.buffer, opaque,
+ window->wl.width, -_GLFW_DECORATION_TOP,
+ _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
+ createDecoration(&window->wl.decorations.bottom, window->wl.surface,
+ window->wl.decorations.buffer, opaque,
+ -_GLFW_DECORATION_WIDTH, window->wl.height,
+ window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
+}
+
+static void destroyDecoration(_GLFWdecorationWayland* decoration)
+{
+ if (decoration->surface)
+ wl_surface_destroy(decoration->surface);
+ if (decoration->subsurface)
+ wl_subsurface_destroy(decoration->subsurface);
+ if (decoration->viewport)
+ wp_viewport_destroy(decoration->viewport);
+ decoration->surface = NULL;
+ decoration->subsurface = NULL;
+ decoration->viewport = NULL;
+}
+
+static void destroyDecorations(_GLFWwindow* window)
+{
+ destroyDecoration(&window->wl.decorations.top);
+ destroyDecoration(&window->wl.decorations.left);
+ destroyDecoration(&window->wl.decorations.right);
+ destroyDecoration(&window->wl.decorations.bottom);
+}
+
+static void xdgDecorationHandleConfigure(void* data,
+ struct zxdg_toplevel_decoration_v1* decoration,
+ uint32_t mode)
+{
+ _GLFWwindow* window = data;
+
+ window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
+
+ if (!window->wl.decorations.serverSide)
+ createDecorations(window);
+}
+
+static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = {
+ xdgDecorationHandleConfigure,
+};
+
+// Makes the surface considered as XRGB instead of ARGB.
+static void setOpaqueRegion(_GLFWwindow* window)
+{
+ struct wl_region* region;
+
+ region = wl_compositor_create_region(_glfw.wl.compositor);
+ if (!region)
+ return;
+
+ wl_region_add(region, 0, 0, window->wl.width, window->wl.height);
+ wl_surface_set_opaque_region(window->wl.surface, region);
+ wl_surface_commit(window->wl.surface);
+ wl_region_destroy(region);
+}
+
+
+static void resizeWindow(_GLFWwindow* window)
+{
+ int scale = window->wl.scale;
+ int scaledWidth = window->wl.width * scale;
+ int scaledHeight = window->wl.height * scale;
+ wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
+ if (!window->wl.transparent)
+ setOpaqueRegion(window);
+ _glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
+ _glfwInputWindowContentScale(window, scale, scale);
+
+ if (!window->wl.decorations.top.surface)
+ return;
+
+ // Top decoration.
+ wp_viewport_set_destination(window->wl.decorations.top.viewport,
+ window->wl.width, _GLFW_DECORATION_TOP);
+ wl_surface_commit(window->wl.decorations.top.surface);
+
+ // Left decoration.
+ wp_viewport_set_destination(window->wl.decorations.left.viewport,
+ _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
+ wl_surface_commit(window->wl.decorations.left.surface);
+
+ // Right decoration.
+ wl_subsurface_set_position(window->wl.decorations.right.subsurface,
+ window->wl.width, -_GLFW_DECORATION_TOP);
+ wp_viewport_set_destination(window->wl.decorations.right.viewport,
+ _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
+ wl_surface_commit(window->wl.decorations.right.surface);
+
+ // Bottom decoration.
+ wl_subsurface_set_position(window->wl.decorations.bottom.subsurface,
+ -_GLFW_DECORATION_WIDTH, window->wl.height);
+ wp_viewport_set_destination(window->wl.decorations.bottom.viewport,
+ window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
+ wl_surface_commit(window->wl.decorations.bottom.surface);
+}
+
+static void checkScaleChange(_GLFWwindow* window)
+{
+ int scale = 1;
+ int i;
+ int monitorScale;
+
+ // Check if we will be able to set the buffer scale or not.
+ if (_glfw.wl.compositorVersion < 3)
+ return;
+
+ // Get the scale factor from the highest scale monitor.
+ for (i = 0; i < window->wl.monitorsCount; ++i)
+ {
+ monitorScale = window->wl.monitors[i]->wl.scale;
+ if (scale < monitorScale)
+ scale = monitorScale;
+ }
+
+ // Only change the framebuffer size if the scale changed.
+ if (scale != window->wl.scale)
+ {
+ window->wl.scale = scale;
+ wl_surface_set_buffer_scale(window->wl.surface, scale);
+ resizeWindow(window);
+ }
+}
+
+static void surfaceHandleEnter(void *data,
+ struct wl_surface *surface,
+ struct wl_output *output)
+{
+ _GLFWwindow* window = data;
+ _GLFWmonitor* monitor = wl_output_get_user_data(output);
+
+ if (window->wl.monitorsCount + 1 > window->wl.monitorsSize)
+ {
+ ++window->wl.monitorsSize;
+ window->wl.monitors =
+ realloc(window->wl.monitors,
+ window->wl.monitorsSize * sizeof(_GLFWmonitor*));
+ }
+
+ window->wl.monitors[window->wl.monitorsCount++] = monitor;
+
+ checkScaleChange(window);
+}
+
+static void surfaceHandleLeave(void *data,
+ struct wl_surface *surface,
+ struct wl_output *output)
+{
+ _GLFWwindow* window = data;
+ _GLFWmonitor* monitor = wl_output_get_user_data(output);
+ GLFWbool found;
+ int i;
+
+ for (i = 0, found = GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i)
+ {
+ if (monitor == window->wl.monitors[i])
+ found = GLFW_TRUE;
+ if (found)
+ window->wl.monitors[i] = window->wl.monitors[i + 1];
+ }
+ window->wl.monitors[--window->wl.monitorsCount] = NULL;
+
+ checkScaleChange(window);
+}
+
+static const struct wl_surface_listener surfaceListener = {
+ surfaceHandleEnter,
+ surfaceHandleLeave
+};
+
+static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
+{
+ if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager)
+ {
+ window->wl.idleInhibitor =
+ zwp_idle_inhibit_manager_v1_create_inhibitor(
+ _glfw.wl.idleInhibitManager, window->wl.surface);
+ if (!window->wl.idleInhibitor)
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Idle inhibitor creation failed");
+ }
+ else if (!enable && window->wl.idleInhibitor)
+ {
+ zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
+ window->wl.idleInhibitor = NULL;
+ }
+}
+
+static GLFWbool createSurface(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig)
+{
+ window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
+ if (!window->wl.surface)
+ return GLFW_FALSE;
+
+ wl_surface_add_listener(window->wl.surface,
+ &surfaceListener,
+ window);
+
+ wl_surface_set_user_data(window->wl.surface, window);
+
+ window->wl.native = wl_egl_window_create(window->wl.surface,
+ wndconfig->width,
+ wndconfig->height);
+ if (!window->wl.native)
+ return GLFW_FALSE;
+
+ window->wl.width = wndconfig->width;
+ window->wl.height = wndconfig->height;
+ window->wl.scale = 1;
+
+ if (!window->wl.transparent)
+ setOpaqueRegion(window);
+
+ return GLFW_TRUE;
+}
+
+static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor,
+ int refreshRate)
+{
+ if (window->wl.xdg.toplevel)
+ {
+ xdg_toplevel_set_fullscreen(
+ window->wl.xdg.toplevel,
+ monitor->wl.output);
+ }
+ else if (window->wl.shellSurface)
+ {
+ wl_shell_surface_set_fullscreen(
+ window->wl.shellSurface,
+ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+ refreshRate * 1000, // Convert Hz to mHz.
+ monitor->wl.output);
+ }
+ setIdleInhibitor(window, GLFW_TRUE);
+ if (!window->wl.decorations.serverSide)
+ destroyDecorations(window);
+}
+
+static GLFWbool createShellSurface(_GLFWwindow* window)
+{
+ if (!_glfw.wl.shell)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: wl_shell protocol not available");
+ return GLFW_FALSE;
+ }
+
+ window->wl.shellSurface = wl_shell_get_shell_surface(_glfw.wl.shell,
+ window->wl.surface);
+ if (!window->wl.shellSurface)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Shell surface creation failed");
+ return GLFW_FALSE;
+ }
+
+ wl_shell_surface_add_listener(window->wl.shellSurface,
+ &shellSurfaceListener,
+ window);
+
+ if (window->wl.title)
+ wl_shell_surface_set_title(window->wl.shellSurface, window->wl.title);
+
+ if (window->monitor)
+ {
+ setFullscreen(window, window->monitor, 0);
+ }
+ else if (window->wl.maximized)
+ {
+ wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
+ setIdleInhibitor(window, GLFW_FALSE);
+ createDecorations(window);
+ }
+ else
+ {
+ wl_shell_surface_set_toplevel(window->wl.shellSurface);
+ setIdleInhibitor(window, GLFW_FALSE);
+ createDecorations(window);
+ }
+
+ wl_surface_commit(window->wl.surface);
+
+ return GLFW_TRUE;
+}
+
+static void xdgToplevelHandleConfigure(void* data,
+ struct xdg_toplevel* toplevel,
+ int32_t width,
+ int32_t height,
+ struct wl_array* states)
+{
+ _GLFWwindow* window = data;
+ float aspectRatio;
+ float targetRatio;
+ uint32_t* state;
+ GLFWbool maximized = GLFW_FALSE;
+ GLFWbool fullscreen = GLFW_FALSE;
+ GLFWbool activated = GLFW_FALSE;
+
+ wl_array_for_each(state, states)
+ {
+ switch (*state)
+ {
+ case XDG_TOPLEVEL_STATE_MAXIMIZED:
+ maximized = GLFW_TRUE;
+ break;
+ case XDG_TOPLEVEL_STATE_FULLSCREEN:
+ fullscreen = GLFW_TRUE;
+ break;
+ case XDG_TOPLEVEL_STATE_RESIZING:
+ break;
+ case XDG_TOPLEVEL_STATE_ACTIVATED:
+ activated = GLFW_TRUE;
+ break;
+ }
+ }
+
+ if (width != 0 && height != 0)
+ {
+ if (!maximized && !fullscreen)
+ {
+ if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
+ {
+ aspectRatio = (float)width / (float)height;
+ targetRatio = (float)window->numer / (float)window->denom;
+ if (aspectRatio < targetRatio)
+ height = width / targetRatio;
+ else if (aspectRatio > targetRatio)
+ width = height * targetRatio;
+ }
+ }
+
+ _glfwInputWindowSize(window, width, height);
+ _glfwPlatformSetWindowSize(window, width, height);
+ _glfwInputWindowDamage(window);
+ }
+
+ if (!window->wl.justCreated && !activated && window->autoIconify)
+ _glfwPlatformIconifyWindow(window);
+ _glfwInputWindowFocus(window, activated);
+ window->wl.justCreated = GLFW_FALSE;
+}
+
+static void xdgToplevelHandleClose(void* data,
+ struct xdg_toplevel* toplevel)
+{
+ _GLFWwindow* window = data;
+ _glfwInputWindowCloseRequest(window);
+}
+
+static const struct xdg_toplevel_listener xdgToplevelListener = {
+ xdgToplevelHandleConfigure,
+ xdgToplevelHandleClose
+};
+
+static void xdgSurfaceHandleConfigure(void* data,
+ struct xdg_surface* surface,
+ uint32_t serial)
+{
+ xdg_surface_ack_configure(surface, serial);
+}
+
+static const struct xdg_surface_listener xdgSurfaceListener = {
+ xdgSurfaceHandleConfigure
+};
+
+static void setXdgDecorations(_GLFWwindow* window)
+{
+ if (_glfw.wl.decorationManager)
+ {
+ window->wl.xdg.decoration =
+ zxdg_decoration_manager_v1_get_toplevel_decoration(
+ _glfw.wl.decorationManager, window->wl.xdg.toplevel);
+ zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration,
+ &xdgDecorationListener,
+ window);
+ zxdg_toplevel_decoration_v1_set_mode(
+ window->wl.xdg.decoration,
+ ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
+ }
+ else
+ {
+ window->wl.decorations.serverSide = GLFW_FALSE;
+ createDecorations(window);
+ }
+}
+
+static GLFWbool createXdgSurface(_GLFWwindow* window)
+{
+ window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(_glfw.wl.wmBase,
+ window->wl.surface);
+ if (!window->wl.xdg.surface)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: xdg-surface creation failed");
+ return GLFW_FALSE;
+ }
+
+ xdg_surface_add_listener(window->wl.xdg.surface,
+ &xdgSurfaceListener,
+ window);
+
+ window->wl.xdg.toplevel = xdg_surface_get_toplevel(window->wl.xdg.surface);
+ if (!window->wl.xdg.toplevel)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: xdg-toplevel creation failed");
+ return GLFW_FALSE;
+ }
+
+ xdg_toplevel_add_listener(window->wl.xdg.toplevel,
+ &xdgToplevelListener,
+ window);
+
+ if (window->wl.title)
+ xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
+
+ if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE)
+ xdg_toplevel_set_min_size(window->wl.xdg.toplevel,
+ window->minwidth, window->minheight);
+ if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE)
+ xdg_toplevel_set_max_size(window->wl.xdg.toplevel,
+ window->maxwidth, window->maxheight);
+
+ if (window->monitor)
+ {
+ xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel,
+ window->monitor->wl.output);
+ setIdleInhibitor(window, GLFW_TRUE);
+ }
+ else if (window->wl.maximized)
+ {
+ xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
+ setIdleInhibitor(window, GLFW_FALSE);
+ setXdgDecorations(window);
+ }
+ else
+ {
+ setIdleInhibitor(window, GLFW_FALSE);
+ setXdgDecorations(window);
+ }
+
+ wl_surface_commit(window->wl.surface);
+ wl_display_roundtrip(_glfw.wl.display);
+
+ return GLFW_TRUE;
+}
+
+static void setCursorImage(_GLFWwindow* window,
+ _GLFWcursorWayland* cursorWayland)
+{
+ struct itimerspec timer = {};
+ struct wl_cursor* wlCursor = cursorWayland->cursor;
+ struct wl_cursor_image* image;
+ struct wl_buffer* buffer;
+ struct wl_surface* surface = _glfw.wl.cursorSurface;
+ int scale = 1;
+
+ if (!wlCursor)
+ buffer = cursorWayland->buffer;
+ else
+ {
+ if (window->wl.scale > 1 && cursorWayland->cursorHiDPI)
+ {
+ wlCursor = cursorWayland->cursorHiDPI;
+ scale = 2;
+ }
+
+ image = wlCursor->images[cursorWayland->currentImage];
+ buffer = wl_cursor_image_get_buffer(image);
+ if (!buffer)
+ return;
+
+ timer.it_value.tv_sec = image->delay / 1000;
+ timer.it_value.tv_nsec = (image->delay % 1000) * 1000000;
+ timerfd_settime(_glfw.wl.cursorTimerfd, 0, &timer, NULL);
+
+ cursorWayland->width = image->width;
+ cursorWayland->height = image->height;
+ cursorWayland->xhot = image->hotspot_x;
+ cursorWayland->yhot = image->hotspot_y;
+ }
+
+ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
+ surface,
+ cursorWayland->xhot / scale,
+ cursorWayland->yhot / scale);
+ wl_surface_set_buffer_scale(surface, scale);
+ wl_surface_attach(surface, buffer, 0, 0);
+ wl_surface_damage(surface, 0, 0,
+ cursorWayland->width, cursorWayland->height);
+ wl_surface_commit(surface);
+}
+
+static void incrementCursorImage(_GLFWwindow* window)
+{
+ _GLFWcursor* cursor;
+
+ if (!window || window->wl.decorations.focus != mainWindow)
+ return;
+
+ cursor = window->wl.currentCursor;
+ if (cursor && cursor->wl.cursor)
+ {
+ cursor->wl.currentImage += 1;
+ cursor->wl.currentImage %= cursor->wl.cursor->image_count;
+ setCursorImage(window, &cursor->wl);
+ }
+}
+
+static void handleEvents(int timeout)
+{
+ struct wl_display* display = _glfw.wl.display;
+ struct pollfd fds[] = {
+ { wl_display_get_fd(display), POLLIN },
+ { _glfw.wl.timerfd, POLLIN },
+ { _glfw.wl.cursorTimerfd, POLLIN },
+ };
+ ssize_t read_ret;
+ uint64_t repeats, i;
+
+ while (wl_display_prepare_read(display) != 0)
+ wl_display_dispatch_pending(display);
+
+ // If an error different from EAGAIN happens, we have likely been
+ // disconnected from the Wayland session, try to handle that the best we
+ // can.
+ if (wl_display_flush(display) < 0 && errno != EAGAIN)
+ {
+ _GLFWwindow* window = _glfw.windowListHead;
+ while (window)
+ {
+ _glfwInputWindowCloseRequest(window);
+ window = window->next;
+ }
+ wl_display_cancel_read(display);
+ return;
+ }
+
+ if (poll(fds, 3, timeout) > 0)
+ {
+ if (fds[0].revents & POLLIN)
+ {
+ wl_display_read_events(display);
+ wl_display_dispatch_pending(display);
+ }
+ else
+ {
+ wl_display_cancel_read(display);
+ }
+
+ if (fds[1].revents & POLLIN)
+ {
+ read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats));
+ if (read_ret != 8)
+ return;
+
+ for (i = 0; i < repeats; ++i)
+ _glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey,
+ _glfw.wl.keyboardLastScancode, GLFW_REPEAT,
+ _glfw.wl.xkb.modifiers);
+ }
+
+ if (fds[2].revents & POLLIN)
+ {
+ read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats));
+ if (read_ret != 8)
+ return;
+
+ incrementCursorImage(_glfw.wl.pointerFocus);
+ }
+ }
+ else
+ {
+ wl_display_cancel_read(display);
+ }
+}
+
+// Translates a GLFW standard cursor to a theme cursor name
+//
+static char *translateCursorShape(int shape)
+{
+ switch (shape)
+ {
+ case GLFW_ARROW_CURSOR:
+ return "left_ptr";
+ case GLFW_IBEAM_CURSOR:
+ return "xterm";
+ case GLFW_CROSSHAIR_CURSOR:
+ return "crosshair";
+ case GLFW_HAND_CURSOR:
+ return "grabbing";
+ case GLFW_HRESIZE_CURSOR:
+ return "sb_h_double_arrow";
+ case GLFW_VRESIZE_CURSOR:
+ return "sb_v_double_arrow";
+ }
+ return NULL;
+}
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformCreateWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ window->wl.justCreated = GLFW_TRUE;
+ window->wl.transparent = fbconfig->transparent;
+
+ if (!createSurface(window, wndconfig))
+ return GLFW_FALSE;
+
+ if (ctxconfig->client != GLFW_NO_API)
+ {
+ if (ctxconfig->source == GLFW_EGL_CONTEXT_API ||
+ ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
+ {
+ if (!_glfwInitEGL())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ if (!_glfwInitOSMesa())
+ return GLFW_FALSE;
+ if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ }
+
+ if (wndconfig->title)
+ window->wl.title = _glfw_strdup(wndconfig->title);
+
+ if (wndconfig->visible)
+ {
+ if (_glfw.wl.wmBase)
+ {
+ if (!createXdgSurface(window))
+ return GLFW_FALSE;
+ }
+ else
+ {
+ if (!createShellSurface(window))
+ return GLFW_FALSE;
+ }
+
+ window->wl.visible = GLFW_TRUE;
+ }
+ else
+ {
+ window->wl.xdg.surface = NULL;
+ window->wl.xdg.toplevel = NULL;
+ window->wl.shellSurface = NULL;
+ window->wl.visible = GLFW_FALSE;
+ }
+
+ window->wl.currentCursor = NULL;
+
+ window->wl.monitors = calloc(1, sizeof(_GLFWmonitor*));
+ window->wl.monitorsCount = 0;
+ window->wl.monitorsSize = 1;
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyWindow(_GLFWwindow* window)
+{
+ if (window == _glfw.wl.pointerFocus)
+ {
+ _glfw.wl.pointerFocus = NULL;
+ _glfwInputCursorEnter(window, GLFW_FALSE);
+ }
+ if (window == _glfw.wl.keyboardFocus)
+ {
+ _glfw.wl.keyboardFocus = NULL;
+ _glfwInputWindowFocus(window, GLFW_FALSE);
+ }
+
+ if (window->wl.idleInhibitor)
+ zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
+
+ if (window->context.destroy)
+ window->context.destroy(window);
+
+ destroyDecorations(window);
+ if (window->wl.xdg.decoration)
+ zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
+
+ if (window->wl.decorations.buffer)
+ wl_buffer_destroy(window->wl.decorations.buffer);
+
+ if (window->wl.native)
+ wl_egl_window_destroy(window->wl.native);
+
+ if (window->wl.shellSurface)
+ wl_shell_surface_destroy(window->wl.shellSurface);
+
+ if (window->wl.xdg.toplevel)
+ xdg_toplevel_destroy(window->wl.xdg.toplevel);
+
+ if (window->wl.xdg.surface)
+ xdg_surface_destroy(window->wl.xdg.surface);
+
+ if (window->wl.surface)
+ wl_surface_destroy(window->wl.surface);
+
+ free(window->wl.title);
+ free(window->wl.monitors);
+}
+
+void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
+{
+ if (window->wl.title)
+ free(window->wl.title);
+ window->wl.title = _glfw_strdup(title);
+ if (window->wl.xdg.toplevel)
+ xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
+ else if (window->wl.shellSurface)
+ wl_shell_surface_set_title(window->wl.shellSurface, title);
+}
+
+void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
+ int count, const GLFWimage* images)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Setting window icon not supported");
+}
+
+void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
+{
+ // A Wayland client is not aware of its position, so just warn and leave it
+ // as (0, 0)
+
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Window position retrieval not supported");
+}
+
+void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
+{
+ // A Wayland client can not set its position, so just warn
+
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Window position setting not supported");
+}
+
+void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
+{
+ if (width)
+ *width = window->wl.width;
+ if (height)
+ *height = window->wl.height;
+}
+
+void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
+{
+ window->wl.width = width;
+ window->wl.height = height;
+ resizeWindow(window);
+}
+
+void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight)
+{
+ if (_glfw.wl.wmBase)
+ {
+ if (window->wl.xdg.toplevel)
+ {
+ if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
+ minwidth = minheight = 0;
+ if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
+ maxwidth = maxheight = 0;
+ xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight);
+ xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight);
+ wl_surface_commit(window->wl.surface);
+ }
+ }
+ else
+ {
+ // TODO: find out how to trigger a resize.
+ // The actual limits are checked in the wl_shell_surface::configure handler.
+ }
+}
+
+void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
+ int numer, int denom)
+{
+ // TODO: find out how to trigger a resize.
+ // The actual limits are checked in the wl_shell_surface::configure handler.
+}
+
+void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
+ int* width, int* height)
+{
+ _glfwPlatformGetWindowSize(window, width, height);
+ *width *= window->wl.scale;
+ *height *= window->wl.scale;
+}
+
+void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
+ int* left, int* top,
+ int* right, int* bottom)
+{
+ if (window->decorated && !window->monitor && !window->wl.decorations.serverSide)
+ {
+ if (top)
+ *top = _GLFW_DECORATION_TOP;
+ if (left)
+ *left = _GLFW_DECORATION_WIDTH;
+ if (right)
+ *right = _GLFW_DECORATION_WIDTH;
+ if (bottom)
+ *bottom = _GLFW_DECORATION_WIDTH;
+ }
+}
+
+void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
+ float* xscale, float* yscale)
+{
+ if (xscale)
+ *xscale = (float) window->wl.scale;
+ if (yscale)
+ *yscale = (float) window->wl.scale;
+}
+
+void _glfwPlatformIconifyWindow(_GLFWwindow* window)
+{
+ if (_glfw.wl.wmBase)
+ {
+ if (window->wl.xdg.toplevel)
+ xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Iconify window not supported on wl_shell");
+ }
+}
+
+void _glfwPlatformRestoreWindow(_GLFWwindow* window)
+{
+ if (window->wl.xdg.toplevel)
+ {
+ if (window->monitor)
+ xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
+ if (window->wl.maximized)
+ xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
+ // There is no way to unset minimized, or even to know if we are
+ // minimized, so there is nothing to do here.
+ }
+ else if (window->wl.shellSurface)
+ {
+ if (window->monitor || window->wl.maximized)
+ wl_shell_surface_set_toplevel(window->wl.shellSurface);
+ }
+ _glfwInputWindowMonitor(window, NULL);
+ window->wl.maximized = GLFW_FALSE;
+}
+
+void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
+{
+ if (window->wl.xdg.toplevel)
+ {
+ xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
+ }
+ else if (window->wl.shellSurface)
+ {
+ // Let the compositor select the best output.
+ wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
+ }
+ window->wl.maximized = GLFW_TRUE;
+}
+
+void _glfwPlatformShowWindow(_GLFWwindow* window)
+{
+ if (!window->wl.visible)
+ {
+ if (_glfw.wl.wmBase)
+ createXdgSurface(window);
+ else if (!window->wl.shellSurface)
+ createShellSurface(window);
+ window->wl.visible = GLFW_TRUE;
+ }
+}
+
+void _glfwPlatformHideWindow(_GLFWwindow* window)
+{
+ if (window->wl.xdg.toplevel)
+ {
+ xdg_toplevel_destroy(window->wl.xdg.toplevel);
+ xdg_surface_destroy(window->wl.xdg.surface);
+ window->wl.xdg.toplevel = NULL;
+ window->wl.xdg.surface = NULL;
+ }
+ else if (window->wl.shellSurface)
+ {
+ wl_shell_surface_destroy(window->wl.shellSurface);
+ window->wl.shellSurface = NULL;
+ }
+ window->wl.visible = GLFW_FALSE;
+}
+
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
+{
+ // TODO
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Window attention request not implemented yet");
+}
+
+void _glfwPlatformFocusWindow(_GLFWwindow* window)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Focusing a window requires user interaction");
+}
+
+void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
+ _GLFWmonitor* monitor,
+ int xpos, int ypos,
+ int width, int height,
+ int refreshRate)
+{
+ if (monitor)
+ {
+ setFullscreen(window, monitor, refreshRate);
+ }
+ else
+ {
+ if (window->wl.xdg.toplevel)
+ xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
+ else if (window->wl.shellSurface)
+ wl_shell_surface_set_toplevel(window->wl.shellSurface);
+ setIdleInhibitor(window, GLFW_FALSE);
+ if (!_glfw.wl.decorationManager)
+ createDecorations(window);
+ }
+ _glfwInputWindowMonitor(window, monitor);
+}
+
+int _glfwPlatformWindowFocused(_GLFWwindow* window)
+{
+ return _glfw.wl.keyboardFocus == window;
+}
+
+int _glfwPlatformWindowIconified(_GLFWwindow* window)
+{
+ // wl_shell doesn't have any iconified concept, and xdg-shell doesn’t give
+ // any way to request whether a surface is iconified.
+ return GLFW_FALSE;
+}
+
+int _glfwPlatformWindowVisible(_GLFWwindow* window)
+{
+ return window->wl.visible;
+}
+
+int _glfwPlatformWindowMaximized(_GLFWwindow* window)
+{
+ return window->wl.maximized;
+}
+
+int _glfwPlatformWindowHovered(_GLFWwindow* window)
+{
+ return window->wl.hovered;
+}
+
+int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
+{
+ return window->wl.transparent;
+}
+
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
+{
+ // TODO
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Window attribute setting not implemented yet");
+}
+
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
+{
+ if (!window->monitor)
+ {
+ if (enabled)
+ createDecorations(window);
+ else
+ destroyDecorations(window);
+ }
+}
+
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
+{
+ // TODO
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Window attribute setting not implemented yet");
+}
+
+float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
+{
+ return 1.f;
+}
+
+void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
+{
+}
+
+void _glfwPlatformPollEvents(void)
+{
+ handleEvents(0);
+}
+
+void _glfwPlatformWaitEvents(void)
+{
+ handleEvents(-1);
+}
+
+void _glfwPlatformWaitEventsTimeout(double timeout)
+{
+ handleEvents((int) (timeout * 1e3));
+}
+
+void _glfwPlatformPostEmptyEvent(void)
+{
+ wl_display_sync(_glfw.wl.display);
+}
+
+void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
+{
+ if (xpos)
+ *xpos = window->wl.cursorPosX;
+ if (ypos)
+ *ypos = window->wl.cursorPosY;
+}
+
+static GLFWbool isPointerLocked(_GLFWwindow* window);
+
+void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
+{
+ if (isPointerLocked(window))
+ {
+ zwp_locked_pointer_v1_set_cursor_position_hint(
+ window->wl.pointerLock.lockedPointer,
+ wl_fixed_from_double(x), wl_fixed_from_double(y));
+ wl_surface_commit(window->wl.surface);
+ }
+}
+
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
+{
+ _glfwPlatformSetCursor(window, window->wl.currentCursor);
+}
+
+const char* _glfwPlatformGetScancodeName(int scancode)
+{
+ // TODO
+ return NULL;
+}
+
+int _glfwPlatformGetKeyScancode(int key)
+{
+ return _glfw.wl.scancodes[key];
+}
+
+int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
+ const GLFWimage* image,
+ int xhot, int yhot)
+{
+ cursor->wl.buffer = createShmBuffer(image);
+ if (!cursor->wl.buffer)
+ return GLFW_FALSE;
+
+ cursor->wl.width = image->width;
+ cursor->wl.height = image->height;
+ cursor->wl.xhot = xhot;
+ cursor->wl.yhot = yhot;
+ return GLFW_TRUE;
+}
+
+int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
+{
+ struct wl_cursor* standardCursor;
+
+ standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme,
+ translateCursorShape(shape));
+ if (!standardCursor)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Standard cursor \"%s\" not found",
+ translateCursorShape(shape));
+ return GLFW_FALSE;
+ }
+
+ cursor->wl.cursor = standardCursor;
+ cursor->wl.currentImage = 0;
+
+ if (_glfw.wl.cursorThemeHiDPI)
+ {
+ standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI,
+ translateCursorShape(shape));
+ cursor->wl.cursorHiDPI = standardCursor;
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
+{
+ // If it's a standard cursor we don't need to do anything here
+ if (cursor->wl.cursor)
+ return;
+
+ if (cursor->wl.buffer)
+ wl_buffer_destroy(cursor->wl.buffer);
+}
+
+static void relativePointerHandleRelativeMotion(void* data,
+ struct zwp_relative_pointer_v1* pointer,
+ uint32_t timeHi,
+ uint32_t timeLo,
+ wl_fixed_t dx,
+ wl_fixed_t dy,
+ wl_fixed_t dxUnaccel,
+ wl_fixed_t dyUnaccel)
+{
+ _GLFWwindow* window = data;
+
+ if (window->cursorMode != GLFW_CURSOR_DISABLED)
+ return;
+
+ _glfwInputCursorPos(window,
+ window->virtualCursorPosX + wl_fixed_to_double(dxUnaccel),
+ window->virtualCursorPosY + wl_fixed_to_double(dyUnaccel));
+}
+
+static const struct zwp_relative_pointer_v1_listener relativePointerListener = {
+ relativePointerHandleRelativeMotion
+};
+
+static void lockedPointerHandleLocked(void* data,
+ struct zwp_locked_pointer_v1* lockedPointer)
+{
+}
+
+static void unlockPointer(_GLFWwindow* window)
+{
+ struct zwp_relative_pointer_v1* relativePointer =
+ window->wl.pointerLock.relativePointer;
+ struct zwp_locked_pointer_v1* lockedPointer =
+ window->wl.pointerLock.lockedPointer;
+
+ zwp_relative_pointer_v1_destroy(relativePointer);
+ zwp_locked_pointer_v1_destroy(lockedPointer);
+
+ window->wl.pointerLock.relativePointer = NULL;
+ window->wl.pointerLock.lockedPointer = NULL;
+}
+
+static void lockPointer(_GLFWwindow* window);
+
+static void lockedPointerHandleUnlocked(void* data,
+ struct zwp_locked_pointer_v1* lockedPointer)
+{
+}
+
+static const struct zwp_locked_pointer_v1_listener lockedPointerListener = {
+ lockedPointerHandleLocked,
+ lockedPointerHandleUnlocked
+};
+
+static void lockPointer(_GLFWwindow* window)
+{
+ struct zwp_relative_pointer_v1* relativePointer;
+ struct zwp_locked_pointer_v1* lockedPointer;
+
+ if (!_glfw.wl.relativePointerManager)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: no relative pointer manager");
+ return;
+ }
+
+ relativePointer =
+ zwp_relative_pointer_manager_v1_get_relative_pointer(
+ _glfw.wl.relativePointerManager,
+ _glfw.wl.pointer);
+ zwp_relative_pointer_v1_add_listener(relativePointer,
+ &relativePointerListener,
+ window);
+
+ lockedPointer =
+ zwp_pointer_constraints_v1_lock_pointer(
+ _glfw.wl.pointerConstraints,
+ window->wl.surface,
+ _glfw.wl.pointer,
+ NULL,
+ ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
+ zwp_locked_pointer_v1_add_listener(lockedPointer,
+ &lockedPointerListener,
+ window);
+
+ window->wl.pointerLock.relativePointer = relativePointer;
+ window->wl.pointerLock.lockedPointer = lockedPointer;
+
+ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
+ NULL, 0, 0);
+}
+
+static GLFWbool isPointerLocked(_GLFWwindow* window)
+{
+ return window->wl.pointerLock.lockedPointer != NULL;
+}
+
+void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
+{
+ struct wl_cursor* defaultCursor;
+ struct wl_cursor* defaultCursorHiDPI = NULL;
+
+ if (!_glfw.wl.pointer)
+ return;
+
+ window->wl.currentCursor = cursor;
+
+ // If we're not in the correct window just save the cursor
+ // the next time the pointer enters the window the cursor will change
+ if (window != _glfw.wl.pointerFocus || window->wl.decorations.focus != mainWindow)
+ return;
+
+ // Unlock possible pointer lock if no longer disabled.
+ if (window->cursorMode != GLFW_CURSOR_DISABLED && isPointerLocked(window))
+ unlockPointer(window);
+
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
+ {
+ if (cursor)
+ setCursorImage(window, &cursor->wl);
+ else
+ {
+ defaultCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme,
+ "left_ptr");
+ if (!defaultCursor)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Standard cursor not found");
+ return;
+ }
+ if (_glfw.wl.cursorThemeHiDPI)
+ defaultCursorHiDPI =
+ wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI,
+ "left_ptr");
+ _GLFWcursorWayland cursorWayland = {
+ defaultCursor,
+ defaultCursorHiDPI,
+ NULL,
+ 0, 0,
+ 0, 0,
+ 0
+ };
+ setCursorImage(window, &cursorWayland);
+ }
+ }
+ else if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ {
+ if (!isPointerLocked(window))
+ lockPointer(window);
+ }
+ else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
+ {
+ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0);
+ }
+}
+
+static void dataSourceHandleTarget(void* data,
+ struct wl_data_source* dataSource,
+ const char* mimeType)
+{
+ if (_glfw.wl.dataSource != dataSource)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Unknown clipboard data source");
+ return;
+ }
+}
+
+static void dataSourceHandleSend(void* data,
+ struct wl_data_source* dataSource,
+ const char* mimeType,
+ int fd)
+{
+ const char* string = _glfw.wl.clipboardSendString;
+ size_t len = _glfw.wl.clipboardSendSize;
+ int ret;
+
+ if (_glfw.wl.dataSource != dataSource)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Unknown clipboard data source");
+ return;
+ }
+
+ if (!string)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Copy requested from an invalid string");
+ return;
+ }
+
+ if (strcmp(mimeType, "text/plain;charset=utf-8") != 0)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Wrong MIME type asked from clipboard");
+ close(fd);
+ return;
+ }
+
+ while (len > 0)
+ {
+ ret = write(fd, string, len);
+ if (ret == -1 && errno == EINTR)
+ continue;
+ if (ret == -1)
+ {
+ // TODO: also report errno maybe.
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Error while writing the clipboard");
+ close(fd);
+ return;
+ }
+ len -= ret;
+ }
+ close(fd);
+}
+
+static void dataSourceHandleCancelled(void* data,
+ struct wl_data_source* dataSource)
+{
+ wl_data_source_destroy(dataSource);
+
+ if (_glfw.wl.dataSource != dataSource)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Unknown clipboard data source");
+ return;
+ }
+
+ _glfw.wl.dataSource = NULL;
+}
+
+static const struct wl_data_source_listener dataSourceListener = {
+ dataSourceHandleTarget,
+ dataSourceHandleSend,
+ dataSourceHandleCancelled,
+};
+
+void _glfwPlatformSetClipboardString(const char* string)
+{
+ if (_glfw.wl.dataSource)
+ {
+ wl_data_source_destroy(_glfw.wl.dataSource);
+ _glfw.wl.dataSource = NULL;
+ }
+
+ if (_glfw.wl.clipboardSendString)
+ {
+ free(_glfw.wl.clipboardSendString);
+ _glfw.wl.clipboardSendString = NULL;
+ }
+
+ _glfw.wl.clipboardSendString = strdup(string);
+ if (!_glfw.wl.clipboardSendString)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Impossible to allocate clipboard string");
+ return;
+ }
+ _glfw.wl.clipboardSendSize = strlen(string);
+ _glfw.wl.dataSource =
+ wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager);
+ if (!_glfw.wl.dataSource)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Impossible to create clipboard source");
+ free(_glfw.wl.clipboardSendString);
+ return;
+ }
+ wl_data_source_add_listener(_glfw.wl.dataSource,
+ &dataSourceListener,
+ NULL);
+ wl_data_source_offer(_glfw.wl.dataSource, "text/plain;charset=utf-8");
+ wl_data_device_set_selection(_glfw.wl.dataDevice,
+ _glfw.wl.dataSource,
+ _glfw.wl.serial);
+}
+
+static GLFWbool growClipboardString(void)
+{
+ char* clipboard = _glfw.wl.clipboardString;
+
+ clipboard = realloc(clipboard, _glfw.wl.clipboardSize * 2);
+ if (!clipboard)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Impossible to grow clipboard string");
+ return GLFW_FALSE;
+ }
+ _glfw.wl.clipboardString = clipboard;
+ _glfw.wl.clipboardSize = _glfw.wl.clipboardSize * 2;
+ return GLFW_TRUE;
+}
+
+const char* _glfwPlatformGetClipboardString(void)
+{
+ int fds[2];
+ int ret;
+ size_t len = 0;
+
+ if (!_glfw.wl.dataOffer)
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "No clipboard data has been sent yet");
+ return NULL;
+ }
+
+ ret = pipe2(fds, O_CLOEXEC);
+ if (ret < 0)
+ {
+ // TODO: also report errno maybe?
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Impossible to create clipboard pipe fds");
+ return NULL;
+ }
+
+ wl_data_offer_receive(_glfw.wl.dataOffer, "text/plain;charset=utf-8", fds[1]);
+ close(fds[1]);
+
+ // XXX: this is a huge hack, this function shouldn’t be synchronous!
+ handleEvents(-1);
+
+ while (1)
+ {
+ // Grow the clipboard if we need to paste something bigger, there is no
+ // shrink operation yet.
+ if (len + 4096 > _glfw.wl.clipboardSize)
+ {
+ if (!growClipboardString())
+ {
+ close(fds[0]);
+ return NULL;
+ }
+ }
+
+ // Then read from the fd to the clipboard, handling all known errors.
+ ret = read(fds[0], _glfw.wl.clipboardString + len, 4096);
+ if (ret == 0)
+ break;
+ if (ret == -1 && errno == EINTR)
+ continue;
+ if (ret == -1)
+ {
+ // TODO: also report errno maybe.
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Impossible to read from clipboard fd");
+ close(fds[0]);
+ return NULL;
+ }
+ len += ret;
+ }
+ close(fds[0]);
+ if (len + 1 > _glfw.wl.clipboardSize)
+ {
+ if (!growClipboardString())
+ return NULL;
+ }
+ _glfw.wl.clipboardString[len] = '\0';
+ return _glfw.wl.clipboardString;
+}
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
+{
+ if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
+ return;
+
+ extensions[0] = "VK_KHR_surface";
+ extensions[1] = "VK_KHR_wayland_surface";
+}
+
+int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily)
+{
+ PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
+ vkGetPhysicalDeviceWaylandPresentationSupportKHR =
+ (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)
+ vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+ if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
+ return VK_NULL_HANDLE;
+ }
+
+ return vkGetPhysicalDeviceWaylandPresentationSupportKHR(device,
+ queuefamily,
+ _glfw.wl.display);
+}
+
+VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
+ _GLFWwindow* window,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface)
+{
+ VkResult err;
+ VkWaylandSurfaceCreateInfoKHR sci;
+ PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
+
+ vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)
+ vkGetInstanceProcAddr(instance, "vkCreateWaylandSurfaceKHR");
+ if (!vkCreateWaylandSurfaceKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ memset(&sci, 0, sizeof(sci));
+ sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
+ sci.display = _glfw.wl.display;
+ sci.surface = window->wl.surface;
+
+ err = vkCreateWaylandSurfaceKHR(instance, &sci, allocator, surface);
+ if (err)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "Wayland: Failed to create Vulkan surface: %s",
+ _glfwGetVulkanResultString(err));
+ }
+
+ return err;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI struct wl_display* glfwGetWaylandDisplay(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return _glfw.wl.display;
+}
+
+GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return window->wl.surface;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/x11_init.c b/Client/ThirdParty/Box2D/extern/glfw/src/x11_init.c
new file mode 100644
index 0000000..e3e3ad5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/x11_init.c
@@ -0,0 +1,1096 @@
+//========================================================================
+// GLFW 3.3 X11 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <X11/Xresource.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <locale.h>
+
+
+// Translate an X11 key code to a GLFW key code.
+//
+static int translateKeyCode(int scancode)
+{
+ int keySym;
+
+ // Valid key code range is [8,255], according to the Xlib manual
+ if (scancode < 8 || scancode > 255)
+ return GLFW_KEY_UNKNOWN;
+
+ if (_glfw.x11.xkb.available)
+ {
+ // Try secondary keysym, for numeric keypad keys
+ // Note: This way we always force "NumLock = ON", which is intentional
+ // since the returned key code should correspond to a physical
+ // location.
+ keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 1);
+ switch (keySym)
+ {
+ case XK_KP_0: return GLFW_KEY_KP_0;
+ case XK_KP_1: return GLFW_KEY_KP_1;
+ case XK_KP_2: return GLFW_KEY_KP_2;
+ case XK_KP_3: return GLFW_KEY_KP_3;
+ case XK_KP_4: return GLFW_KEY_KP_4;
+ case XK_KP_5: return GLFW_KEY_KP_5;
+ case XK_KP_6: return GLFW_KEY_KP_6;
+ case XK_KP_7: return GLFW_KEY_KP_7;
+ case XK_KP_8: return GLFW_KEY_KP_8;
+ case XK_KP_9: return GLFW_KEY_KP_9;
+ case XK_KP_Separator:
+ case XK_KP_Decimal: return GLFW_KEY_KP_DECIMAL;
+ case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
+ case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
+ default: break;
+ }
+
+ // Now try primary keysym for function keys (non-printable keys)
+ // These should not depend on the current keyboard layout
+ keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);
+ }
+ else
+ {
+ int dummy;
+ KeySym* keySyms;
+
+ keySyms = XGetKeyboardMapping(_glfw.x11.display, scancode, 1, &dummy);
+ keySym = keySyms[0];
+ XFree(keySyms);
+ }
+
+ switch (keySym)
+ {
+ case XK_Escape: return GLFW_KEY_ESCAPE;
+ case XK_Tab: return GLFW_KEY_TAB;
+ case XK_Shift_L: return GLFW_KEY_LEFT_SHIFT;
+ case XK_Shift_R: return GLFW_KEY_RIGHT_SHIFT;
+ case XK_Control_L: return GLFW_KEY_LEFT_CONTROL;
+ case XK_Control_R: return GLFW_KEY_RIGHT_CONTROL;
+ case XK_Meta_L:
+ case XK_Alt_L: return GLFW_KEY_LEFT_ALT;
+ case XK_Mode_switch: // Mapped to Alt_R on many keyboards
+ case XK_ISO_Level3_Shift: // AltGr on at least some machines
+ case XK_Meta_R:
+ case XK_Alt_R: return GLFW_KEY_RIGHT_ALT;
+ case XK_Super_L: return GLFW_KEY_LEFT_SUPER;
+ case XK_Super_R: return GLFW_KEY_RIGHT_SUPER;
+ case XK_Menu: return GLFW_KEY_MENU;
+ case XK_Num_Lock: return GLFW_KEY_NUM_LOCK;
+ case XK_Caps_Lock: return GLFW_KEY_CAPS_LOCK;
+ case XK_Print: return GLFW_KEY_PRINT_SCREEN;
+ case XK_Scroll_Lock: return GLFW_KEY_SCROLL_LOCK;
+ case XK_Pause: return GLFW_KEY_PAUSE;
+ case XK_Delete: return GLFW_KEY_DELETE;
+ case XK_BackSpace: return GLFW_KEY_BACKSPACE;
+ case XK_Return: return GLFW_KEY_ENTER;
+ case XK_Home: return GLFW_KEY_HOME;
+ case XK_End: return GLFW_KEY_END;
+ case XK_Page_Up: return GLFW_KEY_PAGE_UP;
+ case XK_Page_Down: return GLFW_KEY_PAGE_DOWN;
+ case XK_Insert: return GLFW_KEY_INSERT;
+ case XK_Left: return GLFW_KEY_LEFT;
+ case XK_Right: return GLFW_KEY_RIGHT;
+ case XK_Down: return GLFW_KEY_DOWN;
+ case XK_Up: return GLFW_KEY_UP;
+ case XK_F1: return GLFW_KEY_F1;
+ case XK_F2: return GLFW_KEY_F2;
+ case XK_F3: return GLFW_KEY_F3;
+ case XK_F4: return GLFW_KEY_F4;
+ case XK_F5: return GLFW_KEY_F5;
+ case XK_F6: return GLFW_KEY_F6;
+ case XK_F7: return GLFW_KEY_F7;
+ case XK_F8: return GLFW_KEY_F8;
+ case XK_F9: return GLFW_KEY_F9;
+ case XK_F10: return GLFW_KEY_F10;
+ case XK_F11: return GLFW_KEY_F11;
+ case XK_F12: return GLFW_KEY_F12;
+ case XK_F13: return GLFW_KEY_F13;
+ case XK_F14: return GLFW_KEY_F14;
+ case XK_F15: return GLFW_KEY_F15;
+ case XK_F16: return GLFW_KEY_F16;
+ case XK_F17: return GLFW_KEY_F17;
+ case XK_F18: return GLFW_KEY_F18;
+ case XK_F19: return GLFW_KEY_F19;
+ case XK_F20: return GLFW_KEY_F20;
+ case XK_F21: return GLFW_KEY_F21;
+ case XK_F22: return GLFW_KEY_F22;
+ case XK_F23: return GLFW_KEY_F23;
+ case XK_F24: return GLFW_KEY_F24;
+ case XK_F25: return GLFW_KEY_F25;
+
+ // Numeric keypad
+ case XK_KP_Divide: return GLFW_KEY_KP_DIVIDE;
+ case XK_KP_Multiply: return GLFW_KEY_KP_MULTIPLY;
+ case XK_KP_Subtract: return GLFW_KEY_KP_SUBTRACT;
+ case XK_KP_Add: return GLFW_KEY_KP_ADD;
+
+ // These should have been detected in secondary keysym test above!
+ case XK_KP_Insert: return GLFW_KEY_KP_0;
+ case XK_KP_End: return GLFW_KEY_KP_1;
+ case XK_KP_Down: return GLFW_KEY_KP_2;
+ case XK_KP_Page_Down: return GLFW_KEY_KP_3;
+ case XK_KP_Left: return GLFW_KEY_KP_4;
+ case XK_KP_Right: return GLFW_KEY_KP_6;
+ case XK_KP_Home: return GLFW_KEY_KP_7;
+ case XK_KP_Up: return GLFW_KEY_KP_8;
+ case XK_KP_Page_Up: return GLFW_KEY_KP_9;
+ case XK_KP_Delete: return GLFW_KEY_KP_DECIMAL;
+ case XK_KP_Equal: return GLFW_KEY_KP_EQUAL;
+ case XK_KP_Enter: return GLFW_KEY_KP_ENTER;
+
+ // Last resort: Check for printable keys (should not happen if the XKB
+ // extension is available). This will give a layout dependent mapping
+ // (which is wrong, and we may miss some keys, especially on non-US
+ // keyboards), but it's better than nothing...
+ case XK_a: return GLFW_KEY_A;
+ case XK_b: return GLFW_KEY_B;
+ case XK_c: return GLFW_KEY_C;
+ case XK_d: return GLFW_KEY_D;
+ case XK_e: return GLFW_KEY_E;
+ case XK_f: return GLFW_KEY_F;
+ case XK_g: return GLFW_KEY_G;
+ case XK_h: return GLFW_KEY_H;
+ case XK_i: return GLFW_KEY_I;
+ case XK_j: return GLFW_KEY_J;
+ case XK_k: return GLFW_KEY_K;
+ case XK_l: return GLFW_KEY_L;
+ case XK_m: return GLFW_KEY_M;
+ case XK_n: return GLFW_KEY_N;
+ case XK_o: return GLFW_KEY_O;
+ case XK_p: return GLFW_KEY_P;
+ case XK_q: return GLFW_KEY_Q;
+ case XK_r: return GLFW_KEY_R;
+ case XK_s: return GLFW_KEY_S;
+ case XK_t: return GLFW_KEY_T;
+ case XK_u: return GLFW_KEY_U;
+ case XK_v: return GLFW_KEY_V;
+ case XK_w: return GLFW_KEY_W;
+ case XK_x: return GLFW_KEY_X;
+ case XK_y: return GLFW_KEY_Y;
+ case XK_z: return GLFW_KEY_Z;
+ case XK_1: return GLFW_KEY_1;
+ case XK_2: return GLFW_KEY_2;
+ case XK_3: return GLFW_KEY_3;
+ case XK_4: return GLFW_KEY_4;
+ case XK_5: return GLFW_KEY_5;
+ case XK_6: return GLFW_KEY_6;
+ case XK_7: return GLFW_KEY_7;
+ case XK_8: return GLFW_KEY_8;
+ case XK_9: return GLFW_KEY_9;
+ case XK_0: return GLFW_KEY_0;
+ case XK_space: return GLFW_KEY_SPACE;
+ case XK_minus: return GLFW_KEY_MINUS;
+ case XK_equal: return GLFW_KEY_EQUAL;
+ case XK_bracketleft: return GLFW_KEY_LEFT_BRACKET;
+ case XK_bracketright: return GLFW_KEY_RIGHT_BRACKET;
+ case XK_backslash: return GLFW_KEY_BACKSLASH;
+ case XK_semicolon: return GLFW_KEY_SEMICOLON;
+ case XK_apostrophe: return GLFW_KEY_APOSTROPHE;
+ case XK_grave: return GLFW_KEY_GRAVE_ACCENT;
+ case XK_comma: return GLFW_KEY_COMMA;
+ case XK_period: return GLFW_KEY_PERIOD;
+ case XK_slash: return GLFW_KEY_SLASH;
+ case XK_less: return GLFW_KEY_WORLD_1; // At least in some layouts...
+ default: break;
+ }
+
+ // No matching translation was found
+ return GLFW_KEY_UNKNOWN;
+}
+
+// Create key code translation tables
+//
+static void createKeyTables(void)
+{
+ int scancode, key;
+
+ memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
+ memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
+
+ if (_glfw.x11.xkb.available)
+ {
+ // Use XKB to determine physical key locations independently of the
+ // current keyboard layout
+
+ char name[XkbKeyNameLength + 1];
+ XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);
+ XkbGetNames(_glfw.x11.display, XkbKeyNamesMask, desc);
+
+ // Find the X11 key code -> GLFW key code mapping
+ for (scancode = desc->min_key_code; scancode <= desc->max_key_code; scancode++)
+ {
+ memcpy(name, desc->names->keys[scancode].name, XkbKeyNameLength);
+ name[XkbKeyNameLength] = '\0';
+
+ // Map the key name to a GLFW key code. Note: We only map printable
+ // keys here, and we use the US keyboard layout. The rest of the
+ // keys (function keys) are mapped using traditional KeySym
+ // translations.
+ if (strcmp(name, "TLDE") == 0) key = GLFW_KEY_GRAVE_ACCENT;
+ else if (strcmp(name, "AE01") == 0) key = GLFW_KEY_1;
+ else if (strcmp(name, "AE02") == 0) key = GLFW_KEY_2;
+ else if (strcmp(name, "AE03") == 0) key = GLFW_KEY_3;
+ else if (strcmp(name, "AE04") == 0) key = GLFW_KEY_4;
+ else if (strcmp(name, "AE05") == 0) key = GLFW_KEY_5;
+ else if (strcmp(name, "AE06") == 0) key = GLFW_KEY_6;
+ else if (strcmp(name, "AE07") == 0) key = GLFW_KEY_7;
+ else if (strcmp(name, "AE08") == 0) key = GLFW_KEY_8;
+ else if (strcmp(name, "AE09") == 0) key = GLFW_KEY_9;
+ else if (strcmp(name, "AE10") == 0) key = GLFW_KEY_0;
+ else if (strcmp(name, "AE11") == 0) key = GLFW_KEY_MINUS;
+ else if (strcmp(name, "AE12") == 0) key = GLFW_KEY_EQUAL;
+ else if (strcmp(name, "AD01") == 0) key = GLFW_KEY_Q;
+ else if (strcmp(name, "AD02") == 0) key = GLFW_KEY_W;
+ else if (strcmp(name, "AD03") == 0) key = GLFW_KEY_E;
+ else if (strcmp(name, "AD04") == 0) key = GLFW_KEY_R;
+ else if (strcmp(name, "AD05") == 0) key = GLFW_KEY_T;
+ else if (strcmp(name, "AD06") == 0) key = GLFW_KEY_Y;
+ else if (strcmp(name, "AD07") == 0) key = GLFW_KEY_U;
+ else if (strcmp(name, "AD08") == 0) key = GLFW_KEY_I;
+ else if (strcmp(name, "AD09") == 0) key = GLFW_KEY_O;
+ else if (strcmp(name, "AD10") == 0) key = GLFW_KEY_P;
+ else if (strcmp(name, "AD11") == 0) key = GLFW_KEY_LEFT_BRACKET;
+ else if (strcmp(name, "AD12") == 0) key = GLFW_KEY_RIGHT_BRACKET;
+ else if (strcmp(name, "AC01") == 0) key = GLFW_KEY_A;
+ else if (strcmp(name, "AC02") == 0) key = GLFW_KEY_S;
+ else if (strcmp(name, "AC03") == 0) key = GLFW_KEY_D;
+ else if (strcmp(name, "AC04") == 0) key = GLFW_KEY_F;
+ else if (strcmp(name, "AC05") == 0) key = GLFW_KEY_G;
+ else if (strcmp(name, "AC06") == 0) key = GLFW_KEY_H;
+ else if (strcmp(name, "AC07") == 0) key = GLFW_KEY_J;
+ else if (strcmp(name, "AC08") == 0) key = GLFW_KEY_K;
+ else if (strcmp(name, "AC09") == 0) key = GLFW_KEY_L;
+ else if (strcmp(name, "AC10") == 0) key = GLFW_KEY_SEMICOLON;
+ else if (strcmp(name, "AC11") == 0) key = GLFW_KEY_APOSTROPHE;
+ else if (strcmp(name, "AB01") == 0) key = GLFW_KEY_Z;
+ else if (strcmp(name, "AB02") == 0) key = GLFW_KEY_X;
+ else if (strcmp(name, "AB03") == 0) key = GLFW_KEY_C;
+ else if (strcmp(name, "AB04") == 0) key = GLFW_KEY_V;
+ else if (strcmp(name, "AB05") == 0) key = GLFW_KEY_B;
+ else if (strcmp(name, "AB06") == 0) key = GLFW_KEY_N;
+ else if (strcmp(name, "AB07") == 0) key = GLFW_KEY_M;
+ else if (strcmp(name, "AB08") == 0) key = GLFW_KEY_COMMA;
+ else if (strcmp(name, "AB09") == 0) key = GLFW_KEY_PERIOD;
+ else if (strcmp(name, "AB10") == 0) key = GLFW_KEY_SLASH;
+ else if (strcmp(name, "BKSL") == 0) key = GLFW_KEY_BACKSLASH;
+ else if (strcmp(name, "LSGT") == 0) key = GLFW_KEY_WORLD_1;
+ else key = GLFW_KEY_UNKNOWN;
+
+ if ((scancode >= 0) && (scancode < 256))
+ _glfw.x11.keycodes[scancode] = key;
+ }
+
+ XkbFreeNames(desc, XkbKeyNamesMask, True);
+ XkbFreeKeyboard(desc, 0, True);
+ }
+
+ for (scancode = 0; scancode < 256; scancode++)
+ {
+ // Translate the un-translated key codes using traditional X11 KeySym
+ // lookups
+ if (_glfw.x11.keycodes[scancode] < 0)
+ _glfw.x11.keycodes[scancode] = translateKeyCode(scancode);
+
+ // Store the reverse translation for faster key name lookup
+ if (_glfw.x11.keycodes[scancode] > 0)
+ _glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode;
+ }
+}
+
+// Check whether the IM has a usable style
+//
+static GLFWbool hasUsableInputMethodStyle(void)
+{
+ unsigned int i;
+ GLFWbool found = GLFW_FALSE;
+ XIMStyles* styles = NULL;
+
+ if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
+ return GLFW_FALSE;
+
+ for (i = 0; i < styles->count_styles; i++)
+ {
+ if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
+ {
+ found = GLFW_TRUE;
+ break;
+ }
+ }
+
+ XFree(styles);
+ return found;
+}
+
+// Check whether the specified atom is supported
+//
+static Atom getSupportedAtom(Atom* supportedAtoms,
+ unsigned long atomCount,
+ const char* atomName)
+{
+ unsigned long i;
+ const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
+
+ for (i = 0; i < atomCount; i++)
+ {
+ if (supportedAtoms[i] == atom)
+ return atom;
+ }
+
+ return None;
+}
+
+// Check whether the running window manager is EWMH-compliant
+//
+static void detectEWMH(void)
+{
+ Window* windowFromRoot = NULL;
+ Window* windowFromChild = NULL;
+
+ // First we need a couple of atoms
+ const Atom supportingWmCheck =
+ XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
+ const Atom wmSupported =
+ XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
+
+ // Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
+ if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
+ supportingWmCheck,
+ XA_WINDOW,
+ (unsigned char**) &windowFromRoot))
+ {
+ return;
+ }
+
+ _glfwGrabErrorHandlerX11();
+
+ // It should be the ID of a child window (of the root)
+ // Then we look for the same property on the child window
+ if (!_glfwGetWindowPropertyX11(*windowFromRoot,
+ supportingWmCheck,
+ XA_WINDOW,
+ (unsigned char**) &windowFromChild))
+ {
+ XFree(windowFromRoot);
+ return;
+ }
+
+ _glfwReleaseErrorHandlerX11();
+
+ // It should be the ID of that same child window
+ if (*windowFromRoot != *windowFromChild)
+ {
+ XFree(windowFromRoot);
+ XFree(windowFromChild);
+ return;
+ }
+
+ XFree(windowFromRoot);
+ XFree(windowFromChild);
+
+ // We are now fairly sure that an EWMH-compliant window manager is running
+
+ Atom* supportedAtoms;
+ unsigned long atomCount;
+
+ // Now we need to check the _NET_SUPPORTED property of the root window
+ // It should be a list of supported WM protocol and state atoms
+ atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root,
+ wmSupported,
+ XA_ATOM,
+ (unsigned char**) &supportedAtoms);
+
+ // See which of the atoms we support that are supported by the WM
+ _glfw.x11.NET_WM_STATE =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE");
+ _glfw.x11.NET_WM_STATE_ABOVE =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
+ _glfw.x11.NET_WM_STATE_FULLSCREEN =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
+ _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
+ _glfw.x11.NET_WM_WINDOW_TYPE =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
+ _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
+ _glfw.x11.NET_ACTIVE_WINDOW =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
+ _glfw.x11.NET_FRAME_EXTENTS =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
+ _glfw.x11.NET_REQUEST_FRAME_EXTENTS =
+ getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
+
+ if (supportedAtoms)
+ XFree(supportedAtoms);
+}
+
+// Look for and initialize supported X11 extensions
+//
+static GLFWbool initExtensions(void)
+{
+ _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1");
+ if (_glfw.x11.vidmode.handle)
+ {
+ _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
+ _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
+ _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
+ _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
+ _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
+ _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
+ _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
+ _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
+
+ _glfw.x11.vidmode.available =
+ XF86VidModeQueryExtension(_glfw.x11.display,
+ &_glfw.x11.vidmode.eventBase,
+ &_glfw.x11.vidmode.errorBase);
+ }
+
+#if defined(__CYGWIN__)
+ _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so");
+#else
+ _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6");
+#endif
+ if (_glfw.x11.xi.handle)
+ {
+ _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion)
+ _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion");
+ _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
+ _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents");
+
+ if (XQueryExtension(_glfw.x11.display,
+ "XInputExtension",
+ &_glfw.x11.xi.majorOpcode,
+ &_glfw.x11.xi.eventBase,
+ &_glfw.x11.xi.errorBase))
+ {
+ _glfw.x11.xi.major = 2;
+ _glfw.x11.xi.minor = 0;
+
+ if (XIQueryVersion(_glfw.x11.display,
+ &_glfw.x11.xi.major,
+ &_glfw.x11.xi.minor) == Success)
+ {
+ _glfw.x11.xi.available = GLFW_TRUE;
+ }
+ }
+ }
+
+#if defined(__CYGWIN__)
+ _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so");
+#else
+ _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2");
+#endif
+ if (_glfw.x11.randr.handle)
+ {
+ _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma");
+ _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
+ _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo");
+ _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
+ _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo");
+ _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources");
+ _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma");
+ _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
+ _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo");
+ _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo");
+ _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary");
+ _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
+ _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension");
+ _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion");
+ _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput");
+ _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig");
+ _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma");
+ _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration)
+ _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration");
+
+ if (XRRQueryExtension(_glfw.x11.display,
+ &_glfw.x11.randr.eventBase,
+ &_glfw.x11.randr.errorBase))
+ {
+ if (XRRQueryVersion(_glfw.x11.display,
+ &_glfw.x11.randr.major,
+ &_glfw.x11.randr.minor))
+ {
+ // The GLFW RandR path requires at least version 1.3
+ if (_glfw.x11.randr.major > 1 || _glfw.x11.randr.minor >= 3)
+ _glfw.x11.randr.available = GLFW_TRUE;
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to query RandR version");
+ }
+ }
+ }
+
+ if (_glfw.x11.randr.available)
+ {
+ XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
+ _glfw.x11.root);
+
+ if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
+ {
+ // This is likely an older Nvidia driver with broken gamma support
+ // Flag it as useless and fall back to xf86vm gamma, if available
+ _glfw.x11.randr.gammaBroken = GLFW_TRUE;
+ }
+
+ if (!sr->ncrtc)
+ {
+ // A system without CRTCs is likely a system with broken RandR
+ // Disable the RandR monitor path and fall back to core functions
+ _glfw.x11.randr.monitorBroken = GLFW_TRUE;
+ }
+
+ XRRFreeScreenResources(sr);
+ }
+
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ XRRSelectInput(_glfw.x11.display, _glfw.x11.root,
+ RROutputChangeNotifyMask);
+ }
+
+#if defined(__CYGWIN__)
+ _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so");
+#else
+ _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1");
+#endif
+ if (_glfw.x11.xcursor.handle)
+ {
+ _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
+ _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate");
+ _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
+ _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
+ _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
+ _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
+ }
+
+#if defined(__CYGWIN__)
+ _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so");
+#else
+ _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1");
+#endif
+ if (_glfw.x11.xinerama.handle)
+ {
+ _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
+ _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive");
+ _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension)
+ _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
+ _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
+ _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
+
+ if (XineramaQueryExtension(_glfw.x11.display,
+ &_glfw.x11.xinerama.major,
+ &_glfw.x11.xinerama.minor))
+ {
+ if (XineramaIsActive(_glfw.x11.display))
+ _glfw.x11.xinerama.available = GLFW_TRUE;
+ }
+ }
+
+ _glfw.x11.xkb.major = 1;
+ _glfw.x11.xkb.minor = 0;
+ _glfw.x11.xkb.available =
+ XkbQueryExtension(_glfw.x11.display,
+ &_glfw.x11.xkb.majorOpcode,
+ &_glfw.x11.xkb.eventBase,
+ &_glfw.x11.xkb.errorBase,
+ &_glfw.x11.xkb.major,
+ &_glfw.x11.xkb.minor);
+
+ if (_glfw.x11.xkb.available)
+ {
+ Bool supported;
+
+ if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
+ {
+ if (supported)
+ _glfw.x11.xkb.detectable = GLFW_TRUE;
+ }
+ }
+
+#if defined(__CYGWIN__)
+ _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
+#else
+ _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
+#endif
+ if (_glfw.x11.x11xcb.handle)
+ {
+ _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
+ _glfw_dlsym(_glfw.x11.x11xcb.handle, "XGetXCBConnection");
+ }
+
+#if defined(__CYGWIN__)
+ _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so");
+#else
+ _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1");
+#endif
+ if (_glfw.x11.xrender.handle)
+ {
+ _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension)
+ _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension");
+ _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion)
+ _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion");
+ _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
+ _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
+
+ if (XRenderQueryExtension(_glfw.x11.display,
+ &_glfw.x11.xrender.errorBase,
+ &_glfw.x11.xrender.eventBase))
+ {
+ if (XRenderQueryVersion(_glfw.x11.display,
+ &_glfw.x11.xrender.major,
+ &_glfw.x11.xrender.minor))
+ {
+ _glfw.x11.xrender.available = GLFW_TRUE;
+ }
+ }
+ }
+
+ // Update the key code LUT
+ // FIXME: We should listen to XkbMapNotify events to track changes to
+ // the keyboard mapping.
+ createKeyTables();
+
+ // Detect whether an EWMH-conformant window manager is running
+ detectEWMH();
+
+ // String format atoms
+ _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
+ _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
+ _glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, "ATOM_PAIR", False);
+
+ // Custom selection property atom
+ _glfw.x11.GLFW_SELECTION =
+ XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
+
+ // ICCCM standard clipboard atoms
+ _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
+ _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
+ _glfw.x11.PRIMARY = XInternAtom(_glfw.x11.display, "PRIMARY", False);
+ _glfw.x11.INCR = XInternAtom(_glfw.x11.display, "INCR", False);
+ _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
+
+ // Clipboard manager atoms
+ _glfw.x11.CLIPBOARD_MANAGER =
+ XInternAtom(_glfw.x11.display, "CLIPBOARD_MANAGER", False);
+ _glfw.x11.SAVE_TARGETS =
+ XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
+
+ // Xdnd (drag and drop) atoms
+ _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
+ _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
+ _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
+ _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
+ _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
+ _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
+ _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
+ _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
+ _glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
+ _glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
+
+ // ICCCM, EWMH and Motif window property atoms
+ // These can be set safely even without WM support
+ // The EWMH atoms that require WM support are handled in detectEWMH
+ _glfw.x11.WM_PROTOCOLS =
+ XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False);
+ _glfw.x11.WM_STATE =
+ XInternAtom(_glfw.x11.display, "WM_STATE", False);
+ _glfw.x11.WM_DELETE_WINDOW =
+ XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
+ _glfw.x11.NET_WM_ICON =
+ XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
+ _glfw.x11.NET_WM_PING =
+ XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
+ _glfw.x11.NET_WM_PID =
+ XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
+ _glfw.x11.NET_WM_NAME =
+ XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
+ _glfw.x11.NET_WM_ICON_NAME =
+ XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
+ _glfw.x11.NET_WM_BYPASS_COMPOSITOR =
+ XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
+ _glfw.x11.NET_WM_WINDOW_OPACITY =
+ XInternAtom(_glfw.x11.display, "_NET_WM_WINDOW_OPACITY", False);
+ _glfw.x11.MOTIF_WM_HINTS =
+ XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False);
+
+ // The compositing manager selection name contains the screen number
+ {
+ char name[32];
+ snprintf(name, sizeof(name), "_NET_WM_CM_S%u", _glfw.x11.screen);
+ _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
+ }
+
+ return GLFW_TRUE;
+}
+
+// Retrieve system content scale via folklore heuristics
+//
+static void getSystemContentScale(float* xscale, float* yscale)
+{
+ // NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if
+ // Xft.dpi retrieval below fails as we don't currently have an exact
+ // policy for which monitor a window is considered to "be on"
+ float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) *
+ 25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
+ float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) *
+ 25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
+
+ // NOTE: Basing the scale on Xft.dpi where available should provide the most
+ // consistent user experience (matches Qt, Gtk, etc), although not
+ // always the most accurate one
+ char* rms = XResourceManagerString(_glfw.x11.display);
+ if (rms)
+ {
+ XrmDatabase db = XrmGetStringDatabase(rms);
+ if (db)
+ {
+ XrmValue value;
+ char* type = NULL;
+
+ if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
+ {
+ if (type && strcmp(type, "String") == 0)
+ xdpi = ydpi = atof(value.addr);
+ }
+
+ XrmDestroyDatabase(db);
+ }
+ }
+
+ *xscale = xdpi / 96.f;
+ *yscale = ydpi / 96.f;
+}
+
+// Create a blank cursor for hidden and disabled cursor modes
+//
+static Cursor createHiddenCursor(void)
+{
+ unsigned char pixels[16 * 16 * 4] = { 0 };
+ GLFWimage image = { 16, 16, pixels };
+ return _glfwCreateCursorX11(&image, 0, 0);
+}
+
+// Create a helper window for IPC
+//
+static Window createHelperWindow(void)
+{
+ XSetWindowAttributes wa;
+ wa.event_mask = PropertyChangeMask;
+
+ return XCreateWindow(_glfw.x11.display, _glfw.x11.root,
+ 0, 0, 1, 1, 0, 0,
+ InputOnly,
+ DefaultVisual(_glfw.x11.display, _glfw.x11.screen),
+ CWEventMask, &wa);
+}
+
+// X error handler
+//
+static int errorHandler(Display *display, XErrorEvent* event)
+{
+ _glfw.x11.errorCode = event->error_code;
+ return 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Sets the X error handler callback
+//
+void _glfwGrabErrorHandlerX11(void)
+{
+ _glfw.x11.errorCode = Success;
+ XSetErrorHandler(errorHandler);
+}
+
+// Clears the X error handler callback
+//
+void _glfwReleaseErrorHandlerX11(void)
+{
+ // Synchronize to make sure all commands are processed
+ XSync(_glfw.x11.display, False);
+ XSetErrorHandler(NULL);
+}
+
+// Reports the specified error, appending information about the last X error
+//
+void _glfwInputErrorX11(int error, const char* message)
+{
+ char buffer[_GLFW_MESSAGE_SIZE];
+ XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
+ buffer, sizeof(buffer));
+
+ _glfwInputError(error, "%s: %s", message, buffer);
+}
+
+// Creates a native cursor object from the specified image and hotspot
+//
+Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
+{
+ int i;
+ Cursor cursor;
+
+ if (!_glfw.x11.xcursor.handle)
+ return None;
+
+ XcursorImage* native = XcursorImageCreate(image->width, image->height);
+ if (native == NULL)
+ return None;
+
+ native->xhot = xhot;
+ native->yhot = yhot;
+
+ unsigned char* source = (unsigned char*) image->pixels;
+ XcursorPixel* target = native->pixels;
+
+ for (i = 0; i < image->width * image->height; i++, target++, source += 4)
+ {
+ unsigned int alpha = source[3];
+
+ *target = (alpha << 24) |
+ ((unsigned char) ((source[0] * alpha) / 255) << 16) |
+ ((unsigned char) ((source[1] * alpha) / 255) << 8) |
+ ((unsigned char) ((source[2] * alpha) / 255) << 0);
+ }
+
+ cursor = XcursorImageLoadCursor(_glfw.x11.display, native);
+ XcursorImageDestroy(native);
+
+ return cursor;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformInit(void)
+{
+#if !defined(X_HAVE_UTF8_STRING)
+ // HACK: If the current locale is "C" and the Xlib UTF-8 functions are
+ // unavailable, apply the environment's locale in the hope that it's
+ // both available and not "C"
+ // This is done because the "C" locale breaks wide character input,
+ // which is what we fall back on when UTF-8 support is missing
+ if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
+ setlocale(LC_CTYPE, "");
+#endif
+
+ XInitThreads();
+ XrmInitialize();
+
+ _glfw.x11.display = XOpenDisplay(NULL);
+ if (!_glfw.x11.display)
+ {
+ const char* display = getenv("DISPLAY");
+ if (display)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to open display %s", display);
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: The DISPLAY environment variable is missing");
+ }
+
+ return GLFW_FALSE;
+ }
+
+ _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
+ _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
+ _glfw.x11.context = XUniqueContext();
+
+ getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY);
+
+ if (!initExtensions())
+ return GLFW_FALSE;
+
+ _glfw.x11.helperWindowHandle = createHelperWindow();
+ _glfw.x11.hiddenCursorHandle = createHiddenCursor();
+
+ if (XSupportsLocale())
+ {
+ XSetLocaleModifiers("");
+
+ _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
+ if (_glfw.x11.im)
+ {
+ if (!hasUsableInputMethodStyle())
+ {
+ XCloseIM(_glfw.x11.im);
+ _glfw.x11.im = NULL;
+ }
+ }
+ }
+
+#if defined(__linux__)
+ if (!_glfwInitJoysticksLinux())
+ return GLFW_FALSE;
+#endif
+
+ _glfwInitTimerPOSIX();
+
+ _glfwPollMonitorsX11();
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformTerminate(void)
+{
+ if (_glfw.x11.helperWindowHandle)
+ {
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
+ _glfw.x11.helperWindowHandle)
+ {
+ _glfwPushSelectionToManagerX11();
+ }
+
+ XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle);
+ _glfw.x11.helperWindowHandle = None;
+ }
+
+ if (_glfw.x11.hiddenCursorHandle)
+ {
+ XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle);
+ _glfw.x11.hiddenCursorHandle = (Cursor) 0;
+ }
+
+ free(_glfw.x11.primarySelectionString);
+ free(_glfw.x11.clipboardString);
+
+ if (_glfw.x11.im)
+ {
+ XCloseIM(_glfw.x11.im);
+ _glfw.x11.im = NULL;
+ }
+
+ if (_glfw.x11.display)
+ {
+ XCloseDisplay(_glfw.x11.display);
+ _glfw.x11.display = NULL;
+ }
+
+ if (_glfw.x11.x11xcb.handle)
+ {
+ _glfw_dlclose(_glfw.x11.x11xcb.handle);
+ _glfw.x11.x11xcb.handle = NULL;
+ }
+
+ if (_glfw.x11.xcursor.handle)
+ {
+ _glfw_dlclose(_glfw.x11.xcursor.handle);
+ _glfw.x11.xcursor.handle = NULL;
+ }
+
+ if (_glfw.x11.randr.handle)
+ {
+ _glfw_dlclose(_glfw.x11.randr.handle);
+ _glfw.x11.randr.handle = NULL;
+ }
+
+ if (_glfw.x11.xinerama.handle)
+ {
+ _glfw_dlclose(_glfw.x11.xinerama.handle);
+ _glfw.x11.xinerama.handle = NULL;
+ }
+
+ if (_glfw.x11.xrender.handle)
+ {
+ _glfw_dlclose(_glfw.x11.xrender.handle);
+ _glfw.x11.xrender.handle = NULL;
+ }
+
+ if (_glfw.x11.vidmode.handle)
+ {
+ _glfw_dlclose(_glfw.x11.vidmode.handle);
+ _glfw.x11.vidmode.handle = NULL;
+ }
+
+ if (_glfw.x11.xi.handle)
+ {
+ _glfw_dlclose(_glfw.x11.xi.handle);
+ _glfw.x11.xi.handle = NULL;
+ }
+
+ // NOTE: These need to be unloaded after XCloseDisplay, as they register
+ // cleanup callbacks that get called by that function
+ _glfwTerminateEGL();
+ _glfwTerminateGLX();
+
+#if defined(__linux__)
+ _glfwTerminateJoysticksLinux();
+#endif
+}
+
+const char* _glfwPlatformGetVersionString(void)
+{
+ return _GLFW_VERSION_NUMBER " X11 GLX EGL"
+#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
+ " clock_gettime"
+#else
+ " gettimeofday"
+#endif
+#if defined(__linux__)
+ " evdev"
+#endif
+#if defined(_GLFW_BUILD_DLL)
+ " shared"
+#endif
+ ;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/x11_monitor.c b/Client/ThirdParty/Box2D/extern/glfw/src/x11_monitor.c
new file mode 100644
index 0000000..df53041
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/x11_monitor.c
@@ -0,0 +1,517 @@
+//========================================================================
+// GLFW 3.3 X11 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+// Check whether the display mode should be included in enumeration
+//
+static GLFWbool modeIsGood(const XRRModeInfo* mi)
+{
+ return (mi->modeFlags & RR_Interlace) == 0;
+}
+
+// Calculates the refresh rate, in Hz, from the specified RandR mode info
+//
+static int calculateRefreshRate(const XRRModeInfo* mi)
+{
+ if (mi->hTotal && mi->vTotal)
+ return (int) ((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
+ else
+ return 0;
+}
+
+// Returns the mode info for a RandR mode XID
+//
+static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
+{
+ int i;
+
+ for (i = 0; i < sr->nmode; i++)
+ {
+ if (sr->modes[i].id == id)
+ return sr->modes + i;
+ }
+
+ return NULL;
+}
+
+// Convert RandR mode info to GLFW video mode
+//
+static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
+ const XRRCrtcInfo* ci)
+{
+ GLFWvidmode mode;
+
+ if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
+ {
+ mode.width = mi->height;
+ mode.height = mi->width;
+ }
+ else
+ {
+ mode.width = mi->width;
+ mode.height = mi->height;
+ }
+
+ mode.refreshRate = calculateRefreshRate(mi);
+
+ _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
+ &mode.redBits, &mode.greenBits, &mode.blueBits);
+
+ return mode;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Poll for changes in the set of connected monitors
+//
+void _glfwPollMonitorsX11(void)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ int i, j, disconnectedCount, screenCount = 0;
+ _GLFWmonitor** disconnected = NULL;
+ XineramaScreenInfo* screens = NULL;
+ XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
+ _glfw.x11.root);
+ RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,
+ _glfw.x11.root);
+
+ if (_glfw.x11.xinerama.available)
+ screens = XineramaQueryScreens(_glfw.x11.display, &screenCount);
+
+ disconnectedCount = _glfw.monitorCount;
+ if (disconnectedCount)
+ {
+ disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
+ memcpy(disconnected,
+ _glfw.monitors,
+ _glfw.monitorCount * sizeof(_GLFWmonitor*));
+ }
+
+ for (i = 0; i < sr->noutput; i++)
+ {
+ int type, widthMM, heightMM;
+ XRROutputInfo* oi;
+ XRRCrtcInfo* ci;
+ _GLFWmonitor* monitor;
+
+ oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
+ if (oi->connection != RR_Connected || oi->crtc == None)
+ {
+ XRRFreeOutputInfo(oi);
+ continue;
+ }
+
+ for (j = 0; j < disconnectedCount; j++)
+ {
+ if (disconnected[j] &&
+ disconnected[j]->x11.output == sr->outputs[i])
+ {
+ disconnected[j] = NULL;
+ break;
+ }
+ }
+
+ if (j < disconnectedCount)
+ {
+ XRRFreeOutputInfo(oi);
+ continue;
+ }
+
+ ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
+ if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
+ {
+ widthMM = oi->mm_height;
+ heightMM = oi->mm_width;
+ }
+ else
+ {
+ widthMM = oi->mm_width;
+ heightMM = oi->mm_height;
+ }
+
+ monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
+ monitor->x11.output = sr->outputs[i];
+ monitor->x11.crtc = oi->crtc;
+
+ for (j = 0; j < screenCount; j++)
+ {
+ if (screens[j].x_org == ci->x &&
+ screens[j].y_org == ci->y &&
+ screens[j].width == ci->width &&
+ screens[j].height == ci->height)
+ {
+ monitor->x11.index = j;
+ break;
+ }
+ }
+
+ if (monitor->x11.output == primary)
+ type = _GLFW_INSERT_FIRST;
+ else
+ type = _GLFW_INSERT_LAST;
+
+ _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
+
+ XRRFreeOutputInfo(oi);
+ XRRFreeCrtcInfo(ci);
+ }
+
+ XRRFreeScreenResources(sr);
+
+ if (screens)
+ XFree(screens);
+
+ for (i = 0; i < disconnectedCount; i++)
+ {
+ if (disconnected[i])
+ _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
+ }
+
+ free(disconnected);
+ }
+ else
+ {
+ const int widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
+ const int heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
+
+ _glfwInputMonitor(_glfwAllocMonitor("Display", widthMM, heightMM),
+ GLFW_CONNECTED,
+ _GLFW_INSERT_FIRST);
+ }
+}
+
+// Set the current video mode for the specified monitor
+//
+void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ XRRScreenResources* sr;
+ XRRCrtcInfo* ci;
+ XRROutputInfo* oi;
+ GLFWvidmode current;
+ const GLFWvidmode* best;
+ RRMode native = None;
+ int i;
+
+ best = _glfwChooseVideoMode(monitor, desired);
+ _glfwPlatformGetVideoMode(monitor, &current);
+ if (_glfwCompareVideoModes(&current, best) == 0)
+ return;
+
+ sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
+ ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
+ oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
+
+ for (i = 0; i < oi->nmode; i++)
+ {
+ const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
+ if (!modeIsGood(mi))
+ continue;
+
+ const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
+ if (_glfwCompareVideoModes(best, &mode) == 0)
+ {
+ native = mi->id;
+ break;
+ }
+ }
+
+ if (native)
+ {
+ if (monitor->x11.oldMode == None)
+ monitor->x11.oldMode = ci->mode;
+
+ XRRSetCrtcConfig(_glfw.x11.display,
+ sr, monitor->x11.crtc,
+ CurrentTime,
+ ci->x, ci->y,
+ native,
+ ci->rotation,
+ ci->outputs,
+ ci->noutput);
+ }
+
+ XRRFreeOutputInfo(oi);
+ XRRFreeCrtcInfo(ci);
+ XRRFreeScreenResources(sr);
+ }
+}
+
+// Restore the saved (original) video mode for the specified monitor
+//
+void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ XRRScreenResources* sr;
+ XRRCrtcInfo* ci;
+
+ if (monitor->x11.oldMode == None)
+ return;
+
+ sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
+ ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
+
+ XRRSetCrtcConfig(_glfw.x11.display,
+ sr, monitor->x11.crtc,
+ CurrentTime,
+ ci->x, ci->y,
+ monitor->x11.oldMode,
+ ci->rotation,
+ ci->outputs,
+ ci->noutput);
+
+ XRRFreeCrtcInfo(ci);
+ XRRFreeScreenResources(sr);
+
+ monitor->x11.oldMode = None;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
+{
+}
+
+void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ XRRScreenResources* sr;
+ XRRCrtcInfo* ci;
+
+ sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
+ ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
+
+ if (xpos)
+ *xpos = ci->x;
+ if (ypos)
+ *ypos = ci->y;
+
+ XRRFreeCrtcInfo(ci);
+ XRRFreeScreenResources(sr);
+ }
+}
+
+void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
+ float* xscale, float* yscale)
+{
+ if (xscale)
+ *xscale = _glfw.x11.contentScaleX;
+ if (yscale)
+ *yscale = _glfw.x11.contentScaleY;
+}
+
+GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
+{
+ GLFWvidmode* result;
+
+ *count = 0;
+
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ int i, j;
+ XRRScreenResources* sr;
+ XRRCrtcInfo* ci;
+ XRROutputInfo* oi;
+
+ sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
+ ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
+ oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
+
+ result = calloc(oi->nmode, sizeof(GLFWvidmode));
+
+ for (i = 0; i < oi->nmode; i++)
+ {
+ const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
+ if (!modeIsGood(mi))
+ continue;
+
+ const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
+
+ for (j = 0; j < *count; j++)
+ {
+ if (_glfwCompareVideoModes(result + j, &mode) == 0)
+ break;
+ }
+
+ // Skip duplicate modes
+ if (j < *count)
+ continue;
+
+ (*count)++;
+ result[*count - 1] = mode;
+ }
+
+ XRRFreeOutputInfo(oi);
+ XRRFreeCrtcInfo(ci);
+ XRRFreeScreenResources(sr);
+ }
+ else
+ {
+ *count = 1;
+ result = calloc(1, sizeof(GLFWvidmode));
+ _glfwPlatformGetVideoMode(monitor, result);
+ }
+
+ return result;
+}
+
+void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
+ {
+ XRRScreenResources* sr;
+ XRRCrtcInfo* ci;
+
+ sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
+ ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
+
+ *mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
+
+ XRRFreeCrtcInfo(ci);
+ XRRFreeScreenResources(sr);
+ }
+ else
+ {
+ mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
+ mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
+ mode->refreshRate = 0;
+
+ _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
+ &mode->redBits, &mode->greenBits, &mode->blueBits);
+ }
+}
+
+GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
+ {
+ const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display,
+ monitor->x11.crtc);
+ XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
+ monitor->x11.crtc);
+
+ _glfwAllocGammaArrays(ramp, size);
+
+ memcpy(ramp->red, gamma->red, size * sizeof(unsigned short));
+ memcpy(ramp->green, gamma->green, size * sizeof(unsigned short));
+ memcpy(ramp->blue, gamma->blue, size * sizeof(unsigned short));
+
+ XRRFreeGamma(gamma);
+ return GLFW_TRUE;
+ }
+ else if (_glfw.x11.vidmode.available)
+ {
+ int size;
+ XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);
+
+ _glfwAllocGammaArrays(ramp, size);
+
+ XF86VidModeGetGammaRamp(_glfw.x11.display,
+ _glfw.x11.screen,
+ ramp->size, ramp->red, ramp->green, ramp->blue);
+ return GLFW_TRUE;
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Gamma ramp access not supported by server");
+ return GLFW_FALSE;
+ }
+}
+
+void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
+{
+ if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
+ {
+ if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Gamma ramp size must match current ramp size");
+ return;
+ }
+
+ XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size);
+
+ memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short));
+ memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short));
+ memcpy(gamma->blue, ramp->blue, ramp->size * sizeof(unsigned short));
+
+ XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);
+ XRRFreeGamma(gamma);
+ }
+ else if (_glfw.x11.vidmode.available)
+ {
+ XF86VidModeSetGammaRamp(_glfw.x11.display,
+ _glfw.x11.screen,
+ ramp->size,
+ (unsigned short*) ramp->red,
+ (unsigned short*) ramp->green,
+ (unsigned short*) ramp->blue);
+ }
+ else
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Gamma ramp access not supported by server");
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(None);
+ return monitor->x11.crtc;
+}
+
+GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
+{
+ _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(None);
+ return monitor->x11.output;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/x11_platform.h b/Client/ThirdParty/Box2D/extern/glfw/src/x11_platform.h
new file mode 100644
index 0000000..c37c740
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/x11_platform.h
@@ -0,0 +1,444 @@
+//========================================================================
+// GLFW 3.3 X11 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdint.h>
+#include <dlfcn.h>
+
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/Xatom.h>
+#include <X11/Xcursor/Xcursor.h>
+
+// The XRandR extension provides mode setting and gamma control
+#include <X11/extensions/Xrandr.h>
+
+// The Xkb extension provides improved keyboard support
+#include <X11/XKBlib.h>
+
+// The Xinerama extension provides legacy monitor indices
+#include <X11/extensions/Xinerama.h>
+
+// The XInput extension provides raw mouse motion input
+#include <X11/extensions/XInput2.h>
+
+typedef XRRCrtcGamma* (* PFN_XRRAllocGamma)(int);
+typedef void (* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo*);
+typedef void (* PFN_XRRFreeGamma)(XRRCrtcGamma*);
+typedef void (* PFN_XRRFreeOutputInfo)(XRROutputInfo*);
+typedef void (* PFN_XRRFreeScreenResources)(XRRScreenResources*);
+typedef XRRCrtcGamma* (* PFN_XRRGetCrtcGamma)(Display*,RRCrtc);
+typedef int (* PFN_XRRGetCrtcGammaSize)(Display*,RRCrtc);
+typedef XRRCrtcInfo* (* PFN_XRRGetCrtcInfo) (Display*,XRRScreenResources*,RRCrtc);
+typedef XRROutputInfo* (* PFN_XRRGetOutputInfo)(Display*,XRRScreenResources*,RROutput);
+typedef RROutput (* PFN_XRRGetOutputPrimary)(Display*,Window);
+typedef XRRScreenResources* (* PFN_XRRGetScreenResourcesCurrent)(Display*,Window);
+typedef Bool (* PFN_XRRQueryExtension)(Display*,int*,int*);
+typedef Status (* PFN_XRRQueryVersion)(Display*,int*,int*);
+typedef void (* PFN_XRRSelectInput)(Display*,Window,int);
+typedef Status (* PFN_XRRSetCrtcConfig)(Display*,XRRScreenResources*,RRCrtc,Time,int,int,RRMode,Rotation,RROutput*,int);
+typedef void (* PFN_XRRSetCrtcGamma)(Display*,RRCrtc,XRRCrtcGamma*);
+typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
+#define XRRAllocGamma _glfw.x11.randr.AllocGamma
+#define XRRFreeCrtcInfo _glfw.x11.randr.FreeCrtcInfo
+#define XRRFreeGamma _glfw.x11.randr.FreeGamma
+#define XRRFreeOutputInfo _glfw.x11.randr.FreeOutputInfo
+#define XRRFreeScreenResources _glfw.x11.randr.FreeScreenResources
+#define XRRGetCrtcGamma _glfw.x11.randr.GetCrtcGamma
+#define XRRGetCrtcGammaSize _glfw.x11.randr.GetCrtcGammaSize
+#define XRRGetCrtcInfo _glfw.x11.randr.GetCrtcInfo
+#define XRRGetOutputInfo _glfw.x11.randr.GetOutputInfo
+#define XRRGetOutputPrimary _glfw.x11.randr.GetOutputPrimary
+#define XRRGetScreenResourcesCurrent _glfw.x11.randr.GetScreenResourcesCurrent
+#define XRRQueryExtension _glfw.x11.randr.QueryExtension
+#define XRRQueryVersion _glfw.x11.randr.QueryVersion
+#define XRRSelectInput _glfw.x11.randr.SelectInput
+#define XRRSetCrtcConfig _glfw.x11.randr.SetCrtcConfig
+#define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
+#define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration
+
+typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
+typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
+typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
+#define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
+#define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
+#define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
+
+typedef Bool (* PFN_XineramaIsActive)(Display*);
+typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
+typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*);
+#define XineramaIsActive _glfw.x11.xinerama.IsActive
+#define XineramaQueryExtension _glfw.x11.xinerama.QueryExtension
+#define XineramaQueryScreens _glfw.x11.xinerama.QueryScreens
+
+typedef XID xcb_window_t;
+typedef XID xcb_visualid_t;
+typedef struct xcb_connection_t xcb_connection_t;
+typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*);
+#define XGetXCBConnection _glfw.x11.x11xcb.GetXCBConnection
+
+typedef Bool (* PFN_XF86VidModeQueryExtension)(Display*,int*,int*);
+typedef Bool (* PFN_XF86VidModeGetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
+typedef Bool (* PFN_XF86VidModeSetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
+typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*);
+#define XF86VidModeQueryExtension _glfw.x11.vidmode.QueryExtension
+#define XF86VidModeGetGammaRamp _glfw.x11.vidmode.GetGammaRamp
+#define XF86VidModeSetGammaRamp _glfw.x11.vidmode.SetGammaRamp
+#define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize
+
+typedef Status (* PFN_XIQueryVersion)(Display*,int*,int*);
+typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int);
+#define XIQueryVersion _glfw.x11.xi.QueryVersion
+#define XISelectEvents _glfw.x11.xi.SelectEvents
+
+typedef Bool (* PFN_XRenderQueryExtension)(Display*,int*,int*);
+typedef Status (* PFN_XRenderQueryVersion)(Display*dpy,int*,int*);
+typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const*);
+#define XRenderQueryExtension _glfw.x11.xrender.QueryExtension
+#define XRenderQueryVersion _glfw.x11.xrender.QueryVersion
+#define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat
+
+typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
+typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
+
+typedef struct VkXlibSurfaceCreateInfoKHR
+{
+ VkStructureType sType;
+ const void* pNext;
+ VkXlibSurfaceCreateFlagsKHR flags;
+ Display* dpy;
+ Window window;
+} VkXlibSurfaceCreateInfoKHR;
+
+typedef struct VkXcbSurfaceCreateInfoKHR
+{
+ VkStructureType sType;
+ const void* pNext;
+ VkXcbSurfaceCreateFlagsKHR flags;
+ xcb_connection_t* connection;
+ xcb_window_t window;
+} VkXcbSurfaceCreateInfoKHR;
+
+typedef VkResult (APIENTRY *PFN_vkCreateXlibSurfaceKHR)(VkInstance,const VkXlibSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
+typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice,uint32_t,Display*,VisualID);
+typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
+typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t);
+
+#include "posix_thread.h"
+#include "posix_time.h"
+#include "xkb_unicode.h"
+#include "glx_context.h"
+#include "egl_context.h"
+#include "osmesa_context.h"
+#if defined(__linux__)
+#include "linux_joystick.h"
+#else
+#include "null_joystick.h"
+#endif
+
+#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
+#define _glfw_dlclose(handle) dlclose(handle)
+#define _glfw_dlsym(handle, name) dlsym(handle, name)
+
+#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->x11.handle)
+#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.x11.display)
+
+#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11
+#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
+#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11
+#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorX11 x11
+
+
+// X11-specific per-window data
+//
+typedef struct _GLFWwindowX11
+{
+ Colormap colormap;
+ Window handle;
+ XIC ic;
+
+ GLFWbool overrideRedirect;
+ GLFWbool iconified;
+ GLFWbool maximized;
+
+ // Whether the visual supports framebuffer transparency
+ GLFWbool transparent;
+
+ // Cached position and size used to filter out duplicate events
+ int width, height;
+ int xpos, ypos;
+
+ // The last received cursor position, regardless of source
+ int lastCursorPosX, lastCursorPosY;
+ // The last position the cursor was warped to by GLFW
+ int warpCursorPosX, warpCursorPosY;
+
+ // The time of the last KeyPress event
+ Time lastKeyTime;
+
+} _GLFWwindowX11;
+
+// X11-specific global data
+//
+typedef struct _GLFWlibraryX11
+{
+ Display* display;
+ int screen;
+ Window root;
+
+ // System content scale
+ float contentScaleX, contentScaleY;
+ // Helper window for IPC
+ Window helperWindowHandle;
+ // Invisible cursor for hidden cursor mode
+ Cursor hiddenCursorHandle;
+ // Context for mapping window XIDs to _GLFWwindow pointers
+ XContext context;
+ // XIM input method
+ XIM im;
+ // Most recent error code received by X error handler
+ int errorCode;
+ // Primary selection string (while the primary selection is owned)
+ char* primarySelectionString;
+ // Clipboard string (while the selection is owned)
+ char* clipboardString;
+ // Key name string
+ char keyName[5];
+ // X11 keycode to GLFW key LUT
+ short int keycodes[256];
+ // GLFW key to X11 keycode LUT
+ short int scancodes[GLFW_KEY_LAST + 1];
+ // Where to place the cursor when re-enabled
+ double restoreCursorPosX, restoreCursorPosY;
+ // The window whose disabled cursor mode is active
+ _GLFWwindow* disabledCursorWindow;
+
+ // Window manager atoms
+ Atom WM_PROTOCOLS;
+ Atom WM_STATE;
+ Atom WM_DELETE_WINDOW;
+ Atom NET_WM_NAME;
+ Atom NET_WM_ICON_NAME;
+ Atom NET_WM_ICON;
+ Atom NET_WM_PID;
+ Atom NET_WM_PING;
+ Atom NET_WM_WINDOW_TYPE;
+ Atom NET_WM_WINDOW_TYPE_NORMAL;
+ Atom NET_WM_STATE;
+ Atom NET_WM_STATE_ABOVE;
+ Atom NET_WM_STATE_FULLSCREEN;
+ Atom NET_WM_STATE_MAXIMIZED_VERT;
+ Atom NET_WM_STATE_MAXIMIZED_HORZ;
+ Atom NET_WM_STATE_DEMANDS_ATTENTION;
+ Atom NET_WM_BYPASS_COMPOSITOR;
+ Atom NET_WM_FULLSCREEN_MONITORS;
+ Atom NET_WM_WINDOW_OPACITY;
+ Atom NET_WM_CM_Sx;
+ Atom NET_ACTIVE_WINDOW;
+ Atom NET_FRAME_EXTENTS;
+ Atom NET_REQUEST_FRAME_EXTENTS;
+ Atom MOTIF_WM_HINTS;
+
+ // Xdnd (drag and drop) atoms
+ Atom XdndAware;
+ Atom XdndEnter;
+ Atom XdndPosition;
+ Atom XdndStatus;
+ Atom XdndActionCopy;
+ Atom XdndDrop;
+ Atom XdndFinished;
+ Atom XdndSelection;
+ Atom XdndTypeList;
+ Atom text_uri_list;
+
+ // Selection (clipboard) atoms
+ Atom TARGETS;
+ Atom MULTIPLE;
+ Atom INCR;
+ Atom CLIPBOARD;
+ Atom PRIMARY;
+ Atom CLIPBOARD_MANAGER;
+ Atom SAVE_TARGETS;
+ Atom NULL_;
+ Atom UTF8_STRING;
+ Atom COMPOUND_STRING;
+ Atom ATOM_PAIR;
+ Atom GLFW_SELECTION;
+
+ struct {
+ GLFWbool available;
+ void* handle;
+ int eventBase;
+ int errorBase;
+ int major;
+ int minor;
+ GLFWbool gammaBroken;
+ GLFWbool monitorBroken;
+ PFN_XRRAllocGamma AllocGamma;
+ PFN_XRRFreeCrtcInfo FreeCrtcInfo;
+ PFN_XRRFreeGamma FreeGamma;
+ PFN_XRRFreeOutputInfo FreeOutputInfo;
+ PFN_XRRFreeScreenResources FreeScreenResources;
+ PFN_XRRGetCrtcGamma GetCrtcGamma;
+ PFN_XRRGetCrtcGammaSize GetCrtcGammaSize;
+ PFN_XRRGetCrtcInfo GetCrtcInfo;
+ PFN_XRRGetOutputInfo GetOutputInfo;
+ PFN_XRRGetOutputPrimary GetOutputPrimary;
+ PFN_XRRGetScreenResourcesCurrent GetScreenResourcesCurrent;
+ PFN_XRRQueryExtension QueryExtension;
+ PFN_XRRQueryVersion QueryVersion;
+ PFN_XRRSelectInput SelectInput;
+ PFN_XRRSetCrtcConfig SetCrtcConfig;
+ PFN_XRRSetCrtcGamma SetCrtcGamma;
+ PFN_XRRUpdateConfiguration UpdateConfiguration;
+ } randr;
+
+ struct {
+ GLFWbool available;
+ GLFWbool detectable;
+ int majorOpcode;
+ int eventBase;
+ int errorBase;
+ int major;
+ int minor;
+ } xkb;
+
+ struct {
+ int count;
+ int timeout;
+ int interval;
+ int blanking;
+ int exposure;
+ } saver;
+
+ struct {
+ int version;
+ Window source;
+ Atom format;
+ } xdnd;
+
+ struct {
+ void* handle;
+ PFN_XcursorImageCreate ImageCreate;
+ PFN_XcursorImageDestroy ImageDestroy;
+ PFN_XcursorImageLoadCursor ImageLoadCursor;
+ } xcursor;
+
+ struct {
+ GLFWbool available;
+ void* handle;
+ int major;
+ int minor;
+ PFN_XineramaIsActive IsActive;
+ PFN_XineramaQueryExtension QueryExtension;
+ PFN_XineramaQueryScreens QueryScreens;
+ } xinerama;
+
+ struct {
+ void* handle;
+ PFN_XGetXCBConnection GetXCBConnection;
+ } x11xcb;
+
+ struct {
+ GLFWbool available;
+ void* handle;
+ int eventBase;
+ int errorBase;
+ PFN_XF86VidModeQueryExtension QueryExtension;
+ PFN_XF86VidModeGetGammaRamp GetGammaRamp;
+ PFN_XF86VidModeSetGammaRamp SetGammaRamp;
+ PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
+ } vidmode;
+
+ struct {
+ GLFWbool available;
+ void* handle;
+ int majorOpcode;
+ int eventBase;
+ int errorBase;
+ int major;
+ int minor;
+ PFN_XIQueryVersion QueryVersion;
+ PFN_XISelectEvents SelectEvents;
+ } xi;
+
+ struct {
+ GLFWbool available;
+ void* handle;
+ int major;
+ int minor;
+ int eventBase;
+ int errorBase;
+ PFN_XRenderQueryExtension QueryExtension;
+ PFN_XRenderQueryVersion QueryVersion;
+ PFN_XRenderFindVisualFormat FindVisualFormat;
+ } xrender;
+
+} _GLFWlibraryX11;
+
+// X11-specific per-monitor data
+//
+typedef struct _GLFWmonitorX11
+{
+ RROutput output;
+ RRCrtc crtc;
+ RRMode oldMode;
+
+ // Index of corresponding Xinerama screen,
+ // for EWMH full screen window placement
+ int index;
+
+} _GLFWmonitorX11;
+
+// X11-specific per-cursor data
+//
+typedef struct _GLFWcursorX11
+{
+ Cursor handle;
+
+} _GLFWcursorX11;
+
+
+void _glfwPollMonitorsX11(void);
+void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
+void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
+
+Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
+
+unsigned long _glfwGetWindowPropertyX11(Window window,
+ Atom property,
+ Atom type,
+ unsigned char** value);
+GLFWbool _glfwIsVisualTransparentX11(Visual* visual);
+
+void _glfwGrabErrorHandlerX11(void);
+void _glfwReleaseErrorHandlerX11(void);
+void _glfwInputErrorX11(int error, const char* message);
+
+void _glfwPushSelectionToManagerX11(void);
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/x11_window.c b/Client/ThirdParty/Box2D/extern/glfw/src/x11_window.c
new file mode 100644
index 0000000..19ed737
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/x11_window.c
@@ -0,0 +1,3066 @@
+//========================================================================
+// GLFW 3.3 X11 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+#include <X11/cursorfont.h>
+#include <X11/Xmd.h>
+
+#include <sys/select.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
+#include <assert.h>
+
+// Action for EWMH client messages
+#define _NET_WM_STATE_REMOVE 0
+#define _NET_WM_STATE_ADD 1
+#define _NET_WM_STATE_TOGGLE 2
+
+// Additional mouse button names for XButtonEvent
+#define Button6 6
+#define Button7 7
+
+#define _GLFW_XDND_VERSION 5
+
+
+// Wait for data to arrive using select
+// This avoids blocking other threads via the per-display Xlib lock that also
+// covers GLX functions
+//
+static GLFWbool waitForEvent(double* timeout)
+{
+ fd_set fds;
+ const int fd = ConnectionNumber(_glfw.x11.display);
+ int count = fd + 1;
+
+#if defined(__linux__)
+ if (_glfw.linjs.inotify > fd)
+ count = _glfw.linjs.inotify + 1;
+#endif
+ for (;;)
+ {
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+#if defined(__linux__)
+ if (_glfw.linjs.inotify > 0)
+ FD_SET(_glfw.linjs.inotify, &fds);
+#endif
+
+ if (timeout)
+ {
+ const long seconds = (long) *timeout;
+ const long microseconds = (long) ((*timeout - seconds) * 1e6);
+ struct timeval tv = { seconds, microseconds };
+ const uint64_t base = _glfwPlatformGetTimerValue();
+
+ const int result = select(count, &fds, NULL, NULL, &tv);
+ const int error = errno;
+
+ *timeout -= (_glfwPlatformGetTimerValue() - base) /
+ (double) _glfwPlatformGetTimerFrequency();
+
+ if (result > 0)
+ return GLFW_TRUE;
+ if ((result == -1 && error == EINTR) || *timeout <= 0.0)
+ return GLFW_FALSE;
+ }
+ else if (select(count, &fds, NULL, NULL, NULL) != -1 || errno != EINTR)
+ return GLFW_TRUE;
+ }
+}
+
+// Waits until a VisibilityNotify event arrives for the specified window or the
+// timeout period elapses (ICCCM section 4.2.2)
+//
+static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
+{
+ XEvent dummy;
+ double timeout = 0.1;
+
+ while (!XCheckTypedWindowEvent(_glfw.x11.display,
+ window->x11.handle,
+ VisibilityNotify,
+ &dummy))
+ {
+ if (!waitForEvent(&timeout))
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+// Returns whether the window is iconified
+//
+static int getWindowState(_GLFWwindow* window)
+{
+ int result = WithdrawnState;
+ struct {
+ CARD32 state;
+ Window icon;
+ } *state = NULL;
+
+ if (_glfwGetWindowPropertyX11(window->x11.handle,
+ _glfw.x11.WM_STATE,
+ _glfw.x11.WM_STATE,
+ (unsigned char**) &state) >= 2)
+ {
+ result = state->state;
+ }
+
+ if (state)
+ XFree(state);
+
+ return result;
+}
+
+// Returns whether the event is a selection event
+//
+static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
+{
+ if (event->xany.window != _glfw.x11.helperWindowHandle)
+ return False;
+
+ return event->type == SelectionRequest ||
+ event->type == SelectionNotify ||
+ event->type == SelectionClear;
+}
+
+// Returns whether it is a _NET_FRAME_EXTENTS event for the specified window
+//
+static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)
+{
+ _GLFWwindow* window = (_GLFWwindow*) pointer;
+ return event->type == PropertyNotify &&
+ event->xproperty.state == PropertyNewValue &&
+ event->xproperty.window == window->x11.handle &&
+ event->xproperty.atom == _glfw.x11.NET_FRAME_EXTENTS;
+}
+
+// Returns whether it is a property event for the specified selection transfer
+//
+static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer pointer)
+{
+ XEvent* notification = (XEvent*) pointer;
+ return event->type == PropertyNotify &&
+ event->xproperty.state == PropertyNewValue &&
+ event->xproperty.window == notification->xselection.requestor &&
+ event->xproperty.atom == notification->xselection.property;
+}
+
+// Translates an X event modifier state mask
+//
+static int translateState(int state)
+{
+ int mods = 0;
+
+ if (state & ShiftMask)
+ mods |= GLFW_MOD_SHIFT;
+ if (state & ControlMask)
+ mods |= GLFW_MOD_CONTROL;
+ if (state & Mod1Mask)
+ mods |= GLFW_MOD_ALT;
+ if (state & Mod4Mask)
+ mods |= GLFW_MOD_SUPER;
+ if (state & LockMask)
+ mods |= GLFW_MOD_CAPS_LOCK;
+ if (state & Mod2Mask)
+ mods |= GLFW_MOD_NUM_LOCK;
+
+ return mods;
+}
+
+// Translates an X11 key code to a GLFW key token
+//
+static int translateKey(int scancode)
+{
+ // Use the pre-filled LUT (see createKeyTables() in x11_init.c)
+ if (scancode < 0 || scancode > 255)
+ return GLFW_KEY_UNKNOWN;
+
+ return _glfw.x11.keycodes[scancode];
+}
+
+// Sends an EWMH or ICCCM event to the window manager
+//
+static void sendEventToWM(_GLFWwindow* window, Atom type,
+ long a, long b, long c, long d, long e)
+{
+ XEvent event;
+ memset(&event, 0, sizeof(event));
+
+ event.type = ClientMessage;
+ event.xclient.window = window->x11.handle;
+ event.xclient.format = 32; // Data is 32-bit longs
+ event.xclient.message_type = type;
+ event.xclient.data.l[0] = a;
+ event.xclient.data.l[1] = b;
+ event.xclient.data.l[2] = c;
+ event.xclient.data.l[3] = d;
+ event.xclient.data.l[4] = e;
+
+ XSendEvent(_glfw.x11.display, _glfw.x11.root,
+ False,
+ SubstructureNotifyMask | SubstructureRedirectMask,
+ &event);
+}
+
+// Updates the normal hints according to the window settings
+//
+static void updateNormalHints(_GLFWwindow* window, int width, int height)
+{
+ XSizeHints* hints = XAllocSizeHints();
+
+ if (!window->monitor)
+ {
+ if (window->resizable)
+ {
+ if (window->minwidth != GLFW_DONT_CARE &&
+ window->minheight != GLFW_DONT_CARE)
+ {
+ hints->flags |= PMinSize;
+ hints->min_width = window->minwidth;
+ hints->min_height = window->minheight;
+ }
+
+ if (window->maxwidth != GLFW_DONT_CARE &&
+ window->maxheight != GLFW_DONT_CARE)
+ {
+ hints->flags |= PMaxSize;
+ hints->max_width = window->maxwidth;
+ hints->max_height = window->maxheight;
+ }
+
+ if (window->numer != GLFW_DONT_CARE &&
+ window->denom != GLFW_DONT_CARE)
+ {
+ hints->flags |= PAspect;
+ hints->min_aspect.x = hints->max_aspect.x = window->numer;
+ hints->min_aspect.y = hints->max_aspect.y = window->denom;
+ }
+ }
+ else
+ {
+ hints->flags |= (PMinSize | PMaxSize);
+ hints->min_width = hints->max_width = width;
+ hints->min_height = hints->max_height = height;
+ }
+ }
+
+ hints->flags |= PWinGravity;
+ hints->win_gravity = StaticGravity;
+
+ XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
+ XFree(hints);
+}
+
+// Updates the full screen status of the window
+//
+static void updateWindowMode(_GLFWwindow* window)
+{
+ if (window->monitor)
+ {
+ if (_glfw.x11.xinerama.available &&
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
+ {
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS,
+ window->monitor->x11.index,
+ window->monitor->x11.index,
+ window->monitor->x11.index,
+ window->monitor->x11.index,
+ 0);
+ }
+
+ if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
+ {
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_STATE,
+ _NET_WM_STATE_ADD,
+ _glfw.x11.NET_WM_STATE_FULLSCREEN,
+ 0, 1, 0);
+ }
+ else
+ {
+ // This is the butcher's way of removing window decorations
+ // Setting the override-redirect attribute on a window makes the
+ // window manager ignore the window completely (ICCCM, section 4)
+ // The good thing is that this makes undecorated full screen windows
+ // easy to do; the bad thing is that we have to do everything
+ // manually and some things (like iconify/restore) won't work at
+ // all, as those are tasks usually performed by the window manager
+
+ XSetWindowAttributes attributes;
+ attributes.override_redirect = True;
+ XChangeWindowAttributes(_glfw.x11.display,
+ window->x11.handle,
+ CWOverrideRedirect,
+ &attributes);
+
+ window->x11.overrideRedirect = GLFW_TRUE;
+ }
+
+ // Enable compositor bypass
+ if (!window->x11.transparent)
+ {
+ const unsigned long value = 1;
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char*) &value, 1);
+ }
+ }
+ else
+ {
+ if (_glfw.x11.xinerama.available &&
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
+ {
+ XDeleteProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_FULLSCREEN_MONITORS);
+ }
+
+ if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
+ {
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_STATE,
+ _NET_WM_STATE_REMOVE,
+ _glfw.x11.NET_WM_STATE_FULLSCREEN,
+ 0, 1, 0);
+ }
+ else
+ {
+ XSetWindowAttributes attributes;
+ attributes.override_redirect = False;
+ XChangeWindowAttributes(_glfw.x11.display,
+ window->x11.handle,
+ CWOverrideRedirect,
+ &attributes);
+
+ window->x11.overrideRedirect = GLFW_FALSE;
+ }
+
+ // Disable compositor bypass
+ if (!window->x11.transparent)
+ {
+ XDeleteProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_BYPASS_COMPOSITOR);
+ }
+ }
+}
+
+// Splits and translates a text/uri-list into separate file paths
+// NOTE: This function destroys the provided string
+//
+static char** parseUriList(char* text, int* count)
+{
+ const char* prefix = "file://";
+ char** paths = NULL;
+ char* line;
+
+ *count = 0;
+
+ while ((line = strtok(text, "\r\n")))
+ {
+ text = NULL;
+
+ if (line[0] == '#')
+ continue;
+
+ if (strncmp(line, prefix, strlen(prefix)) == 0)
+ {
+ line += strlen(prefix);
+ // TODO: Validate hostname
+ while (*line != '/')
+ line++;
+ }
+
+ (*count)++;
+
+ char* path = calloc(strlen(line) + 1, 1);
+ paths = realloc(paths, *count * sizeof(char*));
+ paths[*count - 1] = path;
+
+ while (*line)
+ {
+ if (line[0] == '%' && line[1] && line[2])
+ {
+ const char digits[3] = { line[1], line[2], '\0' };
+ *path = strtol(digits, NULL, 16);
+ line += 2;
+ }
+ else
+ *path = *line;
+
+ path++;
+ line++;
+ }
+ }
+
+ return paths;
+}
+
+// Encode a Unicode code point to a UTF-8 stream
+// Based on cutef8 by Jeff Bezanson (Public Domain)
+//
+static size_t encodeUTF8(char* s, unsigned int ch)
+{
+ size_t count = 0;
+
+ if (ch < 0x80)
+ s[count++] = (char) ch;
+ else if (ch < 0x800)
+ {
+ s[count++] = (ch >> 6) | 0xc0;
+ s[count++] = (ch & 0x3f) | 0x80;
+ }
+ else if (ch < 0x10000)
+ {
+ s[count++] = (ch >> 12) | 0xe0;
+ s[count++] = ((ch >> 6) & 0x3f) | 0x80;
+ s[count++] = (ch & 0x3f) | 0x80;
+ }
+ else if (ch < 0x110000)
+ {
+ s[count++] = (ch >> 18) | 0xf0;
+ s[count++] = ((ch >> 12) & 0x3f) | 0x80;
+ s[count++] = ((ch >> 6) & 0x3f) | 0x80;
+ s[count++] = (ch & 0x3f) | 0x80;
+ }
+
+ return count;
+}
+
+// Decode a Unicode code point from a UTF-8 stream
+// Based on cutef8 by Jeff Bezanson (Public Domain)
+//
+#if defined(X_HAVE_UTF8_STRING)
+static unsigned int decodeUTF8(const char** s)
+{
+ unsigned int ch = 0, count = 0;
+ static const unsigned int offsets[] =
+ {
+ 0x00000000u, 0x00003080u, 0x000e2080u,
+ 0x03c82080u, 0xfa082080u, 0x82082080u
+ };
+
+ do
+ {
+ ch = (ch << 6) + (unsigned char) **s;
+ (*s)++;
+ count++;
+ } while ((**s & 0xc0) == 0x80);
+
+ assert(count <= 6);
+ return ch - offsets[count - 1];
+}
+#endif /*X_HAVE_UTF8_STRING*/
+
+// Convert the specified Latin-1 string to UTF-8
+//
+static char* convertLatin1toUTF8(const char* source)
+{
+ size_t size = 1;
+ const char* sp;
+
+ for (sp = source; *sp; sp++)
+ size += (*sp & 0x80) ? 2 : 1;
+
+ char* target = calloc(size, 1);
+ char* tp = target;
+
+ for (sp = source; *sp; sp++)
+ tp += encodeUTF8(tp, *sp);
+
+ return target;
+}
+
+// Centers the cursor over the window client area
+//
+static void centerCursor(_GLFWwindow* window)
+{
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
+}
+
+// Updates the cursor image according to its cursor mode
+//
+static void updateCursorImage(_GLFWwindow* window)
+{
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
+ {
+ if (window->cursor)
+ {
+ XDefineCursor(_glfw.x11.display, window->x11.handle,
+ window->cursor->x11.handle);
+ }
+ else
+ XUndefineCursor(_glfw.x11.display, window->x11.handle);
+ }
+ else
+ {
+ XDefineCursor(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.hiddenCursorHandle);
+ }
+}
+
+// Apply disabled cursor mode to a focused window
+//
+static void disableCursor(_GLFWwindow* window)
+{
+ if (_glfw.x11.xi.available)
+ {
+ XIEventMask em;
+ unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
+
+ em.deviceid = XIAllMasterDevices;
+ em.mask_len = sizeof(mask);
+ em.mask = mask;
+ XISetMask(mask, XI_RawMotion);
+
+ XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
+ }
+
+ _glfw.x11.disabledCursorWindow = window;
+ _glfwPlatformGetCursorPos(window,
+ &_glfw.x11.restoreCursorPosX,
+ &_glfw.x11.restoreCursorPosY);
+ updateCursorImage(window);
+ centerCursor(window);
+ XGrabPointer(_glfw.x11.display, window->x11.handle, True,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+ GrabModeAsync, GrabModeAsync,
+ window->x11.handle,
+ _glfw.x11.hiddenCursorHandle,
+ CurrentTime);
+}
+
+// Exit disabled cursor mode for the specified window
+//
+static void enableCursor(_GLFWwindow* window)
+{
+ if (_glfw.x11.xi.available)
+ {
+ XIEventMask em;
+ unsigned char mask[] = { 0 };
+
+ em.deviceid = XIAllMasterDevices;
+ em.mask_len = sizeof(mask);
+ em.mask = mask;
+
+ XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
+ }
+
+ _glfw.x11.disabledCursorWindow = NULL;
+ XUngrabPointer(_glfw.x11.display, CurrentTime);
+ _glfwPlatformSetCursorPos(window,
+ _glfw.x11.restoreCursorPosX,
+ _glfw.x11.restoreCursorPosY);
+ updateCursorImage(window);
+}
+
+// Create the X11 window (and its colormap)
+//
+static GLFWbool createNativeWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ Visual* visual, int depth)
+{
+ int width = wndconfig->width;
+ int height = wndconfig->height;
+
+ if (wndconfig->scaleToMonitor)
+ {
+ width *= _glfw.x11.contentScaleX;
+ height *= _glfw.x11.contentScaleY;
+ }
+
+ // Create a colormap based on the visual used by the current context
+ window->x11.colormap = XCreateColormap(_glfw.x11.display,
+ _glfw.x11.root,
+ visual,
+ AllocNone);
+
+ window->x11.transparent = _glfwIsVisualTransparentX11(visual);
+
+ // Create the actual window
+ {
+ XSetWindowAttributes wa;
+ const unsigned long wamask = CWBorderPixel | CWColormap | CWEventMask;
+
+ wa.colormap = window->x11.colormap;
+ wa.border_pixel = 0;
+ wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
+ PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
+ ExposureMask | FocusChangeMask | VisibilityChangeMask |
+ EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
+
+ _glfwGrabErrorHandlerX11();
+
+ window->x11.handle = XCreateWindow(_glfw.x11.display,
+ _glfw.x11.root,
+ 0, 0,
+ width, height,
+ 0, // Border width
+ depth, // Color depth
+ InputOutput,
+ visual,
+ wamask,
+ &wa);
+
+ _glfwReleaseErrorHandlerX11();
+
+ if (!window->x11.handle)
+ {
+ _glfwInputErrorX11(GLFW_PLATFORM_ERROR,
+ "X11: Failed to create window");
+ return GLFW_FALSE;
+ }
+
+ XSaveContext(_glfw.x11.display,
+ window->x11.handle,
+ _glfw.x11.context,
+ (XPointer) window);
+ }
+
+ if (!wndconfig->decorated)
+ _glfwPlatformSetWindowDecorated(window, GLFW_FALSE);
+
+ if (_glfw.x11.NET_WM_STATE && !window->monitor)
+ {
+ Atom states[3];
+ int count = 0;
+
+ if (wndconfig->floating)
+ {
+ if (_glfw.x11.NET_WM_STATE_ABOVE)
+ states[count++] = _glfw.x11.NET_WM_STATE_ABOVE;
+ }
+
+ if (wndconfig->maximized)
+ {
+ if (_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
+ {
+ states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT;
+ states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ;
+ window->x11.maximized = GLFW_TRUE;
+ }
+ }
+
+ if (count)
+ {
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
+ PropModeReplace, (unsigned char*) &states, count);
+ }
+ }
+
+ // Declare the WM protocols supported by GLFW
+ {
+ Atom protocols[] =
+ {
+ _glfw.x11.WM_DELETE_WINDOW,
+ _glfw.x11.NET_WM_PING
+ };
+
+ XSetWMProtocols(_glfw.x11.display, window->x11.handle,
+ protocols, sizeof(protocols) / sizeof(Atom));
+ }
+
+ // Declare our PID
+ {
+ const long pid = getpid();
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_PID, XA_CARDINAL, 32,
+ PropModeReplace,
+ (unsigned char*) &pid, 1);
+ }
+
+ if (_glfw.x11.NET_WM_WINDOW_TYPE && _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL)
+ {
+ Atom type = _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL;
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_WINDOW_TYPE, XA_ATOM, 32,
+ PropModeReplace, (unsigned char*) &type, 1);
+ }
+
+ // Set ICCCM WM_HINTS property
+ {
+ XWMHints* hints = XAllocWMHints();
+ if (!hints)
+ {
+ _glfwInputError(GLFW_OUT_OF_MEMORY,
+ "X11: Failed to allocate WM hints");
+ return GLFW_FALSE;
+ }
+
+ hints->flags = StateHint;
+ hints->initial_state = NormalState;
+
+ XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
+ XFree(hints);
+ }
+
+ updateNormalHints(window, width, height);
+
+ // Set ICCCM WM_CLASS property
+ {
+ XClassHint* hint = XAllocClassHint();
+
+ if (strlen(wndconfig->x11.instanceName) &&
+ strlen(wndconfig->x11.className))
+ {
+ hint->res_name = (char*) wndconfig->x11.instanceName;
+ hint->res_class = (char*) wndconfig->x11.className;
+ }
+ else
+ {
+ const char* resourceName = getenv("RESOURCE_NAME");
+ if (resourceName && strlen(resourceName))
+ hint->res_name = (char*) resourceName;
+ else if (strlen(wndconfig->title))
+ hint->res_name = (char*) wndconfig->title;
+ else
+ hint->res_name = (char*) "glfw-application";
+
+ if (strlen(wndconfig->title))
+ hint->res_class = (char*) wndconfig->title;
+ else
+ hint->res_class = (char*) "GLFW-Application";
+ }
+
+ XSetClassHint(_glfw.x11.display, window->x11.handle, hint);
+ XFree(hint);
+ }
+
+ // Announce support for Xdnd (drag and drop)
+ {
+ const Atom version = _GLFW_XDND_VERSION;
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.XdndAware, XA_ATOM, 32,
+ PropModeReplace, (unsigned char*) &version, 1);
+ }
+
+ _glfwPlatformSetWindowTitle(window, wndconfig->title);
+
+ if (_glfw.x11.im)
+ {
+ window->x11.ic = XCreateIC(_glfw.x11.im,
+ XNInputStyle,
+ XIMPreeditNothing | XIMStatusNothing,
+ XNClientWindow,
+ window->x11.handle,
+ XNFocusWindow,
+ window->x11.handle,
+ NULL);
+ }
+
+ _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);
+ _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);
+
+ return GLFW_TRUE;
+}
+
+// Set the specified property to the selection converted to the requested target
+//
+static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
+{
+ int i;
+ char* selectionString = NULL;
+ const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
+ const int formatCount = sizeof(formats) / sizeof(formats[0]);
+
+ if (request->selection == _glfw.x11.PRIMARY)
+ selectionString = _glfw.x11.primarySelectionString;
+ else
+ selectionString = _glfw.x11.clipboardString;
+
+ if (request->property == None)
+ {
+ // The requester is a legacy client (ICCCM section 2.2)
+ // We don't support legacy clients, so fail here
+ return None;
+ }
+
+ if (request->target == _glfw.x11.TARGETS)
+ {
+ // The list of supported targets was requested
+
+ const Atom targets[] = { _glfw.x11.TARGETS,
+ _glfw.x11.MULTIPLE,
+ _glfw.x11.UTF8_STRING,
+ XA_STRING };
+
+ XChangeProperty(_glfw.x11.display,
+ request->requestor,
+ request->property,
+ XA_ATOM,
+ 32,
+ PropModeReplace,
+ (unsigned char*) targets,
+ sizeof(targets) / sizeof(targets[0]));
+
+ return request->property;
+ }
+
+ if (request->target == _glfw.x11.MULTIPLE)
+ {
+ // Multiple conversions were requested
+
+ Atom* targets;
+ unsigned long i, count;
+
+ count = _glfwGetWindowPropertyX11(request->requestor,
+ request->property,
+ _glfw.x11.ATOM_PAIR,
+ (unsigned char**) &targets);
+
+ for (i = 0; i < count; i += 2)
+ {
+ int j;
+
+ for (j = 0; j < formatCount; j++)
+ {
+ if (targets[i] == formats[j])
+ break;
+ }
+
+ if (j < formatCount)
+ {
+ XChangeProperty(_glfw.x11.display,
+ request->requestor,
+ targets[i + 1],
+ targets[i],
+ 8,
+ PropModeReplace,
+ (unsigned char *) selectionString,
+ strlen(selectionString));
+ }
+ else
+ targets[i + 1] = None;
+ }
+
+ XChangeProperty(_glfw.x11.display,
+ request->requestor,
+ request->property,
+ _glfw.x11.ATOM_PAIR,
+ 32,
+ PropModeReplace,
+ (unsigned char*) targets,
+ count);
+
+ XFree(targets);
+
+ return request->property;
+ }
+
+ if (request->target == _glfw.x11.SAVE_TARGETS)
+ {
+ // The request is a check whether we support SAVE_TARGETS
+ // It should be handled as a no-op side effect target
+
+ XChangeProperty(_glfw.x11.display,
+ request->requestor,
+ request->property,
+ _glfw.x11.NULL_,
+ 32,
+ PropModeReplace,
+ NULL,
+ 0);
+
+ return request->property;
+ }
+
+ // Conversion to a data target was requested
+
+ for (i = 0; i < formatCount; i++)
+ {
+ if (request->target == formats[i])
+ {
+ // The requested target is one we support
+
+ XChangeProperty(_glfw.x11.display,
+ request->requestor,
+ request->property,
+ request->target,
+ 8,
+ PropModeReplace,
+ (unsigned char *) selectionString,
+ strlen(selectionString));
+
+ return request->property;
+ }
+ }
+
+ // The requested target is not supported
+
+ return None;
+}
+
+static void handleSelectionClear(XEvent* event)
+{
+ if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
+ {
+ free(_glfw.x11.primarySelectionString);
+ _glfw.x11.primarySelectionString = NULL;
+ }
+ else
+ {
+ free(_glfw.x11.clipboardString);
+ _glfw.x11.clipboardString = NULL;
+ }
+}
+
+static void handleSelectionRequest(XEvent* event)
+{
+ const XSelectionRequestEvent* request = &event->xselectionrequest;
+
+ XEvent reply;
+ memset(&reply, 0, sizeof(reply));
+
+ reply.xselection.property = writeTargetToProperty(request);
+ reply.xselection.type = SelectionNotify;
+ reply.xselection.display = request->display;
+ reply.xselection.requestor = request->requestor;
+ reply.xselection.selection = request->selection;
+ reply.xselection.target = request->target;
+ reply.xselection.time = request->time;
+
+ XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
+}
+
+static const char* getSelectionString(Atom selection)
+{
+ size_t i;
+ char** selectionString = NULL;
+ const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
+ const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
+
+ if (selection == _glfw.x11.PRIMARY)
+ selectionString = &_glfw.x11.primarySelectionString;
+ else
+ selectionString = &_glfw.x11.clipboardString;
+
+ if (XGetSelectionOwner(_glfw.x11.display, selection) ==
+ _glfw.x11.helperWindowHandle)
+ {
+ // Instead of doing a large number of X round-trips just to put this
+ // string into a window property and then read it back, just return it
+ return *selectionString;
+ }
+
+ free(*selectionString);
+ *selectionString = NULL;
+
+ for (i = 0; i < targetCount; i++)
+ {
+ char* data;
+ Atom actualType;
+ int actualFormat;
+ unsigned long itemCount, bytesAfter;
+ XEvent notification, dummy;
+
+ XConvertSelection(_glfw.x11.display,
+ selection,
+ targets[i],
+ _glfw.x11.GLFW_SELECTION,
+ _glfw.x11.helperWindowHandle,
+ CurrentTime);
+
+ while (!XCheckTypedWindowEvent(_glfw.x11.display,
+ _glfw.x11.helperWindowHandle,
+ SelectionNotify,
+ &notification))
+ {
+ waitForEvent(NULL);
+ }
+
+ if (notification.xselection.property == None)
+ continue;
+
+ XCheckIfEvent(_glfw.x11.display,
+ &dummy,
+ isSelPropNewValueNotify,
+ (XPointer) &notification);
+
+ XGetWindowProperty(_glfw.x11.display,
+ notification.xselection.requestor,
+ notification.xselection.property,
+ 0,
+ LONG_MAX,
+ True,
+ AnyPropertyType,
+ &actualType,
+ &actualFormat,
+ &itemCount,
+ &bytesAfter,
+ (unsigned char**) &data);
+
+ if (actualType == _glfw.x11.INCR)
+ {
+ size_t size = 1;
+ char* string = NULL;
+
+ for (;;)
+ {
+ while (!XCheckIfEvent(_glfw.x11.display,
+ &dummy,
+ isSelPropNewValueNotify,
+ (XPointer) &notification))
+ {
+ waitForEvent(NULL);
+ }
+
+ XFree(data);
+ XGetWindowProperty(_glfw.x11.display,
+ notification.xselection.requestor,
+ notification.xselection.property,
+ 0,
+ LONG_MAX,
+ True,
+ AnyPropertyType,
+ &actualType,
+ &actualFormat,
+ &itemCount,
+ &bytesAfter,
+ (unsigned char**) &data);
+
+ if (itemCount)
+ {
+ size += itemCount;
+ string = realloc(string, size);
+ string[size - itemCount - 1] = '\0';
+ strcat(string, data);
+ }
+
+ if (!itemCount)
+ {
+ if (targets[i] == XA_STRING)
+ {
+ *selectionString = convertLatin1toUTF8(string);
+ free(string);
+ }
+ else
+ *selectionString = string;
+
+ break;
+ }
+ }
+ }
+ else if (actualType == targets[i])
+ {
+ if (targets[i] == XA_STRING)
+ *selectionString = convertLatin1toUTF8(data);
+ else
+ *selectionString = _glfw_strdup(data);
+ }
+
+ XFree(data);
+
+ if (*selectionString)
+ break;
+ }
+
+ if (!*selectionString)
+ {
+ _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
+ "X11: Failed to convert selection to string");
+ }
+
+ return *selectionString;
+}
+
+// Make the specified window and its video mode active on its monitor
+//
+static void acquireMonitor(_GLFWwindow* window)
+{
+ if (_glfw.x11.saver.count == 0)
+ {
+ // Remember old screen saver settings
+ XGetScreenSaver(_glfw.x11.display,
+ &_glfw.x11.saver.timeout,
+ &_glfw.x11.saver.interval,
+ &_glfw.x11.saver.blanking,
+ &_glfw.x11.saver.exposure);
+
+ // Disable screen saver
+ XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
+ DefaultExposures);
+ }
+
+ if (!window->monitor->window)
+ _glfw.x11.saver.count++;
+
+ _glfwSetVideoModeX11(window->monitor, &window->videoMode);
+
+ if (window->x11.overrideRedirect)
+ {
+ int xpos, ypos;
+ GLFWvidmode mode;
+
+ // Manually position the window over its monitor
+ _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
+ _glfwPlatformGetVideoMode(window->monitor, &mode);
+
+ XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
+ xpos, ypos, mode.width, mode.height);
+ }
+
+ _glfwInputMonitorWindow(window->monitor, window);
+}
+
+// Remove the window and restore the original video mode
+//
+static void releaseMonitor(_GLFWwindow* window)
+{
+ if (window->monitor->window != window)
+ return;
+
+ _glfwInputMonitorWindow(window->monitor, NULL);
+ _glfwRestoreVideoModeX11(window->monitor);
+
+ _glfw.x11.saver.count--;
+
+ if (_glfw.x11.saver.count == 0)
+ {
+ // Restore old screen saver settings
+ XSetScreenSaver(_glfw.x11.display,
+ _glfw.x11.saver.timeout,
+ _glfw.x11.saver.interval,
+ _glfw.x11.saver.blanking,
+ _glfw.x11.saver.exposure);
+ }
+}
+
+// Process the specified X event
+//
+static void processEvent(XEvent *event)
+{
+ _GLFWwindow* window = NULL;
+ int keycode = 0;
+ Bool filtered = False;
+
+ // HACK: Save scancode as some IMs clear the field in XFilterEvent
+ if (event->type == KeyPress || event->type == KeyRelease)
+ keycode = event->xkey.keycode;
+
+ if (_glfw.x11.im)
+ filtered = XFilterEvent(event, None);
+
+ if (_glfw.x11.randr.available)
+ {
+ if (event->type == _glfw.x11.randr.eventBase + RRNotify)
+ {
+ XRRUpdateConfiguration(event);
+ _glfwPollMonitorsX11();
+ return;
+ }
+ }
+
+ if (event->type == GenericEvent)
+ {
+ if (_glfw.x11.xi.available)
+ {
+ _GLFWwindow* window = _glfw.x11.disabledCursorWindow;
+
+ if (window &&
+ event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
+ XGetEventData(_glfw.x11.display, &event->xcookie) &&
+ event->xcookie.evtype == XI_RawMotion)
+ {
+ XIRawEvent* re = event->xcookie.data;
+ if (re->valuators.mask_len)
+ {
+ const double* values = re->raw_values;
+ double xpos = window->virtualCursorPosX;
+ double ypos = window->virtualCursorPosY;
+
+ if (XIMaskIsSet(re->valuators.mask, 0))
+ {
+ xpos += *values;
+ values++;
+ }
+
+ if (XIMaskIsSet(re->valuators.mask, 1))
+ ypos += *values;
+
+ _glfwInputCursorPos(window, xpos, ypos);
+ }
+ }
+
+ XFreeEventData(_glfw.x11.display, &event->xcookie);
+ }
+
+ return;
+ }
+
+ if (event->type == SelectionClear)
+ {
+ handleSelectionClear(event);
+ return;
+ }
+ else if (event->type == SelectionRequest)
+ {
+ handleSelectionRequest(event);
+ return;
+ }
+
+ if (XFindContext(_glfw.x11.display,
+ event->xany.window,
+ _glfw.x11.context,
+ (XPointer*) &window) != 0)
+ {
+ // This is an event for a window that has already been destroyed
+ return;
+ }
+
+ switch (event->type)
+ {
+ case KeyPress:
+ {
+ const int key = translateKey(keycode);
+ const int mods = translateState(event->xkey.state);
+ const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
+
+ if (window->x11.ic)
+ {
+ // HACK: Ignore duplicate key press events generated by ibus
+ // These have the same timestamp as the original event
+ // Corresponding release events are filtered out
+ // implicitly by the GLFW key repeat logic
+ if (window->x11.lastKeyTime < event->xkey.time)
+ {
+ if (keycode)
+ _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
+
+ window->x11.lastKeyTime = event->xkey.time;
+ }
+
+ if (!filtered)
+ {
+ int count;
+ Status status;
+#if defined(X_HAVE_UTF8_STRING)
+ char buffer[100];
+ char* chars = buffer;
+
+ count = Xutf8LookupString(window->x11.ic,
+ &event->xkey,
+ buffer, sizeof(buffer) - 1,
+ NULL, &status);
+
+ if (status == XBufferOverflow)
+ {
+ chars = calloc(count + 1, 1);
+ count = Xutf8LookupString(window->x11.ic,
+ &event->xkey,
+ chars, count,
+ NULL, &status);
+ }
+
+ if (status == XLookupChars || status == XLookupBoth)
+ {
+ const char* c = chars;
+ chars[count] = '\0';
+ while (c - chars < count)
+ _glfwInputChar(window, decodeUTF8(&c), mods, plain);
+ }
+#else /*X_HAVE_UTF8_STRING*/
+ wchar_t buffer[16];
+ wchar_t* chars = buffer;
+
+ count = XwcLookupString(window->x11.ic,
+ &event->xkey,
+ buffer,
+ sizeof(buffer) / sizeof(wchar_t),
+ NULL,
+ &status);
+
+ if (status == XBufferOverflow)
+ {
+ chars = calloc(count, sizeof(wchar_t));
+ count = XwcLookupString(window->x11.ic,
+ &event->xkey,
+ chars, count,
+ NULL, &status);
+ }
+
+ if (status == XLookupChars || status == XLookupBoth)
+ {
+ int i;
+ for (i = 0; i < count; i++)
+ _glfwInputChar(window, chars[i], mods, plain);
+ }
+#endif /*X_HAVE_UTF8_STRING*/
+
+ if (chars != buffer)
+ free(chars);
+ }
+ }
+ else
+ {
+ KeySym keysym;
+ XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
+
+ _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
+
+ const long character = _glfwKeySym2Unicode(keysym);
+ if (character != -1)
+ _glfwInputChar(window, character, mods, plain);
+ }
+
+ return;
+ }
+
+ case KeyRelease:
+ {
+ const int key = translateKey(keycode);
+ const int mods = translateState(event->xkey.state);
+
+ if (!_glfw.x11.xkb.detectable)
+ {
+ // HACK: Key repeat events will arrive as KeyRelease/KeyPress
+ // pairs with similar or identical time stamps
+ // The key repeat logic in _glfwInputKey expects only key
+ // presses to repeat, so detect and discard release events
+ if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
+ {
+ XEvent next;
+ XPeekEvent(_glfw.x11.display, &next);
+
+ if (next.type == KeyPress &&
+ next.xkey.window == event->xkey.window &&
+ next.xkey.keycode == keycode)
+ {
+ // HACK: The time of repeat events sometimes doesn't
+ // match that of the press event, so add an
+ // epsilon
+ // Toshiyuki Takahashi can press a button
+ // 16 times per second so it's fairly safe to
+ // assume that no human is pressing the key 50
+ // times per second (value is ms)
+ if ((next.xkey.time - event->xkey.time) < 20)
+ {
+ // This is very likely a server-generated key repeat
+ // event, so ignore it
+ return;
+ }
+ }
+ }
+ }
+
+ _glfwInputKey(window, key, keycode, GLFW_RELEASE, mods);
+ return;
+ }
+
+ case ButtonPress:
+ {
+ const int mods = translateState(event->xbutton.state);
+
+ if (event->xbutton.button == Button1)
+ _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
+ else if (event->xbutton.button == Button2)
+ _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
+ else if (event->xbutton.button == Button3)
+ _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
+
+ // Modern X provides scroll events as mouse button presses
+ else if (event->xbutton.button == Button4)
+ _glfwInputScroll(window, 0.0, 1.0);
+ else if (event->xbutton.button == Button5)
+ _glfwInputScroll(window, 0.0, -1.0);
+ else if (event->xbutton.button == Button6)
+ _glfwInputScroll(window, 1.0, 0.0);
+ else if (event->xbutton.button == Button7)
+ _glfwInputScroll(window, -1.0, 0.0);
+
+ else
+ {
+ // Additional buttons after 7 are treated as regular buttons
+ // We subtract 4 to fill the gap left by scroll input above
+ _glfwInputMouseClick(window,
+ event->xbutton.button - Button1 - 4,
+ GLFW_PRESS,
+ mods);
+ }
+
+ return;
+ }
+
+ case ButtonRelease:
+ {
+ const int mods = translateState(event->xbutton.state);
+
+ if (event->xbutton.button == Button1)
+ {
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_LEFT,
+ GLFW_RELEASE,
+ mods);
+ }
+ else if (event->xbutton.button == Button2)
+ {
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_MIDDLE,
+ GLFW_RELEASE,
+ mods);
+ }
+ else if (event->xbutton.button == Button3)
+ {
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_RIGHT,
+ GLFW_RELEASE,
+ mods);
+ }
+ else if (event->xbutton.button > Button7)
+ {
+ // Additional buttons after 7 are treated as regular buttons
+ // We subtract 4 to fill the gap left by scroll input above
+ _glfwInputMouseClick(window,
+ event->xbutton.button - Button1 - 4,
+ GLFW_RELEASE,
+ mods);
+ }
+
+ return;
+ }
+
+ case EnterNotify:
+ {
+ // XEnterWindowEvent is XCrossingEvent
+ const int x = event->xcrossing.x;
+ const int y = event->xcrossing.y;
+
+ // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
+ // ignore the defined cursor for hidden cursor mode
+ if (window->cursorMode == GLFW_CURSOR_HIDDEN)
+ updateCursorImage(window);
+
+ _glfwInputCursorEnter(window, GLFW_TRUE);
+ _glfwInputCursorPos(window, x, y);
+
+ window->x11.lastCursorPosX = x;
+ window->x11.lastCursorPosY = y;
+ return;
+ }
+
+ case LeaveNotify:
+ {
+ _glfwInputCursorEnter(window, GLFW_FALSE);
+ return;
+ }
+
+ case MotionNotify:
+ {
+ const int x = event->xmotion.x;
+ const int y = event->xmotion.y;
+
+ if (x != window->x11.warpCursorPosX ||
+ y != window->x11.warpCursorPosY)
+ {
+ // The cursor was moved by something other than GLFW
+
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ {
+ if (_glfw.x11.disabledCursorWindow != window)
+ return;
+ if (_glfw.x11.xi.available)
+ return;
+
+ const int dx = x - window->x11.lastCursorPosX;
+ const int dy = y - window->x11.lastCursorPosY;
+
+ _glfwInputCursorPos(window,
+ window->virtualCursorPosX + dx,
+ window->virtualCursorPosY + dy);
+ }
+ else
+ _glfwInputCursorPos(window, x, y);
+ }
+
+ window->x11.lastCursorPosX = x;
+ window->x11.lastCursorPosY = y;
+ return;
+ }
+
+ case ConfigureNotify:
+ {
+ if (event->xconfigure.width != window->x11.width ||
+ event->xconfigure.height != window->x11.height)
+ {
+ _glfwInputFramebufferSize(window,
+ event->xconfigure.width,
+ event->xconfigure.height);
+
+ _glfwInputWindowSize(window,
+ event->xconfigure.width,
+ event->xconfigure.height);
+
+ window->x11.width = event->xconfigure.width;
+ window->x11.height = event->xconfigure.height;
+ }
+
+ if (event->xconfigure.x != window->x11.xpos ||
+ event->xconfigure.y != window->x11.ypos)
+ {
+ if (window->x11.overrideRedirect || event->xany.send_event)
+ {
+ _glfwInputWindowPos(window,
+ event->xconfigure.x,
+ event->xconfigure.y);
+
+ window->x11.xpos = event->xconfigure.x;
+ window->x11.ypos = event->xconfigure.y;
+ }
+ }
+
+ return;
+ }
+
+ case ClientMessage:
+ {
+ // Custom client message, probably from the window manager
+
+ if (filtered)
+ return;
+
+ if (event->xclient.message_type == None)
+ return;
+
+ if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS)
+ {
+ const Atom protocol = event->xclient.data.l[0];
+ if (protocol == None)
+ return;
+
+ if (protocol == _glfw.x11.WM_DELETE_WINDOW)
+ {
+ // The window manager was asked to close the window, for
+ // example by the user pressing a 'close' window decoration
+ // button
+ _glfwInputWindowCloseRequest(window);
+ }
+ else if (protocol == _glfw.x11.NET_WM_PING)
+ {
+ // The window manager is pinging the application to ensure
+ // it's still responding to events
+
+ XEvent reply = *event;
+ reply.xclient.window = _glfw.x11.root;
+
+ XSendEvent(_glfw.x11.display, _glfw.x11.root,
+ False,
+ SubstructureNotifyMask | SubstructureRedirectMask,
+ &reply);
+ }
+ }
+ else if (event->xclient.message_type == _glfw.x11.XdndEnter)
+ {
+ // A drag operation has entered the window
+ unsigned long i, count;
+ Atom* formats = NULL;
+ const GLFWbool list = event->xclient.data.l[1] & 1;
+
+ _glfw.x11.xdnd.source = event->xclient.data.l[0];
+ _glfw.x11.xdnd.version = event->xclient.data.l[1] >> 24;
+ _glfw.x11.xdnd.format = None;
+
+ if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
+ return;
+
+ if (list)
+ {
+ count = _glfwGetWindowPropertyX11(_glfw.x11.xdnd.source,
+ _glfw.x11.XdndTypeList,
+ XA_ATOM,
+ (unsigned char**) &formats);
+ }
+ else
+ {
+ count = 3;
+ formats = (Atom*) event->xclient.data.l + 2;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ if (formats[i] == _glfw.x11.text_uri_list)
+ {
+ _glfw.x11.xdnd.format = _glfw.x11.text_uri_list;
+ break;
+ }
+ }
+
+ if (list && formats)
+ XFree(formats);
+ }
+ else if (event->xclient.message_type == _glfw.x11.XdndDrop)
+ {
+ // The drag operation has finished by dropping on the window
+ Time time = CurrentTime;
+
+ if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
+ return;
+
+ if (_glfw.x11.xdnd.format)
+ {
+ if (_glfw.x11.xdnd.version >= 1)
+ time = event->xclient.data.l[2];
+
+ // Request the chosen format from the source window
+ XConvertSelection(_glfw.x11.display,
+ _glfw.x11.XdndSelection,
+ _glfw.x11.xdnd.format,
+ _glfw.x11.XdndSelection,
+ window->x11.handle,
+ time);
+ }
+ else if (_glfw.x11.xdnd.version >= 2)
+ {
+ XEvent reply;
+ memset(&reply, 0, sizeof(reply));
+
+ reply.type = ClientMessage;
+ reply.xclient.window = _glfw.x11.xdnd.source;
+ reply.xclient.message_type = _glfw.x11.XdndFinished;
+ reply.xclient.format = 32;
+ reply.xclient.data.l[0] = window->x11.handle;
+ reply.xclient.data.l[1] = 0; // The drag was rejected
+ reply.xclient.data.l[2] = None;
+
+ XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
+ False, NoEventMask, &reply);
+ XFlush(_glfw.x11.display);
+ }
+ }
+ else if (event->xclient.message_type == _glfw.x11.XdndPosition)
+ {
+ // The drag operation has moved over the window
+ const int xabs = (event->xclient.data.l[2] >> 16) & 0xffff;
+ const int yabs = (event->xclient.data.l[2]) & 0xffff;
+ Window dummy;
+ int xpos, ypos;
+
+ if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
+ return;
+
+ XTranslateCoordinates(_glfw.x11.display,
+ _glfw.x11.root,
+ window->x11.handle,
+ xabs, yabs,
+ &xpos, &ypos,
+ &dummy);
+
+ _glfwInputCursorPos(window, xpos, ypos);
+
+ XEvent reply;
+ memset(&reply, 0, sizeof(reply));
+
+ reply.type = ClientMessage;
+ reply.xclient.window = _glfw.x11.xdnd.source;
+ reply.xclient.message_type = _glfw.x11.XdndStatus;
+ reply.xclient.format = 32;
+ reply.xclient.data.l[0] = window->x11.handle;
+ reply.xclient.data.l[2] = 0; // Specify an empty rectangle
+ reply.xclient.data.l[3] = 0;
+
+ if (_glfw.x11.xdnd.format)
+ {
+ // Reply that we are ready to copy the dragged data
+ reply.xclient.data.l[1] = 1; // Accept with no rectangle
+ if (_glfw.x11.xdnd.version >= 2)
+ reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;
+ }
+
+ XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
+ False, NoEventMask, &reply);
+ XFlush(_glfw.x11.display);
+ }
+
+ return;
+ }
+
+ case SelectionNotify:
+ {
+ if (event->xselection.property == _glfw.x11.XdndSelection)
+ {
+ // The converted data from the drag operation has arrived
+ char* data;
+ const unsigned long result =
+ _glfwGetWindowPropertyX11(event->xselection.requestor,
+ event->xselection.property,
+ event->xselection.target,
+ (unsigned char**) &data);
+
+ if (result)
+ {
+ int i, count;
+ char** paths = parseUriList(data, &count);
+
+ _glfwInputDrop(window, count, (const char**) paths);
+
+ for (i = 0; i < count; i++)
+ free(paths[i]);
+ free(paths);
+ }
+
+ if (data)
+ XFree(data);
+
+ if (_glfw.x11.xdnd.version >= 2)
+ {
+ XEvent reply;
+ memset(&reply, 0, sizeof(reply));
+
+ reply.type = ClientMessage;
+ reply.xclient.window = _glfw.x11.xdnd.source;
+ reply.xclient.message_type = _glfw.x11.XdndFinished;
+ reply.xclient.format = 32;
+ reply.xclient.data.l[0] = window->x11.handle;
+ reply.xclient.data.l[1] = result;
+ reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;
+
+ XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
+ False, NoEventMask, &reply);
+ XFlush(_glfw.x11.display);
+ }
+ }
+
+ return;
+ }
+
+ case FocusIn:
+ {
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ disableCursor(window);
+
+ if (event->xfocus.mode == NotifyGrab ||
+ event->xfocus.mode == NotifyUngrab)
+ {
+ // Ignore focus events from popup indicator windows, window menu
+ // key chords and window dragging
+ return;
+ }
+
+ if (window->x11.ic)
+ XSetICFocus(window->x11.ic);
+
+ _glfwInputWindowFocus(window, GLFW_TRUE);
+ return;
+ }
+
+ case FocusOut:
+ {
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ enableCursor(window);
+
+ if (event->xfocus.mode == NotifyGrab ||
+ event->xfocus.mode == NotifyUngrab)
+ {
+ // Ignore focus events from popup indicator windows, window menu
+ // key chords and window dragging
+ return;
+ }
+
+ if (window->x11.ic)
+ XUnsetICFocus(window->x11.ic);
+
+ if (window->monitor && window->autoIconify)
+ _glfwPlatformIconifyWindow(window);
+
+ _glfwInputWindowFocus(window, GLFW_FALSE);
+ return;
+ }
+
+ case Expose:
+ {
+ _glfwInputWindowDamage(window);
+ return;
+ }
+
+ case PropertyNotify:
+ {
+ if (event->xproperty.state != PropertyNewValue)
+ return;
+
+ if (event->xproperty.atom == _glfw.x11.WM_STATE)
+ {
+ const int state = getWindowState(window);
+ if (state != IconicState && state != NormalState)
+ return;
+
+ const GLFWbool iconified = (state == IconicState);
+ if (window->x11.iconified != iconified)
+ {
+ if (window->monitor)
+ {
+ if (iconified)
+ releaseMonitor(window);
+ else
+ acquireMonitor(window);
+ }
+
+ window->x11.iconified = iconified;
+ _glfwInputWindowIconify(window, iconified);
+ }
+ }
+ else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE)
+ {
+ const GLFWbool maximized = _glfwPlatformWindowMaximized(window);
+ if (window->x11.maximized != maximized)
+ {
+ window->x11.maximized = maximized;
+ _glfwInputWindowMaximize(window, maximized);
+ }
+ }
+
+ return;
+ }
+
+ case DestroyNotify:
+ return;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Retrieve a single window property of the specified type
+// Inspired by fghGetWindowProperty from freeglut
+//
+unsigned long _glfwGetWindowPropertyX11(Window window,
+ Atom property,
+ Atom type,
+ unsigned char** value)
+{
+ Atom actualType;
+ int actualFormat;
+ unsigned long itemCount, bytesAfter;
+
+ XGetWindowProperty(_glfw.x11.display,
+ window,
+ property,
+ 0,
+ LONG_MAX,
+ False,
+ type,
+ &actualType,
+ &actualFormat,
+ &itemCount,
+ &bytesAfter,
+ value);
+
+ return itemCount;
+}
+
+GLFWbool _glfwIsVisualTransparentX11(Visual* visual)
+{
+ if (!_glfw.x11.xrender.available)
+ return GLFW_FALSE;
+
+ XRenderPictFormat* pf = XRenderFindVisualFormat(_glfw.x11.display, visual);
+ return pf && pf->direct.alphaMask;
+}
+
+// Push contents of our selection to clipboard manager
+//
+void _glfwPushSelectionToManagerX11(void)
+{
+ XConvertSelection(_glfw.x11.display,
+ _glfw.x11.CLIPBOARD_MANAGER,
+ _glfw.x11.SAVE_TARGETS,
+ None,
+ _glfw.x11.helperWindowHandle,
+ CurrentTime);
+
+ for (;;)
+ {
+ XEvent event;
+
+ while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
+ {
+ switch (event.type)
+ {
+ case SelectionRequest:
+ handleSelectionRequest(&event);
+ break;
+
+ case SelectionClear:
+ handleSelectionClear(&event);
+ break;
+
+ case SelectionNotify:
+ {
+ if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
+ {
+ // This means one of two things; either the selection
+ // was not owned, which means there is no clipboard
+ // manager, or the transfer to the clipboard manager has
+ // completed
+ // In either case, it means we are done here
+ return;
+ }
+
+ break;
+ }
+ }
+ }
+
+ waitForEvent(NULL);
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW platform API //////
+//////////////////////////////////////////////////////////////////////////
+
+int _glfwPlatformCreateWindow(_GLFWwindow* window,
+ const _GLFWwndconfig* wndconfig,
+ const _GLFWctxconfig* ctxconfig,
+ const _GLFWfbconfig* fbconfig)
+{
+ Visual* visual;
+ int depth;
+
+ if (ctxconfig->client != GLFW_NO_API)
+ {
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
+ {
+ if (!_glfwInitGLX())
+ return GLFW_FALSE;
+ if (!_glfwChooseVisualGLX(wndconfig, ctxconfig, fbconfig, &visual, &depth))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
+ {
+ if (!_glfwInitEGL())
+ return GLFW_FALSE;
+ if (!_glfwChooseVisualEGL(wndconfig, ctxconfig, fbconfig, &visual, &depth))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ if (!_glfwInitOSMesa())
+ return GLFW_FALSE;
+ }
+ }
+
+ if (ctxconfig->client == GLFW_NO_API ||
+ ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen);
+ depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
+ }
+
+ if (!createNativeWindow(window, wndconfig, visual, depth))
+ return GLFW_FALSE;
+
+ if (ctxconfig->client != GLFW_NO_API)
+ {
+ if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
+ {
+ if (!_glfwCreateContextGLX(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
+ {
+ if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
+ {
+ if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
+ return GLFW_FALSE;
+ }
+ }
+
+ if (window->monitor)
+ {
+ _glfwPlatformShowWindow(window);
+ updateWindowMode(window);
+ acquireMonitor(window);
+ }
+
+ XFlush(_glfw.x11.display);
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyWindow(_GLFWwindow* window)
+{
+ if (_glfw.x11.disabledCursorWindow == window)
+ _glfw.x11.disabledCursorWindow = NULL;
+
+ if (window->monitor)
+ releaseMonitor(window);
+
+ if (window->x11.ic)
+ {
+ XDestroyIC(window->x11.ic);
+ window->x11.ic = NULL;
+ }
+
+ if (window->context.destroy)
+ window->context.destroy(window);
+
+ if (window->x11.handle)
+ {
+ XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);
+ XUnmapWindow(_glfw.x11.display, window->x11.handle);
+ XDestroyWindow(_glfw.x11.display, window->x11.handle);
+ window->x11.handle = (Window) 0;
+ }
+
+ if (window->x11.colormap)
+ {
+ XFreeColormap(_glfw.x11.display, window->x11.colormap);
+ window->x11.colormap = (Colormap) 0;
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
+{
+#if defined(X_HAVE_UTF8_STRING)
+ Xutf8SetWMProperties(_glfw.x11.display,
+ window->x11.handle,
+ title, title,
+ NULL, 0,
+ NULL, NULL, NULL);
+#else
+ // This may be a slightly better fallback than using XStoreName and
+ // XSetIconName, which always store their arguments using STRING
+ XmbSetWMProperties(_glfw.x11.display,
+ window->x11.handle,
+ title, title,
+ NULL, 0,
+ NULL, NULL, NULL);
+#endif
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
+ PropModeReplace,
+ (unsigned char*) title, strlen(title));
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
+ PropModeReplace,
+ (unsigned char*) title, strlen(title));
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
+ int count, const GLFWimage* images)
+{
+ if (count)
+ {
+ int i, j, longCount = 0;
+
+ for (i = 0; i < count; i++)
+ longCount += 2 + images[i].width * images[i].height;
+
+ long* icon = calloc(longCount, sizeof(long));
+ long* target = icon;
+
+ for (i = 0; i < count; i++)
+ {
+ *target++ = images[i].width;
+ *target++ = images[i].height;
+
+ for (j = 0; j < images[i].width * images[i].height; j++)
+ {
+ *target++ = (images[i].pixels[j * 4 + 0] << 16) |
+ (images[i].pixels[j * 4 + 1] << 8) |
+ (images[i].pixels[j * 4 + 2] << 0) |
+ (images[i].pixels[j * 4 + 3] << 24);
+ }
+ }
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_ICON,
+ XA_CARDINAL, 32,
+ PropModeReplace,
+ (unsigned char*) icon,
+ longCount);
+
+ free(icon);
+ }
+ else
+ {
+ XDeleteProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_ICON);
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
+{
+ Window dummy;
+ int x, y;
+
+ XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
+ 0, 0, &x, &y, &dummy);
+
+ if (xpos)
+ *xpos = x;
+ if (ypos)
+ *ypos = y;
+}
+
+void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
+{
+ // HACK: Explicitly setting PPosition to any value causes some WMs, notably
+ // Compiz and Metacity, to honor the position of unmapped windows
+ if (!_glfwPlatformWindowVisible(window))
+ {
+ long supplied;
+ XSizeHints* hints = XAllocSizeHints();
+
+ if (XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied))
+ {
+ hints->flags |= PPosition;
+ hints->x = hints->y = 0;
+
+ XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
+ }
+
+ XFree(hints);
+ }
+
+ XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
+{
+ XWindowAttributes attribs;
+ XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
+
+ if (width)
+ *width = attribs.width;
+ if (height)
+ *height = attribs.height;
+}
+
+void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
+{
+ if (window->monitor)
+ {
+ if (window->monitor->window == window)
+ acquireMonitor(window);
+ }
+ else
+ {
+ if (!window->resizable)
+ updateNormalHints(window, width, height);
+
+ XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
+ int minwidth, int minheight,
+ int maxwidth, int maxheight)
+{
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ updateNormalHints(window, width, height);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
+{
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ updateNormalHints(window, width, height);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
+{
+ _glfwPlatformGetWindowSize(window, width, height);
+}
+
+void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
+ int* left, int* top,
+ int* right, int* bottom)
+{
+ long* extents = NULL;
+
+ if (window->monitor || !window->decorated)
+ return;
+
+ if (_glfw.x11.NET_FRAME_EXTENTS == None)
+ return;
+
+ if (!_glfwPlatformWindowVisible(window) &&
+ _glfw.x11.NET_REQUEST_FRAME_EXTENTS)
+ {
+ XEvent event;
+ double timeout = 0.5;
+
+ // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
+ // function before the window is mapped
+ sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,
+ 0, 0, 0, 0, 0);
+
+ // HACK: Use a timeout because earlier versions of some window managers
+ // (at least Unity, Fluxbox and Xfwm) failed to send the reply
+ // They have been fixed but broken versions are still in the wild
+ // If you are affected by this and your window manager is NOT
+ // listed above, PLEASE report it to their and our issue trackers
+ while (!XCheckIfEvent(_glfw.x11.display,
+ &event,
+ isFrameExtentsEvent,
+ (XPointer) window))
+ {
+ if (!waitForEvent(&timeout))
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
+ return;
+ }
+ }
+ }
+
+ if (_glfwGetWindowPropertyX11(window->x11.handle,
+ _glfw.x11.NET_FRAME_EXTENTS,
+ XA_CARDINAL,
+ (unsigned char**) &extents) == 4)
+ {
+ if (left)
+ *left = extents[0];
+ if (top)
+ *top = extents[2];
+ if (right)
+ *right = extents[1];
+ if (bottom)
+ *bottom = extents[3];
+ }
+
+ if (extents)
+ XFree(extents);
+}
+
+void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
+ float* xscale, float* yscale)
+{
+ if (xscale)
+ *xscale = _glfw.x11.contentScaleX;
+ if (yscale)
+ *yscale = _glfw.x11.contentScaleY;
+}
+
+void _glfwPlatformIconifyWindow(_GLFWwindow* window)
+{
+ if (window->x11.overrideRedirect)
+ {
+ // Override-redirect windows cannot be iconified or restored, as those
+ // tasks are performed by the window manager
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
+ return;
+ }
+
+ XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformRestoreWindow(_GLFWwindow* window)
+{
+ if (window->x11.overrideRedirect)
+ {
+ // Override-redirect windows cannot be iconified or restored, as those
+ // tasks are performed by the window manager
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
+ return;
+ }
+
+ if (_glfwPlatformWindowIconified(window))
+ {
+ XMapWindow(_glfw.x11.display, window->x11.handle);
+ waitForVisibilityNotify(window);
+ }
+ else if (_glfwPlatformWindowVisible(window))
+ {
+ if (_glfw.x11.NET_WM_STATE &&
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
+ {
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_STATE,
+ _NET_WM_STATE_REMOVE,
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
+ 1, 0);
+ }
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
+{
+ if (_glfw.x11.NET_WM_STATE &&
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
+ {
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_STATE,
+ _NET_WM_STATE_ADD,
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
+ _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
+ 1, 0);
+ XFlush(_glfw.x11.display);
+ }
+}
+
+void _glfwPlatformShowWindow(_GLFWwindow* window)
+{
+ if (_glfwPlatformWindowVisible(window))
+ return;
+
+ XMapWindow(_glfw.x11.display, window->x11.handle);
+ waitForVisibilityNotify(window);
+}
+
+void _glfwPlatformHideWindow(_GLFWwindow* window)
+{
+ XUnmapWindow(_glfw.x11.display, window->x11.handle);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
+{
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_STATE,
+ _NET_WM_STATE_ADD,
+ _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION,
+ 0, 1, 0);
+}
+
+void _glfwPlatformFocusWindow(_GLFWwindow* window)
+{
+ if (_glfw.x11.NET_ACTIVE_WINDOW)
+ sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0);
+ else
+ {
+ XRaiseWindow(_glfw.x11.display, window->x11.handle);
+ XSetInputFocus(_glfw.x11.display, window->x11.handle,
+ RevertToParent, CurrentTime);
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
+ _GLFWmonitor* monitor,
+ int xpos, int ypos,
+ int width, int height,
+ int refreshRate)
+{
+ if (window->monitor == monitor)
+ {
+ if (monitor)
+ {
+ if (monitor->window == window)
+ acquireMonitor(window);
+ }
+ else
+ {
+ if (!window->resizable)
+ updateNormalHints(window, width, height);
+
+ XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
+ xpos, ypos, width, height);
+ }
+
+ XFlush(_glfw.x11.display);
+ return;
+ }
+
+ if (window->monitor)
+ releaseMonitor(window);
+
+ _glfwInputWindowMonitor(window, monitor);
+ updateNormalHints(window, width, height);
+ updateWindowMode(window);
+
+ if (window->monitor)
+ {
+ XMapRaised(_glfw.x11.display, window->x11.handle);
+ if (waitForVisibilityNotify(window))
+ acquireMonitor(window);
+ }
+ else
+ {
+ XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
+ xpos, ypos, width, height);
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+int _glfwPlatformWindowFocused(_GLFWwindow* window)
+{
+ Window focused;
+ int state;
+
+ XGetInputFocus(_glfw.x11.display, &focused, &state);
+ return window->x11.handle == focused;
+}
+
+int _glfwPlatformWindowIconified(_GLFWwindow* window)
+{
+ return getWindowState(window) == IconicState;
+}
+
+int _glfwPlatformWindowVisible(_GLFWwindow* window)
+{
+ XWindowAttributes wa;
+ XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
+ return wa.map_state == IsViewable;
+}
+
+int _glfwPlatformWindowMaximized(_GLFWwindow* window)
+{
+ Atom* states;
+ unsigned long i;
+ GLFWbool maximized = GLFW_FALSE;
+
+ if (!_glfw.x11.NET_WM_STATE ||
+ !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
+ !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
+ {
+ return maximized;
+ }
+
+ const unsigned long count =
+ _glfwGetWindowPropertyX11(window->x11.handle,
+ _glfw.x11.NET_WM_STATE,
+ XA_ATOM,
+ (unsigned char**) &states);
+
+ for (i = 0; i < count; i++)
+ {
+ if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
+ states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
+ {
+ maximized = GLFW_TRUE;
+ break;
+ }
+ }
+
+ if (states)
+ XFree(states);
+
+ return maximized;
+}
+
+int _glfwPlatformWindowHovered(_GLFWwindow* window)
+{
+ Window w = _glfw.x11.root;
+ while (w)
+ {
+ Window root;
+ int rootX, rootY, childX, childY;
+ unsigned int mask;
+
+ if (!XQueryPointer(_glfw.x11.display, w,
+ &root, &w, &rootX, &rootY, &childX, &childY, &mask))
+ {
+ return GLFW_FALSE;
+ }
+
+ if (w == window->x11.handle)
+ return GLFW_TRUE;
+ }
+
+ return GLFW_FALSE;
+}
+
+int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
+{
+ if (!window->x11.transparent)
+ return GLFW_FALSE;
+
+ return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None;
+}
+
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
+{
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+ updateNormalHints(window, width, height);
+}
+
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
+{
+ if (enabled)
+ {
+ XDeleteProperty(_glfw.x11.display,
+ window->x11.handle,
+ _glfw.x11.MOTIF_WM_HINTS);
+ }
+ else
+ {
+ struct
+ {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+ long input_mode;
+ unsigned long status;
+ } hints;
+
+ hints.flags = 2; // Set decorations
+ hints.decorations = 0; // No decorations
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.MOTIF_WM_HINTS,
+ _glfw.x11.MOTIF_WM_HINTS, 32,
+ PropModeReplace,
+ (unsigned char*) &hints,
+ sizeof(hints) / sizeof(long));
+ }
+}
+
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
+{
+ if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE)
+ return;
+
+ if (_glfwPlatformWindowVisible(window))
+ {
+ const Atom action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+ sendEventToWM(window,
+ _glfw.x11.NET_WM_STATE,
+ action,
+ _glfw.x11.NET_WM_STATE_ABOVE,
+ 0, 1, 0);
+ }
+ else
+ {
+ Atom* states;
+ unsigned long i, count;
+
+ count = _glfwGetWindowPropertyX11(window->x11.handle,
+ _glfw.x11.NET_WM_STATE,
+ XA_ATOM,
+ (unsigned char**) &states);
+ if (!states)
+ return;
+
+ if (enabled)
+ {
+ for (i = 0; i < count; i++)
+ {
+ if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
+ break;
+ }
+
+ if (i == count)
+ {
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
+ PropModeAppend,
+ (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
+ 1);
+ }
+ }
+ else
+ {
+ for (i = 0; i < count; i++)
+ {
+ if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
+ {
+ states[i] = states[count - 1];
+ count--;
+ }
+ }
+
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
+ PropModeReplace, (unsigned char*) &states, count);
+ }
+
+ XFree(states);
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
+{
+ float opacity = 1.f;
+
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx))
+ {
+ CARD32* value = NULL;
+
+ if (_glfwGetWindowPropertyX11(window->x11.handle,
+ _glfw.x11.NET_WM_WINDOW_OPACITY,
+ XA_CARDINAL,
+ (unsigned char**) &value))
+ {
+ opacity = (float) (*value / (double) 0xffffffffu);
+ }
+
+ if (value)
+ XFree(value);
+ }
+
+ return opacity;
+}
+
+void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
+{
+ const CARD32 value = (CARD32) (0xffffffffu * (double) opacity);
+ XChangeProperty(_glfw.x11.display, window->x11.handle,
+ _glfw.x11.NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char*) &value, 1);
+}
+
+void _glfwPlatformPollEvents(void)
+{
+ _GLFWwindow* window;
+
+#if defined(__linux__)
+ _glfwDetectJoystickConnectionLinux();
+#endif
+ XPending(_glfw.x11.display);
+
+ while (XQLength(_glfw.x11.display))
+ {
+ XEvent event;
+ XNextEvent(_glfw.x11.display, &event);
+ processEvent(&event);
+ }
+
+ window = _glfw.x11.disabledCursorWindow;
+ if (window)
+ {
+ int width, height;
+ _glfwPlatformGetWindowSize(window, &width, &height);
+
+ // NOTE: Re-center the cursor only if it has moved since the last call,
+ // to avoid breaking glfwWaitEvents with MotionNotify
+ if (window->x11.lastCursorPosX != width / 2 ||
+ window->x11.lastCursorPosY != height / 2)
+ {
+ _glfwPlatformSetCursorPos(window, width / 2, height / 2);
+ }
+ }
+
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformWaitEvents(void)
+{
+ while (!XPending(_glfw.x11.display))
+ waitForEvent(NULL);
+
+ _glfwPlatformPollEvents();
+}
+
+void _glfwPlatformWaitEventsTimeout(double timeout)
+{
+ while (!XPending(_glfw.x11.display))
+ {
+ if (!waitForEvent(&timeout))
+ break;
+ }
+
+ _glfwPlatformPollEvents();
+}
+
+void _glfwPlatformPostEmptyEvent(void)
+{
+ XEvent event;
+
+ memset(&event, 0, sizeof(event));
+ event.type = ClientMessage;
+ event.xclient.window = _glfw.x11.helperWindowHandle;
+ event.xclient.format = 32; // Data is 32-bit longs
+ event.xclient.message_type = _glfw.x11.NULL_;
+
+ XSendEvent(_glfw.x11.display, _glfw.x11.helperWindowHandle, False, 0, &event);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
+{
+ Window root, child;
+ int rootX, rootY, childX, childY;
+ unsigned int mask;
+
+ XQueryPointer(_glfw.x11.display, window->x11.handle,
+ &root, &child,
+ &rootX, &rootY, &childX, &childY,
+ &mask);
+
+ if (xpos)
+ *xpos = childX;
+ if (ypos)
+ *ypos = childY;
+}
+
+void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
+{
+ // Store the new position so it can be recognized later
+ window->x11.warpCursorPosX = (int) x;
+ window->x11.warpCursorPosY = (int) y;
+
+ XWarpPointer(_glfw.x11.display, None, window->x11.handle,
+ 0,0,0,0, (int) x, (int) y);
+ XFlush(_glfw.x11.display);
+}
+
+void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
+{
+ if (mode == GLFW_CURSOR_DISABLED)
+ {
+ if (_glfwPlatformWindowFocused(window))
+ disableCursor(window);
+ }
+ else if (_glfw.x11.disabledCursorWindow == window)
+ enableCursor(window);
+ else
+ updateCursorImage(window);
+
+ XFlush(_glfw.x11.display);
+}
+
+const char* _glfwPlatformGetScancodeName(int scancode)
+{
+ if (!_glfw.x11.xkb.available)
+ return NULL;
+
+ const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);
+ if (keysym == NoSymbol)
+ return NULL;
+
+ const long ch = _glfwKeySym2Unicode(keysym);
+ if (ch == -1)
+ return NULL;
+
+ const size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch);
+ if (count == 0)
+ return NULL;
+
+ _glfw.x11.keyName[count] = '\0';
+ return _glfw.x11.keyName;
+}
+
+int _glfwPlatformGetKeyScancode(int key)
+{
+ return _glfw.x11.scancodes[key];
+}
+
+int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
+ const GLFWimage* image,
+ int xhot, int yhot)
+{
+ cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot);
+ if (!cursor->x11.handle)
+ return GLFW_FALSE;
+
+ return GLFW_TRUE;
+}
+
+int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
+{
+ int native = 0;
+
+ if (shape == GLFW_ARROW_CURSOR)
+ native = XC_left_ptr;
+ else if (shape == GLFW_IBEAM_CURSOR)
+ native = XC_xterm;
+ else if (shape == GLFW_CROSSHAIR_CURSOR)
+ native = XC_crosshair;
+ else if (shape == GLFW_HAND_CURSOR)
+ native = XC_hand1;
+ else if (shape == GLFW_HRESIZE_CURSOR)
+ native = XC_sb_h_double_arrow;
+ else if (shape == GLFW_VRESIZE_CURSOR)
+ native = XC_sb_v_double_arrow;
+ else
+ return GLFW_FALSE;
+
+ cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
+ if (!cursor->x11.handle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to create standard cursor");
+ return GLFW_FALSE;
+ }
+
+ return GLFW_TRUE;
+}
+
+void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
+{
+ if (cursor->x11.handle)
+ XFreeCursor(_glfw.x11.display, cursor->x11.handle);
+}
+
+void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
+{
+ if (window->cursorMode == GLFW_CURSOR_NORMAL)
+ {
+ updateCursorImage(window);
+ XFlush(_glfw.x11.display);
+ }
+}
+
+void _glfwPlatformSetClipboardString(const char* string)
+{
+ free(_glfw.x11.clipboardString);
+ _glfw.x11.clipboardString = _glfw_strdup(string);
+
+ XSetSelectionOwner(_glfw.x11.display,
+ _glfw.x11.CLIPBOARD,
+ _glfw.x11.helperWindowHandle,
+ CurrentTime);
+
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=
+ _glfw.x11.helperWindowHandle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to become owner of clipboard selection");
+ }
+}
+
+const char* _glfwPlatformGetClipboardString(void)
+{
+ return getSelectionString(_glfw.x11.CLIPBOARD);
+}
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
+{
+ if (!_glfw.vk.KHR_surface)
+ return;
+
+ if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
+ {
+ if (!_glfw.vk.KHR_xlib_surface)
+ return;
+ }
+
+ extensions[0] = "VK_KHR_surface";
+
+ // NOTE: VK_KHR_xcb_surface is preferred due to some early ICDs exposing but
+ // not correctly implementing VK_KHR_xlib_surface
+ if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
+ extensions[1] = "VK_KHR_xcb_surface";
+ else
+ extensions[1] = "VK_KHR_xlib_surface";
+}
+
+int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
+ VkPhysicalDevice device,
+ uint32_t queuefamily)
+{
+ VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
+ _glfw.x11.screen));
+
+ if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
+ {
+ PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
+ vkGetPhysicalDeviceXcbPresentationSupportKHR =
+ (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
+ vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
+ if (!vkGetPhysicalDeviceXcbPresentationSupportKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
+ return GLFW_FALSE;
+ }
+
+ xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
+ if (!connection)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to retrieve XCB connection");
+ return GLFW_FALSE;
+ }
+
+ return vkGetPhysicalDeviceXcbPresentationSupportKHR(device,
+ queuefamily,
+ connection,
+ visualID);
+ }
+ else
+ {
+ PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
+ vkGetPhysicalDeviceXlibPresentationSupportKHR =
+ (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
+ vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+ if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
+ return GLFW_FALSE;
+ }
+
+ return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
+ queuefamily,
+ _glfw.x11.display,
+ visualID);
+ }
+}
+
+VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
+ _GLFWwindow* window,
+ const VkAllocationCallbacks* allocator,
+ VkSurfaceKHR* surface)
+{
+ if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
+ {
+ VkResult err;
+ VkXcbSurfaceCreateInfoKHR sci;
+ PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
+
+ xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
+ if (!connection)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to retrieve XCB connection");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)
+ vkGetInstanceProcAddr(instance, "vkCreateXcbSurfaceKHR");
+ if (!vkCreateXcbSurfaceKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ memset(&sci, 0, sizeof(sci));
+ sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+ sci.connection = connection;
+ sci.window = window->x11.handle;
+
+ err = vkCreateXcbSurfaceKHR(instance, &sci, allocator, surface);
+ if (err)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to create Vulkan XCB surface: %s",
+ _glfwGetVulkanResultString(err));
+ }
+
+ return err;
+ }
+ else
+ {
+ VkResult err;
+ VkXlibSurfaceCreateInfoKHR sci;
+ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
+
+ vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
+ vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
+ if (!vkCreateXlibSurfaceKHR)
+ {
+ _glfwInputError(GLFW_API_UNAVAILABLE,
+ "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
+ return VK_ERROR_EXTENSION_NOT_PRESENT;
+ }
+
+ memset(&sci, 0, sizeof(sci));
+ sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
+ sci.dpy = _glfw.x11.display;
+ sci.window = window->x11.handle;
+
+ err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
+ if (err)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to create Vulkan X11 surface: %s",
+ _glfwGetVulkanResultString(err));
+ }
+
+ return err;
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW native API //////
+//////////////////////////////////////////////////////////////////////////
+
+GLFWAPI Display* glfwGetX11Display(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return _glfw.x11.display;
+}
+
+GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+ _GLFW_REQUIRE_INIT_OR_RETURN(None);
+ return window->x11.handle;
+}
+
+GLFWAPI void glfwSetX11SelectionString(const char* string)
+{
+ _GLFW_REQUIRE_INIT();
+
+ free(_glfw.x11.primarySelectionString);
+ _glfw.x11.primarySelectionString = _glfw_strdup(string);
+
+ XSetSelectionOwner(_glfw.x11.display,
+ _glfw.x11.PRIMARY,
+ _glfw.x11.helperWindowHandle,
+ CurrentTime);
+
+ if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.PRIMARY) !=
+ _glfw.x11.helperWindowHandle)
+ {
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "X11: Failed to become owner of primary selection");
+ }
+}
+
+GLFWAPI const char* glfwGetX11SelectionString(void)
+{
+ _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
+ return getSelectionString(_glfw.x11.PRIMARY);
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.c b/Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.c
new file mode 100644
index 0000000..ecfdc2a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.c
@@ -0,0 +1,940 @@
+//========================================================================
+// GLFW 3.3 X11 - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2002-2006 Marcus Geelnard
+// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+#include "internal.h"
+
+
+/*
+ * Marcus: This code was originally written by Markus G. Kuhn.
+ * I have made some slight changes (trimmed it down a bit from >60 KB to
+ * 20 KB), but the functionality is the same.
+ */
+
+/*
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary
+ * search, therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * Original author: Markus G. Kuhn <mkuhn@acm.org>, University of
+ * Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ */
+
+
+//************************************************************************
+//**** KeySym to Unicode mapping table ****
+//************************************************************************
+
+static const struct codepair {
+ unsigned short keysym;
+ unsigned short ucs;
+} keysymtab[] = {
+ { 0x01a1, 0x0104 },
+ { 0x01a2, 0x02d8 },
+ { 0x01a3, 0x0141 },
+ { 0x01a5, 0x013d },
+ { 0x01a6, 0x015a },
+ { 0x01a9, 0x0160 },
+ { 0x01aa, 0x015e },
+ { 0x01ab, 0x0164 },
+ { 0x01ac, 0x0179 },
+ { 0x01ae, 0x017d },
+ { 0x01af, 0x017b },
+ { 0x01b1, 0x0105 },
+ { 0x01b2, 0x02db },
+ { 0x01b3, 0x0142 },
+ { 0x01b5, 0x013e },
+ { 0x01b6, 0x015b },
+ { 0x01b7, 0x02c7 },
+ { 0x01b9, 0x0161 },
+ { 0x01ba, 0x015f },
+ { 0x01bb, 0x0165 },
+ { 0x01bc, 0x017a },
+ { 0x01bd, 0x02dd },
+ { 0x01be, 0x017e },
+ { 0x01bf, 0x017c },
+ { 0x01c0, 0x0154 },
+ { 0x01c3, 0x0102 },
+ { 0x01c5, 0x0139 },
+ { 0x01c6, 0x0106 },
+ { 0x01c8, 0x010c },
+ { 0x01ca, 0x0118 },
+ { 0x01cc, 0x011a },
+ { 0x01cf, 0x010e },
+ { 0x01d0, 0x0110 },
+ { 0x01d1, 0x0143 },
+ { 0x01d2, 0x0147 },
+ { 0x01d5, 0x0150 },
+ { 0x01d8, 0x0158 },
+ { 0x01d9, 0x016e },
+ { 0x01db, 0x0170 },
+ { 0x01de, 0x0162 },
+ { 0x01e0, 0x0155 },
+ { 0x01e3, 0x0103 },
+ { 0x01e5, 0x013a },
+ { 0x01e6, 0x0107 },
+ { 0x01e8, 0x010d },
+ { 0x01ea, 0x0119 },
+ { 0x01ec, 0x011b },
+ { 0x01ef, 0x010f },
+ { 0x01f0, 0x0111 },
+ { 0x01f1, 0x0144 },
+ { 0x01f2, 0x0148 },
+ { 0x01f5, 0x0151 },
+ { 0x01f8, 0x0159 },
+ { 0x01f9, 0x016f },
+ { 0x01fb, 0x0171 },
+ { 0x01fe, 0x0163 },
+ { 0x01ff, 0x02d9 },
+ { 0x02a1, 0x0126 },
+ { 0x02a6, 0x0124 },
+ { 0x02a9, 0x0130 },
+ { 0x02ab, 0x011e },
+ { 0x02ac, 0x0134 },
+ { 0x02b1, 0x0127 },
+ { 0x02b6, 0x0125 },
+ { 0x02b9, 0x0131 },
+ { 0x02bb, 0x011f },
+ { 0x02bc, 0x0135 },
+ { 0x02c5, 0x010a },
+ { 0x02c6, 0x0108 },
+ { 0x02d5, 0x0120 },
+ { 0x02d8, 0x011c },
+ { 0x02dd, 0x016c },
+ { 0x02de, 0x015c },
+ { 0x02e5, 0x010b },
+ { 0x02e6, 0x0109 },
+ { 0x02f5, 0x0121 },
+ { 0x02f8, 0x011d },
+ { 0x02fd, 0x016d },
+ { 0x02fe, 0x015d },
+ { 0x03a2, 0x0138 },
+ { 0x03a3, 0x0156 },
+ { 0x03a5, 0x0128 },
+ { 0x03a6, 0x013b },
+ { 0x03aa, 0x0112 },
+ { 0x03ab, 0x0122 },
+ { 0x03ac, 0x0166 },
+ { 0x03b3, 0x0157 },
+ { 0x03b5, 0x0129 },
+ { 0x03b6, 0x013c },
+ { 0x03ba, 0x0113 },
+ { 0x03bb, 0x0123 },
+ { 0x03bc, 0x0167 },
+ { 0x03bd, 0x014a },
+ { 0x03bf, 0x014b },
+ { 0x03c0, 0x0100 },
+ { 0x03c7, 0x012e },
+ { 0x03cc, 0x0116 },
+ { 0x03cf, 0x012a },
+ { 0x03d1, 0x0145 },
+ { 0x03d2, 0x014c },
+ { 0x03d3, 0x0136 },
+ { 0x03d9, 0x0172 },
+ { 0x03dd, 0x0168 },
+ { 0x03de, 0x016a },
+ { 0x03e0, 0x0101 },
+ { 0x03e7, 0x012f },
+ { 0x03ec, 0x0117 },
+ { 0x03ef, 0x012b },
+ { 0x03f1, 0x0146 },
+ { 0x03f2, 0x014d },
+ { 0x03f3, 0x0137 },
+ { 0x03f9, 0x0173 },
+ { 0x03fd, 0x0169 },
+ { 0x03fe, 0x016b },
+ { 0x047e, 0x203e },
+ { 0x04a1, 0x3002 },
+ { 0x04a2, 0x300c },
+ { 0x04a3, 0x300d },
+ { 0x04a4, 0x3001 },
+ { 0x04a5, 0x30fb },
+ { 0x04a6, 0x30f2 },
+ { 0x04a7, 0x30a1 },
+ { 0x04a8, 0x30a3 },
+ { 0x04a9, 0x30a5 },
+ { 0x04aa, 0x30a7 },
+ { 0x04ab, 0x30a9 },
+ { 0x04ac, 0x30e3 },
+ { 0x04ad, 0x30e5 },
+ { 0x04ae, 0x30e7 },
+ { 0x04af, 0x30c3 },
+ { 0x04b0, 0x30fc },
+ { 0x04b1, 0x30a2 },
+ { 0x04b2, 0x30a4 },
+ { 0x04b3, 0x30a6 },
+ { 0x04b4, 0x30a8 },
+ { 0x04b5, 0x30aa },
+ { 0x04b6, 0x30ab },
+ { 0x04b7, 0x30ad },
+ { 0x04b8, 0x30af },
+ { 0x04b9, 0x30b1 },
+ { 0x04ba, 0x30b3 },
+ { 0x04bb, 0x30b5 },
+ { 0x04bc, 0x30b7 },
+ { 0x04bd, 0x30b9 },
+ { 0x04be, 0x30bb },
+ { 0x04bf, 0x30bd },
+ { 0x04c0, 0x30bf },
+ { 0x04c1, 0x30c1 },
+ { 0x04c2, 0x30c4 },
+ { 0x04c3, 0x30c6 },
+ { 0x04c4, 0x30c8 },
+ { 0x04c5, 0x30ca },
+ { 0x04c6, 0x30cb },
+ { 0x04c7, 0x30cc },
+ { 0x04c8, 0x30cd },
+ { 0x04c9, 0x30ce },
+ { 0x04ca, 0x30cf },
+ { 0x04cb, 0x30d2 },
+ { 0x04cc, 0x30d5 },
+ { 0x04cd, 0x30d8 },
+ { 0x04ce, 0x30db },
+ { 0x04cf, 0x30de },
+ { 0x04d0, 0x30df },
+ { 0x04d1, 0x30e0 },
+ { 0x04d2, 0x30e1 },
+ { 0x04d3, 0x30e2 },
+ { 0x04d4, 0x30e4 },
+ { 0x04d5, 0x30e6 },
+ { 0x04d6, 0x30e8 },
+ { 0x04d7, 0x30e9 },
+ { 0x04d8, 0x30ea },
+ { 0x04d9, 0x30eb },
+ { 0x04da, 0x30ec },
+ { 0x04db, 0x30ed },
+ { 0x04dc, 0x30ef },
+ { 0x04dd, 0x30f3 },
+ { 0x04de, 0x309b },
+ { 0x04df, 0x309c },
+ { 0x05ac, 0x060c },
+ { 0x05bb, 0x061b },
+ { 0x05bf, 0x061f },
+ { 0x05c1, 0x0621 },
+ { 0x05c2, 0x0622 },
+ { 0x05c3, 0x0623 },
+ { 0x05c4, 0x0624 },
+ { 0x05c5, 0x0625 },
+ { 0x05c6, 0x0626 },
+ { 0x05c7, 0x0627 },
+ { 0x05c8, 0x0628 },
+ { 0x05c9, 0x0629 },
+ { 0x05ca, 0x062a },
+ { 0x05cb, 0x062b },
+ { 0x05cc, 0x062c },
+ { 0x05cd, 0x062d },
+ { 0x05ce, 0x062e },
+ { 0x05cf, 0x062f },
+ { 0x05d0, 0x0630 },
+ { 0x05d1, 0x0631 },
+ { 0x05d2, 0x0632 },
+ { 0x05d3, 0x0633 },
+ { 0x05d4, 0x0634 },
+ { 0x05d5, 0x0635 },
+ { 0x05d6, 0x0636 },
+ { 0x05d7, 0x0637 },
+ { 0x05d8, 0x0638 },
+ { 0x05d9, 0x0639 },
+ { 0x05da, 0x063a },
+ { 0x05e0, 0x0640 },
+ { 0x05e1, 0x0641 },
+ { 0x05e2, 0x0642 },
+ { 0x05e3, 0x0643 },
+ { 0x05e4, 0x0644 },
+ { 0x05e5, 0x0645 },
+ { 0x05e6, 0x0646 },
+ { 0x05e7, 0x0647 },
+ { 0x05e8, 0x0648 },
+ { 0x05e9, 0x0649 },
+ { 0x05ea, 0x064a },
+ { 0x05eb, 0x064b },
+ { 0x05ec, 0x064c },
+ { 0x05ed, 0x064d },
+ { 0x05ee, 0x064e },
+ { 0x05ef, 0x064f },
+ { 0x05f0, 0x0650 },
+ { 0x05f1, 0x0651 },
+ { 0x05f2, 0x0652 },
+ { 0x06a1, 0x0452 },
+ { 0x06a2, 0x0453 },
+ { 0x06a3, 0x0451 },
+ { 0x06a4, 0x0454 },
+ { 0x06a5, 0x0455 },
+ { 0x06a6, 0x0456 },
+ { 0x06a7, 0x0457 },
+ { 0x06a8, 0x0458 },
+ { 0x06a9, 0x0459 },
+ { 0x06aa, 0x045a },
+ { 0x06ab, 0x045b },
+ { 0x06ac, 0x045c },
+ { 0x06ae, 0x045e },
+ { 0x06af, 0x045f },
+ { 0x06b0, 0x2116 },
+ { 0x06b1, 0x0402 },
+ { 0x06b2, 0x0403 },
+ { 0x06b3, 0x0401 },
+ { 0x06b4, 0x0404 },
+ { 0x06b5, 0x0405 },
+ { 0x06b6, 0x0406 },
+ { 0x06b7, 0x0407 },
+ { 0x06b8, 0x0408 },
+ { 0x06b9, 0x0409 },
+ { 0x06ba, 0x040a },
+ { 0x06bb, 0x040b },
+ { 0x06bc, 0x040c },
+ { 0x06be, 0x040e },
+ { 0x06bf, 0x040f },
+ { 0x06c0, 0x044e },
+ { 0x06c1, 0x0430 },
+ { 0x06c2, 0x0431 },
+ { 0x06c3, 0x0446 },
+ { 0x06c4, 0x0434 },
+ { 0x06c5, 0x0435 },
+ { 0x06c6, 0x0444 },
+ { 0x06c7, 0x0433 },
+ { 0x06c8, 0x0445 },
+ { 0x06c9, 0x0438 },
+ { 0x06ca, 0x0439 },
+ { 0x06cb, 0x043a },
+ { 0x06cc, 0x043b },
+ { 0x06cd, 0x043c },
+ { 0x06ce, 0x043d },
+ { 0x06cf, 0x043e },
+ { 0x06d0, 0x043f },
+ { 0x06d1, 0x044f },
+ { 0x06d2, 0x0440 },
+ { 0x06d3, 0x0441 },
+ { 0x06d4, 0x0442 },
+ { 0x06d5, 0x0443 },
+ { 0x06d6, 0x0436 },
+ { 0x06d7, 0x0432 },
+ { 0x06d8, 0x044c },
+ { 0x06d9, 0x044b },
+ { 0x06da, 0x0437 },
+ { 0x06db, 0x0448 },
+ { 0x06dc, 0x044d },
+ { 0x06dd, 0x0449 },
+ { 0x06de, 0x0447 },
+ { 0x06df, 0x044a },
+ { 0x06e0, 0x042e },
+ { 0x06e1, 0x0410 },
+ { 0x06e2, 0x0411 },
+ { 0x06e3, 0x0426 },
+ { 0x06e4, 0x0414 },
+ { 0x06e5, 0x0415 },
+ { 0x06e6, 0x0424 },
+ { 0x06e7, 0x0413 },
+ { 0x06e8, 0x0425 },
+ { 0x06e9, 0x0418 },
+ { 0x06ea, 0x0419 },
+ { 0x06eb, 0x041a },
+ { 0x06ec, 0x041b },
+ { 0x06ed, 0x041c },
+ { 0x06ee, 0x041d },
+ { 0x06ef, 0x041e },
+ { 0x06f0, 0x041f },
+ { 0x06f1, 0x042f },
+ { 0x06f2, 0x0420 },
+ { 0x06f3, 0x0421 },
+ { 0x06f4, 0x0422 },
+ { 0x06f5, 0x0423 },
+ { 0x06f6, 0x0416 },
+ { 0x06f7, 0x0412 },
+ { 0x06f8, 0x042c },
+ { 0x06f9, 0x042b },
+ { 0x06fa, 0x0417 },
+ { 0x06fb, 0x0428 },
+ { 0x06fc, 0x042d },
+ { 0x06fd, 0x0429 },
+ { 0x06fe, 0x0427 },
+ { 0x06ff, 0x042a },
+ { 0x07a1, 0x0386 },
+ { 0x07a2, 0x0388 },
+ { 0x07a3, 0x0389 },
+ { 0x07a4, 0x038a },
+ { 0x07a5, 0x03aa },
+ { 0x07a7, 0x038c },
+ { 0x07a8, 0x038e },
+ { 0x07a9, 0x03ab },
+ { 0x07ab, 0x038f },
+ { 0x07ae, 0x0385 },
+ { 0x07af, 0x2015 },
+ { 0x07b1, 0x03ac },
+ { 0x07b2, 0x03ad },
+ { 0x07b3, 0x03ae },
+ { 0x07b4, 0x03af },
+ { 0x07b5, 0x03ca },
+ { 0x07b6, 0x0390 },
+ { 0x07b7, 0x03cc },
+ { 0x07b8, 0x03cd },
+ { 0x07b9, 0x03cb },
+ { 0x07ba, 0x03b0 },
+ { 0x07bb, 0x03ce },
+ { 0x07c1, 0x0391 },
+ { 0x07c2, 0x0392 },
+ { 0x07c3, 0x0393 },
+ { 0x07c4, 0x0394 },
+ { 0x07c5, 0x0395 },
+ { 0x07c6, 0x0396 },
+ { 0x07c7, 0x0397 },
+ { 0x07c8, 0x0398 },
+ { 0x07c9, 0x0399 },
+ { 0x07ca, 0x039a },
+ { 0x07cb, 0x039b },
+ { 0x07cc, 0x039c },
+ { 0x07cd, 0x039d },
+ { 0x07ce, 0x039e },
+ { 0x07cf, 0x039f },
+ { 0x07d0, 0x03a0 },
+ { 0x07d1, 0x03a1 },
+ { 0x07d2, 0x03a3 },
+ { 0x07d4, 0x03a4 },
+ { 0x07d5, 0x03a5 },
+ { 0x07d6, 0x03a6 },
+ { 0x07d7, 0x03a7 },
+ { 0x07d8, 0x03a8 },
+ { 0x07d9, 0x03a9 },
+ { 0x07e1, 0x03b1 },
+ { 0x07e2, 0x03b2 },
+ { 0x07e3, 0x03b3 },
+ { 0x07e4, 0x03b4 },
+ { 0x07e5, 0x03b5 },
+ { 0x07e6, 0x03b6 },
+ { 0x07e7, 0x03b7 },
+ { 0x07e8, 0x03b8 },
+ { 0x07e9, 0x03b9 },
+ { 0x07ea, 0x03ba },
+ { 0x07eb, 0x03bb },
+ { 0x07ec, 0x03bc },
+ { 0x07ed, 0x03bd },
+ { 0x07ee, 0x03be },
+ { 0x07ef, 0x03bf },
+ { 0x07f0, 0x03c0 },
+ { 0x07f1, 0x03c1 },
+ { 0x07f2, 0x03c3 },
+ { 0x07f3, 0x03c2 },
+ { 0x07f4, 0x03c4 },
+ { 0x07f5, 0x03c5 },
+ { 0x07f6, 0x03c6 },
+ { 0x07f7, 0x03c7 },
+ { 0x07f8, 0x03c8 },
+ { 0x07f9, 0x03c9 },
+ { 0x08a1, 0x23b7 },
+ { 0x08a2, 0x250c },
+ { 0x08a3, 0x2500 },
+ { 0x08a4, 0x2320 },
+ { 0x08a5, 0x2321 },
+ { 0x08a6, 0x2502 },
+ { 0x08a7, 0x23a1 },
+ { 0x08a8, 0x23a3 },
+ { 0x08a9, 0x23a4 },
+ { 0x08aa, 0x23a6 },
+ { 0x08ab, 0x239b },
+ { 0x08ac, 0x239d },
+ { 0x08ad, 0x239e },
+ { 0x08ae, 0x23a0 },
+ { 0x08af, 0x23a8 },
+ { 0x08b0, 0x23ac },
+ { 0x08bc, 0x2264 },
+ { 0x08bd, 0x2260 },
+ { 0x08be, 0x2265 },
+ { 0x08bf, 0x222b },
+ { 0x08c0, 0x2234 },
+ { 0x08c1, 0x221d },
+ { 0x08c2, 0x221e },
+ { 0x08c5, 0x2207 },
+ { 0x08c8, 0x223c },
+ { 0x08c9, 0x2243 },
+ { 0x08cd, 0x21d4 },
+ { 0x08ce, 0x21d2 },
+ { 0x08cf, 0x2261 },
+ { 0x08d6, 0x221a },
+ { 0x08da, 0x2282 },
+ { 0x08db, 0x2283 },
+ { 0x08dc, 0x2229 },
+ { 0x08dd, 0x222a },
+ { 0x08de, 0x2227 },
+ { 0x08df, 0x2228 },
+ { 0x08ef, 0x2202 },
+ { 0x08f6, 0x0192 },
+ { 0x08fb, 0x2190 },
+ { 0x08fc, 0x2191 },
+ { 0x08fd, 0x2192 },
+ { 0x08fe, 0x2193 },
+ { 0x09e0, 0x25c6 },
+ { 0x09e1, 0x2592 },
+ { 0x09e2, 0x2409 },
+ { 0x09e3, 0x240c },
+ { 0x09e4, 0x240d },
+ { 0x09e5, 0x240a },
+ { 0x09e8, 0x2424 },
+ { 0x09e9, 0x240b },
+ { 0x09ea, 0x2518 },
+ { 0x09eb, 0x2510 },
+ { 0x09ec, 0x250c },
+ { 0x09ed, 0x2514 },
+ { 0x09ee, 0x253c },
+ { 0x09ef, 0x23ba },
+ { 0x09f0, 0x23bb },
+ { 0x09f1, 0x2500 },
+ { 0x09f2, 0x23bc },
+ { 0x09f3, 0x23bd },
+ { 0x09f4, 0x251c },
+ { 0x09f5, 0x2524 },
+ { 0x09f6, 0x2534 },
+ { 0x09f7, 0x252c },
+ { 0x09f8, 0x2502 },
+ { 0x0aa1, 0x2003 },
+ { 0x0aa2, 0x2002 },
+ { 0x0aa3, 0x2004 },
+ { 0x0aa4, 0x2005 },
+ { 0x0aa5, 0x2007 },
+ { 0x0aa6, 0x2008 },
+ { 0x0aa7, 0x2009 },
+ { 0x0aa8, 0x200a },
+ { 0x0aa9, 0x2014 },
+ { 0x0aaa, 0x2013 },
+ { 0x0aae, 0x2026 },
+ { 0x0aaf, 0x2025 },
+ { 0x0ab0, 0x2153 },
+ { 0x0ab1, 0x2154 },
+ { 0x0ab2, 0x2155 },
+ { 0x0ab3, 0x2156 },
+ { 0x0ab4, 0x2157 },
+ { 0x0ab5, 0x2158 },
+ { 0x0ab6, 0x2159 },
+ { 0x0ab7, 0x215a },
+ { 0x0ab8, 0x2105 },
+ { 0x0abb, 0x2012 },
+ { 0x0abc, 0x2329 },
+ { 0x0abe, 0x232a },
+ { 0x0ac3, 0x215b },
+ { 0x0ac4, 0x215c },
+ { 0x0ac5, 0x215d },
+ { 0x0ac6, 0x215e },
+ { 0x0ac9, 0x2122 },
+ { 0x0aca, 0x2613 },
+ { 0x0acc, 0x25c1 },
+ { 0x0acd, 0x25b7 },
+ { 0x0ace, 0x25cb },
+ { 0x0acf, 0x25af },
+ { 0x0ad0, 0x2018 },
+ { 0x0ad1, 0x2019 },
+ { 0x0ad2, 0x201c },
+ { 0x0ad3, 0x201d },
+ { 0x0ad4, 0x211e },
+ { 0x0ad6, 0x2032 },
+ { 0x0ad7, 0x2033 },
+ { 0x0ad9, 0x271d },
+ { 0x0adb, 0x25ac },
+ { 0x0adc, 0x25c0 },
+ { 0x0add, 0x25b6 },
+ { 0x0ade, 0x25cf },
+ { 0x0adf, 0x25ae },
+ { 0x0ae0, 0x25e6 },
+ { 0x0ae1, 0x25ab },
+ { 0x0ae2, 0x25ad },
+ { 0x0ae3, 0x25b3 },
+ { 0x0ae4, 0x25bd },
+ { 0x0ae5, 0x2606 },
+ { 0x0ae6, 0x2022 },
+ { 0x0ae7, 0x25aa },
+ { 0x0ae8, 0x25b2 },
+ { 0x0ae9, 0x25bc },
+ { 0x0aea, 0x261c },
+ { 0x0aeb, 0x261e },
+ { 0x0aec, 0x2663 },
+ { 0x0aed, 0x2666 },
+ { 0x0aee, 0x2665 },
+ { 0x0af0, 0x2720 },
+ { 0x0af1, 0x2020 },
+ { 0x0af2, 0x2021 },
+ { 0x0af3, 0x2713 },
+ { 0x0af4, 0x2717 },
+ { 0x0af5, 0x266f },
+ { 0x0af6, 0x266d },
+ { 0x0af7, 0x2642 },
+ { 0x0af8, 0x2640 },
+ { 0x0af9, 0x260e },
+ { 0x0afa, 0x2315 },
+ { 0x0afb, 0x2117 },
+ { 0x0afc, 0x2038 },
+ { 0x0afd, 0x201a },
+ { 0x0afe, 0x201e },
+ { 0x0ba3, 0x003c },
+ { 0x0ba6, 0x003e },
+ { 0x0ba8, 0x2228 },
+ { 0x0ba9, 0x2227 },
+ { 0x0bc0, 0x00af },
+ { 0x0bc2, 0x22a5 },
+ { 0x0bc3, 0x2229 },
+ { 0x0bc4, 0x230a },
+ { 0x0bc6, 0x005f },
+ { 0x0bca, 0x2218 },
+ { 0x0bcc, 0x2395 },
+ { 0x0bce, 0x22a4 },
+ { 0x0bcf, 0x25cb },
+ { 0x0bd3, 0x2308 },
+ { 0x0bd6, 0x222a },
+ { 0x0bd8, 0x2283 },
+ { 0x0bda, 0x2282 },
+ { 0x0bdc, 0x22a2 },
+ { 0x0bfc, 0x22a3 },
+ { 0x0cdf, 0x2017 },
+ { 0x0ce0, 0x05d0 },
+ { 0x0ce1, 0x05d1 },
+ { 0x0ce2, 0x05d2 },
+ { 0x0ce3, 0x05d3 },
+ { 0x0ce4, 0x05d4 },
+ { 0x0ce5, 0x05d5 },
+ { 0x0ce6, 0x05d6 },
+ { 0x0ce7, 0x05d7 },
+ { 0x0ce8, 0x05d8 },
+ { 0x0ce9, 0x05d9 },
+ { 0x0cea, 0x05da },
+ { 0x0ceb, 0x05db },
+ { 0x0cec, 0x05dc },
+ { 0x0ced, 0x05dd },
+ { 0x0cee, 0x05de },
+ { 0x0cef, 0x05df },
+ { 0x0cf0, 0x05e0 },
+ { 0x0cf1, 0x05e1 },
+ { 0x0cf2, 0x05e2 },
+ { 0x0cf3, 0x05e3 },
+ { 0x0cf4, 0x05e4 },
+ { 0x0cf5, 0x05e5 },
+ { 0x0cf6, 0x05e6 },
+ { 0x0cf7, 0x05e7 },
+ { 0x0cf8, 0x05e8 },
+ { 0x0cf9, 0x05e9 },
+ { 0x0cfa, 0x05ea },
+ { 0x0da1, 0x0e01 },
+ { 0x0da2, 0x0e02 },
+ { 0x0da3, 0x0e03 },
+ { 0x0da4, 0x0e04 },
+ { 0x0da5, 0x0e05 },
+ { 0x0da6, 0x0e06 },
+ { 0x0da7, 0x0e07 },
+ { 0x0da8, 0x0e08 },
+ { 0x0da9, 0x0e09 },
+ { 0x0daa, 0x0e0a },
+ { 0x0dab, 0x0e0b },
+ { 0x0dac, 0x0e0c },
+ { 0x0dad, 0x0e0d },
+ { 0x0dae, 0x0e0e },
+ { 0x0daf, 0x0e0f },
+ { 0x0db0, 0x0e10 },
+ { 0x0db1, 0x0e11 },
+ { 0x0db2, 0x0e12 },
+ { 0x0db3, 0x0e13 },
+ { 0x0db4, 0x0e14 },
+ { 0x0db5, 0x0e15 },
+ { 0x0db6, 0x0e16 },
+ { 0x0db7, 0x0e17 },
+ { 0x0db8, 0x0e18 },
+ { 0x0db9, 0x0e19 },
+ { 0x0dba, 0x0e1a },
+ { 0x0dbb, 0x0e1b },
+ { 0x0dbc, 0x0e1c },
+ { 0x0dbd, 0x0e1d },
+ { 0x0dbe, 0x0e1e },
+ { 0x0dbf, 0x0e1f },
+ { 0x0dc0, 0x0e20 },
+ { 0x0dc1, 0x0e21 },
+ { 0x0dc2, 0x0e22 },
+ { 0x0dc3, 0x0e23 },
+ { 0x0dc4, 0x0e24 },
+ { 0x0dc5, 0x0e25 },
+ { 0x0dc6, 0x0e26 },
+ { 0x0dc7, 0x0e27 },
+ { 0x0dc8, 0x0e28 },
+ { 0x0dc9, 0x0e29 },
+ { 0x0dca, 0x0e2a },
+ { 0x0dcb, 0x0e2b },
+ { 0x0dcc, 0x0e2c },
+ { 0x0dcd, 0x0e2d },
+ { 0x0dce, 0x0e2e },
+ { 0x0dcf, 0x0e2f },
+ { 0x0dd0, 0x0e30 },
+ { 0x0dd1, 0x0e31 },
+ { 0x0dd2, 0x0e32 },
+ { 0x0dd3, 0x0e33 },
+ { 0x0dd4, 0x0e34 },
+ { 0x0dd5, 0x0e35 },
+ { 0x0dd6, 0x0e36 },
+ { 0x0dd7, 0x0e37 },
+ { 0x0dd8, 0x0e38 },
+ { 0x0dd9, 0x0e39 },
+ { 0x0dda, 0x0e3a },
+ { 0x0ddf, 0x0e3f },
+ { 0x0de0, 0x0e40 },
+ { 0x0de1, 0x0e41 },
+ { 0x0de2, 0x0e42 },
+ { 0x0de3, 0x0e43 },
+ { 0x0de4, 0x0e44 },
+ { 0x0de5, 0x0e45 },
+ { 0x0de6, 0x0e46 },
+ { 0x0de7, 0x0e47 },
+ { 0x0de8, 0x0e48 },
+ { 0x0de9, 0x0e49 },
+ { 0x0dea, 0x0e4a },
+ { 0x0deb, 0x0e4b },
+ { 0x0dec, 0x0e4c },
+ { 0x0ded, 0x0e4d },
+ { 0x0df0, 0x0e50 },
+ { 0x0df1, 0x0e51 },
+ { 0x0df2, 0x0e52 },
+ { 0x0df3, 0x0e53 },
+ { 0x0df4, 0x0e54 },
+ { 0x0df5, 0x0e55 },
+ { 0x0df6, 0x0e56 },
+ { 0x0df7, 0x0e57 },
+ { 0x0df8, 0x0e58 },
+ { 0x0df9, 0x0e59 },
+ { 0x0ea1, 0x3131 },
+ { 0x0ea2, 0x3132 },
+ { 0x0ea3, 0x3133 },
+ { 0x0ea4, 0x3134 },
+ { 0x0ea5, 0x3135 },
+ { 0x0ea6, 0x3136 },
+ { 0x0ea7, 0x3137 },
+ { 0x0ea8, 0x3138 },
+ { 0x0ea9, 0x3139 },
+ { 0x0eaa, 0x313a },
+ { 0x0eab, 0x313b },
+ { 0x0eac, 0x313c },
+ { 0x0ead, 0x313d },
+ { 0x0eae, 0x313e },
+ { 0x0eaf, 0x313f },
+ { 0x0eb0, 0x3140 },
+ { 0x0eb1, 0x3141 },
+ { 0x0eb2, 0x3142 },
+ { 0x0eb3, 0x3143 },
+ { 0x0eb4, 0x3144 },
+ { 0x0eb5, 0x3145 },
+ { 0x0eb6, 0x3146 },
+ { 0x0eb7, 0x3147 },
+ { 0x0eb8, 0x3148 },
+ { 0x0eb9, 0x3149 },
+ { 0x0eba, 0x314a },
+ { 0x0ebb, 0x314b },
+ { 0x0ebc, 0x314c },
+ { 0x0ebd, 0x314d },
+ { 0x0ebe, 0x314e },
+ { 0x0ebf, 0x314f },
+ { 0x0ec0, 0x3150 },
+ { 0x0ec1, 0x3151 },
+ { 0x0ec2, 0x3152 },
+ { 0x0ec3, 0x3153 },
+ { 0x0ec4, 0x3154 },
+ { 0x0ec5, 0x3155 },
+ { 0x0ec6, 0x3156 },
+ { 0x0ec7, 0x3157 },
+ { 0x0ec8, 0x3158 },
+ { 0x0ec9, 0x3159 },
+ { 0x0eca, 0x315a },
+ { 0x0ecb, 0x315b },
+ { 0x0ecc, 0x315c },
+ { 0x0ecd, 0x315d },
+ { 0x0ece, 0x315e },
+ { 0x0ecf, 0x315f },
+ { 0x0ed0, 0x3160 },
+ { 0x0ed1, 0x3161 },
+ { 0x0ed2, 0x3162 },
+ { 0x0ed3, 0x3163 },
+ { 0x0ed4, 0x11a8 },
+ { 0x0ed5, 0x11a9 },
+ { 0x0ed6, 0x11aa },
+ { 0x0ed7, 0x11ab },
+ { 0x0ed8, 0x11ac },
+ { 0x0ed9, 0x11ad },
+ { 0x0eda, 0x11ae },
+ { 0x0edb, 0x11af },
+ { 0x0edc, 0x11b0 },
+ { 0x0edd, 0x11b1 },
+ { 0x0ede, 0x11b2 },
+ { 0x0edf, 0x11b3 },
+ { 0x0ee0, 0x11b4 },
+ { 0x0ee1, 0x11b5 },
+ { 0x0ee2, 0x11b6 },
+ { 0x0ee3, 0x11b7 },
+ { 0x0ee4, 0x11b8 },
+ { 0x0ee5, 0x11b9 },
+ { 0x0ee6, 0x11ba },
+ { 0x0ee7, 0x11bb },
+ { 0x0ee8, 0x11bc },
+ { 0x0ee9, 0x11bd },
+ { 0x0eea, 0x11be },
+ { 0x0eeb, 0x11bf },
+ { 0x0eec, 0x11c0 },
+ { 0x0eed, 0x11c1 },
+ { 0x0eee, 0x11c2 },
+ { 0x0eef, 0x316d },
+ { 0x0ef0, 0x3171 },
+ { 0x0ef1, 0x3178 },
+ { 0x0ef2, 0x317f },
+ { 0x0ef3, 0x3181 },
+ { 0x0ef4, 0x3184 },
+ { 0x0ef5, 0x3186 },
+ { 0x0ef6, 0x318d },
+ { 0x0ef7, 0x318e },
+ { 0x0ef8, 0x11eb },
+ { 0x0ef9, 0x11f0 },
+ { 0x0efa, 0x11f9 },
+ { 0x0eff, 0x20a9 },
+ { 0x13a4, 0x20ac },
+ { 0x13bc, 0x0152 },
+ { 0x13bd, 0x0153 },
+ { 0x13be, 0x0178 },
+ { 0x20ac, 0x20ac },
+ { 0xfe50, '`' },
+ { 0xfe51, 0x00b4 },
+ { 0xfe52, '^' },
+ { 0xfe53, '~' },
+ { 0xfe54, 0x00af },
+ { 0xfe55, 0x02d8 },
+ { 0xfe56, 0x02d9 },
+ { 0xfe57, 0x00a8 },
+ { 0xfe58, 0x02da },
+ { 0xfe59, 0x02dd },
+ { 0xfe5a, 0x02c7 },
+ { 0xfe5b, 0x00b8 },
+ { 0xfe5c, 0x02db },
+ { 0xfe5d, 0x037a },
+ { 0xfe5e, 0x309b },
+ { 0xfe5f, 0x309c },
+ { 0xfe63, '/' },
+ { 0xfe64, 0x02bc },
+ { 0xfe65, 0x02bd },
+ { 0xfe66, 0x02f5 },
+ { 0xfe67, 0x02f3 },
+ { 0xfe68, 0x02cd },
+ { 0xfe69, 0xa788 },
+ { 0xfe6a, 0x02f7 },
+ { 0xfe6e, ',' },
+ { 0xfe6f, 0x00a4 },
+ { 0xfe80, 'a' }, // XK_dead_a
+ { 0xfe81, 'A' }, // XK_dead_A
+ { 0xfe82, 'e' }, // XK_dead_e
+ { 0xfe83, 'E' }, // XK_dead_E
+ { 0xfe84, 'i' }, // XK_dead_i
+ { 0xfe85, 'I' }, // XK_dead_I
+ { 0xfe86, 'o' }, // XK_dead_o
+ { 0xfe87, 'O' }, // XK_dead_O
+ { 0xfe88, 'u' }, // XK_dead_u
+ { 0xfe89, 'U' }, // XK_dead_U
+ { 0xfe8a, 0x0259 },
+ { 0xfe8b, 0x018f },
+ { 0xfe8c, 0x00b5 },
+ { 0xfe90, '_' },
+ { 0xfe91, 0x02c8 },
+ { 0xfe92, 0x02cc },
+ { 0xff80 /*XKB_KEY_KP_Space*/, ' ' },
+ { 0xff95 /*XKB_KEY_KP_7*/, 0x0037 },
+ { 0xff96 /*XKB_KEY_KP_4*/, 0x0034 },
+ { 0xff97 /*XKB_KEY_KP_8*/, 0x0038 },
+ { 0xff98 /*XKB_KEY_KP_6*/, 0x0036 },
+ { 0xff99 /*XKB_KEY_KP_2*/, 0x0032 },
+ { 0xff9a /*XKB_KEY_KP_9*/, 0x0039 },
+ { 0xff9b /*XKB_KEY_KP_3*/, 0x0033 },
+ { 0xff9c /*XKB_KEY_KP_1*/, 0x0031 },
+ { 0xff9d /*XKB_KEY_KP_5*/, 0x0035 },
+ { 0xff9e /*XKB_KEY_KP_0*/, 0x0030 },
+ { 0xffaa /*XKB_KEY_KP_Multiply*/, '*' },
+ { 0xffab /*XKB_KEY_KP_Add*/, '+' },
+ { 0xffac /*XKB_KEY_KP_Separator*/, ',' },
+ { 0xffad /*XKB_KEY_KP_Subtract*/, '-' },
+ { 0xffae /*XKB_KEY_KP_Decimal*/, '.' },
+ { 0xffaf /*XKB_KEY_KP_Divide*/, '/' },
+ { 0xffb0 /*XKB_KEY_KP_0*/, 0x0030 },
+ { 0xffb1 /*XKB_KEY_KP_1*/, 0x0031 },
+ { 0xffb2 /*XKB_KEY_KP_2*/, 0x0032 },
+ { 0xffb3 /*XKB_KEY_KP_3*/, 0x0033 },
+ { 0xffb4 /*XKB_KEY_KP_4*/, 0x0034 },
+ { 0xffb5 /*XKB_KEY_KP_5*/, 0x0035 },
+ { 0xffb6 /*XKB_KEY_KP_6*/, 0x0036 },
+ { 0xffb7 /*XKB_KEY_KP_7*/, 0x0037 },
+ { 0xffb8 /*XKB_KEY_KP_8*/, 0x0038 },
+ { 0xffb9 /*XKB_KEY_KP_9*/, 0x0039 },
+ { 0xffbd /*XKB_KEY_KP_Equal*/, '=' }
+};
+
+
+//////////////////////////////////////////////////////////////////////////
+////// GLFW internal API //////
+//////////////////////////////////////////////////////////////////////////
+
+// Convert XKB KeySym to Unicode
+//
+long _glfwKeySym2Unicode(unsigned int keysym)
+{
+ int min = 0;
+ int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+ int mid;
+
+ // First check for Latin-1 characters (1:1 mapping)
+ if ((keysym >= 0x0020 && keysym <= 0x007e) ||
+ (keysym >= 0x00a0 && keysym <= 0x00ff))
+ {
+ return keysym;
+ }
+
+ // Also check for directly encoded 24-bit UCS characters
+ if ((keysym & 0xff000000) == 0x01000000)
+ return keysym & 0x00ffffff;
+
+ // Binary search in table
+ while (max >= min)
+ {
+ mid = (min + max) / 2;
+ if (keysymtab[mid].keysym < keysym)
+ min = mid + 1;
+ else if (keysymtab[mid].keysym > keysym)
+ max = mid - 1;
+ else
+ return keysymtab[mid].ucs;
+ }
+
+ // No matching Unicode value found
+ return -1;
+}
+
diff --git a/Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.h b/Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.h
new file mode 100644
index 0000000..f95e14f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/glfw/src/xkb_unicode.h
@@ -0,0 +1,28 @@
+//========================================================================
+// GLFW 3.3 Linux - www.glfw.org
+//------------------------------------------------------------------------
+// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would
+// be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not
+// be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+//========================================================================
+
+long _glfwKeySym2Unicode(unsigned int keysym);
+
diff --git a/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt b/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt
new file mode 100644
index 0000000..c42dcc9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt
@@ -0,0 +1,19 @@
+# dear imgui
+set(IMGUI_SOURCE_FILES
+ imgui.cpp
+ imgui_demo.cpp
+ imgui_draw.cpp
+ imgui_widgets.cpp)
+
+set(IMGUI_HEADER_FILES
+ imconfig.h
+ imgui.h
+ imgui_internal.h
+ imstb_rectpack.h
+ imstb_textedit.h
+ imstb_truetype.h)
+
+add_library(imgui STATIC ${IMGUI_SOURCE_FILES} ${IMGUI_HEADER_FILES})
+target_include_directories(imgui PUBLIC ..)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${IMGUI_SOURCE_FILES} ${IMGUI_HEADER_FILES})
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imconfig.h b/Client/ThirdParty/Box2D/extern/imgui/imconfig.h
new file mode 100644
index 0000000..825505b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imconfig.h
@@ -0,0 +1,73 @@
+//-----------------------------------------------------------------------------
+// COMPILE-TIME OPTIONS FOR DEAR IMGUI
+// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
+// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
+//-----------------------------------------------------------------------------
+// A) You may edit imconfig.h (and not overwrite it when updating imgui, or maintain a patch/branch with your modifications to imconfig.h)
+// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
+// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ dear imgui is used, which include
+// the imgui*.cpp files but also _any_ of your code that uses imgui. This is because some compile-time options have an affect on data structures.
+// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
+// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
+//-----------------------------------------------------------------------------
+
+#pragma once
+
+//---- Define assertion handler. Defaults to calling assert().
+//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
+//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
+
+//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
+//#define IMGUI_API __declspec( dllexport )
+//#define IMGUI_API __declspec( dllimport )
+
+//---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
+//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+
+//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
+//---- It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
+//#define IMGUI_DISABLE_DEMO_WINDOWS
+
+//---- Don't implement some functions to reduce linkage requirements.
+//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
+//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
+//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function.
+//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf.
+//#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h.
+//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
+
+//---- Include imgui_user.h at the end of imgui.h as a convenience
+//#define IMGUI_INCLUDE_IMGUI_USER_H
+
+//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
+//#define IMGUI_USE_BGRA_PACKED_COLOR
+
+//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
+// By default the embedded implementations are declared static and not available outside of imgui cpp files.
+//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
+//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
+//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
+//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
+
+//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
+// This will be inlined as part of ImVec2 and ImVec4 class declarations.
+/*
+#define IM_VEC2_CLASS_EXTRA \
+ ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
+ operator MyVec2() const { return MyVec2(x,y); }
+
+#define IM_VEC4_CLASS_EXTRA \
+ ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
+ operator MyVec4() const { return MyVec4(x,y,z,w); }
+*/
+
+//---- Use 32-bit vertex indices (default is 16-bit) to allow meshes with more than 64K vertices. Render function needs to support it.
+//#define ImDrawIdx unsigned int
+
+//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
+/*
+namespace ImGui
+{
+ void MyFunction(const char* name, const MyMatrix44& v);
+}
+*/
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imgui.cpp b/Client/ThirdParty/Box2D/extern/imgui/imgui.cpp
new file mode 100644
index 0000000..8c11891
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imgui.cpp
@@ -0,0 +1,9349 @@
+// dear imgui, v1.67 WIP
+// (main code and documentation)
+
+// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
+// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
+// Get latest version at https://github.com/ocornut/imgui
+// Releases change-log at https://github.com/ocornut/imgui/releases
+// Technical Support for Getting Started https://discourse.dearimgui.org/c/getting-started
+// Gallery (please post your screenshots/video there!): https://github.com/ocornut/imgui/issues/1269
+
+// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
+// See LICENSE.txt for copyright and licensing details (standard MIT License).
+// This library is free but I need your support to sustain development and maintenance.
+// Businesses: you can support continued maintenance and development via support contracts or sponsoring, see docs/README.
+// Individuals: you can support continued maintenance and development via donations or Patreon https://www.patreon.com/imgui.
+
+// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
+// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
+// modifying imgui.h or imgui.cpp. You may include imgui_internal.h to access internal data structures, but it doesn't
+// come with any guarantee of forward compatibility. Discussing your changes on the GitHub Issue Tracker may lead you
+// to a better solution or official support for them.
+
+/*
+
+Index of this file:
+
+DOCUMENTATION
+
+- MISSION STATEMENT
+- END-USER GUIDE
+- PROGRAMMER GUIDE (read me!)
+ - Read first.
+ - How to update to a newer version of Dear ImGui.
+ - Getting started with integrating Dear ImGui in your code/engine.
+ - This is how a simple application may look like (2 variations).
+ - This is how a simple rendering function may look like.
+ - Using gamepad/keyboard navigation controls.
+- API BREAKING CHANGES (read me when you update!)
+- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
+ - How can I tell whether to dispatch mouse/keyboard to imgui or to my application?
+ - How can I display an image? What is ImTextureID, how does it works?
+ - How can I have multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack.
+ - How can I use my own math types instead of ImVec2/ImVec4?
+ - How can I load a different font than the default?
+ - How can I easily use icons in my application?
+ - How can I load multiple fonts?
+ - How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
+ - How can I interact with standard C++ types (such as std::string and std::vector)?
+ - How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
+ - How can I use Dear ImGui on a platform that doesn't have a mouse or a keyboard? (input share, remoting, gamepad)
+ - I integrated Dear ImGui in my engine and the text or lines are blurry..
+ - I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
+ - How can I help?
+
+CODE
+(search for "[SECTION]" in the code to find them)
+
+// [SECTION] FORWARD DECLARATIONS
+// [SECTION] CONTEXT AND MEMORY ALLOCATORS
+// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
+// [SECTION] MISC HELPER/UTILITIES (Maths, String, Format, Hash, File functions)
+// [SECTION] MISC HELPER/UTILITIES (ImText* functions)
+// [SECTION] MISC HELPER/UTILITIES (Color functions)
+// [SECTION] ImGuiStorage
+// [SECTION] ImGuiTextFilter
+// [SECTION] ImGuiTextBuffer
+// [SECTION] ImGuiListClipper
+// [SECTION] RENDER HELPERS
+// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
+// [SECTION] TOOLTIPS
+// [SECTION] POPUPS
+// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
+// [SECTION] COLUMNS
+// [SECTION] DRAG AND DROP
+// [SECTION] LOGGING/CAPTURING
+// [SECTION] SETTINGS
+// [SECTION] PLATFORM DEPENDENT HELPERS
+// [SECTION] METRICS/DEBUG WINDOW
+
+*/
+
+//-----------------------------------------------------------------------------
+// DOCUMENTATION
+//-----------------------------------------------------------------------------
+
+/*
+
+ MISSION STATEMENT
+ =================
+
+ - Easy to use to create code-driven and data-driven tools.
+ - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools.
+ - Easy to hack and improve.
+ - Minimize screen real-estate usage.
+ - Minimize setup and maintenance.
+ - Minimize state storage on user side.
+ - Portable, minimize dependencies, run on target (consoles, phones, etc.).
+ - Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window,.
+ opening a tree node for the first time, etc. but a typical frame should not allocate anything).
+
+ Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes:
+ - Doesn't look fancy, doesn't animate.
+ - Limited layout features, intricate layouts are typically crafted in code.
+
+
+ END-USER GUIDE
+ ==============
+
+ - Double-click on title bar to collapse window.
+ - Click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin().
+ - Click and drag on lower right corner to resize window (double-click to auto fit window to its contents).
+ - Click and drag on any empty space to move window.
+ - TAB/SHIFT+TAB to cycle through keyboard editable fields.
+ - CTRL+Click on a slider or drag box to input value as text.
+ - Use mouse wheel to scroll.
+ - Text editor:
+ - Hold SHIFT or use mouse to select text.
+ - CTRL+Left/Right to word jump.
+ - CTRL+Shift+Left/Right to select words.
+ - CTRL+A our Double-Click to select all.
+ - CTRL+X,CTRL+C,CTRL+V to use OS clipboard/
+ - CTRL+Z,CTRL+Y to undo/redo.
+ - ESCAPE to revert text to its original value.
+ - You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!)
+ - Controls are automatically adjusted for OSX to match standard OSX text editing operations.
+ - General Keyboard controls: enable with ImGuiConfigFlags_NavEnableKeyboard.
+ - General Gamepad controls: enable with ImGuiConfigFlags_NavEnableGamepad. See suggested mappings in imgui.h ImGuiNavInput_ + download PNG/PSD at http://goo.gl/9LgVZW
+
+
+ PROGRAMMER GUIDE
+ ================
+
+ READ FIRST:
+
+ - Read the FAQ below this section!
+ - Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction
+ or destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, less bugs.
+ - Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
+ - The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
+ - Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
+ You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links docs/README.md.
+ - Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances.
+ For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI,
+ where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
+ - Our origin are on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right.
+ - This codebase is also optimized to yield decent performances with typical "Debug" builds settings.
+ - Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected).
+ If you get an assert, read the messages and comments around the assert.
+ - C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace.
+ - C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
+ See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
+ However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
+ - C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
+
+ HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI:
+
+ - Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h)
+ - Or maintain your own branch where you have imconfig.h modified.
+ - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes.
+ If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed
+ from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will
+ likely be a comment about it. Please report any issue to the GitHub page!
+ - Try to keep your copy of dear imgui reasonably up to date.
+
+ GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE:
+
+ - Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
+ - Add the Dear ImGui source files to your projects or using your preferred build system.
+ It is recommended you build and statically link the .cpp files as part of your project and not as shared library (DLL).
+ - You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating imgui types with your own maths types.
+ - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them.
+ - Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide.
+ Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render"
+ phases of your own application. All rendering informatioe are stored into command-lists that you will retrieve after calling ImGui::Render().
+ - Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code.
+ - If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder.
+
+ HOW A SIMPLE APPLICATION MAY LOOK LIKE:
+ EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder).
+
+ // Application init: create a dear imgui context, setup some options, load fonts
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO();
+ // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls.
+ // TODO: Fill optional fields of the io structure later.
+ // TODO: Load TTF/OTF fonts if you don't want to use the default font.
+
+ // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32 and imgui_impl_dx11)
+ ImGui_ImplWin32_Init(hwnd);
+ ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
+
+ // Application main loop
+ while (true)
+ {
+ // Feed inputs to dear imgui, start new frame
+ ImGui_ImplDX11_NewFrame();
+ ImGui_ImplWin32_NewFrame();
+ ImGui::NewFrame();
+
+ // Any application code here
+ ImGui::Text("Hello, world!");
+
+ // Render dear imgui into screen
+ ImGui::Render();
+ ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
+ g_pSwapChain->Present(1, 0);
+ }
+
+ // Shutdown
+ ImGui_ImplDX11_Shutdown();
+ ImGui_ImplWin32_Shutdown();
+ ImGui::DestroyContext();
+
+ HOW A SIMPLE APPLICATION MAY LOOK LIKE:
+ EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE.
+
+ // Application init: create a dear imgui context, setup some options, load fonts
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO();
+ // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls.
+ // TODO: Fill optional fields of the io structure later.
+ // TODO: Load TTF/OTF fonts if you don't want to use the default font.
+
+ // Build and load the texture atlas into a texture
+ // (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer)
+ int width, height;
+ unsigned char* pixels = NULL;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
+
+ // At this point you've got the texture data and you need to upload that your your graphic system:
+ // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'.
+ // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ below for details about ImTextureID.
+ MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32)
+ io.Fonts->TexID = (void*)texture;
+
+ // Application main loop
+ while (true)
+ {
+ // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc.
+ // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform bindings)
+ io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds)
+ io.DisplaySize.x = 1920.0f; // set the current display width
+ io.DisplaySize.y = 1280.0f; // set the current display height here
+ io.MousePos = my_mouse_pos; // set the mouse position
+ io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states
+ io.MouseDown[1] = my_mouse_buttons[1];
+
+ // Call NewFrame(), after this point you can use ImGui::* functions anytime
+ // (So you want to try calling NewFrame() as early as you can in your mainloop to be able to use imgui everywhere)
+ ImGui::NewFrame();
+
+ // Most of your application code here
+ ImGui::Text("Hello, world!");
+ MyGameUpdate(); // may use any ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End();
+ MyGameRender(); // may use any ImGui functions as well!
+
+ // Render imgui, swap buffers
+ // (You want to try calling EndFrame/Render as late as you can, to be able to use imgui in your own game rendering code)
+ ImGui::EndFrame();
+ ImGui::Render();
+ ImDrawData* draw_data = ImGui::GetDrawData();
+ MyImGuiRenderFunction(draw_data);
+ SwapBuffers();
+ }
+
+ // Shutdown
+ ImGui::DestroyContext();
+
+ HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE:
+
+ void void MyImGuiRenderFunction(ImDrawData* draw_data)
+ {
+ // TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
+ // TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
+ // TODO: Setup orthographic projection matrix cover draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
+ // TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color.
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by ImGui
+ const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by ImGui
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ // The texture for the draw call is specified by pcmd->TextureId.
+ // The vast majority of draw calls will use the imgui texture atlas, which value you have set yourself during initialization.
+ MyEngineBindTexture((MyTexture*)pcmd->TextureId);
+
+ // We are using scissoring to clip some objects. All low-level graphics API should supports it.
+ // - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches
+ // (some elements visible outside their bounds) but you can fix that once everything else works!
+ // - Clipping coordinates are provided in imgui coordinates space (from draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize)
+ // In a single viewport application, draw_data->DisplayPos will always be (0,0) and draw_data->DisplaySize will always be == io.DisplaySize.
+ // However, in the interest of supporting multi-viewport applications in the future (see 'viewport' branch on github),
+ // always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space.
+ // - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min)
+ ImVec2 pos = draw_data->DisplayPos;
+ MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y));
+
+ // Render 'pcmd->ElemCount/3' indexed triangles.
+ // By default the indices ImDrawIdx are 16-bits, you can change them to 32-bits in imconfig.h if your engine doesn't support 16-bits indices.
+ MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer);
+ }
+ idx_buffer += pcmd->ElemCount;
+ }
+ }
+ }
+
+ - The examples/ folders contains many actual implementation of the pseudo-codes above.
+ - When calling NewFrame(), the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags are updated.
+ They tell you if Dear ImGui intends to use your inputs. When a flag is set you want to hide the corresponding inputs
+ from the rest of your application. In every cases you need to pass on the inputs to imgui. Refer to the FAQ for more information.
+ - Please read the FAQ below!. Amusingly, it is called a FAQ because people frequently run into the same issues!
+
+ USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
+
+ - The gamepad/keyboard navigation is fairly functional and keeps being improved.
+ - Gamepad support is particularly useful to use dear imgui on a console system (e.g. PS4, Switch, XB1) without a mouse!
+ - You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787
+ - The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
+ - Gamepad:
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable.
+ - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame().
+ Note that io.NavInputs[] is cleared by EndFrame().
+ - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values:
+ 0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks.
+ - We uses a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone.
+ Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, etc.).
+ - You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://goo.gl/9LgVZW.
+ - If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo
+ to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved.
+ - Keyboard:
+ - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable.
+ NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
+ - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag
+ will be set. For more advanced uses, you may want to read from:
+ - io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set.
+ - io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used).
+ - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions.
+ Please reach out if you think the game vs navigation input sharing could be improved.
+ - Mouse:
+ - PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
+ - Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard.
+ - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag.
+ Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements.
+ When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved.
+ When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that.
+ (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!)
+ (In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want
+ to set a boolean to ignore your other external mouse positions until the external source is moved again.)
+
+
+ API BREAKING CHANGES
+ ====================
+
+ Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix.
+ Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code.
+ When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
+ You can read releases logs https://github.com/ocornut/imgui/releases for more details.
+
+ - 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
+ - 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Keep redirection typedef (will obsolete).
+ - 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags.
+ - 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files.
+ - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete).
+ - 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h.
+ If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths.
+ - 2018/09/05 (1.65) - renamed io.OptCursorBlink/io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427)
+ - 2018/08/31 (1.64) - added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. Re-ordered some of the code remaining in imgui.cpp.
+ NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTION HAS BEEN MOVED.
+ Because of this, any local modifications to imgui.cpp will likely conflict when you update. Read docs/CHANGELOG.txt for suggestions.
+ - 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent).
+ - 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete).
+ - 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly).
+ - 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges [update 1.67 renamed to ConfigWindowsResizeFromEdges] to enable the feature.
+ - 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency.
+ - 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
+ - 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
+ - 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.).
+ old binding will still work as is, however prefer using the separated bindings as they will be updated to be multi-viewport conformant.
+ when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call.
+ - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
+ - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details.
+ - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
+ If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
+ To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
+ If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them.
+ - 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format",
+ consistent with other functions. Kept redirection functions (will obsolete).
+ - 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value.
+ - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch).
+ - 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now.
+ - 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically.
+ - 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
+ - 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
+ - 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
+ - 2018/02/07 (1.60) - reorganized context handling to be more explicit,
+ - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
+ - removed Shutdown() function, as DestroyContext() serve this purpose.
+ - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
+ - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
+ - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
+ - 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
+ - 2018/01/11 (1.60) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
+ - 2018/01/11 (1.60) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
+ - 2018/01/03 (1.60) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
+ - 2017/12/29 (1.60) - removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side.
+ - 2017/12/24 (1.53) - renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). Kept redirection function (will obsolete).
+ - 2017/12/21 (1.53) - ImDrawList: renamed style.AntiAliasedShapes to style.AntiAliasedFill for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags
+ - 2017/12/21 (1.53) - ImDrawList: removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame.
+ - 2017/12/14 (1.53) - using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set.
+ - 2017/12/13 (1.53) - renamed GetItemsLineHeightWithSpacing() to GetFrameHeightWithSpacing(). Kept redirection function (will obsolete).
+ - 2017/12/13 (1.53) - obsoleted IsRootWindowFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Kept redirection function (will obsolete).
+ - obsoleted IsRootWindowOrAnyChildFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows). Kept redirection function (will obsolete).
+ - 2017/12/12 (1.53) - renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. Kept redirection enum (will obsolete).
+ - 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete).
+ - 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed.
+ - 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up.
+ Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions.
+ - 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency.
+ - 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg.
+ - 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding.
+ - 2017/11/02 (1.53) - obsoleted IsRootWindowOrAnyChildHovered() in favor of using IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows);
+ - 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency.
+ - 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it.
+ - 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details.
+ removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting.
+ - 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead!
+ - 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete).
+ - 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Keep redirection typedef (will obsolete).
+ - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete).
+ - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
+ - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)!
+ - renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete).
+ - renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete).
+ - 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency.
+ - 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix.
+ - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame.
+ - 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely.
+ - 2017/08/13 (1.51) - renamed ImGuiCol_Columns*** to ImGuiCol_Separator***. Kept redirection enums (will obsolete).
+ - 2017/08/11 (1.51) - renamed ImGuiSetCond_*** types and flags to ImGuiCond_***. Kept redirection enums (will obsolete).
+ - 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton().
+ - 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu.
+ - changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options.
+ - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))'
+ - 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse
+ - 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
+ - 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity.
+ - 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
+ - 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
+ - 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
+ - 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
+ - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
+ If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you.
+ If your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
+ This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color.
+ ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
+ {
+ float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a;
+ return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
+ }
+ If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.
+ - 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext().
+ - 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection.
+ - 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen).
+ - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDrawList::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer.
+ - 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337).
+ - 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337)
+ - 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete).
+ - 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert.
+ - 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you.
+ - 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis.
+ - 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete.
+ - 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position.
+ GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side.
+ GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out!
+ - 2015/08/29 (1.45) - renamed style.ScrollbarWidth to style.ScrollbarSize
+ - 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project.
+ - 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason
+ - 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure.
+ you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text.
+ - 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost.
+ this necessary change will break your rendering function! the fix should be very easy. sorry for that :(
+ - if you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update your copy and you can ignore the rest.
+ - the signature of the io.RenderDrawListsFn handler has changed!
+ old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
+ new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data).
+ parameters: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount'
+ ImDrawList: 'commands' becomes 'CmdBuffer', 'vtx_buffer' becomes 'VtxBuffer', 'IdxBuffer' is new.
+ ImDrawCmd: 'vtx_count' becomes 'ElemCount', 'clip_rect' becomes 'ClipRect', 'user_callback' becomes 'UserCallback', 'texture_id' becomes 'TextureId'.
+ - each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer.
+ - if you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering!
+ - refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. please upgrade!
+ - 2015/07/10 (1.43) - changed SameLine() parameters from int to float.
+ - 2015/07/02 (1.42) - renamed SetScrollPosHere() to SetScrollFromCursorPos(). Kept inline redirection function (will obsolete).
+ - 2015/07/02 (1.42) - renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion along with other scrolling functions, because positions (e.g. cursor position) are not equivalent to scrolling amount.
+ - 2015/06/14 (1.41) - changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent) - makes a difference when texture have transparence
+ - 2015/06/14 (1.41) - changed Selectable() API from (label, selected, size) to (label, selected, flags, size). Size override should have been rarely be used. Sorry!
+ - 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete).
+ - 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete).
+ - 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons.
+ - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened.
+ - 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same).
+ - 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function until 1.50.
+ - 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API
+ - 2015/04/03 (1.38) - removed ImGuiCol_CheckHovered, ImGuiCol_CheckActive, replaced with the more general ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive.
+ - 2014/04/03 (1.38) - removed support for passing -FLT_MAX..+FLT_MAX as the range for a SliderFloat(). Use DragFloat() or Inputfloat() instead.
+ - 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function until 1.50.
+ - 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing
+ - 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function until 1.50.
+ - 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing)
+ - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function until 1.50.
+ - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once.
+ - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now.
+ - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior
+ - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing()
+ - 2015/02/01 (1.31) - removed IO.MemReallocFn (unused)
+ - 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions.
+ - 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader.
+ (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
+ font init: { const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); <..Upload texture to GPU..>; }
+ became: { unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); <..Upload texture to GPU>; io.Fonts->TexId = YourTextureIdentifier; }
+ you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs.
+ it is now recommended that you sample the font texture with bilinear interpolation.
+ (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID.
+ (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix)
+ (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets
+ - 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver)
+ - 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph)
+ - 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility
+ - 2014/11/07 (1.15) - renamed IsHovered() to IsItemHovered()
+ - 2014/10/02 (1.14) - renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly)
+ - 2014/09/25 (1.13) - removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity)
+ - 2014/09/24 (1.12) - renamed SetFontScale() to SetWindowFontScale()
+ - 2014/09/24 (1.12) - moved IM_MALLOC/IM_REALLOC/IM_FREE preprocessor defines to IO.MemAllocFn/IO.MemReallocFn/IO.MemFreeFn
+ - 2014/08/30 (1.09) - removed IO.FontHeight (now computed automatically)
+ - 2014/08/30 (1.09) - moved IMGUI_FONT_TEX_UV_FOR_WHITE preprocessor define to IO.FontTexUvForWhite
+ - 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes
+
+
+ FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
+ ======================================
+
+ Q: How can I tell whether to dispatch mouse/keyboard to imgui or to my application?
+ A: You can read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags from the ImGuiIO structure (e.g. if (ImGui::GetIO().WantCaptureMouse) { ... } )
+ - When 'io.WantCaptureMouse' is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
+ - When 'io.WantCaptureKeyboard' is set, imgui wants to use your keyboard state, and you may want to discard/hide the inputs from the rest of your application.
+ - When 'io.WantTextInput' is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
+ Note: you should always pass your mouse/keyboard inputs to imgui, even when the io.WantCaptureXXX flag are set false.
+ This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
+ Note: The 'io.WantCaptureMouse' is more accurate that any attempt to "check if the mouse is hovering a window" (don't do that!).
+ It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs.
+ Those flags are updated by ImGui::NewFrame(). Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also
+ perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to UpdateHoveredWindowAndCaptureFlags().
+ Note: Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically
+ have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
+ were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
+
+ Q: How can I display an image? What is ImTextureID, how does it works?
+ A: Short explanation:
+ - You may use functions such as ImGui::Image(), ImGui::ImageButton() or lower-level ImDrawList::AddImage() to emit draw calls that will use your own textures.
+ - Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
+ - Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
+ Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.
+
+ Long explanation:
+ - Dear ImGui's job is to create "meshes", defined in a renderer-agnostic format made of draw commands and vertices.
+ At the end of the frame those meshes (ImDrawList) will be displayed by your rendering function. They are made up of textured polygons and the code
+ to render them is generally fairly short (a few dozen lines). In the examples/ folder we provide functions for popular graphics API (OpenGL, DirectX, etc.).
+ - Each rendering function decides on a data type to represent "textures". The concept of what is a "texture" is entirely tied to your underlying engine/graphics API.
+ We carry the information to identify a "texture" in the ImTextureID type.
+ ImTextureID is nothing more that a void*, aka 4/8 bytes worth of data: just enough to store 1 pointer or 1 integer of your choice.
+ Dear ImGui doesn't know or understand what you are storing in ImTextureID, it merely pass ImTextureID values until they reach your rendering function.
+ - In the examples/ bindings, for each graphics API binding we decided on a type that is likely to be a good representation for specifying
+ an image from the end-user perspective. This is what the _examples_ rendering functions are using:
+
+ OpenGL: ImTextureID = GLuint (see ImGui_ImplGlfwGL3_RenderDrawData() function in imgui_impl_glfw_gl3.cpp)
+ DirectX9: ImTextureID = LPDIRECT3DTEXTURE9 (see ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp)
+ DirectX11: ImTextureID = ID3D11ShaderResourceView* (see ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp)
+ DirectX12: ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE (see ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp)
+
+ For example, in the OpenGL example binding we store raw OpenGL texture identifier (GLuint) inside ImTextureID.
+ Whereas in the DirectX11 example binding we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure
+ tying together both the texture and information about its format and how to read it.
+ - If you have a custom engine built over e.g. OpenGL, instead of passing GLuint around you may decide to use a high-level data type to carry information about
+ the texture as well as how to display it (shaders, etc.). The decision of what to use as ImTextureID can always be made better knowing how your codebase
+ is designed. If your engine has high-level data types for "textures" and "material" then you may want to use them.
+ If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID
+ representation suggested by the example bindings is probably the best choice.
+ (Advanced users may also decide to keep a low-level type in ImTextureID, and use ImDrawList callback and pass information to their renderer)
+
+ User code may do:
+
+ // Cast our texture type to ImTextureID / void*
+ MyTexture* texture = g_CoffeeTableTexture;
+ ImGui::Image((void*)texture, ImVec2(texture->Width, texture->Height));
+
+ The renderer function called after ImGui::Render() will receive that same value that the user code passed:
+
+ // Cast ImTextureID / void* stored in the draw command as our texture type
+ MyTexture* texture = (MyTexture*)pcmd->TextureId;
+ MyEngineBindTexture2D(texture);
+
+ Once you understand this design you will understand that loading image files and turning them into displayable textures is not within the scope of Dear ImGui.
+ This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
+ If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
+
+ Here's a simplified OpenGL example using stb_image.h:
+
+ // Use stb_image.h to load a PNG from disk and turn it into raw RGBA pixel data:
+ #define STB_IMAGE_IMPLEMENTATION
+ #include <stb_image.h>
+ [...]
+ int my_image_width, my_image_height;
+ unsigned char* my_image_data = stbi_load("my_image.png", &my_image_width, &my_image_height, NULL, 4);
+
+ // Turn the RGBA pixel data into an OpenGL texture:
+ GLuint my_opengl_texture;
+ glGenTextures(1, &my_opengl_texture);
+ glBindTexture(GL_TEXTURE_2D, my_opengl_texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
+
+ // Now that we have an OpenGL texture, assuming our imgui rendering function (imgui_impl_xxx.cpp file) takes GLuint as ImTextureID, we can display it:
+ ImGui::Image((void*)(intptr_t)my_opengl_texture, ImVec2(my_image_width, my_image_height));
+
+ C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTexture / void*, and vice-versa.
+ Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTexture / void*.
+ Examples:
+
+ GLuint my_tex = XXX;
+ void* my_void_ptr;
+ my_void_ptr = (void*)(intptr_t)my_tex; // cast a GLuint into a void* (we don't take its address! we literally store the value inside the pointer)
+ my_tex = (GLuint)(intptr_t)my_void_ptr; // cast a void* into a GLuint
+
+ ID3D11ShaderResourceView* my_dx11_srv = XXX;
+ void* my_void_ptr;
+ my_void_ptr = (void*)my_dx11_srv; // cast a ID3D11ShaderResourceView* into an opaque void*
+ my_dx11_srv = (ID3D11ShaderResourceView*)my_void_ptr; // cast a void* into a ID3D11ShaderResourceView*
+
+ Finally, you may call ImGui::ShowMetricsWindow() to explore/visualize/understand how the ImDrawList are generated.
+
+ Q: How can I have multiple widgets with the same label or with an empty label?
+ Q: I have multiple widgets with the same label, and only the first one works. Why is that?
+ A: A primer on labels and the ID Stack...
+
+ Dear ImGui internally need to uniquely identify UI elements.
+ Elements that are typically not clickable (such as calls to the Text functions) don't need an ID.
+ Interactive widgets (such as calls to Button buttons) need a unique ID.
+ Unique ID are used internally to track active widgets and occasionally associate state to widgets.
+ Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.
+
+ - Unique ID are often derived from a string label:
+
+ Button("OK"); // Label = "OK", ID = hash of (..., "OK")
+ Button("Cancel"); // Label = "Cancel", ID = hash of (..., "Cancel")
+
+ - ID are uniquely scoped within windows, tree nodes, etc. which all pushes to the ID stack. Having
+ two buttons labeled "OK" in different windows or different tree locations is fine.
+ We used "..." above to signify whatever was already pushed to the ID stack previously:
+
+ Begin("MyWindow");
+ Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK")
+ End();
+ Begin("MyOtherWindow");
+ Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK")
+ End();
+
+ - If you have a same ID twice in the same location, you'll have a conflict:
+
+ Button("OK");
+ Button("OK"); // ID collision! Interacting with either button will trigger the first one.
+
+ Fear not! this is easy to solve and there are many ways to solve it!
+
+ - Solving ID conflict in a simple/local context:
+ When passing a label you can optionally specify extra ID information within string itself.
+ Use "##" to pass a complement to the ID that won't be visible to the end-user.
+ This helps solving the simple collision cases when you know e.g. at compilation time which items
+ are going to be created:
+
+ Begin("MyWindow");
+ Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play")
+ Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from above
+ Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from above
+ End();
+
+ - If you want to completely hide the label, but still need an ID:
+
+ Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox!
+
+ - Occasionally/rarely you might want change a label while preserving a constant ID. This allows
+ you to animate labels. For example you may want to include varying information in a window title bar,
+ but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID:
+
+ Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "ID")
+ Button("World###ID"); // Label = "World", ID = hash of (..., "ID") // Same as above, even though the label looks different
+
+ sprintf(buf, "My game (%f FPS)###MyGame", fps);
+ Begin(buf); // Variable title, ID = hash of "MyGame"
+
+ - Solving ID conflict in a more general manner:
+ Use PushID() / PopID() to create scopes and manipulate the ID stack, as to avoid ID conflicts
+ within the same window. This is the most convenient way of distinguishing ID when iterating and
+ creating many UI elements programmatically.
+ You can push a pointer, a string or an integer value into the ID stack.
+ Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack.
+ At each level of the stack we store the seed used for items at this level of the ID stack.
+
+ Begin("Window");
+ for (int i = 0; i < 100; i++)
+ {
+ PushID(i); // Push i to the id tack
+ Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click")
+ PopID();
+ }
+ for (int i = 0; i < 100; i++)
+ {
+ MyObject* obj = Objects[i];
+ PushID(obj);
+ Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click")
+ PopID();
+ }
+ for (int i = 0; i < 100; i++)
+ {
+ MyObject* obj = Objects[i];
+ PushID(obj->Name);
+ Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click")
+ PopID();
+ }
+ End();
+
+ - You can stack multiple prefixes into the ID stack:
+
+ Button("Click"); // Label = "Click", ID = hash of (..., "Click")
+ PushID("node");
+ Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
+ PushID(my_ptr);
+ Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click")
+ PopID();
+ PopID();
+
+ - Tree nodes implicitly creates a scope for you by calling PushID().
+
+ Button("Click"); // Label = "Click", ID = hash of (..., "Click")
+ if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag)
+ {
+ Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
+ TreePop();
+ }
+
+ - When working with trees, ID are used to preserve the open/close state of each tree node.
+ Depending on your use cases you may want to use strings, indices or pointers as ID.
+ e.g. when following a single pointer that may change over time, using a static string as ID
+ will preserve your node open/closed state when the targeted object change.
+ e.g. when displaying a list of objects, using indices or pointers as ID will preserve the
+ node open/closed state differently. See what makes more sense in your situation!
+
+ Q: How can I use my own math types instead of ImVec2/ImVec4?
+ A: You can edit imconfig.h and setup the IM_VEC2_CLASS_EXTRA/IM_VEC4_CLASS_EXTRA macros to add implicit type conversions.
+ This way you'll be able to use your own types everywhere, e.g. passsing glm::vec2 to ImGui functions instead of ImVec2.
+
+ Q: How can I load a different font than the default?
+ A: Use the font atlas to load the TTF/OTF file you want:
+ ImGuiIO& io = ImGui::GetIO();
+ io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
+ io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
+ Default is ProggyClean.ttf, monospace, rendered at size 13, embedded in dear imgui's source code.
+ (Tip: monospace fonts are convenient because they allow to facilitate horizontal alignment directly at the string level.)
+ (Read the 'misc/fonts/README.txt' file for more details about font loading.)
+
+ New programmers: remember that in C/C++ and most programming languages if you want to use a
+ backslash \ within a string literal, you need to write it double backslash "\\":
+ io.Fonts->AddFontFromFileTTF("MyDataFolder\MyFontFile.ttf", size_in_pixels); // WRONG (you are escape the M here!)
+ io.Fonts->AddFontFromFileTTF("MyDataFolder\\MyFontFile.ttf", size_in_pixels); // CORRECT
+ io.Fonts->AddFontFromFileTTF("MyDataFolder/MyFontFile.ttf", size_in_pixels); // ALSO CORRECT
+
+ Q: How can I easily use icons in my application?
+ A: The most convenient and practical way is to merge an icon font such as FontAwesome inside you
+ main font. Then you can refer to icons within your strings.
+ You may want to see ImFontConfig::GlyphMinAdvanceX to make your icon look monospace to facilitate alignment.
+ (Read the 'misc/fonts/README.txt' file for more details about icons font loading.)
+
+ Q: How can I load multiple fonts?
+ A: Use the font atlas to pack them into a single texture:
+ (Read the 'misc/fonts/README.txt' file and the code in ImFontAtlas for more details.)
+
+ ImGuiIO& io = ImGui::GetIO();
+ ImFont* font0 = io.Fonts->AddFontDefault();
+ ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
+ ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
+ io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
+ // the first loaded font gets used by default
+ // use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
+
+ // Options
+ ImFontConfig config;
+ config.OversampleH = 3;
+ config.OversampleV = 1;
+ config.GlyphOffset.y -= 2.0f; // Move everything by 2 pixels up
+ config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
+ io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config);
+
+ // Combine multiple fonts into one (e.g. for icon fonts)
+ static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
+ ImFontConfig config;
+ config.MergeMode = true;
+ io.Fonts->AddFontDefault();
+ io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
+ io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
+
+ Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
+ A: When loading a font, pass custom Unicode ranges to specify the glyphs to load.
+
+ // Add default Japanese ranges
+ io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
+
+ // Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need)
+ ImVector<ImWchar> ranges;
+ ImFontGlyphRangesBuilder builder;
+ builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
+ builder.AddChar(0x7262); // Add a specific character
+ builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
+ builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
+ io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
+
+ All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8
+ by using the u8"hello" syntax. Specifying literal in your source code using a local code page
+ (such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
+ Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
+
+ Text input: it is up to your application to pass the right character code by calling io.AddInputCharacter().
+ The applications in examples/ are doing that.
+ Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
+ You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
+ Windows: if your language is relying on an Input Method Editor (IME), you copy the HWND of your window to io.ImeWindowHandle in order for
+ the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft IME position correctly.
+
+ Q: How can I interact with standard C++ types (such as std::string and std::vector)?
+ A: - Being highly portable (bindings for several languages, frameworks, programming style, obscure or older platforms/compilers),
+ and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use
+ any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases.
+ - To use ImGui::InputText() with a std::string or any resizable string class, see misc/cpp/imgui_stdlib.h.
+ - To use combo boxes and list boxes with std::vector or any other data structure: the BeginCombo()/EndCombo() API
+ lets you iterate and submit items yourself, so does the ListBoxHeader()/ListBoxFooter() API.
+ Prefer using them over the old and awkward Combo()/ListBox() api.
+ - Generally for most high-level types you should be able to access the underlying data type.
+ You may write your own one-liner wrappers to facilitate user code (tip: add new functions in ImGui:: namespace from your code).
+ - Dear ImGui applications often need to make intensive use of strings. It is expected that many of the strings you will pass
+ to the API are raw literals (free in C/C++) or allocated in a manner that won't incur a large cost on your application.
+ Please bear in mind that using std::string on applications with large amount of UI may incur unsatisfactory performances.
+ Modern implementations of std::string often include small-string optimization (which is often a local buffer) but those
+ are not configurable and not the same across implementations.
+ - If you are finding your UI traversal cost to be too large, make sure your string usage is not leading to excessive amount
+ of heap allocations. Consider using literals, statically sized buffers and your own helper functions. A common pattern
+ is that you will need to build lots of strings on the fly, and their maximum length can be easily be scoped ahead.
+ One possible implementation of a helper to facilitate printf-style building of strings: https://github.com/ocornut/Str
+ This is a small helper where you can instance strings with configurable local buffers length. Many game engines will
+ provide similar or better string helpers.
+
+ Q: How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
+ A: - You can create a dummy window. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags.
+ (The ImGuiWindowFlags_NoDecoration flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse)
+ Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
+ - You can call ImGui::GetOverlayDrawList() and use this draw list to display contents over every other imgui windows.
+ - You can create your own ImDrawList instance. You'll need to initialize them ImGui::GetDrawListSharedData(), or create
+ your own ImDrawListSharedData, and then call your rendered code with your own ImDrawList or ImDrawData data.
+
+ Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
+ A: - You can control Dear ImGui with a gamepad. Read about navigation in "Using gamepad/keyboard navigation controls".
+ (short version: map gamepad inputs into the io.NavInputs[] array + set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad)
+ - You can share your computer mouse seamlessly with your console/tablet/phone using Synergy (https://symless.com/synergy)
+ This is the preferred solution for developer productivity.
+ In particular, the "micro-synergy-client" repository (https://github.com/symless/micro-synergy-client) has simple
+ and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect
+ to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer.
+ Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols.
+ - You may also use a third party solution such as Remote ImGui (https://github.com/JordiRos/remoteimgui) which sends
+ the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine.
+ - For touch inputs, you can increase the hit box of widgets (via the style.TouchPadding setting) to accommodate
+ for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing
+ for screen real-estate and precision.
+
+ Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
+ A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
+ Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
+
+ Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
+ A: You are probably mishandling the clipping rectangles in your render function.
+ Rectangles provided by ImGui are defined as (x1=left,y1=top,x2=right,y2=bottom) and NOT as (x1,y1,width,height).
+
+ Q: How can I help?
+ A: - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt
+ and see how you want to help and can help!
+ - Businesses: convince your company to fund development via support contracts/sponsoring! This is among the most useful thing you can do for dear imgui.
+ - Individuals: you can also become a Patron (http://www.patreon.com/imgui) or donate on PayPal! See README.
+ - Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
+ You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/1902). Visuals are ideal as they inspire other programmers.
+ But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
+ - If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately).
+
+ - tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window.
+ this is also useful to set yourself in the context of another window (to get/set other settings)
+ - tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug".
+ - tip: the ImGuiOnceUponAFrame helper will allow run the block of code only once a frame. You can use it to quickly add custom UI in the middle
+ of a deep nested inner loop in your code.
+ - tip: you can call Render() multiple times (e.g for VR renders).
+ - tip: call and read the ShowDemoWindow() code in imgui_demo.cpp for more example of how to use ImGui!
+
+*/
+
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "imgui.h"
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
+#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
+#include "imgui_internal.h"
+
+#include <ctype.h> // toupper, isprint
+#include <stdio.h> // vsnprintf, sscanf, printf
+#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
+#include <stddef.h> // intptr_t
+#else
+#include <stdint.h> // intptr_t
+#endif
+
+// Debug options
+#define IMGUI_DEBUG_NAV_SCORING 0
+#define IMGUI_DEBUG_NAV_RECTS 0
+
+// Visual Studio warnings
+#ifdef _MSC_VER
+#pragma warning (disable: 4127) // condition expression is constant
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#endif
+
+// Clang/GCC warnings with -Weverything
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great!
+#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
+#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
+#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
+#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
+#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it.
+#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
+#pragma clang diagnostic ignored "-Wformat-pedantic" // warning : format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic.
+#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
+#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
+#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*'
+#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
+#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
+#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false
+#if __GNUC__ >= 8
+#pragma GCC diagnostic ignored "-Wclass-memaccess" // warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
+#endif
+#endif
+
+// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch.
+static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in
+static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear
+
+// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
+static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
+static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
+
+//-------------------------------------------------------------------------
+// [SECTION] FORWARD DECLARATIONS
+//-------------------------------------------------------------------------
+
+static void SetCurrentWindow(ImGuiWindow* window);
+static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond);
+static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond);
+static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond);
+static void FindHoveredWindow();
+static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
+static void CheckStacksSize(ImGuiWindow* window, bool write);
+static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges);
+
+static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
+static void AddWindowToDrawData(ImVector<ImDrawList*>* out_list, ImGuiWindow* window);
+static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
+
+static ImRect GetViewportRect();
+
+// Settings
+static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
+static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
+static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
+
+// Platform Dependents default implementation for IO functions
+static const char* GetClipboardTextFn_DefaultImpl(void* user_data);
+static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text);
+static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
+
+namespace ImGui
+{
+static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
+
+// Navigation
+static void NavUpdate();
+static void NavUpdateWindowing();
+static void NavUpdateWindowingList();
+static void NavUpdateMoveResult();
+static float NavUpdatePageUpPageDown(int allowed_dir_flags);
+static inline void NavUpdateAnyRequestFlag();
+static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id);
+static ImVec2 NavCalcPreferredRefPos();
+static void NavSaveLastChildNavWindow(ImGuiWindow* nav_window);
+static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window);
+
+// Misc
+static void UpdateMouseInputs();
+static void UpdateMouseWheel();
+static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] CONTEXT AND MEMORY ALLOCATORS
+//-----------------------------------------------------------------------------
+
+// Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL.
+// CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
+// If you use DLL hotreloading you might need to call SetCurrentContext() after reloading code from this file.
+// ImGui functions are not thread-safe because of this pointer. If you want thread-safety to allow N threads to access N different contexts, you can:
+// - Change this variable to use thread local storage. You may #define GImGui in imconfig.h for that purpose. Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
+// - Having multiple instances of the ImGui code compiled inside different namespace (easiest/safest, if you have a finite number of contexts)
+#ifndef GImGui
+ImGuiContext* GImGui = NULL;
+#endif
+
+// Memory Allocator functions. Use SetAllocatorFunctions() to change them.
+// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
+// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
+#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
+static void* MallocWrapper(size_t size, void* user_data) { (void)user_data; return malloc(size); }
+static void FreeWrapper(void* ptr, void* user_data) { (void)user_data; free(ptr); }
+#else
+static void* MallocWrapper(size_t size, void* user_data) { (void)user_data; (void)size; IM_ASSERT(0); return NULL; }
+static void FreeWrapper(void* ptr, void* user_data) { (void)user_data; (void)ptr; IM_ASSERT(0); }
+#endif
+
+static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
+static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
+static void* GImAllocatorUserData = NULL;
+
+//-----------------------------------------------------------------------------
+// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
+//-----------------------------------------------------------------------------
+
+ImGuiStyle::ImGuiStyle()
+{
+ Alpha = 1.0f; // Global alpha applies to everything in ImGui
+ WindowPadding = ImVec2(8,8); // Padding within a window
+ WindowRounding = 7.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows
+ WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested.
+ WindowMinSize = ImVec2(32,32); // Minimum window size
+ WindowTitleAlign = ImVec2(0.0f,0.5f);// Alignment for title bar text
+ ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows
+ ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested.
+ PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows
+ PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested.
+ FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets)
+ FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
+ FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested.
+ ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
+ ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
+ TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
+ IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
+ ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns
+ ScrollbarSize = 16.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar
+ ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar
+ GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar
+ GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
+ TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
+ TabBorderSize = 0.0f; // Thickness of border around tabs.
+ ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
+ DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
+ DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
+ MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
+ AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
+ AntiAliasedFill = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
+ CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
+
+ // Default theme
+ ImGui::StyleColorsDark(this);
+}
+
+// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you.
+// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times.
+void ImGuiStyle::ScaleAllSizes(float scale_factor)
+{
+ WindowPadding = ImFloor(WindowPadding * scale_factor);
+ WindowRounding = ImFloor(WindowRounding * scale_factor);
+ WindowMinSize = ImFloor(WindowMinSize * scale_factor);
+ ChildRounding = ImFloor(ChildRounding * scale_factor);
+ PopupRounding = ImFloor(PopupRounding * scale_factor);
+ FramePadding = ImFloor(FramePadding * scale_factor);
+ FrameRounding = ImFloor(FrameRounding * scale_factor);
+ TabRounding = ImFloor(TabRounding * scale_factor);
+ ItemSpacing = ImFloor(ItemSpacing * scale_factor);
+ ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor);
+ TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor);
+ IndentSpacing = ImFloor(IndentSpacing * scale_factor);
+ ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor);
+ ScrollbarSize = ImFloor(ScrollbarSize * scale_factor);
+ ScrollbarRounding = ImFloor(ScrollbarRounding * scale_factor);
+ GrabMinSize = ImFloor(GrabMinSize * scale_factor);
+ GrabRounding = ImFloor(GrabRounding * scale_factor);
+ DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
+ DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
+ MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
+}
+
+ImGuiIO::ImGuiIO()
+{
+ // Most fields are initialized with zero
+ memset(this, 0, sizeof(*this));
+
+ // Settings
+ ConfigFlags = ImGuiConfigFlags_None;
+ BackendFlags = ImGuiBackendFlags_None;
+ DisplaySize = ImVec2(-1.0f, -1.0f);
+ DeltaTime = 1.0f/60.0f;
+ IniSavingRate = 5.0f;
+ IniFilename = "imgui.ini";
+ LogFilename = "imgui_log.txt";
+ MouseDoubleClickTime = 0.30f;
+ MouseDoubleClickMaxDist = 6.0f;
+ for (int i = 0; i < ImGuiKey_COUNT; i++)
+ KeyMap[i] = -1;
+ KeyRepeatDelay = 0.250f;
+ KeyRepeatRate = 0.050f;
+ UserData = NULL;
+
+ Fonts = NULL;
+ FontGlobalScale = 1.0f;
+ FontDefault = NULL;
+ FontAllowUserScaling = false;
+ DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
+ DisplayVisibleMin = DisplayVisibleMax = ImVec2(0.0f, 0.0f);
+
+ // Miscellaneous configuration options
+#ifdef __APPLE__
+ ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag
+#else
+ ConfigMacOSXBehaviors = false;
+#endif
+ ConfigInputTextCursorBlink = true;
+ ConfigWindowsResizeFromEdges = true;
+ ConfigWindowsMoveFromTitleBarOnly = false;
+
+ // Platform Functions
+ BackendPlatformName = BackendRendererName = NULL;
+ BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL;
+ GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
+ SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
+ ClipboardUserData = NULL;
+ ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
+ ImeWindowHandle = NULL;
+
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ RenderDrawListsFn = NULL;
+#endif
+
+ // Input (NB: we already have memset zero the entire structure!)
+ MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+ MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
+ MouseDragThreshold = 6.0f;
+ for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
+ for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f;
+ for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f;
+}
+
+// Pass in translated ASCII characters for text input.
+// - with glfw you can get those from the callback set in glfwSetCharCallback()
+// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message
+void ImGuiIO::AddInputCharacter(ImWchar c)
+{
+ InputQueueCharacters.push_back(c);
+}
+
+void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
+{
+ while (*utf8_chars != 0)
+ {
+ unsigned int c = 0;
+ utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL);
+ if (c > 0 && c <= 0xFFFF)
+ InputQueueCharacters.push_back((ImWchar)c);
+ }
+}
+
+void ImGuiIO::ClearInputCharacters()
+{
+ InputQueueCharacters.resize(0);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] MISC HELPER/UTILITIES (Maths, String, Format, Hash, File functions)
+//-----------------------------------------------------------------------------
+
+ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p)
+{
+ ImVec2 ap = p - a;
+ ImVec2 ab_dir = b - a;
+ float dot = ap.x * ab_dir.x + ap.y * ab_dir.y;
+ if (dot < 0.0f)
+ return a;
+ float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y;
+ if (dot > ab_len_sqr)
+ return b;
+ return a + ab_dir * dot / ab_len_sqr;
+}
+
+bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
+{
+ bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f;
+ bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f;
+ bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f;
+ return ((b1 == b2) && (b2 == b3));
+}
+
+void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w)
+{
+ ImVec2 v0 = b - a;
+ ImVec2 v1 = c - a;
+ ImVec2 v2 = p - a;
+ const float denom = v0.x * v1.y - v1.x * v0.y;
+ out_v = (v2.x * v1.y - v1.x * v2.y) / denom;
+ out_w = (v0.x * v2.y - v2.x * v0.y) / denom;
+ out_u = 1.0f - out_v - out_w;
+}
+
+ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
+{
+ ImVec2 proj_ab = ImLineClosestPoint(a, b, p);
+ ImVec2 proj_bc = ImLineClosestPoint(b, c, p);
+ ImVec2 proj_ca = ImLineClosestPoint(c, a, p);
+ float dist2_ab = ImLengthSqr(p - proj_ab);
+ float dist2_bc = ImLengthSqr(p - proj_bc);
+ float dist2_ca = ImLengthSqr(p - proj_ca);
+ float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca));
+ if (m == dist2_ab)
+ return proj_ab;
+ if (m == dist2_bc)
+ return proj_bc;
+ return proj_ca;
+}
+
+int ImStricmp(const char* str1, const char* str2)
+{
+ int d;
+ while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; }
+ return d;
+}
+
+int ImStrnicmp(const char* str1, const char* str2, size_t count)
+{
+ int d = 0;
+ while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; }
+ return d;
+}
+
+void ImStrncpy(char* dst, const char* src, size_t count)
+{
+ if (count < 1) return;
+ strncpy(dst, src, count);
+ dst[count-1] = 0;
+}
+
+char* ImStrdup(const char* str)
+{
+ size_t len = strlen(str);
+ void* buf = ImGui::MemAlloc(len + 1);
+ return (char*)memcpy(buf, (const void*)str, len + 1);
+}
+
+char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
+{
+ size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1;
+ size_t src_size = strlen(src) + 1;
+ if (dst_buf_size < src_size)
+ {
+ ImGui::MemFree(dst);
+ dst = (char*)ImGui::MemAlloc(src_size);
+ if (p_dst_size)
+ *p_dst_size = src_size;
+ }
+ return (char*)memcpy(dst, (const void*)src, src_size);
+}
+
+const char* ImStrchrRange(const char* str, const char* str_end, char c)
+{
+ const char* p = (const char*)memchr(str, (int)c, str_end - str);
+ return p;
+}
+
+int ImStrlenW(const ImWchar* str)
+{
+ //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bits
+ int n = 0;
+ while (*str++) n++;
+ return n;
+}
+
+// Find end-of-line. Return pointer will point to either first \n, either str_end.
+const char* ImStreolRange(const char* str, const char* str_end)
+{
+ const char* p = (const char*)memchr(str, '\n', str_end - str);
+ return p ? p : str_end;
+}
+
+const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line
+{
+ while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n')
+ buf_mid_line--;
+ return buf_mid_line;
+}
+
+const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end)
+{
+ if (!needle_end)
+ needle_end = needle + strlen(needle);
+
+ const char un0 = (char)toupper(*needle);
+ while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end))
+ {
+ if (toupper(*haystack) == un0)
+ {
+ const char* b = needle + 1;
+ for (const char* a = haystack + 1; b < needle_end; a++, b++)
+ if (toupper(*a) != toupper(*b))
+ break;
+ if (b == needle_end)
+ return haystack;
+ }
+ haystack++;
+ }
+ return NULL;
+}
+
+// Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible.
+void ImStrTrimBlanks(char* buf)
+{
+ char* p = buf;
+ while (p[0] == ' ' || p[0] == '\t') // Leading blanks
+ p++;
+ char* p_start = p;
+ while (*p != 0) // Find end of string
+ p++;
+ while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks
+ p--;
+ if (p_start != buf) // Copy memory if we had leading blanks
+ memmove(buf, p_start, p - p_start);
+ buf[p - p_start] = 0; // Zero terminate
+}
+
+// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size).
+// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm.
+// B) When buf==NULL vsnprintf() will return the output size.
+#ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
+
+//#define IMGUI_USE_STB_SPRINTF
+#ifdef IMGUI_USE_STB_SPRINTF
+#define STB_SPRINTF_IMPLEMENTATION
+#include "imstb_sprintf.h"
+#endif
+
+#if defined(_MSC_VER) && !defined(vsnprintf)
+#define vsnprintf _vsnprintf
+#endif
+
+int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+#ifdef IMGUI_USE_STB_SPRINTF
+ int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args);
+#else
+ int w = vsnprintf(buf, buf_size, fmt, args);
+#endif
+ va_end(args);
+ if (buf == NULL)
+ return w;
+ if (w == -1 || w >= (int)buf_size)
+ w = (int)buf_size - 1;
+ buf[w] = 0;
+ return w;
+}
+
+int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
+{
+#ifdef IMGUI_USE_STB_SPRINTF
+ int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args);
+#else
+ int w = vsnprintf(buf, buf_size, fmt, args);
+#endif
+ if (buf == NULL)
+ return w;
+ if (w == -1 || w >= (int)buf_size)
+ w = (int)buf_size - 1;
+ buf[w] = 0;
+ return w;
+}
+#endif // #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
+
+// Pass data_size == 0 for zero-terminated strings, data_size > 0 for non-string data.
+// Pay attention that data_size==0 will yield different results than passing strlen(data) because the zero-terminated codepath handles ###.
+// This should technically be split into two distinct functions (ImHashData/ImHashStr), perhaps once we remove the silly static variable.
+// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
+ImU32 ImHash(const void* data, int data_size, ImU32 seed)
+{
+ static ImU32 crc32_lut[256] = { 0 };
+ if (!crc32_lut[1])
+ {
+ const ImU32 polynomial = 0xEDB88320;
+ for (ImU32 i = 0; i < 256; i++)
+ {
+ ImU32 crc = i;
+ for (ImU32 j = 0; j < 8; j++)
+ crc = (crc >> 1) ^ (ImU32(-int(crc & 1)) & polynomial);
+ crc32_lut[i] = crc;
+ }
+ }
+
+ seed = ~seed;
+ ImU32 crc = seed;
+ const unsigned char* current = (const unsigned char*)data;
+
+ if (data_size > 0)
+ {
+ // Known size
+ while (data_size--)
+ crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *current++];
+ }
+ else
+ {
+ // Zero-terminated string
+ while (unsigned char c = *current++)
+ {
+ // We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.
+ // Because this syntax is rarely used we are optimizing for the common case.
+ // - If we reach ### in the string we discard the hash so far and reset to the seed.
+ // - We don't do 'current += 2; continue;' after handling ### to keep the code smaller.
+ if (c == '#' && current[0] == '#' && current[1] == '#')
+ crc = seed;
+ crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
+ }
+ }
+ return ~crc;
+}
+
+FILE* ImFileOpen(const char* filename, const char* mode)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
+ // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can)
+ const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1;
+ const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1;
+ ImVector<ImWchar> buf;
+ buf.resize(filename_wsize + mode_wsize);
+ ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL);
+ ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL);
+ return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]);
+#else
+ return fopen(filename, mode);
+#endif
+}
+
+// Load file content into memory
+// Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree()
+void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, int padding_bytes)
+{
+ IM_ASSERT(filename && file_open_mode);
+ if (out_file_size)
+ *out_file_size = 0;
+
+ FILE* f;
+ if ((f = ImFileOpen(filename, file_open_mode)) == NULL)
+ return NULL;
+
+ long file_size_signed;
+ if (fseek(f, 0, SEEK_END) || (file_size_signed = ftell(f)) == -1 || fseek(f, 0, SEEK_SET))
+ {
+ fclose(f);
+ return NULL;
+ }
+
+ size_t file_size = (size_t)file_size_signed;
+ void* file_data = ImGui::MemAlloc(file_size + padding_bytes);
+ if (file_data == NULL)
+ {
+ fclose(f);
+ return NULL;
+ }
+ if (fread(file_data, 1, file_size, f) != file_size)
+ {
+ fclose(f);
+ ImGui::MemFree(file_data);
+ return NULL;
+ }
+ if (padding_bytes > 0)
+ memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes);
+
+ fclose(f);
+ if (out_file_size)
+ *out_file_size = file_size;
+
+ return file_data;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
+//-----------------------------------------------------------------------------
+
+// Convert UTF-8 to 32-bits character, process single character input.
+// Based on stb_from_utf8() from github.com/nothings/stb/
+// We handle UTF-8 decoding error by skipping forward.
+int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end)
+{
+ unsigned int c = (unsigned int)-1;
+ const unsigned char* str = (const unsigned char*)in_text;
+ if (!(*str & 0x80))
+ {
+ c = (unsigned int)(*str++);
+ *out_char = c;
+ return 1;
+ }
+ if ((*str & 0xe0) == 0xc0)
+ {
+ *out_char = 0xFFFD; // will be invalid but not end of string
+ if (in_text_end && in_text_end - (const char*)str < 2) return 1;
+ if (*str < 0xc2) return 2;
+ c = (unsigned int)((*str++ & 0x1f) << 6);
+ if ((*str & 0xc0) != 0x80) return 2;
+ c += (*str++ & 0x3f);
+ *out_char = c;
+ return 2;
+ }
+ if ((*str & 0xf0) == 0xe0)
+ {
+ *out_char = 0xFFFD; // will be invalid but not end of string
+ if (in_text_end && in_text_end - (const char*)str < 3) return 1;
+ if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
+ if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
+ c = (unsigned int)((*str++ & 0x0f) << 12);
+ if ((*str & 0xc0) != 0x80) return 3;
+ c += (unsigned int)((*str++ & 0x3f) << 6);
+ if ((*str & 0xc0) != 0x80) return 3;
+ c += (*str++ & 0x3f);
+ *out_char = c;
+ return 3;
+ }
+ if ((*str & 0xf8) == 0xf0)
+ {
+ *out_char = 0xFFFD; // will be invalid but not end of string
+ if (in_text_end && in_text_end - (const char*)str < 4) return 1;
+ if (*str > 0xf4) return 4;
+ if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
+ if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below
+ c = (unsigned int)((*str++ & 0x07) << 18);
+ if ((*str & 0xc0) != 0x80) return 4;
+ c += (unsigned int)((*str++ & 0x3f) << 12);
+ if ((*str & 0xc0) != 0x80) return 4;
+ c += (unsigned int)((*str++ & 0x3f) << 6);
+ if ((*str & 0xc0) != 0x80) return 4;
+ c += (*str++ & 0x3f);
+ // utf-8 encodings of values used in surrogate pairs are invalid
+ if ((c & 0xFFFFF800) == 0xD800) return 4;
+ *out_char = c;
+ return 4;
+ }
+ *out_char = 0;
+ return 0;
+}
+
+int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining)
+{
+ ImWchar* buf_out = buf;
+ ImWchar* buf_end = buf + buf_size;
+ while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text)
+ {
+ unsigned int c;
+ in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
+ if (c == 0)
+ break;
+ if (c < 0x10000) // FIXME: Losing characters that don't fit in 2 bytes
+ *buf_out++ = (ImWchar)c;
+ }
+ *buf_out = 0;
+ if (in_text_remaining)
+ *in_text_remaining = in_text;
+ return (int)(buf_out - buf);
+}
+
+int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end)
+{
+ int char_count = 0;
+ while ((!in_text_end || in_text < in_text_end) && *in_text)
+ {
+ unsigned int c;
+ in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
+ if (c == 0)
+ break;
+ if (c < 0x10000)
+ char_count++;
+ }
+ return char_count;
+}
+
+// Based on stb_to_utf8() from github.com/nothings/stb/
+static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
+{
+ if (c < 0x80)
+ {
+ buf[0] = (char)c;
+ return 1;
+ }
+ if (c < 0x800)
+ {
+ if (buf_size < 2) return 0;
+ buf[0] = (char)(0xc0 + (c >> 6));
+ buf[1] = (char)(0x80 + (c & 0x3f));
+ return 2;
+ }
+ if (c >= 0xdc00 && c < 0xe000)
+ {
+ return 0;
+ }
+ if (c >= 0xd800 && c < 0xdc00)
+ {
+ if (buf_size < 4) return 0;
+ buf[0] = (char)(0xf0 + (c >> 18));
+ buf[1] = (char)(0x80 + ((c >> 12) & 0x3f));
+ buf[2] = (char)(0x80 + ((c >> 6) & 0x3f));
+ buf[3] = (char)(0x80 + ((c ) & 0x3f));
+ return 4;
+ }
+ //else if (c < 0x10000)
+ {
+ if (buf_size < 3) return 0;
+ buf[0] = (char)(0xe0 + (c >> 12));
+ buf[1] = (char)(0x80 + ((c>> 6) & 0x3f));
+ buf[2] = (char)(0x80 + ((c ) & 0x3f));
+ return 3;
+ }
+}
+
+// Not optimal but we very rarely use this function.
+int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end)
+{
+ unsigned int dummy = 0;
+ return ImTextCharFromUtf8(&dummy, in_text, in_text_end);
+}
+
+static inline int ImTextCountUtf8BytesFromChar(unsigned int c)
+{
+ if (c < 0x80) return 1;
+ if (c < 0x800) return 2;
+ if (c >= 0xdc00 && c < 0xe000) return 0;
+ if (c >= 0xd800 && c < 0xdc00) return 4;
+ return 3;
+}
+
+int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end)
+{
+ char* buf_out = buf;
+ const char* buf_end = buf + buf_size;
+ while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text)
+ {
+ unsigned int c = (unsigned int)(*in_text++);
+ if (c < 0x80)
+ *buf_out++ = (char)c;
+ else
+ buf_out += ImTextCharToUtf8(buf_out, (int)(buf_end-buf_out-1), c);
+ }
+ *buf_out = 0;
+ return (int)(buf_out - buf);
+}
+
+int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end)
+{
+ int bytes_count = 0;
+ while ((!in_text_end || in_text < in_text_end) && *in_text)
+ {
+ unsigned int c = (unsigned int)(*in_text++);
+ if (c < 0x80)
+ bytes_count++;
+ else
+ bytes_count += ImTextCountUtf8BytesFromChar(c);
+ }
+ return bytes_count;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] MISC HELPER/UTILTIES (Color functions)
+// Note: The Convert functions are early design which are not consistent with other API.
+//-----------------------------------------------------------------------------
+
+ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in)
+{
+ float s = 1.0f/255.0f;
+ return ImVec4(
+ ((in >> IM_COL32_R_SHIFT) & 0xFF) * s,
+ ((in >> IM_COL32_G_SHIFT) & 0xFF) * s,
+ ((in >> IM_COL32_B_SHIFT) & 0xFF) * s,
+ ((in >> IM_COL32_A_SHIFT) & 0xFF) * s);
+}
+
+ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in)
+{
+ ImU32 out;
+ out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT;
+ out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT;
+ out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT;
+ out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT;
+ return out;
+}
+
+// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592
+// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv
+void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v)
+{
+ float K = 0.f;
+ if (g < b)
+ {
+ ImSwap(g, b);
+ K = -1.f;
+ }
+ if (r < g)
+ {
+ ImSwap(r, g);
+ K = -2.f / 6.f - K;
+ }
+
+ const float chroma = r - (g < b ? g : b);
+ out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f));
+ out_s = chroma / (r + 1e-20f);
+ out_v = r;
+}
+
+// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593
+// also http://en.wikipedia.org/wiki/HSL_and_HSV
+void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b)
+{
+ if (s == 0.0f)
+ {
+ // gray
+ out_r = out_g = out_b = v;
+ return;
+ }
+
+ h = ImFmod(h, 1.0f) / (60.0f/360.0f);
+ int i = (int)h;
+ float f = h - (float)i;
+ float p = v * (1.0f - s);
+ float q = v * (1.0f - s * f);
+ float t = v * (1.0f - s * (1.0f - f));
+
+ switch (i)
+ {
+ case 0: out_r = v; out_g = t; out_b = p; break;
+ case 1: out_r = q; out_g = v; out_b = p; break;
+ case 2: out_r = p; out_g = v; out_b = t; break;
+ case 3: out_r = p; out_g = q; out_b = v; break;
+ case 4: out_r = t; out_g = p; out_b = v; break;
+ case 5: default: out_r = v; out_g = p; out_b = q; break;
+ }
+}
+
+ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
+{
+ ImGuiStyle& style = GImGui->Style;
+ ImVec4 c = style.Colors[idx];
+ c.w *= style.Alpha * alpha_mul;
+ return ColorConvertFloat4ToU32(c);
+}
+
+ImU32 ImGui::GetColorU32(const ImVec4& col)
+{
+ ImGuiStyle& style = GImGui->Style;
+ ImVec4 c = col;
+ c.w *= style.Alpha;
+ return ColorConvertFloat4ToU32(c);
+}
+
+const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
+{
+ ImGuiStyle& style = GImGui->Style;
+ return style.Colors[idx];
+}
+
+ImU32 ImGui::GetColorU32(ImU32 col)
+{
+ float style_alpha = GImGui->Style.Alpha;
+ if (style_alpha >= 1.0f)
+ return col;
+ ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
+ a = (ImU32)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
+ return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImGuiStorage
+// Helper: Key->value storage
+//-----------------------------------------------------------------------------
+
+// std::lower_bound but without the bullshit
+static ImGuiStorage::Pair* LowerBound(ImVector<ImGuiStorage::Pair>& data, ImGuiID key)
+{
+ ImGuiStorage::Pair* first = data.Data;
+ ImGuiStorage::Pair* last = data.Data + data.Size;
+ size_t count = (size_t)(last - first);
+ while (count > 0)
+ {
+ size_t count2 = count >> 1;
+ ImGuiStorage::Pair* mid = first + count2;
+ if (mid->key < key)
+ {
+ first = ++mid;
+ count -= count2 + 1;
+ }
+ else
+ {
+ count = count2;
+ }
+ }
+ return first;
+}
+
+// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
+void ImGuiStorage::BuildSortByKey()
+{
+ struct StaticFunc
+ {
+ static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs)
+ {
+ // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
+ if (((const Pair*)lhs)->key > ((const Pair*)rhs)->key) return +1;
+ if (((const Pair*)lhs)->key < ((const Pair*)rhs)->key) return -1;
+ return 0;
+ }
+ };
+ if (Data.Size > 1)
+ ImQsort(Data.Data, (size_t)Data.Size, sizeof(Pair), StaticFunc::PairCompareByID);
+}
+
+int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
+{
+ ImGuiStorage::Pair* it = LowerBound(const_cast<ImVector<ImGuiStorage::Pair>&>(Data), key);
+ if (it == Data.end() || it->key != key)
+ return default_val;
+ return it->val_i;
+}
+
+bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const
+{
+ return GetInt(key, default_val ? 1 : 0) != 0;
+}
+
+float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const
+{
+ ImGuiStorage::Pair* it = LowerBound(const_cast<ImVector<ImGuiStorage::Pair>&>(Data), key);
+ if (it == Data.end() || it->key != key)
+ return default_val;
+ return it->val_f;
+}
+
+void* ImGuiStorage::GetVoidPtr(ImGuiID key) const
+{
+ ImGuiStorage::Pair* it = LowerBound(const_cast<ImVector<ImGuiStorage::Pair>&>(Data), key);
+ if (it == Data.end() || it->key != key)
+ return NULL;
+ return it->val_p;
+}
+
+// References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
+int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val)
+{
+ ImGuiStorage::Pair* it = LowerBound(Data, key);
+ if (it == Data.end() || it->key != key)
+ it = Data.insert(it, Pair(key, default_val));
+ return &it->val_i;
+}
+
+bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val)
+{
+ return (bool*)GetIntRef(key, default_val ? 1 : 0);
+}
+
+float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
+{
+ ImGuiStorage::Pair* it = LowerBound(Data, key);
+ if (it == Data.end() || it->key != key)
+ it = Data.insert(it, Pair(key, default_val));
+ return &it->val_f;
+}
+
+void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
+{
+ ImGuiStorage::Pair* it = LowerBound(Data, key);
+ if (it == Data.end() || it->key != key)
+ it = Data.insert(it, Pair(key, default_val));
+ return &it->val_p;
+}
+
+// FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame)
+void ImGuiStorage::SetInt(ImGuiID key, int val)
+{
+ ImGuiStorage::Pair* it = LowerBound(Data, key);
+ if (it == Data.end() || it->key != key)
+ {
+ Data.insert(it, Pair(key, val));
+ return;
+ }
+ it->val_i = val;
+}
+
+void ImGuiStorage::SetBool(ImGuiID key, bool val)
+{
+ SetInt(key, val ? 1 : 0);
+}
+
+void ImGuiStorage::SetFloat(ImGuiID key, float val)
+{
+ ImGuiStorage::Pair* it = LowerBound(Data, key);
+ if (it == Data.end() || it->key != key)
+ {
+ Data.insert(it, Pair(key, val));
+ return;
+ }
+ it->val_f = val;
+}
+
+void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val)
+{
+ ImGuiStorage::Pair* it = LowerBound(Data, key);
+ if (it == Data.end() || it->key != key)
+ {
+ Data.insert(it, Pair(key, val));
+ return;
+ }
+ it->val_p = val;
+}
+
+void ImGuiStorage::SetAllInt(int v)
+{
+ for (int i = 0; i < Data.Size; i++)
+ Data[i].val_i = v;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImGuiTextFilter
+//-----------------------------------------------------------------------------
+
+// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
+ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
+{
+ if (default_filter)
+ {
+ ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf));
+ Build();
+ }
+ else
+ {
+ InputBuf[0] = 0;
+ CountGrep = 0;
+ }
+}
+
+bool ImGuiTextFilter::Draw(const char* label, float width)
+{
+ if (width != 0.0f)
+ ImGui::PushItemWidth(width);
+ bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
+ if (width != 0.0f)
+ ImGui::PopItemWidth();
+ if (value_changed)
+ Build();
+ return value_changed;
+}
+
+void ImGuiTextFilter::TextRange::split(char separator, ImVector<TextRange>* out) const
+{
+ out->resize(0);
+ const char* wb = b;
+ const char* we = wb;
+ while (we < e)
+ {
+ if (*we == separator)
+ {
+ out->push_back(TextRange(wb, we));
+ wb = we + 1;
+ }
+ we++;
+ }
+ if (wb != we)
+ out->push_back(TextRange(wb, we));
+}
+
+void ImGuiTextFilter::Build()
+{
+ Filters.resize(0);
+ TextRange input_range(InputBuf, InputBuf+strlen(InputBuf));
+ input_range.split(',', &Filters);
+
+ CountGrep = 0;
+ for (int i = 0; i != Filters.Size; i++)
+ {
+ TextRange& f = Filters[i];
+ while (f.b < f.e && ImCharIsBlankA(f.b[0]))
+ f.b++;
+ while (f.e > f.b && ImCharIsBlankA(f.e[-1]))
+ f.e--;
+ if (f.empty())
+ continue;
+ if (Filters[i].b[0] != '-')
+ CountGrep += 1;
+ }
+}
+
+bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
+{
+ if (Filters.empty())
+ return true;
+
+ if (text == NULL)
+ text = "";
+
+ for (int i = 0; i != Filters.Size; i++)
+ {
+ const TextRange& f = Filters[i];
+ if (f.empty())
+ continue;
+ if (f.b[0] == '-')
+ {
+ // Subtract
+ if (ImStristr(text, text_end, f.begin()+1, f.end()) != NULL)
+ return false;
+ }
+ else
+ {
+ // Grep
+ if (ImStristr(text, text_end, f.begin(), f.end()) != NULL)
+ return true;
+ }
+ }
+
+ // Implicit * grep
+ if (CountGrep == 0)
+ return true;
+
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImGuiTextBuffer
+//-----------------------------------------------------------------------------
+
+// On some platform vsnprintf() takes va_list by reference and modifies it.
+// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it.
+#ifndef va_copy
+#if defined(__GNUC__) || defined(__clang__)
+#define va_copy(dest, src) __builtin_va_copy(dest, src)
+#else
+#define va_copy(dest, src) (dest = src)
+#endif
+#endif
+
+char ImGuiTextBuffer::EmptyString[1] = { 0 };
+
+// Helper: Text buffer for logging/accumulating text
+void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
+{
+ va_list args_copy;
+ va_copy(args_copy, args);
+
+ int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
+ if (len <= 0)
+ {
+ va_end(args_copy);
+ return;
+ }
+
+ // Add zero-terminator the first time
+ const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
+ const int needed_sz = write_off + len;
+ if (write_off + len >= Buf.Capacity)
+ {
+ int double_capacity = Buf.Capacity * 2;
+ Buf.reserve(needed_sz > double_capacity ? needed_sz : double_capacity);
+ }
+
+ Buf.resize(needed_sz);
+ ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
+ va_end(args_copy);
+}
+
+void ImGuiTextBuffer::appendf(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ appendfv(fmt, args);
+ va_end(args);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImGuiListClipper
+// This is currently not as flexible/powerful as it should be, needs some rework (see TODO)
+//-----------------------------------------------------------------------------
+
+static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
+{
+ // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor.
+ // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue.
+ // The clipper should probably have a 4th step to display the last item in a regular manner.
+ ImGui::SetCursorPosY(pos_y);
+ ImGuiWindow* window = ImGui::GetCurrentWindow();
+ window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage.
+ window->DC.PrevLineSize.y = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
+ if (window->DC.ColumnsSet)
+ window->DC.ColumnsSet->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
+}
+
+// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
+// Use case B: Begin() called from constructor with items_height>0
+// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style.
+void ImGuiListClipper::Begin(int count, float items_height)
+{
+ StartPosY = ImGui::GetCursorPosY();
+ ItemsHeight = items_height;
+ ItemsCount = count;
+ StepNo = 0;
+ DisplayEnd = DisplayStart = -1;
+ if (ItemsHeight > 0.0f)
+ {
+ ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display
+ if (DisplayStart > 0)
+ SetCursorPosYAndSetupDummyPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor
+ StepNo = 2;
+ }
+}
+
+void ImGuiListClipper::End()
+{
+ if (ItemsCount < 0)
+ return;
+ // In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user.
+ if (ItemsCount < INT_MAX)
+ SetCursorPosYAndSetupDummyPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor
+ ItemsCount = -1;
+ StepNo = 3;
+}
+
+bool ImGuiListClipper::Step()
+{
+ if (ItemsCount == 0 || ImGui::GetCurrentWindowRead()->SkipItems)
+ {
+ ItemsCount = -1;
+ return false;
+ }
+ if (StepNo == 0) // Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height.
+ {
+ DisplayStart = 0;
+ DisplayEnd = 1;
+ StartPosY = ImGui::GetCursorPosY();
+ StepNo = 1;
+ return true;
+ }
+ if (StepNo == 1) // Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
+ {
+ if (ItemsCount == 1) { ItemsCount = -1; return false; }
+ float items_height = ImGui::GetCursorPosY() - StartPosY;
+ IM_ASSERT(items_height > 0.0f); // If this triggers, it means Item 0 hasn't moved the cursor vertically
+ Begin(ItemsCount-1, items_height);
+ DisplayStart++;
+ DisplayEnd++;
+ StepNo = 3;
+ return true;
+ }
+ if (StepNo == 2) // Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3.
+ {
+ IM_ASSERT(DisplayStart >= 0 && DisplayEnd >= 0);
+ StepNo = 3;
+ return true;
+ }
+ if (StepNo == 3) // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
+ End();
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] RENDER HELPERS
+// Those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
+// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: state.
+//-----------------------------------------------------------------------------
+
+const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
+{
+ const char* text_display_end = text;
+ if (!text_end)
+ text_end = (const char*)-1;
+
+ while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
+ text_display_end++;
+ return text_display_end;
+}
+
+// Internal ImGui functions to render text
+// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText()
+void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ // Hide anything after a '##' string
+ const char* text_display_end;
+ if (hide_text_after_hash)
+ {
+ text_display_end = FindRenderedTextEnd(text, text_end);
+ }
+ else
+ {
+ if (!text_end)
+ text_end = text + strlen(text); // FIXME-OPT
+ text_display_end = text_end;
+ }
+
+ if (text != text_display_end)
+ {
+ window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
+ if (g.LogEnabled)
+ LogRenderedText(&pos, text, text_display_end);
+ }
+}
+
+void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (!text_end)
+ text_end = text + strlen(text); // FIXME-OPT
+
+ if (text != text_end)
+ {
+ window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width);
+ if (g.LogEnabled)
+ LogRenderedText(&pos, text, text_end);
+ }
+}
+
+// Default clip_rect uses (pos_min,pos_max)
+// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges)
+void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
+{
+ // Perform CPU side clipping for single clipped element to avoid using scissor state
+ ImVec2 pos = pos_min;
+ const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f);
+
+ const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min;
+ const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max;
+ bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y);
+ if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min
+ need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y);
+
+ // Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment.
+ if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x);
+ if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y);
+
+ // Render
+ if (need_clipping)
+ {
+ ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y);
+ draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect);
+ }
+ else
+ {
+ draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL);
+ }
+}
+
+void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
+{
+ // Hide anything after a '##' string
+ const char* text_display_end = FindRenderedTextEnd(text, text_end);
+ const int text_len = (int)(text_display_end - text);
+ if (text_len == 0)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect);
+ if (g.LogEnabled)
+ LogRenderedText(&pos_min, text, text_display_end);
+}
+
+// Render a rectangle shaped with optional rounding and borders
+void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
+ const float border_size = g.Style.FrameBorderSize;
+ if (border && border_size > 0.0f)
+ {
+ window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size);
+ window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size);
+ }
+}
+
+void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ const float border_size = g.Style.FrameBorderSize;
+ if (border_size > 0.0f)
+ {
+ window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size);
+ window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size);
+ }
+}
+
+// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state
+void ImGui::RenderArrow(ImVec2 p_min, ImGuiDir dir, float scale)
+{
+ ImGuiContext& g = *GImGui;
+
+ const float h = g.FontSize * 1.00f;
+ float r = h * 0.40f * scale;
+ ImVec2 center = p_min + ImVec2(h * 0.50f, h * 0.50f * scale);
+
+ ImVec2 a, b, c;
+ switch (dir)
+ {
+ case ImGuiDir_Up:
+ case ImGuiDir_Down:
+ if (dir == ImGuiDir_Up) r = -r;
+ a = ImVec2(+0.000f,+0.750f) * r;
+ b = ImVec2(-0.866f,-0.750f) * r;
+ c = ImVec2(+0.866f,-0.750f) * r;
+ break;
+ case ImGuiDir_Left:
+ case ImGuiDir_Right:
+ if (dir == ImGuiDir_Left) r = -r;
+ a = ImVec2(+0.750f,+0.000f) * r;
+ b = ImVec2(-0.750f,+0.866f) * r;
+ c = ImVec2(-0.750f,-0.866f) * r;
+ break;
+ case ImGuiDir_None:
+ case ImGuiDir_COUNT:
+ IM_ASSERT(0);
+ break;
+ }
+
+ g.CurrentWindow->DrawList->AddTriangleFilled(center + a, center + b, center + c, GetColorU32(ImGuiCol_Text));
+}
+
+void ImGui::RenderBullet(ImVec2 pos)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ window->DrawList->AddCircleFilled(pos, g.FontSize*0.20f, GetColorU32(ImGuiCol_Text), 8);
+}
+
+void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ float thickness = ImMax(sz / 5.0f, 1.0f);
+ sz -= thickness*0.5f;
+ pos += ImVec2(thickness*0.25f, thickness*0.25f);
+
+ float third = sz / 3.0f;
+ float bx = pos.x + third;
+ float by = pos.y + sz - third*0.5f;
+ window->DrawList->PathLineTo(ImVec2(bx - third, by - third));
+ window->DrawList->PathLineTo(ImVec2(bx, by));
+ window->DrawList->PathLineTo(ImVec2(bx + third*2, by - third*2));
+ window->DrawList->PathStroke(col, false, thickness);
+}
+
+void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (id != g.NavId)
+ return;
+ if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw))
+ return;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->DC.NavHideHighlightOneFrame)
+ return;
+
+ float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding;
+ ImRect display_rect = bb;
+ display_rect.ClipWith(window->ClipRect);
+ if (flags & ImGuiNavHighlightFlags_TypeDefault)
+ {
+ const float THICKNESS = 2.0f;
+ const float DISTANCE = 3.0f + THICKNESS * 0.5f;
+ display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
+ bool fully_visible = window->ClipRect.Contains(display_rect);
+ if (!fully_visible)
+ window->DrawList->PushClipRect(display_rect.Min, display_rect.Max);
+ window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), display_rect.Max - ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), GetColorU32(ImGuiCol_NavHighlight), rounding, ImDrawCornerFlags_All, THICKNESS);
+ if (!fully_visible)
+ window->DrawList->PopClipRect();
+ }
+ if (flags & ImGuiNavHighlightFlags_TypeThin)
+ {
+ window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, ~0, 1.0f);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
+//-----------------------------------------------------------------------------
+
+// ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods
+ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
+ : DrawListInst(&context->DrawListSharedData)
+{
+ Name = ImStrdup(name);
+ ID = ImHash(name, 0);
+ IDStack.push_back(ID);
+ Flags = ImGuiWindowFlags_None;
+ Pos = ImVec2(0.0f, 0.0f);
+ Size = SizeFull = ImVec2(0.0f, 0.0f);
+ SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
+ WindowPadding = ImVec2(0.0f, 0.0f);
+ WindowRounding = 0.0f;
+ WindowBorderSize = 0.0f;
+ NameBufLen = (int)strlen(name) + 1;
+ MoveId = GetID("#MOVE");
+ ChildId = 0;
+ Scroll = ImVec2(0.0f, 0.0f);
+ ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
+ ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
+ ScrollbarSizes = ImVec2(0.0f, 0.0f);
+ ScrollbarX = ScrollbarY = false;
+ Active = WasActive = false;
+ WriteAccessed = false;
+ Collapsed = false;
+ WantCollapseToggle = false;
+ SkipItems = false;
+ Appearing = false;
+ Hidden = false;
+ HasCloseButton = false;
+ BeginCount = 0;
+ BeginOrderWithinParent = -1;
+ BeginOrderWithinContext = -1;
+ PopupId = 0;
+ AutoFitFramesX = AutoFitFramesY = -1;
+ AutoFitOnlyGrows = false;
+ AutoFitChildAxises = 0x00;
+ AutoPosLastDirection = ImGuiDir_None;
+ HiddenFramesRegular = HiddenFramesForResize = 0;
+ SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
+ SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
+
+ LastFrameActive = -1;
+ ItemWidthDefault = 0.0f;
+ FontWindowScale = 1.0f;
+ SettingsIdx = -1;
+
+ DrawList = &DrawListInst;
+ DrawList->_OwnerName = Name;
+ ParentWindow = NULL;
+ RootWindow = NULL;
+ RootWindowForTitleBarHighlight = NULL;
+ RootWindowForNav = NULL;
+
+ NavLastIds[0] = NavLastIds[1] = 0;
+ NavRectRel[0] = NavRectRel[1] = ImRect();
+ NavLastChildNavWindow = NULL;
+
+ FocusIdxAllCounter = FocusIdxTabCounter = -1;
+ FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = INT_MAX;
+ FocusIdxAllRequestNext = FocusIdxTabRequestNext = INT_MAX;
+}
+
+ImGuiWindow::~ImGuiWindow()
+{
+ IM_ASSERT(DrawList == &DrawListInst);
+ IM_DELETE(Name);
+ for (int i = 0; i != ColumnsStorage.Size; i++)
+ ColumnsStorage[i].~ImGuiColumnsSet();
+}
+
+ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
+{
+ ImGuiID seed = IDStack.back();
+ ImGuiID id = ImHash(str, str_end ? (int)(str_end - str) : 0, seed);
+ ImGui::KeepAliveID(id);
+ return id;
+}
+
+ImGuiID ImGuiWindow::GetID(const void* ptr)
+{
+ ImGuiID seed = IDStack.back();
+ ImGuiID id = ImHash(&ptr, sizeof(void*), seed);
+ ImGui::KeepAliveID(id);
+ return id;
+}
+
+ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
+{
+ ImGuiID seed = IDStack.back();
+ return ImHash(str, str_end ? (int)(str_end - str) : 0, seed);
+}
+
+ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr)
+{
+ ImGuiID seed = IDStack.back();
+ return ImHash(&ptr, sizeof(void*), seed);
+}
+
+// This is only used in rare/specific situations to manufacture an ID out of nowhere.
+ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
+{
+ ImGuiID seed = IDStack.back();
+ const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) };
+ ImGuiID id = ImHash(&r_rel, sizeof(r_rel), seed);
+ ImGui::KeepAliveID(id);
+ return id;
+}
+
+static void SetCurrentWindow(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ g.CurrentWindow = window;
+ if (window)
+ g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
+}
+
+void ImGui::SetNavID(ImGuiID id, int nav_layer)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavWindow);
+ IM_ASSERT(nav_layer == 0 || nav_layer == 1);
+ g.NavId = id;
+ g.NavWindow->NavLastIds[nav_layer] = id;
+}
+
+void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel)
+{
+ ImGuiContext& g = *GImGui;
+ SetNavID(id, nav_layer);
+ g.NavWindow->NavRectRel[nav_layer] = rect_rel;
+ g.NavMousePosDirty = true;
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
+}
+
+void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ g.ActiveIdIsJustActivated = (g.ActiveId != id);
+ if (g.ActiveIdIsJustActivated)
+ {
+ g.ActiveIdTimer = 0.0f;
+ g.ActiveIdHasBeenEdited = false;
+ if (id != 0)
+ {
+ g.LastActiveId = id;
+ g.LastActiveIdTimer = 0.0f;
+ }
+ }
+ g.ActiveId = id;
+ g.ActiveIdAllowNavDirFlags = 0;
+ g.ActiveIdAllowOverlap = false;
+ g.ActiveIdWindow = window;
+ if (id)
+ {
+ g.ActiveIdIsAlive = id;
+ g.ActiveIdSource = (g.NavActivateId == id || g.NavInputId == id || g.NavJustTabbedId == id || g.NavJustMovedToId == id) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse;
+ }
+}
+
+// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
+void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(id != 0);
+
+ // Assume that SetFocusID() is called in the context where its NavLayer is the current layer, which is the case everywhere we call it.
+ const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
+ if (g.NavWindow != window)
+ g.NavInitRequest = false;
+ g.NavId = id;
+ g.NavWindow = window;
+ g.NavLayer = nav_layer;
+ window->NavLastIds[nav_layer] = id;
+ if (window->DC.LastItemId == id)
+ window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
+
+ if (g.ActiveIdSource == ImGuiInputSource_Nav)
+ g.NavDisableMouseHover = true;
+ else
+ g.NavDisableHighlight = true;
+}
+
+void ImGui::ClearActiveID()
+{
+ SetActiveID(0, NULL);
+}
+
+void ImGui::SetHoveredID(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ g.HoveredId = id;
+ g.HoveredIdAllowOverlap = false;
+ if (id != 0 && g.HoveredIdPreviousFrame != id)
+ g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f;
+}
+
+ImGuiID ImGui::GetHoveredID()
+{
+ ImGuiContext& g = *GImGui;
+ return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame;
+}
+
+void ImGui::KeepAliveID(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.ActiveId == id)
+ g.ActiveIdIsAlive = id;
+ if (g.ActiveIdPreviousFrame == id)
+ g.ActiveIdPreviousFrameIsAlive = true;
+}
+
+void ImGui::MarkItemEdited(ImGuiID id)
+{
+ // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
+ // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data.
+ (void)id; // Avoid unused variable warnings when asserts are compiled out.
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
+ //IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
+ g.ActiveIdHasBeenEdited = true;
+ g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
+}
+
+static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags)
+{
+ // An active popup disable hovering on other windows (apart from its own children)
+ // FIXME-OPT: This could be cached/stored within the window.
+ ImGuiContext& g = *GImGui;
+ if (g.NavWindow)
+ if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
+ if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
+ {
+ // For the purpose of those flags we differentiate "standard popup" from "modal popup"
+ // NB: The order of those two tests is important because Modal windows are also Popups.
+ if (focused_root_window->Flags & ImGuiWindowFlags_Modal)
+ return false;
+ if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ return false;
+ }
+
+ return true;
+}
+
+// Advance cursor given item size for layout.
+void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->SkipItems)
+ return;
+
+ // Always align ourselves on pixel boundaries
+ const float line_height = ImMax(window->DC.CurrentLineSize.y, size.y);
+ const float text_base_offset = ImMax(window->DC.CurrentLineTextBaseOffset, text_offset_y);
+ //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
+ window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x + size.x, window->DC.CursorPos.y);
+ window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
+ window->DC.CursorPos.y = (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y);
+ window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
+ window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y);
+ //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
+
+ window->DC.PrevLineSize.y = line_height;
+ window->DC.PrevLineTextBaseOffset = text_base_offset;
+ window->DC.CurrentLineSize.y = window->DC.CurrentLineTextBaseOffset = 0.0f;
+
+ // Horizontal layout mode
+ if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
+ SameLine();
+}
+
+void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
+{
+ ItemSize(bb.GetSize(), text_offset_y);
+}
+
+// Declare item bounding box for clipping and interaction.
+// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
+// declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd().
+bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (id != 0)
+ {
+ // Navigation processing runs prior to clipping early-out
+ // (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
+ // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests unfortunately, but it is still limited to one window.
+ // it may not scale very well for windows with ten of thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
+ // We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick)
+ window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
+ if (g.NavId == id || g.NavAnyRequest)
+ if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
+ if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
+ NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);
+ }
+
+ window->DC.LastItemId = id;
+ window->DC.LastItemRect = bb;
+ window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None;
+
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+ if (id != 0)
+ ImGuiTestEngineHook_ItemAdd(&g, bb, id);
+#endif
+
+ // Clipping test
+ const bool is_clipped = IsClippedEx(bb, id, false);
+ if (is_clipped)
+ return false;
+ //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
+
+ // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
+ if (IsMouseHoveringRect(bb.Min, bb.Max))
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect;
+ return true;
+}
+
+// This is roughly matching the behavior of internal-facing ItemHoverable()
+// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
+// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
+bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.NavDisableMouseHover && !g.NavDisableHighlight)
+ return IsItemFocused();
+
+ // Test for bounding box overlap, as updated as ItemAdd()
+ if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
+ return false;
+ IM_ASSERT((flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) == 0); // Flags not supported by this function
+
+ // Test if we are hovering the right window (our window could be behind another window)
+ // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself.
+ // Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while.
+ //if (g.HoveredWindow != window)
+ // return false;
+ if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped))
+ return false;
+
+ // Test if another item is active (e.g. being dragged)
+ if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
+ if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
+ return false;
+
+ // Test if interactions on this window are blocked by an active popup or modal
+ if (!IsWindowContentHoverable(window, flags))
+ return false;
+
+ // Test if the item is disabled
+ if ((window->DC.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
+ return false;
+
+ // Special handling for the 1st item after Begin() which represent the title bar. When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect tht case.
+ if (window->DC.LastItemId == window->MoveId && window->WriteAccessed)
+ return false;
+ return true;
+}
+
+// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
+bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap)
+ return false;
+
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.HoveredWindow != window)
+ return false;
+ if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
+ return false;
+ if (!IsMouseHoveringRect(bb.Min, bb.Max))
+ return false;
+ if (g.NavDisableMouseHover || !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
+ return false;
+ if (window->DC.ItemFlags & ImGuiItemFlags_Disabled)
+ return false;
+
+ SetHoveredID(id);
+ return true;
+}
+
+bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (!bb.Overlaps(window->ClipRect))
+ if (id == 0 || id != g.ActiveId)
+ if (clip_even_when_logged || !g.LogEnabled)
+ return true;
+ return false;
+}
+
+bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop)
+{
+ ImGuiContext& g = *GImGui;
+
+ const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
+ window->FocusIdxAllCounter++;
+ if (is_tab_stop)
+ window->FocusIdxTabCounter++;
+
+ // Process keyboard input at this point: TAB/Shift-TAB to tab out of the currently focused item.
+ // Note that we can always TAB out of a widget that doesn't allow tabbing in.
+ if (tab_stop && (g.ActiveId == id) && window->FocusIdxAllRequestNext == INT_MAX && window->FocusIdxTabRequestNext == INT_MAX && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab))
+ window->FocusIdxTabRequestNext = window->FocusIdxTabCounter + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
+
+ if (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent)
+ return true;
+ if (is_tab_stop && window->FocusIdxTabCounter == window->FocusIdxTabRequestCurrent)
+ {
+ g.NavJustTabbedId = id;
+ return true;
+ }
+
+ return false;
+}
+
+void ImGui::FocusableItemUnregister(ImGuiWindow* window)
+{
+ window->FocusIdxAllCounter--;
+ window->FocusIdxTabCounter--;
+}
+
+ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_x, float default_y)
+{
+ ImGuiContext& g = *GImGui;
+ ImVec2 content_max;
+ if (size.x < 0.0f || size.y < 0.0f)
+ content_max = g.CurrentWindow->Pos + GetContentRegionMax();
+ if (size.x <= 0.0f)
+ size.x = (size.x == 0.0f) ? default_x : ImMax(content_max.x - g.CurrentWindow->DC.CursorPos.x, 4.0f) + size.x;
+ if (size.y <= 0.0f)
+ size.y = (size.y == 0.0f) ? default_y : ImMax(content_max.y - g.CurrentWindow->DC.CursorPos.y, 4.0f) + size.y;
+ return size;
+}
+
+float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
+{
+ if (wrap_pos_x < 0.0f)
+ return 0.0f;
+
+ ImGuiWindow* window = GetCurrentWindowRead();
+ if (wrap_pos_x == 0.0f)
+ wrap_pos_x = GetContentRegionMax().x + window->Pos.x;
+ else if (wrap_pos_x > 0.0f)
+ wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
+
+ return ImMax(wrap_pos_x - pos.x, 1.0f);
+}
+
+void* ImGui::MemAlloc(size_t size)
+{
+ if (ImGuiContext* ctx = GImGui)
+ ctx->IO.MetricsActiveAllocations++;
+ return GImAllocatorAllocFunc(size, GImAllocatorUserData);
+}
+
+void ImGui::MemFree(void* ptr)
+{
+ if (ptr)
+ if (ImGuiContext* ctx = GImGui)
+ ctx->IO.MetricsActiveAllocations--;
+ return GImAllocatorFreeFunc(ptr, GImAllocatorUserData);
+}
+
+const char* ImGui::GetClipboardText()
+{
+ return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn(GImGui->IO.ClipboardUserData) : "";
+}
+
+void ImGui::SetClipboardText(const char* text)
+{
+ if (GImGui->IO.SetClipboardTextFn)
+ GImGui->IO.SetClipboardTextFn(GImGui->IO.ClipboardUserData, text);
+}
+
+const char* ImGui::GetVersion()
+{
+ return IMGUI_VERSION;
+}
+
+// Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
+// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module
+ImGuiContext* ImGui::GetCurrentContext()
+{
+ return GImGui;
+}
+
+void ImGui::SetCurrentContext(ImGuiContext* ctx)
+{
+#ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC
+ IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this.
+#else
+ GImGui = ctx;
+#endif
+}
+
+// Helper function to verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit
+// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. you may see different structures from what imgui.cpp sees which is highly problematic.
+bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert)
+{
+ bool error = false;
+ if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatched version string!"); }
+ if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
+ if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
+ if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
+ if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
+ if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
+ return !error;
+}
+
+void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data)
+{
+ GImAllocatorAllocFunc = alloc_func;
+ GImAllocatorFreeFunc = free_func;
+ GImAllocatorUserData = user_data;
+}
+
+ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas)
+{
+ ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas);
+ if (GImGui == NULL)
+ SetCurrentContext(ctx);
+ Initialize(ctx);
+ return ctx;
+}
+
+void ImGui::DestroyContext(ImGuiContext* ctx)
+{
+ if (ctx == NULL)
+ ctx = GImGui;
+ Shutdown(ctx);
+ if (GImGui == ctx)
+ SetCurrentContext(NULL);
+ IM_DELETE(ctx);
+}
+
+ImGuiIO& ImGui::GetIO()
+{
+ IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
+ return GImGui->IO;
+}
+
+ImGuiStyle& ImGui::GetStyle()
+{
+ IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
+ return GImGui->Style;
+}
+
+// Same value as passed to the old io.RenderDrawListsFn function. Valid after Render() and until the next call to NewFrame()
+ImDrawData* ImGui::GetDrawData()
+{
+ ImGuiContext& g = *GImGui;
+ return g.DrawData.Valid ? &g.DrawData : NULL;
+}
+
+double ImGui::GetTime()
+{
+ return GImGui->Time;
+}
+
+int ImGui::GetFrameCount()
+{
+ return GImGui->FrameCount;
+}
+
+static ImDrawList* GetOverlayDrawList(ImGuiWindow*)
+{
+ // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'viewport' branches.
+ return &GImGui->OverlayDrawList;
+}
+
+ImDrawList* ImGui::GetOverlayDrawList()
+{
+ return &GImGui->OverlayDrawList;
+}
+
+ImDrawListSharedData* ImGui::GetDrawListSharedData()
+{
+ return &GImGui->DrawListSharedData;
+}
+
+void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
+{
+ // Set ActiveId even if the _NoMove flag is set. Without it, dragging away from a window with _NoMove would activate hover on other windows.
+ // We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward.
+ // This is because we want ActiveId to be set even when the window is stuck from moving.
+ ImGuiContext& g = *GImGui;
+ FocusWindow(window);
+ SetActiveID(window->MoveId, window);
+ g.NavDisableHighlight = true;
+ g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos;
+ if (!(window->Flags & ImGuiWindowFlags_NoMove) && !(window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
+ g.MovingWindow = window;
+}
+
+// Handle mouse moving window
+// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
+void ImGui::UpdateMouseMovingWindowNewFrame()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.MovingWindow != NULL)
+ {
+ // We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window).
+ // We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency.
+ KeepAliveID(g.ActiveId);
+ IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
+ ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
+ if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
+ {
+ ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
+ if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y)
+ {
+ MarkIniSettingsDirty(moving_window);
+ SetWindowPos(moving_window, pos, ImGuiCond_Always);
+ }
+ FocusWindow(g.MovingWindow);
+ }
+ else
+ {
+ ClearActiveID();
+ g.MovingWindow = NULL;
+ }
+ }
+ else
+ {
+ // When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others.
+ if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId)
+ {
+ KeepAliveID(g.ActiveId);
+ if (!g.IO.MouseDown[0])
+ ClearActiveID();
+ }
+ }
+}
+
+// Initiate moving window, handle left-click and right-click focus
+void ImGui::UpdateMouseMovingWindowEndFrame()
+{
+ // Initiate moving window
+ ImGuiContext& g = *GImGui;
+ if (g.ActiveId != 0 || g.HoveredId != 0)
+ return;
+
+ // Unless we just made a window/popup appear
+ if (g.NavWindow && g.NavWindow->Appearing)
+ return;
+
+ // Click to focus window and start moving (after we're done with all our widgets)
+ if (g.IO.MouseClicked[0])
+ {
+ if (g.HoveredRootWindow != NULL)
+ {
+ StartMouseMovingWindow(g.HoveredWindow);
+ if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar))
+ if (!g.HoveredRootWindow->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
+ g.MovingWindow = NULL;
+ }
+ else if (g.NavWindow != NULL && GetFrontMostPopupModal() == NULL)
+ {
+ FocusWindow(NULL); // Clicking on void disable focus
+ }
+ }
+
+ // With right mouse button we close popups without changing focus
+ // (The left mouse button path calls FocusWindow which will lead NewFrame->ClosePopupsOverWindow to trigger)
+ if (g.IO.MouseClicked[1])
+ {
+ // Find the top-most window between HoveredWindow and the front most Modal Window.
+ // This is where we can trim the popup stack.
+ ImGuiWindow* modal = GetFrontMostPopupModal();
+ bool hovered_window_above_modal = false;
+ if (modal == NULL)
+ hovered_window_above_modal = true;
+ for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--)
+ {
+ ImGuiWindow* window = g.Windows[i];
+ if (window == modal)
+ break;
+ if (window == g.HoveredWindow)
+ hovered_window_above_modal = true;
+ }
+ ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal);
+ }
+}
+
+static bool IsWindowActiveAndVisible(ImGuiWindow* window)
+{
+ return (window->Active) && (!window->Hidden);
+}
+
+static void ImGui::UpdateMouseInputs()
+{
+ ImGuiContext& g = *GImGui;
+
+ // Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
+ if (IsMousePosValid(&g.IO.MousePos))
+ g.IO.MousePos = g.LastValidMousePos = ImFloor(g.IO.MousePos);
+
+ // If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta
+ if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev))
+ g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev;
+ else
+ g.IO.MouseDelta = ImVec2(0.0f, 0.0f);
+ if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)
+ g.NavDisableMouseHover = false;
+
+ g.IO.MousePosPrev = g.IO.MousePos;
+ for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
+ {
+ g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f;
+ g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f;
+ g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i];
+ g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f;
+ g.IO.MouseDoubleClicked[i] = false;
+ if (g.IO.MouseClicked[i])
+ {
+ if ((float)(g.Time - g.IO.MouseClickedTime[i]) < g.IO.MouseDoubleClickTime)
+ {
+ ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
+ if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist)
+ g.IO.MouseDoubleClicked[i] = true;
+ g.IO.MouseClickedTime[i] = -FLT_MAX; // so the third click isn't turned into a double-click
+ }
+ else
+ {
+ g.IO.MouseClickedTime[i] = g.Time;
+ }
+ g.IO.MouseClickedPos[i] = g.IO.MousePos;
+ g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f);
+ g.IO.MouseDragMaxDistanceSqr[i] = 0.0f;
+ }
+ else if (g.IO.MouseDown[i])
+ {
+ // Maintain the maximum distance we reaching from the initial click position, which is used with dragging threshold
+ ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
+ g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(delta_from_click_pos));
+ g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x);
+ g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y);
+ }
+ if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation
+ g.NavDisableMouseHover = false;
+ }
+}
+
+void ImGui::UpdateMouseWheel()
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.HoveredWindow || g.HoveredWindow->Collapsed)
+ return;
+ if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f)
+ return;
+
+ // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent (unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set).
+ ImGuiWindow* window = g.HoveredWindow;
+ ImGuiWindow* scroll_window = window;
+ while ((scroll_window->Flags & ImGuiWindowFlags_ChildWindow) && (scroll_window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(scroll_window->Flags & ImGuiWindowFlags_NoScrollbar) && !(scroll_window->Flags & ImGuiWindowFlags_NoMouseInputs) && scroll_window->ParentWindow)
+ scroll_window = scroll_window->ParentWindow;
+ const bool scroll_allowed = !(scroll_window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(scroll_window->Flags & ImGuiWindowFlags_NoMouseInputs);
+
+ if (g.IO.MouseWheel != 0.0f)
+ {
+ if (g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
+ {
+ // Zoom / Scale window
+ const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
+ const float scale = new_font_scale / window->FontWindowScale;
+ window->FontWindowScale = new_font_scale;
+
+ const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
+ window->Pos += offset;
+ window->Size *= scale;
+ window->SizeFull *= scale;
+ }
+ else if (!g.IO.KeyCtrl && scroll_allowed)
+ {
+ // Mouse wheel vertical scrolling
+ float scroll_amount = 5 * scroll_window->CalcFontSize();
+ scroll_amount = (float)(int)ImMin(scroll_amount, (scroll_window->ContentsRegionRect.GetHeight() + scroll_window->WindowPadding.y * 2.0f) * 0.67f);
+ SetWindowScrollY(scroll_window, scroll_window->Scroll.y - g.IO.MouseWheel * scroll_amount);
+ }
+ }
+ if (g.IO.MouseWheelH != 0.0f && scroll_allowed && !g.IO.KeyCtrl)
+ {
+ // Mouse wheel horizontal scrolling (for hardware that supports it)
+ float scroll_amount = scroll_window->CalcFontSize();
+ SetWindowScrollX(scroll_window, scroll_window->Scroll.x - g.IO.MouseWheelH * scroll_amount);
+ }
+}
+
+// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
+void ImGui::UpdateHoveredWindowAndCaptureFlags()
+{
+ ImGuiContext& g = *GImGui;
+
+ // Find the window hovered by mouse:
+ // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow.
+ // - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
+ // - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
+ FindHoveredWindow();
+
+ // Modal windows prevents cursor from hovering behind them.
+ ImGuiWindow* modal_window = GetFrontMostPopupModal();
+ if (modal_window)
+ if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window))
+ g.HoveredRootWindow = g.HoveredWindow = NULL;
+
+ // Disabled mouse?
+ if (g.IO.ConfigFlags & ImGuiConfigFlags_NoMouse)
+ g.HoveredWindow = g.HoveredRootWindow = NULL;
+
+ // We track click ownership. When clicked outside of a window the click is owned by the application and won't report hovering nor request capture even while dragging over our windows afterward.
+ int mouse_earliest_button_down = -1;
+ bool mouse_any_down = false;
+ for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
+ {
+ if (g.IO.MouseClicked[i])
+ g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty());
+ mouse_any_down |= g.IO.MouseDown[i];
+ if (g.IO.MouseDown[i])
+ if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down])
+ mouse_earliest_button_down = i;
+ }
+ const bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down];
+
+ // If mouse was first clicked outside of ImGui bounds we also cancel out hovering.
+ // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02)
+ const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0;
+ if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload)
+ g.HoveredWindow = g.HoveredRootWindow = NULL;
+
+ // Update io.WantCaptureMouse for the user application (true = dispatch mouse info to imgui, false = dispatch mouse info to imgui + app)
+ if (g.WantCaptureMouseNextFrame != -1)
+ g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0);
+ else
+ g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (!g.OpenPopupStack.empty());
+
+ // Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to imgui, false = dispatch keyboard info to imgui + app)
+ if (g.WantCaptureKeyboardNextFrame != -1)
+ g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
+ else
+ g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
+ if (g.IO.NavActive && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
+ g.IO.WantCaptureKeyboard = true;
+
+ // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible
+ g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
+}
+
+void ImGui::NewFrame()
+{
+ IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
+ ImGuiContext& g = *GImGui;
+
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+ ImGuiTestEngineHook_PreNewFrame(&g);
+#endif
+
+ // Check user data
+ // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
+ IM_ASSERT(g.Initialized);
+ IM_ASSERT(g.IO.DeltaTime >= 0.0f && "Need a positive DeltaTime (zero is tolerated but will cause some timing issues)");
+ IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value");
+ IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
+ IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
+ IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting");
+ IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)");
+ IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
+ for (int n = 0; n < ImGuiKey_COUNT; n++)
+ IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
+
+ // Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
+ if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
+ IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
+
+ // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
+ if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
+ g.IO.ConfigWindowsResizeFromEdges = false;
+
+ // Load settings on first frame (if not explicitly loaded manually before)
+ if (!g.SettingsLoaded)
+ {
+ IM_ASSERT(g.SettingsWindows.empty());
+ if (g.IO.IniFilename)
+ LoadIniSettingsFromDisk(g.IO.IniFilename);
+ g.SettingsLoaded = true;
+ }
+
+ // Save settings (with a delay after the last modification, so we don't spam disk too much)
+ if (g.SettingsDirtyTimer > 0.0f)
+ {
+ g.SettingsDirtyTimer -= g.IO.DeltaTime;
+ if (g.SettingsDirtyTimer <= 0.0f)
+ {
+ if (g.IO.IniFilename != NULL)
+ SaveIniSettingsToDisk(g.IO.IniFilename);
+ else
+ g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves.
+ g.SettingsDirtyTimer = 0.0f;
+ }
+ }
+
+ g.Time += g.IO.DeltaTime;
+ g.FrameScopeActive = true;
+ g.FrameCount += 1;
+ g.TooltipOverrideCount = 0;
+ g.WindowsActiveCount = 0;
+
+ // Setup current font and draw list
+ g.IO.Fonts->Locked = true;
+ SetCurrentFont(GetDefaultFont());
+ IM_ASSERT(g.Font->IsLoaded());
+ g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
+ g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
+
+ g.OverlayDrawList.Clear();
+ g.OverlayDrawList.PushTextureID(g.IO.Fonts->TexID);
+ g.OverlayDrawList.PushClipRectFullScreen();
+ g.OverlayDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
+
+ // Mark rendering data as invalid to prevent user who may have a handle on it to use it
+ g.DrawData.Clear();
+
+ // Drag and drop keep the source ID alive so even if the source disappear our state is consistent
+ if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId)
+ KeepAliveID(g.DragDropPayload.SourceId);
+
+ // Clear reference to active widget if the widget isn't alive anymore
+ if (!g.HoveredIdPreviousFrame)
+ g.HoveredIdTimer = 0.0f;
+ if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId))
+ g.HoveredIdNotActiveTimer = 0.0f;
+ if (g.HoveredId)
+ g.HoveredIdTimer += g.IO.DeltaTime;
+ if (g.HoveredId && g.ActiveId != g.HoveredId)
+ g.HoveredIdNotActiveTimer += g.IO.DeltaTime;
+ g.HoveredIdPreviousFrame = g.HoveredId;
+ g.HoveredId = 0;
+ g.HoveredIdAllowOverlap = false;
+ if (g.ActiveIdIsAlive != g.ActiveId && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
+ ClearActiveID();
+ if (g.ActiveId)
+ g.ActiveIdTimer += g.IO.DeltaTime;
+ g.LastActiveIdTimer += g.IO.DeltaTime;
+ g.ActiveIdPreviousFrame = g.ActiveId;
+ g.ActiveIdPreviousFrameWindow = g.ActiveIdWindow;
+ g.ActiveIdPreviousFrameHasBeenEdited = g.ActiveIdHasBeenEdited;
+ g.ActiveIdIsAlive = 0;
+ g.ActiveIdPreviousFrameIsAlive = false;
+ g.ActiveIdIsJustActivated = false;
+ if (g.ScalarAsInputTextId && g.ActiveId != g.ScalarAsInputTextId)
+ g.ScalarAsInputTextId = 0;
+
+ // Drag and drop
+ g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
+ g.DragDropAcceptIdCurr = 0;
+ g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
+ g.DragDropWithinSourceOrTarget = false;
+
+ // Update keyboard input state
+ memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
+ for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++)
+ g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f;
+
+ // Update gamepad/keyboard directional navigation
+ NavUpdate();
+
+ // Update mouse input state
+ UpdateMouseInputs();
+
+ // Calculate frame-rate for the user, as a purely luxurious feature
+ g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
+ g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime;
+ g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
+ g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
+
+ // Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
+ UpdateMouseMovingWindowNewFrame();
+ UpdateHoveredWindowAndCaptureFlags();
+
+ // Background darkening/whitening
+ if (GetFrontMostPopupModal() != NULL || (g.NavWindowingTarget != NULL && g.NavWindowingHighlightAlpha > 0.0f))
+ g.DimBgRatio = ImMin(g.DimBgRatio + g.IO.DeltaTime * 6.0f, 1.0f);
+ else
+ g.DimBgRatio = ImMax(g.DimBgRatio - g.IO.DeltaTime * 10.0f, 0.0f);
+
+ g.MouseCursor = ImGuiMouseCursor_Arrow;
+ g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1;
+ g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
+
+ // Mouse wheel scrolling, scale
+ UpdateMouseWheel();
+
+ // Pressing TAB activate widget focus
+ if (g.ActiveId == 0 && g.NavWindow != NULL && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab, false))
+ {
+ if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
+ g.NavWindow->FocusIdxTabRequestNext = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
+ else
+ g.NavWindow->FocusIdxTabRequestNext = g.IO.KeyShift ? -1 : 0;
+ }
+ g.NavIdTabCounter = INT_MAX;
+
+ // Mark all windows as not visible
+ IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size);
+ for (int i = 0; i != g.Windows.Size; i++)
+ {
+ ImGuiWindow* window = g.Windows[i];
+ window->WasActive = window->Active;
+ window->Active = false;
+ window->WriteAccessed = false;
+ }
+
+ // Closing the focused window restore focus to the first active root window in descending z-order
+ if (g.NavWindow && !g.NavWindow->WasActive)
+ FocusPreviousWindowIgnoringOne(NULL);
+
+ // No window should be open at the beginning of the frame.
+ // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
+ g.CurrentWindowStack.resize(0);
+ g.BeginPopupStack.resize(0);
+ ClosePopupsOverWindow(g.NavWindow);
+
+ // Create implicit/fallback window - which we will only render it if the user has added something to it.
+ // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
+ // This fallback is particularly important as it avoid ImGui:: calls from crashing.
+ SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
+ Begin("Debug##Default");
+ g.FrameScopePushedImplicitWindow = true;
+
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+ ImGuiTestEngineHook_PostNewFrame(&g);
+#endif
+}
+
+void ImGui::Initialize(ImGuiContext* context)
+{
+ ImGuiContext& g = *context;
+ IM_ASSERT(!g.Initialized && !g.SettingsLoaded);
+
+ // Add .ini handle for ImGuiWindow type
+ ImGuiSettingsHandler ini_handler;
+ ini_handler.TypeName = "Window";
+ ini_handler.TypeHash = ImHash("Window", 0, 0);
+ ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
+ ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
+ ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
+ g.SettingsHandlers.push_front(ini_handler);
+
+ g.Initialized = true;
+}
+
+// This function is merely here to free heap allocations.
+void ImGui::Shutdown(ImGuiContext* context)
+{
+ // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
+ ImGuiContext& g = *context;
+ if (g.IO.Fonts && g.FontAtlasOwnedByContext)
+ {
+ g.IO.Fonts->Locked = false;
+ IM_DELETE(g.IO.Fonts);
+ }
+ g.IO.Fonts = NULL;
+
+ // Cleanup of other data are conditional on actually having initialized ImGui.
+ if (!g.Initialized)
+ return;
+
+ // Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file)
+ if (g.SettingsLoaded && g.IO.IniFilename != NULL)
+ {
+ ImGuiContext* backup_context = GImGui;
+ SetCurrentContext(context);
+ SaveIniSettingsToDisk(g.IO.IniFilename);
+ SetCurrentContext(backup_context);
+ }
+
+ // Clear everything else
+ for (int i = 0; i < g.Windows.Size; i++)
+ IM_DELETE(g.Windows[i]);
+ g.Windows.clear();
+ g.WindowsFocusOrder.clear();
+ g.WindowsSortBuffer.clear();
+ g.CurrentWindow = NULL;
+ g.CurrentWindowStack.clear();
+ g.WindowsById.Clear();
+ g.NavWindow = NULL;
+ g.HoveredWindow = NULL;
+ g.HoveredRootWindow = NULL;
+ g.ActiveIdWindow = g.ActiveIdPreviousFrameWindow = NULL;
+ g.MovingWindow = NULL;
+ g.ColorModifiers.clear();
+ g.StyleModifiers.clear();
+ g.FontStack.clear();
+ g.OpenPopupStack.clear();
+ g.BeginPopupStack.clear();
+ g.DrawDataBuilder.ClearFreeMemory();
+ g.OverlayDrawList.ClearFreeMemory();
+ g.PrivateClipboard.clear();
+ g.InputTextState.TextW.clear();
+ g.InputTextState.InitialText.clear();
+ g.InputTextState.TempBuffer.clear();
+
+ for (int i = 0; i < g.SettingsWindows.Size; i++)
+ IM_DELETE(g.SettingsWindows[i].Name);
+ g.SettingsWindows.clear();
+ g.SettingsHandlers.clear();
+
+ if (g.LogFile && g.LogFile != stdout)
+ {
+ fclose(g.LogFile);
+ g.LogFile = NULL;
+ }
+ g.LogClipboard.clear();
+
+ g.Initialized = false;
+}
+
+// FIXME: Add a more explicit sort order in the window structure.
+static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs)
+{
+ const ImGuiWindow* const a = *(const ImGuiWindow* const *)lhs;
+ const ImGuiWindow* const b = *(const ImGuiWindow* const *)rhs;
+ if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup))
+ return d;
+ if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip))
+ return d;
+ return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
+}
+
+static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window)
+{
+ out_sorted_windows->push_back(window);
+ if (window->Active)
+ {
+ int count = window->DC.ChildWindows.Size;
+ if (count > 1)
+ ImQsort(window->DC.ChildWindows.begin(), (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer);
+ for (int i = 0; i < count; i++)
+ {
+ ImGuiWindow* child = window->DC.ChildWindows[i];
+ if (child->Active)
+ AddWindowToSortBuffer(out_sorted_windows, child);
+ }
+ }
+}
+
+static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
+{
+ if (draw_list->CmdBuffer.empty())
+ return;
+
+ // Remove trailing command if unused
+ ImDrawCmd& last_cmd = draw_list->CmdBuffer.back();
+ if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL)
+ {
+ draw_list->CmdBuffer.pop_back();
+ if (draw_list->CmdBuffer.empty())
+ return;
+ }
+
+ // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. May trigger for you if you are using PrimXXX functions incorrectly.
+ IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
+ IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
+ IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
+
+ // Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
+ // If this assert triggers because you are drawing lots of stuff manually:
+ // A) Make sure you are coarse clipping, because ImDrawList let all your vertices pass. You can use the Metrics window to inspect draw list contents.
+ // B) If you need/want meshes with more than 64K vertices, uncomment the '#define ImDrawIdx unsigned int' line in imconfig.h to set the index size to 4 bytes.
+ // You'll need to handle the 4-bytes indices to your renderer. For example, the OpenGL example code detect index size at compile-time by doing:
+ // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
+ // Your own engine or render API may use different parameters or function calls to specify index sizes. 2 and 4 bytes indices are generally supported by most API.
+ // C) If for some reason you cannot use 4 bytes indices or don't want to, a workaround is to call BeginChild()/EndChild() before reaching the 64K limit to split your draw commands in multiple draw lists.
+ if (sizeof(ImDrawIdx) == 2)
+ IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
+
+ out_list->push_back(draw_list);
+}
+
+static void AddWindowToDrawData(ImVector<ImDrawList*>* out_render_list, ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ g.IO.MetricsRenderWindows++;
+ AddDrawListToDrawData(out_render_list, window->DrawList);
+ for (int i = 0; i < window->DC.ChildWindows.Size; i++)
+ {
+ ImGuiWindow* child = window->DC.ChildWindows[i];
+ if (IsWindowActiveAndVisible(child)) // clipped children may have been marked not active
+ AddWindowToDrawData(out_render_list, child);
+ }
+}
+
+static void AddWindowToDrawDataSelectLayer(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ if (window->Flags & ImGuiWindowFlags_Tooltip)
+ AddWindowToDrawData(&g.DrawDataBuilder.Layers[1], window);
+ else
+ AddWindowToDrawData(&g.DrawDataBuilder.Layers[0], window);
+}
+
+void ImDrawDataBuilder::FlattenIntoSingleLayer()
+{
+ int n = Layers[0].Size;
+ int size = n;
+ for (int i = 1; i < IM_ARRAYSIZE(Layers); i++)
+ size += Layers[i].Size;
+ Layers[0].resize(size);
+ for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++)
+ {
+ ImVector<ImDrawList*>& layer = Layers[layer_n];
+ if (layer.empty())
+ continue;
+ memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
+ n += layer.Size;
+ layer.resize(0);
+ }
+}
+
+static void SetupDrawData(ImVector<ImDrawList*>* draw_lists, ImDrawData* draw_data)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ draw_data->Valid = true;
+ draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL;
+ draw_data->CmdListsCount = draw_lists->Size;
+ draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
+ draw_data->DisplayPos = ImVec2(0.0f, 0.0f);
+ draw_data->DisplaySize = io.DisplaySize;
+ for (int n = 0; n < draw_lists->Size; n++)
+ {
+ draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size;
+ draw_data->TotalIdxCount += draw_lists->Data[n]->IdxBuffer.Size;
+ }
+}
+
+// When using this function it is sane to ensure that float are perfectly rounded to integer values, to that e.g. (int)(max.x-min.x) in user's render produce correct result.
+void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect);
+ window->ClipRect = window->DrawList->_ClipRectStack.back();
+}
+
+void ImGui::PopClipRect()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DrawList->PopClipRect();
+ window->ClipRect = window->DrawList->_ClipRectStack.back();
+}
+
+// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal.
+void ImGui::EndFrame()
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.Initialized);
+ if (g.FrameCountEnded == g.FrameCount) // Don't process EndFrame() multiple times.
+ return;
+ IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");
+
+ // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
+ if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)
+ {
+ g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y);
+ g.PlatformImeLastPos = g.PlatformImePos;
+ }
+
+ // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you
+ // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API).
+ if (g.CurrentWindowStack.Size != 1)
+ {
+ if (g.CurrentWindowStack.Size > 1)
+ {
+ IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
+ while (g.CurrentWindowStack.Size > 1) // FIXME-ERRORHANDLING
+ End();
+ }
+ else
+ {
+ IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
+ }
+ }
+
+ // Hide implicit/fallback "Debug" window if it hasn't been used
+ g.FrameScopePushedImplicitWindow = false;
+ if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
+ g.CurrentWindow->Active = false;
+ End();
+
+ // Show CTRL+TAB list window
+ if (g.NavWindowingTarget)
+ NavUpdateWindowingList();
+
+ // Drag and Drop: Elapse payload (if delivered, or if source stops being submitted)
+ if (g.DragDropActive)
+ {
+ bool is_delivered = g.DragDropPayload.Delivery;
+ bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton));
+ if (is_delivered || is_elapsed)
+ ClearDragDrop();
+ }
+
+ // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
+ if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)
+ {
+ g.DragDropWithinSourceOrTarget = true;
+ SetTooltip("...");
+ g.DragDropWithinSourceOrTarget = false;
+ }
+
+ // End frame
+ g.FrameScopeActive = false;
+ g.FrameCountEnded = g.FrameCount;
+
+ // Initiate moving window + handle left-click and right-click focus
+ UpdateMouseMovingWindowEndFrame();
+
+ // Sort the window list so that all child windows are after their parent
+ // We cannot do that on FocusWindow() because childs may not exist yet
+ g.WindowsSortBuffer.resize(0);
+ g.WindowsSortBuffer.reserve(g.Windows.Size);
+ for (int i = 0; i != g.Windows.Size; i++)
+ {
+ ImGuiWindow* window = g.Windows[i];
+ if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
+ continue;
+ AddWindowToSortBuffer(&g.WindowsSortBuffer, window);
+ }
+
+ IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong
+ g.Windows.swap(g.WindowsSortBuffer);
+ g.IO.MetricsActiveWindows = g.WindowsActiveCount;
+
+ // Unlock font atlas
+ g.IO.Fonts->Locked = false;
+
+ // Clear Input data for next frame
+ g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f;
+ g.IO.InputQueueCharacters.resize(0);
+ memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs));
+}
+
+void ImGui::Render()
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.Initialized);
+
+ if (g.FrameCountEnded != g.FrameCount)
+ EndFrame();
+ g.FrameCountRendered = g.FrameCount;
+
+ // Gather ImDrawList to render (for each active window)
+ g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsRenderWindows = 0;
+ g.DrawDataBuilder.Clear();
+ ImGuiWindow* windows_to_render_front_most[2];
+ windows_to_render_front_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
+ windows_to_render_front_most[1] = g.NavWindowingTarget ? g.NavWindowingList : NULL;
+ for (int n = 0; n != g.Windows.Size; n++)
+ {
+ ImGuiWindow* window = g.Windows[n];
+ if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_front_most[0] && window != windows_to_render_front_most[1])
+ AddWindowToDrawDataSelectLayer(window);
+ }
+ for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_front_most); n++)
+ if (windows_to_render_front_most[n] && IsWindowActiveAndVisible(windows_to_render_front_most[n])) // NavWindowingTarget is always temporarily displayed as the front-most window
+ AddWindowToDrawDataSelectLayer(windows_to_render_front_most[n]);
+ g.DrawDataBuilder.FlattenIntoSingleLayer();
+
+ // Draw software mouse cursor if requested
+ if (g.IO.MouseDrawCursor)
+ RenderMouseCursor(&g.OverlayDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor);
+
+ if (!g.OverlayDrawList.VtxBuffer.empty())
+ AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.OverlayDrawList);
+
+ // Setup ImDrawData structure for end-user
+ SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData);
+ g.IO.MetricsRenderVertices = g.DrawData.TotalVtxCount;
+ g.IO.MetricsRenderIndices = g.DrawData.TotalIdxCount;
+
+ // (Legacy) Call the Render callback function. The current prefer way is to let the user retrieve GetDrawData() and call the render function themselves.
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ if (g.DrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL)
+ g.IO.RenderDrawListsFn(&g.DrawData);
+#endif
+}
+
+// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker.
+// CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize)
+ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
+{
+ ImGuiContext& g = *GImGui;
+
+ const char* text_display_end;
+ if (hide_text_after_double_hash)
+ text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
+ else
+ text_display_end = text_end;
+
+ ImFont* font = g.Font;
+ const float font_size = g.FontSize;
+ if (text == text_display_end)
+ return ImVec2(0.0f, font_size);
+ ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
+
+ // Cancel out character spacing for the last character of a line (it is baked into glyph->AdvanceX field)
+ const float font_scale = font_size / font->FontSize;
+ const float character_spacing_x = 1.0f * font_scale;
+ if (text_size.x > 0.0f)
+ text_size.x -= character_spacing_x;
+ text_size.x = (float)(int)(text_size.x + 0.95f);
+
+ return text_size;
+}
+
+// Helper to calculate coarse clipping of large list of evenly sized items.
+// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern.
+// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX
+void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.LogEnabled)
+ {
+ // If logging is active, do not perform any clipping
+ *out_items_display_start = 0;
+ *out_items_display_end = items_count;
+ return;
+ }
+ if (window->SkipItems)
+ {
+ *out_items_display_start = *out_items_display_end = 0;
+ return;
+ }
+
+ // We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
+ ImRect unclipped_rect = window->ClipRect;
+ if (g.NavMoveRequest)
+ unclipped_rect.Add(g.NavScoringRectScreen);
+
+ const ImVec2 pos = window->DC.CursorPos;
+ int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
+ int end = (int)((unclipped_rect.Max.y - pos.y) / items_height);
+
+ // When performing a navigation request, ensure we have one item extra in the direction we are moving to
+ if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up)
+ start--;
+ if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down)
+ end++;
+
+ start = ImClamp(start, 0, items_count);
+ end = ImClamp(end + 1, start, items_count);
+ *out_items_display_start = start;
+ *out_items_display_end = end;
+}
+
+// Find window given position, search front-to-back
+// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programatically
+// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is
+// called, aka before the next Begin(). Moving window isn't affected.
+static void FindHoveredWindow()
+{
+ ImGuiContext& g = *GImGui;
+
+ ImGuiWindow* hovered_window = NULL;
+ if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs))
+ hovered_window = g.MovingWindow;
+
+ ImVec2 padding_regular = g.Style.TouchExtraPadding;
+ ImVec2 padding_for_resize_from_edges = g.IO.ConfigWindowsResizeFromEdges ? ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS)) : padding_regular;
+ for (int i = g.Windows.Size - 1; i >= 0; i--)
+ {
+ ImGuiWindow* window = g.Windows[i];
+ if (!window->Active || window->Hidden)
+ continue;
+ if (window->Flags & ImGuiWindowFlags_NoMouseInputs)
+ continue;
+
+ // Using the clipped AABB, a child window will typically be clipped by its parent (not always)
+ ImRect bb(window->OuterRectClipped);
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_NoResize))
+ bb.Expand(padding_regular);
+ else
+ bb.Expand(padding_for_resize_from_edges);
+ if (!bb.Contains(g.IO.MousePos))
+ continue;
+
+ // Those seemingly unnecessary extra tests are because the code here is a little different in viewport/docking branches.
+ if (hovered_window == NULL)
+ hovered_window = window;
+ if (hovered_window)
+ break;
+ }
+
+ g.HoveredWindow = hovered_window;
+ g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
+
+}
+
+// Test if mouse cursor is hovering given rectangle
+// NB- Rectangle is clipped by our current clip setting
+// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
+bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
+{
+ ImGuiContext& g = *GImGui;
+
+ // Clip
+ ImRect rect_clipped(r_min, r_max);
+ if (clip)
+ rect_clipped.ClipWith(g.CurrentWindow->ClipRect);
+
+ // Expand for touch input
+ const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
+ if (!rect_for_touch.Contains(g.IO.MousePos))
+ return false;
+ return true;
+}
+
+int ImGui::GetKeyIndex(ImGuiKey imgui_key)
+{
+ IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT);
+ return GImGui->IO.KeyMap[imgui_key];
+}
+
+// Note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]!
+bool ImGui::IsKeyDown(int user_key_index)
+{
+ if (user_key_index < 0) return false;
+ IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(GImGui->IO.KeysDown));
+ return GImGui->IO.KeysDown[user_key_index];
+}
+
+int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate)
+{
+ if (t == 0.0f)
+ return 1;
+ if (t <= repeat_delay || repeat_rate <= 0.0f)
+ return 0;
+ const int count = (int)((t - repeat_delay) / repeat_rate) - (int)((t_prev - repeat_delay) / repeat_rate);
+ return (count > 0) ? count : 0;
+}
+
+int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate)
+{
+ ImGuiContext& g = *GImGui;
+ if (key_index < 0) return false;
+ IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
+ const float t = g.IO.KeysDownDuration[key_index];
+ return CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, repeat_delay, repeat_rate);
+}
+
+bool ImGui::IsKeyPressed(int user_key_index, bool repeat)
+{
+ ImGuiContext& g = *GImGui;
+ if (user_key_index < 0) return false;
+ IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
+ const float t = g.IO.KeysDownDuration[user_key_index];
+ if (t == 0.0f)
+ return true;
+ if (repeat && t > g.IO.KeyRepeatDelay)
+ return GetKeyPressedAmount(user_key_index, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0;
+ return false;
+}
+
+bool ImGui::IsKeyReleased(int user_key_index)
+{
+ ImGuiContext& g = *GImGui;
+ if (user_key_index < 0) return false;
+ IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
+ return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index];
+}
+
+bool ImGui::IsMouseDown(int button)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ return g.IO.MouseDown[button];
+}
+
+bool ImGui::IsAnyMouseDown()
+{
+ ImGuiContext& g = *GImGui;
+ for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++)
+ if (g.IO.MouseDown[n])
+ return true;
+ return false;
+}
+
+bool ImGui::IsMouseClicked(int button, bool repeat)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ const float t = g.IO.MouseDownDuration[button];
+ if (t == 0.0f)
+ return true;
+
+ if (repeat && t > g.IO.KeyRepeatDelay)
+ {
+ float delay = g.IO.KeyRepeatDelay, rate = g.IO.KeyRepeatRate;
+ if ((ImFmod(t - delay, rate) > rate*0.5f) != (ImFmod(t - delay - g.IO.DeltaTime, rate) > rate*0.5f))
+ return true;
+ }
+
+ return false;
+}
+
+bool ImGui::IsMouseReleased(int button)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ return g.IO.MouseReleased[button];
+}
+
+bool ImGui::IsMouseDoubleClicked(int button)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ return g.IO.MouseDoubleClicked[button];
+}
+
+bool ImGui::IsMouseDragging(int button, float lock_threshold)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ if (!g.IO.MouseDown[button])
+ return false;
+ if (lock_threshold < 0.0f)
+ lock_threshold = g.IO.MouseDragThreshold;
+ return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
+}
+
+ImVec2 ImGui::GetMousePos()
+{
+ return GImGui->IO.MousePos;
+}
+
+// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed!
+ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.BeginPopupStack.Size > 0)
+ return g.OpenPopupStack[g.BeginPopupStack.Size-1].OpenMousePos;
+ return g.IO.MousePos;
+}
+
+// We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position
+bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
+{
+ if (mouse_pos == NULL)
+ mouse_pos = &GImGui->IO.MousePos;
+ const float MOUSE_INVALID = -256000.0f;
+ return mouse_pos->x >= MOUSE_INVALID && mouse_pos->y >= MOUSE_INVALID;
+}
+
+// Return the delta from the initial clicking position.
+// This is locked and return 0.0f until the mouse moves past a distance threshold at least once.
+// NB: This is only valid if IsMousePosValid(). Back-ends in theory should always keep mouse position valid when dragging even outside the client window.
+ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ if (lock_threshold < 0.0f)
+ lock_threshold = g.IO.MouseDragThreshold;
+ if (g.IO.MouseDown[button])
+ if (g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold)
+ return g.IO.MousePos - g.IO.MouseClickedPos[button]; // Assume we can only get active with left-mouse button (at the moment).
+ return ImVec2(0.0f, 0.0f);
+}
+
+void ImGui::ResetMouseDragDelta(int button)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
+ // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr
+ g.IO.MouseClickedPos[button] = g.IO.MousePos;
+}
+
+ImGuiMouseCursor ImGui::GetMouseCursor()
+{
+ return GImGui->MouseCursor;
+}
+
+void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type)
+{
+ GImGui->MouseCursor = cursor_type;
+}
+
+void ImGui::CaptureKeyboardFromApp(bool capture)
+{
+ GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0;
+}
+
+void ImGui::CaptureMouseFromApp(bool capture)
+{
+ GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0;
+}
+
+bool ImGui::IsItemActive()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.ActiveId)
+ {
+ ImGuiWindow* window = g.CurrentWindow;
+ return g.ActiveId == window->DC.LastItemId;
+ }
+ return false;
+}
+
+bool ImGui::IsItemDeactivated()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ return (g.ActiveIdPreviousFrame == window->DC.LastItemId && g.ActiveIdPreviousFrame != 0 && g.ActiveId != window->DC.LastItemId);
+}
+
+bool ImGui::IsItemDeactivatedAfterEdit()
+{
+ ImGuiContext& g = *GImGui;
+ return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEdited || (g.ActiveId == 0 && g.ActiveIdHasBeenEdited));
+}
+
+bool ImGui::IsItemFocused()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ return g.NavId && !g.NavDisableHighlight && g.NavId == window->DC.LastItemId;
+}
+
+bool ImGui::IsItemClicked(int mouse_button)
+{
+ return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None);
+}
+
+bool ImGui::IsAnyItemHovered()
+{
+ ImGuiContext& g = *GImGui;
+ return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0;
+}
+
+bool ImGui::IsAnyItemActive()
+{
+ ImGuiContext& g = *GImGui;
+ return g.ActiveId != 0;
+}
+
+bool ImGui::IsAnyItemFocused()
+{
+ ImGuiContext& g = *GImGui;
+ return g.NavId != 0 && !g.NavDisableHighlight;
+}
+
+bool ImGui::IsItemVisible()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->ClipRect.Overlaps(window->DC.LastItemRect);
+}
+
+bool ImGui::IsItemEdited()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Edited) != 0;
+}
+
+// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority.
+void ImGui::SetItemAllowOverlap()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.HoveredId == g.CurrentWindow->DC.LastItemId)
+ g.HoveredIdAllowOverlap = true;
+ if (g.ActiveId == g.CurrentWindow->DC.LastItemId)
+ g.ActiveIdAllowOverlap = true;
+}
+
+ImVec2 ImGui::GetItemRectMin()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.LastItemRect.Min;
+}
+
+ImVec2 ImGui::GetItemRectMax()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.LastItemRect.Max;
+}
+
+ImVec2 ImGui::GetItemRectSize()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.LastItemRect.GetSize();
+}
+
+static ImRect GetViewportRect()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y)
+ return ImRect(g.IO.DisplayVisibleMin, g.IO.DisplayVisibleMax);
+ return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
+}
+
+static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* parent_window = g.CurrentWindow;
+
+ flags |= ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow;
+ flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
+
+ // Size
+ const ImVec2 content_avail = GetContentRegionAvail();
+ ImVec2 size = ImFloor(size_arg);
+ const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00);
+ if (size.x <= 0.0f)
+ size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues)
+ if (size.y <= 0.0f)
+ size.y = ImMax(content_avail.y + size.y, 4.0f);
+ SetNextWindowSize(size);
+
+ // Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value.
+ char title[256];
+ if (name)
+ ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s_%08X", parent_window->Name, name, id);
+ else
+ ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id);
+
+ const float backup_border_size = g.Style.ChildBorderSize;
+ if (!border)
+ g.Style.ChildBorderSize = 0.0f;
+ bool ret = Begin(title, NULL, flags);
+ g.Style.ChildBorderSize = backup_border_size;
+
+ ImGuiWindow* child_window = g.CurrentWindow;
+ child_window->ChildId = id;
+ child_window->AutoFitChildAxises = auto_fit_axises;
+
+ // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually.
+ // While this is not really documented/defined, it seems that the expected thing to do.
+ parent_window->DC.CursorPos = child_window->Pos;
+
+ // Process navigation-in immediately so NavInit can run on first frame
+ if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll))
+ {
+ FocusWindow(child_window);
+ NavInitWindow(child_window, false);
+ SetActiveID(id+1, child_window); // Steal ActiveId with a dummy id so that key-press won't activate child item
+ g.ActiveIdSource = ImGuiInputSource_Nav;
+ }
+ return ret;
+}
+
+bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
+}
+
+bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
+{
+ IM_ASSERT(id != 0);
+ return BeginChildEx(NULL, id, size_arg, border, extra_flags);
+}
+
+void ImGui::EndChild()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() callss
+ if (window->BeginCount > 1)
+ {
+ End();
+ }
+ else
+ {
+ ImVec2 sz = window->Size;
+ if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f
+ sz.x = ImMax(4.0f, sz.x);
+ if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y))
+ sz.y = ImMax(4.0f, sz.y);
+ End();
+
+ ImGuiWindow* parent_window = g.CurrentWindow;
+ ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz);
+ ItemSize(sz);
+ if ((window->DC.NavLayerActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened))
+ {
+ ItemAdd(bb, window->ChildId);
+ RenderNavHighlight(bb, window->ChildId);
+
+ // When browsing a window that has no activable items (scroll only) we keep a highlight on the child
+ if (window->DC.NavLayerActiveMask == 0 && window == g.NavWindow)
+ RenderNavHighlight(ImRect(bb.Min - ImVec2(2,2), bb.Max + ImVec2(2,2)), g.NavId, ImGuiNavHighlightFlags_TypeThin);
+ }
+ else
+ {
+ // Not navigable into
+ ItemAdd(bb, 0);
+ }
+ }
+}
+
+// Helper to create a child window / scrolling region that looks like a normal widget frame.
+bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
+{
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
+ PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
+ PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
+ PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
+ bool ret = BeginChild(id, size, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags);
+ PopStyleVar(3);
+ PopStyleColor();
+ return ret;
+}
+
+void ImGui::EndChildFrame()
+{
+ EndChild();
+}
+
+// Save and compare stack sizes on Begin()/End() to detect usage errors
+static void CheckStacksSize(ImGuiWindow* window, bool write)
+{
+ // NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin)
+ ImGuiContext& g = *GImGui;
+ short* p_backup = &window->DC.StackSizesBackup[0];
+ { int current = window->IDStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "PushID/PopID or TreeNode/TreePop Mismatch!"); p_backup++; } // Too few or too many PopID()/TreePop()
+ { int current = window->DC.GroupStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "BeginGroup/EndGroup Mismatch!"); p_backup++; } // Too few or too many EndGroup()
+ { int current = g.BeginPopupStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch"); p_backup++;}// Too few or too many EndMenu()/EndPopup()
+ // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them.
+ { int current = g.ColorModifiers.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushStyleColor/PopStyleColor Mismatch!"); p_backup++; } // Too few or too many PopStyleColor()
+ { int current = g.StyleModifiers.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushStyleVar/PopStyleVar Mismatch!"); p_backup++; } // Too few or too many PopStyleVar()
+ { int current = g.FontStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushFont/PopFont Mismatch!"); p_backup++; } // Too few or too many PopFont()
+ IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup));
+}
+
+static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
+{
+ window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags);
+ window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags);
+ window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags);
+}
+
+ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id);
+}
+
+ImGuiWindow* ImGui::FindWindowByName(const char* name)
+{
+ ImGuiID id = ImHash(name, 0);
+ return FindWindowByID(id);
+}
+
+static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+
+ // Create window the first time
+ ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name);
+ window->Flags = flags;
+ g.WindowsById.SetVoidPtr(window->ID, window);
+
+ // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
+ window->Pos = ImVec2(60, 60);
+
+ // User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
+ if (!(flags & ImGuiWindowFlags_NoSavedSettings))
+ if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
+ {
+ // Retrieve settings from .ini file
+ window->SettingsIdx = g.SettingsWindows.index_from_ptr(settings);
+ SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
+ window->Pos = ImFloor(settings->Pos);
+ window->Collapsed = settings->Collapsed;
+ if (ImLengthSqr(settings->Size) > 0.00001f)
+ size = ImFloor(settings->Size);
+ }
+ window->Size = window->SizeFull = window->SizeFullAtLastBegin = ImFloor(size);
+ window->DC.CursorMaxPos = window->Pos; // So first call to CalcSizeContents() doesn't return crazy values
+
+ if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
+ {
+ window->AutoFitFramesX = window->AutoFitFramesY = 2;
+ window->AutoFitOnlyGrows = false;
+ }
+ else
+ {
+ if (window->Size.x <= 0.0f)
+ window->AutoFitFramesX = 2;
+ if (window->Size.y <= 0.0f)
+ window->AutoFitFramesY = 2;
+ window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
+ }
+
+ g.WindowsFocusOrder.push_back(window);
+ if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
+ g.Windows.push_front(window); // Quite slow but rare and only once
+ else
+ g.Windows.push_back(window);
+ return window;
+}
+
+static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NextWindowData.SizeConstraintCond != 0)
+ {
+ // Using -1,-1 on either X/Y axis to preserve the current size.
+ ImRect cr = g.NextWindowData.SizeConstraintRect;
+ new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x;
+ new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y;
+ if (g.NextWindowData.SizeCallback)
+ {
+ ImGuiSizeCallbackData data;
+ data.UserData = g.NextWindowData.SizeCallbackUserData;
+ data.Pos = window->Pos;
+ data.CurrentSize = window->SizeFull;
+ data.DesiredSize = new_size;
+ g.NextWindowData.SizeCallback(&data);
+ new_size = data.DesiredSize;
+ }
+ }
+
+ // Minimum size
+ if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
+ {
+ new_size = ImMax(new_size, g.Style.WindowMinSize);
+ new_size.y = ImMax(new_size.y, window->TitleBarHeight() + window->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
+ }
+ return new_size;
+}
+
+static ImVec2 CalcSizeContents(ImGuiWindow* window)
+{
+ if (window->Collapsed)
+ return window->SizeContents;
+ if (window->Hidden && window->HiddenFramesForResize == 0 && window->HiddenFramesRegular > 0)
+ return window->SizeContents;
+
+ ImVec2 sz;
+ sz.x = (float)(int)((window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : (window->DC.CursorMaxPos.x - window->Pos.x + window->Scroll.x));
+ sz.y = (float)(int)((window->SizeContentsExplicit.y != 0.0f) ? window->SizeContentsExplicit.y : (window->DC.CursorMaxPos.y - window->Pos.y + window->Scroll.y));
+ return sz + window->WindowPadding;
+}
+
+static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiStyle& style = g.Style;
+ if (window->Flags & ImGuiWindowFlags_Tooltip)
+ {
+ // Tooltip always resize
+ return size_contents;
+ }
+ else
+ {
+ // When the window cannot fit all contents (either because of constraints, either because screen is too small): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding.
+ const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0;
+ const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0;
+ ImVec2 size_min = style.WindowMinSize;
+ if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
+ size_min = ImMin(size_min, ImVec2(4.0f, 4.0f));
+ ImVec2 size_auto_fit = ImClamp(size_contents, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f));
+ ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit);
+ if (size_auto_fit_after_constraint.x < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar))
+ size_auto_fit.y += style.ScrollbarSize;
+ if (size_auto_fit_after_constraint.y < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar))
+ size_auto_fit.x += style.ScrollbarSize;
+ return size_auto_fit;
+ }
+}
+
+ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window)
+{
+ ImVec2 size_contents = CalcSizeContents(window);
+ return CalcSizeAfterConstraint(window, CalcSizeAutoFit(window, size_contents));
+}
+
+float ImGui::GetWindowScrollMaxX(ImGuiWindow* window)
+{
+ return ImMax(0.0f, window->SizeContents.x - (window->SizeFull.x - window->ScrollbarSizes.x));
+}
+
+float ImGui::GetWindowScrollMaxY(ImGuiWindow* window)
+{
+ return ImMax(0.0f, window->SizeContents.y - (window->SizeFull.y - window->ScrollbarSizes.y));
+}
+
+static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges)
+{
+ ImGuiContext& g = *GImGui;
+ ImVec2 scroll = window->Scroll;
+ if (window->ScrollTarget.x < FLT_MAX)
+ {
+ float cr_x = window->ScrollTargetCenterRatio.x;
+ scroll.x = window->ScrollTarget.x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x);
+ }
+ if (window->ScrollTarget.y < FLT_MAX)
+ {
+ // 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding.
+ float cr_y = window->ScrollTargetCenterRatio.y;
+ float target_y = window->ScrollTarget.y;
+ if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y)
+ target_y = 0.0f;
+ if (snap_on_edges && cr_y >= 1.0f && target_y >= window->SizeContents.y - window->WindowPadding.y + g.Style.ItemSpacing.y)
+ target_y = window->SizeContents.y;
+ scroll.y = target_y - (1.0f - cr_y) * (window->TitleBarHeight() + window->MenuBarHeight()) - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y);
+ }
+ scroll = ImMax(scroll, ImVec2(0.0f, 0.0f));
+ if (!window->Collapsed && !window->SkipItems)
+ {
+ scroll.x = ImMin(scroll.x, ImGui::GetWindowScrollMaxX(window));
+ scroll.y = ImMin(scroll.y, ImGui::GetWindowScrollMaxY(window));
+ }
+ return scroll;
+}
+
+static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
+{
+ if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
+ return ImGuiCol_PopupBg;
+ if (flags & ImGuiWindowFlags_ChildWindow)
+ return ImGuiCol_ChildBg;
+ return ImGuiCol_WindowBg;
+}
+
+static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size)
+{
+ ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left
+ ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right
+ ImVec2 size_expected = pos_max - pos_min;
+ ImVec2 size_constrained = CalcSizeAfterConstraint(window, size_expected);
+ *out_pos = pos_min;
+ if (corner_norm.x == 0.0f)
+ out_pos->x -= (size_constrained.x - size_expected.x);
+ if (corner_norm.y == 0.0f)
+ out_pos->y -= (size_constrained.y - size_expected.y);
+ *out_size = size_constrained;
+}
+
+struct ImGuiResizeGripDef
+{
+ ImVec2 CornerPos;
+ ImVec2 InnerDir;
+ int AngleMin12, AngleMax12;
+};
+
+const ImGuiResizeGripDef resize_grip_def[4] =
+{
+ { ImVec2(1,1), ImVec2(-1,-1), 0, 3 }, // Lower right
+ { ImVec2(0,1), ImVec2(+1,-1), 3, 6 }, // Lower left
+ { ImVec2(0,0), ImVec2(+1,+1), 6, 9 }, // Upper left
+ { ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper right
+};
+
+static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness)
+{
+ ImRect rect = window->Rect();
+ if (thickness == 0.0f) rect.Max -= ImVec2(1,1);
+ if (border_n == 0) return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness);
+ if (border_n == 1) return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding);
+ if (border_n == 2) return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness);
+ if (border_n == 3) return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding);
+ IM_ASSERT(0);
+ return ImRect();
+}
+
+// Handle resize for: Resize Grips, Borders, Gamepad
+static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4])
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindowFlags flags = window->Flags;
+ if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
+ return;
+ if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit/fallback Debug window.
+ return;
+
+ const int resize_border_count = g.IO.ConfigWindowsResizeFromEdges ? 4 : 0;
+ const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
+ const float grip_hover_inner_size = (float)(int)(grip_draw_size * 0.75f);
+ const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS : 0.0f;
+
+ ImVec2 pos_target(FLT_MAX, FLT_MAX);
+ ImVec2 size_target(FLT_MAX, FLT_MAX);
+
+ // Manual resize grips
+ PushID("#RESIZE");
+ for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
+ {
+ const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n];
+ const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPos);
+
+ // Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
+ ImRect resize_rect(corner - grip.InnerDir * grip_hover_outer_size, corner + grip.InnerDir * grip_hover_inner_size);
+ if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x);
+ if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
+ bool hovered, held;
+ ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
+ //GetOverlayDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
+ if (hovered || held)
+ g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
+
+ if (held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0)
+ {
+ // Manual auto-fit when double-clicking
+ size_target = CalcSizeAfterConstraint(window, size_auto_fit);
+ ClearActiveID();
+ }
+ else if (held)
+ {
+ // Resize from any of the four corners
+ // We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
+ ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(grip.InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip.CornerPos); // Corner of the window corresponding to our corner grip
+ CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPos, &pos_target, &size_target);
+ }
+ if (resize_grip_n == 0 || held || hovered)
+ resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
+ }
+ for (int border_n = 0; border_n < resize_border_count; border_n++)
+ {
+ bool hovered, held;
+ ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS);
+ ButtonBehavior(border_rect, window->GetID((void*)(intptr_t)(border_n + 4)), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
+ //GetOverlayDrawList(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
+ if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held)
+ {
+ g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
+ if (held) *border_held = border_n;
+ }
+ if (held)
+ {
+ ImVec2 border_target = window->Pos;
+ ImVec2 border_posn;
+ if (border_n == 0) { border_posn = ImVec2(0, 0); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); }
+ if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); }
+ if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); }
+ if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); }
+ CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target);
+ }
+ }
+ PopID();
+
+ // Navigation resize (keyboard/gamepad)
+ if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window)
+ {
+ ImVec2 nav_resize_delta;
+ if (g.NavInputSource == ImGuiInputSource_NavKeyboard && g.IO.KeyShift)
+ nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
+ if (g.NavInputSource == ImGuiInputSource_NavGamepad)
+ nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down);
+ if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f)
+ {
+ const float NAV_RESIZE_SPEED = 600.0f;
+ nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
+ g.NavWindowingToggleLayer = false;
+ g.NavDisableMouseHover = true;
+ resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive);
+ // FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck.
+ size_target = CalcSizeAfterConstraint(window, window->SizeFull + nav_resize_delta);
+ }
+ }
+
+ // Apply back modified position/size to window
+ if (size_target.x != FLT_MAX)
+ {
+ window->SizeFull = size_target;
+ MarkIniSettingsDirty(window);
+ }
+ if (pos_target.x != FLT_MAX)
+ {
+ window->Pos = ImFloor(pos_target);
+ MarkIniSettingsDirty(window);
+ }
+
+ window->Size = window->SizeFull;
+}
+
+void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window)
+{
+ window->ParentWindow = parent_window;
+ window->RootWindow = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window;
+ if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip))
+ window->RootWindow = parent_window->RootWindow;
+ if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
+ window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight;
+ while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened)
+ window->RootWindowForNav = window->RootWindowForNav->ParentWindow;
+}
+
+// Push a new ImGui window to add widgets to.
+// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair.
+// - Begin/End can be called multiple times during the frame with the same window name to append content.
+// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file).
+// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
+// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
+// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
+bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required
+ IM_ASSERT(g.FrameScopeActive); // Forgot to call ImGui::NewFrame()
+ IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet
+
+ // Find or create
+ ImGuiWindow* window = FindWindowByName(name);
+ const bool window_just_created = (window == NULL);
+ if (window_just_created)
+ {
+ ImVec2 size_on_first_use = (g.NextWindowData.SizeCond != 0) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here.
+ window = CreateNewWindow(name, size_on_first_use, flags);
+ }
+
+ // Automatically disable manual moving/resizing when NoInputs is set
+ if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs)
+ flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
+
+ if (flags & ImGuiWindowFlags_NavFlattened)
+ IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow);
+
+ const int current_frame = g.FrameCount;
+ const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
+
+ // Update Flags, LastFrameActive, BeginOrderXXX fields
+ if (first_begin_of_the_frame)
+ window->Flags = (ImGuiWindowFlags)flags;
+ else
+ flags = window->Flags;
+
+ // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
+ ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
+ ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow;
+ IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow));
+ window->HasCloseButton = (p_open != NULL);
+
+ // Update the Appearing flag
+ bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
+ const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesForResize > 0);
+ if (flags & ImGuiWindowFlags_Popup)
+ {
+ ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size];
+ window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed
+ window_just_activated_by_user |= (window != popup_ref.Window);
+ }
+ window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize);
+ if (window->Appearing)
+ SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true);
+
+ // Add to stack
+ g.CurrentWindowStack.push_back(window);
+ SetCurrentWindow(window);
+ CheckStacksSize(window, true);
+ if (flags & ImGuiWindowFlags_Popup)
+ {
+ ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size];
+ popup_ref.Window = window;
+ g.BeginPopupStack.push_back(popup_ref);
+ window->PopupId = popup_ref.PopupId;
+ }
+
+ if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow))
+ window->NavLastIds[0] = 0;
+
+ // Process SetNextWindow***() calls
+ bool window_pos_set_by_api = false;
+ bool window_size_x_set_by_api = false, window_size_y_set_by_api = false;
+ if (g.NextWindowData.PosCond)
+ {
+ window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0;
+ if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f)
+ {
+ // May be processed on the next frame if this is our first frame and we are measuring size
+ // FIXME: Look into removing the branch so everything can go through this same code path for consistency.
+ window->SetWindowPosVal = g.NextWindowData.PosVal;
+ window->SetWindowPosPivot = g.NextWindowData.PosPivotVal;
+ window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
+ }
+ else
+ {
+ SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond);
+ }
+ }
+ if (g.NextWindowData.SizeCond)
+ {
+ window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f);
+ window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
+ SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
+ }
+ if (g.NextWindowData.ContentSizeCond)
+ {
+ // Adjust passed "client size" to become a "window size"
+ window->SizeContentsExplicit = g.NextWindowData.ContentSizeVal;
+ if (window->SizeContentsExplicit.y != 0.0f)
+ window->SizeContentsExplicit.y += window->TitleBarHeight() + window->MenuBarHeight();
+ }
+ else if (first_begin_of_the_frame)
+ {
+ window->SizeContentsExplicit = ImVec2(0.0f, 0.0f);
+ }
+ if (g.NextWindowData.CollapsedCond)
+ SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
+ if (g.NextWindowData.FocusCond)
+ FocusWindow(window);
+ if (window->Appearing)
+ SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
+
+ // When reusing window again multiple times a frame, just append content (don't need to setup again)
+ if (first_begin_of_the_frame)
+ {
+ // Initialize
+ const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
+ UpdateWindowParentAndRootLinks(window, flags, parent_window);
+
+ window->Active = true;
+ window->BeginOrderWithinParent = 0;
+ window->BeginOrderWithinContext = (short)(g.WindowsActiveCount++);
+ window->BeginCount = 0;
+ window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
+ window->LastFrameActive = current_frame;
+ window->IDStack.resize(1);
+
+ // Update stored window name when it changes (which can _only_ happen with the "###" operator, so the ID would stay unchanged).
+ // The title bar always display the 'name' parameter, so we only update the string storage if it needs to be visible to the end-user elsewhere.
+ bool window_title_visible_elsewhere = false;
+ if (g.NavWindowingList != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB
+ window_title_visible_elsewhere = true;
+ if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0)
+ {
+ size_t buf_len = (size_t)window->NameBufLen;
+ window->Name = ImStrdupcpy(window->Name, &buf_len, name);
+ window->NameBufLen = (int)buf_len;
+ }
+
+ // UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS
+
+ // Update contents size from last frame for auto-fitting (or use explicit size)
+ window->SizeContents = CalcSizeContents(window);
+ if (window->HiddenFramesRegular > 0)
+ window->HiddenFramesRegular--;
+ if (window->HiddenFramesForResize > 0)
+ window->HiddenFramesForResize--;
+
+ // Hide new windows for one frame until they calculate their size
+ if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
+ window->HiddenFramesForResize = 1;
+
+ // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
+ // We reset Size/SizeContents for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size.
+ if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0)
+ {
+ window->HiddenFramesForResize = 1;
+ if (flags & ImGuiWindowFlags_AlwaysAutoResize)
+ {
+ if (!window_size_x_set_by_api)
+ window->Size.x = window->SizeFull.x = 0.f;
+ if (!window_size_y_set_by_api)
+ window->Size.y = window->SizeFull.y = 0.f;
+ window->SizeContents = ImVec2(0.f, 0.f);
+ }
+ }
+
+ SetCurrentWindow(window);
+
+ // Lock border size and padding for the frame (so that altering them doesn't cause inconsistencies)
+ window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildBorderSize : ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
+ window->WindowPadding = style.WindowPadding;
+ if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
+ window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
+ window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
+ window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
+
+ // Collapse window by double-clicking on title bar
+ // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
+ if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse))
+ {
+ // We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar.
+ ImRect title_bar_rect = window->TitleBarRect();
+ if (g.HoveredWindow == window && g.HoveredId == 0 && g.HoveredIdPreviousFrame == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0])
+ window->WantCollapseToggle = true;
+ if (window->WantCollapseToggle)
+ {
+ window->Collapsed = !window->Collapsed;
+ MarkIniSettingsDirty(window);
+ FocusWindow(window);
+ }
+ }
+ else
+ {
+ window->Collapsed = false;
+ }
+ window->WantCollapseToggle = false;
+
+ // SIZE
+
+ // Calculate auto-fit size, handle automatic resize
+ const ImVec2 size_auto_fit = CalcSizeAutoFit(window, window->SizeContents);
+ ImVec2 size_full_modified(FLT_MAX, FLT_MAX);
+ if ((flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed)
+ {
+ // Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc.
+ if (!window_size_x_set_by_api)
+ window->SizeFull.x = size_full_modified.x = size_auto_fit.x;
+ if (!window_size_y_set_by_api)
+ window->SizeFull.y = size_full_modified.y = size_auto_fit.y;
+ }
+ else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
+ {
+ // Auto-fit may only grow window during the first few frames
+ // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed.
+ if (!window_size_x_set_by_api && window->AutoFitFramesX > 0)
+ window->SizeFull.x = size_full_modified.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x;
+ if (!window_size_y_set_by_api && window->AutoFitFramesY > 0)
+ window->SizeFull.y = size_full_modified.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y;
+ if (!window->Collapsed)
+ MarkIniSettingsDirty(window);
+ }
+
+ // Apply minimum/maximum window size constraints and final size
+ window->SizeFull = CalcSizeAfterConstraint(window, window->SizeFull);
+ window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull;
+
+ // SCROLLBAR STATUS
+
+ // Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size).
+ if (!window->Collapsed)
+ {
+ // When reading the current size we need to read it after size constraints have been applied
+ float size_x_for_scrollbars = size_full_modified.x != FLT_MAX ? window->SizeFull.x : window->SizeFullAtLastBegin.x;
+ float size_y_for_scrollbars = size_full_modified.y != FLT_MAX ? window->SizeFull.y : window->SizeFullAtLastBegin.y;
+ window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar));
+ window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
+ if (window->ScrollbarX && !window->ScrollbarY)
+ window->ScrollbarY = (window->SizeContents.y > size_y_for_scrollbars - style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar);
+ window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);
+ }
+
+ // POSITION
+
+ // Popup latch its initial position, will position itself when it appears next frame
+ if (window_just_activated_by_user)
+ {
+ window->AutoPosLastDirection = ImGuiDir_None;
+ if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
+ window->Pos = g.BeginPopupStack.back().OpenPopupPos;
+ }
+
+ // Position child window
+ if (flags & ImGuiWindowFlags_ChildWindow)
+ {
+ IM_ASSERT(parent_window->Active);
+ window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size;
+ parent_window->DC.ChildWindows.push_back(window);
+ if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip)
+ window->Pos = parent_window->DC.CursorPos;
+ }
+
+ const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesForResize == 0);
+ if (window_pos_with_pivot)
+ SetWindowPos(window, ImMax(style.DisplaySafeAreaPadding, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot), 0); // Position given a pivot (e.g. for centering)
+ else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
+ window->Pos = FindBestWindowPosForPopup(window);
+ else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
+ window->Pos = FindBestWindowPosForPopup(window);
+ else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
+ window->Pos = FindBestWindowPosForPopup(window);
+
+ // Clamp position so it stays visible
+ if (!(flags & ImGuiWindowFlags_ChildWindow))
+ {
+ if (!window_pos_set_by_api && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && g.IO.DisplaySize.x > 0.0f && g.IO.DisplaySize.y > 0.0f) // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
+ {
+ ImVec2 padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
+ ImVec2 size_for_clamping = ((g.IO.ConfigWindowsMoveFromTitleBarOnly) && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) ? ImVec2(window->Size.x, window->TitleBarHeight()) : window->Size;
+ window->Pos = ImMax(window->Pos + size_for_clamping, padding) - size_for_clamping;
+ window->Pos = ImMin(window->Pos, g.IO.DisplaySize - padding);
+ }
+ }
+ window->Pos = ImFloor(window->Pos);
+
+ // Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
+ window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
+
+ // Prepare for item focus requests
+ window->FocusIdxAllRequestCurrent = (window->FocusIdxAllRequestNext == INT_MAX || window->FocusIdxAllCounter == -1) ? INT_MAX : (window->FocusIdxAllRequestNext + (window->FocusIdxAllCounter+1)) % (window->FocusIdxAllCounter+1);
+ window->FocusIdxTabRequestCurrent = (window->FocusIdxTabRequestNext == INT_MAX || window->FocusIdxTabCounter == -1) ? INT_MAX : (window->FocusIdxTabRequestNext + (window->FocusIdxTabCounter+1)) % (window->FocusIdxTabCounter+1);
+ window->FocusIdxAllCounter = window->FocusIdxTabCounter = -1;
+ window->FocusIdxAllRequestNext = window->FocusIdxTabRequestNext = INT_MAX;
+
+ // Apply scrolling
+ window->Scroll = CalcNextScrollFromScrollTargetAndClamp(window, true);
+ window->ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
+
+ // Apply window focus (new and reactivated windows are moved to front)
+ bool want_focus = false;
+ if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
+ if (!(flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) || (flags & ImGuiWindowFlags_Popup))
+ want_focus = true;
+
+ // Handle manual resize: Resize Grips, Borders, Gamepad
+ int border_held = -1;
+ ImU32 resize_grip_col[4] = { 0 };
+ const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // 4
+ const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
+ if (!window->Collapsed)
+ UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]);
+
+ // Default item width. Make it proportional to window size if window manually resizes
+ if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
+ window->ItemWidthDefault = (float)(int)(window->Size.x * 0.65f);
+ else
+ window->ItemWidthDefault = (float)(int)(g.FontSize * 16.0f);
+
+ // DRAWING
+
+ // Setup draw list and outer clipping rectangle
+ window->DrawList->Clear();
+ window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
+ window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
+ ImRect viewport_rect(GetViewportRect());
+ if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip)
+ PushClipRect(parent_window->ClipRect.Min, parent_window->ClipRect.Max, true);
+ else
+ PushClipRect(viewport_rect.Min, viewport_rect.Max, true);
+
+ // Draw modal window background (darkens what is behind them, all viewports)
+ const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetFrontMostPopupModal() && window->HiddenFramesForResize <= 0;
+ const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && (window == g.NavWindowingTargetAnim->RootWindow);
+ if (dim_bg_for_modal || dim_bg_for_window_list)
+ {
+ const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
+ window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, dim_bg_col);
+ }
+
+ // Draw navigation selection/windowing rectangle background
+ if (dim_bg_for_window_list && window == g.NavWindowingTargetAnim)
+ {
+ ImRect bb = window->Rect();
+ bb.Expand(g.FontSize);
+ if (!bb.Contains(viewport_rect)) // Avoid drawing if the window covers all the viewport anyway
+ window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding);
+ }
+
+ // Draw window + handle manual resize
+ const float window_rounding = window->WindowRounding;
+ const float window_border_size = window->WindowBorderSize;
+ const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow;
+ const bool title_bar_is_highlight = want_focus || (window_to_highlight && window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight);
+ const ImRect title_bar_rect = window->TitleBarRect();
+ if (window->Collapsed)
+ {
+ // Title bar only
+ float backup_border_size = style.FrameBorderSize;
+ g.Style.FrameBorderSize = window->WindowBorderSize;
+ ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed);
+ RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding);
+ g.Style.FrameBorderSize = backup_border_size;
+ }
+ else
+ {
+ // Window background
+ if (!(flags & ImGuiWindowFlags_NoBackground))
+ {
+ ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
+ if (g.NextWindowData.BgAlphaCond != 0)
+ bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(g.NextWindowData.BgAlphaVal) << IM_COL32_A_SHIFT);
+ window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
+ }
+ g.NextWindowData.BgAlphaCond = 0;
+
+ // Title bar
+ if (!(flags & ImGuiWindowFlags_NoTitleBar))
+ {
+ ImU32 title_bar_col = GetColorU32(window->Collapsed ? ImGuiCol_TitleBgCollapsed : title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
+ window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawCornerFlags_Top);
+ }
+
+ // Menu bar
+ if (flags & ImGuiWindowFlags_MenuBar)
+ {
+ ImRect menu_bar_rect = window->MenuBarRect();
+ menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them.
+ window->DrawList->AddRectFilled(menu_bar_rect.Min, menu_bar_rect.Max, GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawCornerFlags_Top);
+ if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y)
+ window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
+ }
+
+ // Scrollbars
+ if (window->ScrollbarX)
+ Scrollbar(ImGuiLayoutType_Horizontal);
+ if (window->ScrollbarY)
+ Scrollbar(ImGuiLayoutType_Vertical);
+
+ // Render resize grips (after their input handling so we don't have a frame of latency)
+ if (!(flags & ImGuiWindowFlags_NoResize))
+ {
+ for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
+ {
+ const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n];
+ const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPos);
+ window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, grip_draw_size) : ImVec2(grip_draw_size, window_border_size)));
+ window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(grip_draw_size, window_border_size) : ImVec2(window_border_size, grip_draw_size)));
+ window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12);
+ window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]);
+ }
+ }
+
+ // Borders
+ if (window_border_size > 0.0f && !(flags & ImGuiWindowFlags_NoBackground))
+ window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), window_rounding, ImDrawCornerFlags_All, window_border_size);
+ if (border_held != -1)
+ {
+ ImRect border = GetResizeBorderRect(window, border_held, grip_draw_size, 0.0f);
+ window->DrawList->AddLine(border.Min, border.Max, GetColorU32(ImGuiCol_SeparatorActive), ImMax(1.0f, window_border_size));
+ }
+ if (style.FrameBorderSize > 0 && !(flags & ImGuiWindowFlags_NoTitleBar))
+ window->DrawList->AddLine(title_bar_rect.GetBL() + ImVec2(style.WindowBorderSize, -1), title_bar_rect.GetBR() + ImVec2(-style.WindowBorderSize, -1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
+ }
+
+ // Draw navigation selection/windowing rectangle border
+ if (g.NavWindowingTargetAnim == window)
+ {
+ float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
+ ImRect bb = window->Rect();
+ bb.Expand(g.FontSize);
+ if (bb.Contains(viewport_rect)) // If a window fits the entire viewport, adjust its highlight inward
+ {
+ bb.Expand(-g.FontSize - 1.0f);
+ rounding = window->WindowRounding;
+ }
+ window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f);
+ }
+
+ // Store a backup of SizeFull which we will use next frame to decide if we need scrollbars.
+ window->SizeFullAtLastBegin = window->SizeFull;
+
+ // Update various regions. Variables they depends on are set above in this function.
+ // FIXME: window->ContentsRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
+ window->ContentsRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
+ window->ContentsRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + window->TitleBarHeight() + window->MenuBarHeight();
+ window->ContentsRegionRect.Max.x = window->Pos.x - window->Scroll.x - window->WindowPadding.x + (window->SizeContentsExplicit.x != 0.0f ? window->SizeContentsExplicit.x : (window->Size.x - window->ScrollbarSizes.x));
+ window->ContentsRegionRect.Max.y = window->Pos.y - window->Scroll.y - window->WindowPadding.y + (window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : (window->Size.y - window->ScrollbarSizes.y));
+
+ // Setup drawing context
+ // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.)
+ window->DC.Indent.x = 0.0f + window->WindowPadding.x - window->Scroll.x;
+ window->DC.GroupOffset.x = 0.0f;
+ window->DC.ColumnsOffset.x = 0.0f;
+ window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.Indent.x + window->DC.ColumnsOffset.x, window->TitleBarHeight() + window->MenuBarHeight() + window->WindowPadding.y - window->Scroll.y);
+ window->DC.CursorPos = window->DC.CursorStartPos;
+ window->DC.CursorPosPrevLine = window->DC.CursorPos;
+ window->DC.CursorMaxPos = window->DC.CursorStartPos;
+ window->DC.CurrentLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f);
+ window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
+ window->DC.NavHideHighlightOneFrame = false;
+ window->DC.NavHasScroll = (GetWindowScrollMaxY(window) > 0.0f);
+ window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext;
+ window->DC.NavLayerActiveMaskNext = 0x00;
+ window->DC.MenuBarAppending = false;
+ window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f;
+ window->DC.ChildWindows.resize(0);
+ window->DC.LayoutType = ImGuiLayoutType_Vertical;
+ window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical;
+ window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_;
+ window->DC.ItemWidth = window->ItemWidthDefault;
+ window->DC.TextWrapPos = -1.0f; // disabled
+ window->DC.ItemFlagsStack.resize(0);
+ window->DC.ItemWidthStack.resize(0);
+ window->DC.TextWrapPosStack.resize(0);
+ window->DC.ColumnsSet = NULL;
+ window->DC.TreeDepth = 0;
+ window->DC.TreeDepthMayJumpToParentOnPop = 0x00;
+ window->DC.StateStorage = &window->StateStorage;
+ window->DC.GroupStack.resize(0);
+ window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
+
+ if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags))
+ {
+ window->DC.ItemFlags = parent_window->DC.ItemFlags;
+ window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags);
+ }
+
+ if (window->AutoFitFramesX > 0)
+ window->AutoFitFramesX--;
+ if (window->AutoFitFramesY > 0)
+ window->AutoFitFramesY--;
+
+ // Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there)
+ if (want_focus)
+ {
+ FocusWindow(window);
+ NavInitWindow(window, false);
+ }
+
+ // Title bar
+ if (!(flags & ImGuiWindowFlags_NoTitleBar))
+ {
+ // Close & collapse button are on layer 1 (same as menus) and don't default focus
+ const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags;
+ window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus;
+ window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
+ window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
+
+ // Collapse button
+ if (!(flags & ImGuiWindowFlags_NoCollapse))
+ if (CollapseButton(window->GetID("#COLLAPSE"), window->Pos))
+ window->WantCollapseToggle = true; // Defer collapsing to next frame as we are too far in the Begin() function
+
+ // Close button
+ if (p_open != NULL)
+ {
+ const float pad = style.FramePadding.y;
+ const float rad = g.FontSize * 0.5f;
+ if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-pad - rad, pad + rad), rad + 1))
+ *p_open = false;
+ }
+
+ window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
+ window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
+ window->DC.ItemFlags = item_flags_backup;
+
+ // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker)
+ // FIXME: Refactor text alignment facilities along with RenderText helpers, this is too much code..
+ const char* UNSAVED_DOCUMENT_MARKER = "*";
+ float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f;
+ ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f);
+ ImRect text_r = title_bar_rect;
+ float pad_left = (flags & ImGuiWindowFlags_NoCollapse) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x);
+ float pad_right = (p_open == NULL) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x);
+ if (style.WindowTitleAlign.x > 0.0f)
+ pad_right = ImLerp(pad_right, pad_left, style.WindowTitleAlign.x);
+ text_r.Min.x += pad_left;
+ text_r.Max.x -= pad_right;
+ ImRect clip_rect = text_r;
+ clip_rect.Max.x = window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x); // Match the size of CloseButton()
+ RenderTextClipped(text_r.Min, text_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_rect);
+ if (flags & ImGuiWindowFlags_UnsavedDocument)
+ {
+ ImVec2 marker_pos = ImVec2(ImMax(text_r.Min.x, text_r.Min.x + (text_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, text_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f);
+ ImVec2 off = ImVec2(0.0f, (float)(int)(-g.FontSize * 0.25f));
+ RenderTextClipped(marker_pos + off, text_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_rect);
+ }
+ }
+
+ // Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
+ window->OuterRectClipped = window->Rect();
+ window->OuterRectClipped.ClipWith(window->ClipRect);
+
+ // Pressing CTRL+C while holding on a window copy its content to the clipboard
+ // This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope.
+ // Maybe we can support CTRL+C on every element?
+ /*
+ if (g.ActiveId == move_id)
+ if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C))
+ LogToClipboard();
+ */
+
+ // Inner rectangle
+ // We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
+ // Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior.
+ window->InnerMainRect.Min.x = title_bar_rect.Min.x + window->WindowBorderSize;
+ window->InnerMainRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight() + (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize);
+ window->InnerMainRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x - window->WindowBorderSize;
+ window->InnerMainRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y - window->WindowBorderSize;
+ //window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE);
+
+ // Inner clipping rectangle
+ // Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
+ window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerMainRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - window->WindowBorderSize)));
+ window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerMainRect.Min.y);
+ window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerMainRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - window->WindowBorderSize)));
+ window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerMainRect.Max.y);
+
+ // After Begin() we fill the last item / hovered data based on title bar data. It is a standard behavior (to allow creation of context menus on title bar only, etc.).
+ window->DC.LastItemId = window->MoveId;
+ window->DC.LastItemStatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
+ window->DC.LastItemRect = title_bar_rect;
+ }
+
+ PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
+
+ // Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
+ if (first_begin_of_the_frame)
+ window->WriteAccessed = false;
+
+ window->BeginCount++;
+ g.NextWindowData.Clear();
+
+ if (flags & ImGuiWindowFlags_ChildWindow)
+ {
+ // Child window can be out of sight and have "negative" clip windows.
+ // Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar).
+ IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0);
+
+ if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
+ if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y)
+ window->HiddenFramesRegular = 1;
+
+ // Completely hide along with parent or if parent is collapsed
+ if (parent_window && (parent_window->Collapsed || parent_window->Hidden))
+ window->HiddenFramesRegular = 1;
+ }
+
+ // Don't render if style alpha is 0.0 at the time of Begin(). This is arbitrary and inconsistent but has been there for a long while (may remove at some point)
+ if (style.Alpha <= 0.0f)
+ window->HiddenFramesRegular = 1;
+
+ // Update the Hidden flag
+ window->Hidden = (window->HiddenFramesRegular > 0) || (window->HiddenFramesForResize > 0);
+
+ // Return false if we don't intend to display anything to allow user to perform an early out optimization
+ window->SkipItems = (window->Collapsed || !window->Active || window->Hidden) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && window->HiddenFramesForResize <= 0;
+
+ return !window->SkipItems;
+}
+
+// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()/SetNextWindowBgAlpha() + Begin() instead.
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, float bg_alpha_override, ImGuiWindowFlags flags)
+{
+ // Old API feature: we could pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file.
+ if (size_first_use.x != 0.0f || size_first_use.y != 0.0f)
+ SetNextWindowSize(size_first_use, ImGuiCond_FirstUseEver);
+
+ // Old API feature: override the window background alpha with a parameter.
+ if (bg_alpha_override >= 0.0f)
+ SetNextWindowBgAlpha(bg_alpha_override);
+
+ return Begin(name, p_open, flags);
+}
+#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+
+void ImGui::End()
+{
+ ImGuiContext& g = *GImGui;
+
+ if (g.CurrentWindowStack.Size <= 1 && g.FrameScopePushedImplicitWindow)
+ {
+ IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
+ return; // FIXME-ERRORHANDLING
+ }
+ IM_ASSERT(g.CurrentWindowStack.Size > 0);
+
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (window->DC.ColumnsSet != NULL)
+ EndColumns();
+ PopClipRect(); // Inner window clip rectangle
+
+ // Stop logging
+ if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
+ LogFinish();
+
+ // Pop from window stack
+ g.CurrentWindowStack.pop_back();
+ if (window->Flags & ImGuiWindowFlags_Popup)
+ g.BeginPopupStack.pop_back();
+ CheckStacksSize(window, false);
+ SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back());
+}
+
+void ImGui::BringWindowToFocusFront(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.WindowsFocusOrder.back() == window)
+ return;
+ for (int i = g.WindowsFocusOrder.Size - 2; i >= 0; i--) // We can ignore the front most window
+ if (g.WindowsFocusOrder[i] == window)
+ {
+ memmove(&g.WindowsFocusOrder[i], &g.WindowsFocusOrder[i + 1], (size_t)(g.WindowsFocusOrder.Size - i - 1) * sizeof(ImGuiWindow*));
+ g.WindowsFocusOrder[g.WindowsFocusOrder.Size - 1] = window;
+ break;
+ }
+}
+
+void ImGui::BringWindowToDisplayFront(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* current_front_window = g.Windows.back();
+ if (current_front_window == window || current_front_window->RootWindow == window)
+ return;
+ for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the front most window
+ if (g.Windows[i] == window)
+ {
+ memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*));
+ g.Windows[g.Windows.Size - 1] = window;
+ break;
+ }
+}
+
+void ImGui::BringWindowToDisplayBack(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.Windows[0] == window)
+ return;
+ for (int i = 0; i < g.Windows.Size; i++)
+ if (g.Windows[i] == window)
+ {
+ memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*));
+ g.Windows[0] = window;
+ break;
+ }
+}
+
+// Moving window to front of display and set focus (which happens to be back of our sorted list)
+void ImGui::FocusWindow(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+
+ if (g.NavWindow != window)
+ {
+ g.NavWindow = window;
+ if (window && g.NavDisableMouseHover)
+ g.NavMousePosDirty = true;
+ g.NavInitRequest = false;
+ g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
+ g.NavIdIsAlive = false;
+ g.NavLayer = ImGuiNavLayer_Main;
+ //IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", g.FrameCount, window ? window->Name : NULL);
+ }
+
+ // Passing NULL allow to disable keyboard focus
+ if (!window)
+ return;
+
+ // Move the root window to the top of the pile
+ if (window->RootWindow)
+ window = window->RootWindow;
+
+ // Steal focus on active widgets
+ if (window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement should be unnecessary. Need further testing before removing it..
+ if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window)
+ ClearActiveID();
+
+ // Bring to front
+ BringWindowToFocusFront(window);
+ if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus))
+ BringWindowToDisplayFront(window);
+}
+
+void ImGui::FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window)
+{
+ ImGuiContext& g = *GImGui;
+ for (int i = g.WindowsFocusOrder.Size - 1; i >= 0; i--)
+ {
+ // We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user.
+ ImGuiWindow* window = g.WindowsFocusOrder[i];
+ if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow))
+ if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
+ {
+ ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
+ FocusWindow(focus_window);
+ return;
+ }
+ }
+}
+
+void ImGui::PushItemWidth(float item_width)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width);
+ window->DC.ItemWidthStack.push_back(window->DC.ItemWidth);
+}
+
+void ImGui::PushMultiItemsWidths(int components, float w_full)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ const ImGuiStyle& style = GImGui->Style;
+ if (w_full <= 0.0f)
+ w_full = CalcItemWidth();
+ const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
+ const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
+ window->DC.ItemWidthStack.push_back(w_item_last);
+ for (int i = 0; i < components-1; i++)
+ window->DC.ItemWidthStack.push_back(w_item_one);
+ window->DC.ItemWidth = window->DC.ItemWidthStack.back();
+}
+
+void ImGui::PopItemWidth()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.ItemWidthStack.pop_back();
+ window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back();
+}
+
+float ImGui::CalcItemWidth()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ float w = window->DC.ItemWidth;
+ if (w < 0.0f)
+ {
+ // Align to a right-side limit. We include 1 frame padding in the calculation because this is how the width is always used (we add 2 frame padding to it), but we could move that responsibility to the widget as well.
+ float width_to_right_edge = GetContentRegionAvail().x;
+ w = ImMax(1.0f, width_to_right_edge + w);
+ }
+ w = (float)(int)w;
+ return w;
+}
+
+void ImGui::SetCurrentFont(ImFont* font)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?
+ IM_ASSERT(font->Scale > 0.0f);
+ g.Font = font;
+ g.FontBaseSize = g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale;
+ g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f;
+
+ ImFontAtlas* atlas = g.Font->ContainerAtlas;
+ g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel;
+ g.DrawListSharedData.Font = g.Font;
+ g.DrawListSharedData.FontSize = g.FontSize;
+}
+
+void ImGui::PushFont(ImFont* font)
+{
+ ImGuiContext& g = *GImGui;
+ if (!font)
+ font = GetDefaultFont();
+ SetCurrentFont(font);
+ g.FontStack.push_back(font);
+ g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID);
+}
+
+void ImGui::PopFont()
+{
+ ImGuiContext& g = *GImGui;
+ g.CurrentWindow->DrawList->PopTextureID();
+ g.FontStack.pop_back();
+ SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back());
+}
+
+void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (enabled)
+ window->DC.ItemFlags |= option;
+ else
+ window->DC.ItemFlags &= ~option;
+ window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags);
+}
+
+void ImGui::PopItemFlag()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.ItemFlagsStack.pop_back();
+ window->DC.ItemFlags = window->DC.ItemFlagsStack.empty() ? ImGuiItemFlags_Default_ : window->DC.ItemFlagsStack.back();
+}
+
+// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system.
+void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus)
+{
+ PushItemFlag(ImGuiItemFlags_NoTabStop, !allow_keyboard_focus);
+}
+
+void ImGui::PopAllowKeyboardFocus()
+{
+ PopItemFlag();
+}
+
+void ImGui::PushButtonRepeat(bool repeat)
+{
+ PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat);
+}
+
+void ImGui::PopButtonRepeat()
+{
+ PopItemFlag();
+}
+
+void ImGui::PushTextWrapPos(float wrap_pos_x)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.TextWrapPos = wrap_pos_x;
+ window->DC.TextWrapPosStack.push_back(wrap_pos_x);
+}
+
+void ImGui::PopTextWrapPos()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.TextWrapPosStack.pop_back();
+ window->DC.TextWrapPos = window->DC.TextWrapPosStack.empty() ? -1.0f : window->DC.TextWrapPosStack.back();
+}
+
+// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32
+void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiColorMod backup;
+ backup.Col = idx;
+ backup.BackupValue = g.Style.Colors[idx];
+ g.ColorModifiers.push_back(backup);
+ g.Style.Colors[idx] = ColorConvertU32ToFloat4(col);
+}
+
+void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiColorMod backup;
+ backup.Col = idx;
+ backup.BackupValue = g.Style.Colors[idx];
+ g.ColorModifiers.push_back(backup);
+ g.Style.Colors[idx] = col;
+}
+
+void ImGui::PopStyleColor(int count)
+{
+ ImGuiContext& g = *GImGui;
+ while (count > 0)
+ {
+ ImGuiColorMod& backup = g.ColorModifiers.back();
+ g.Style.Colors[backup.Col] = backup.BackupValue;
+ g.ColorModifiers.pop_back();
+ count--;
+ }
+}
+
+struct ImGuiStyleVarInfo
+{
+ ImGuiDataType Type;
+ ImU32 Count;
+ ImU32 Offset;
+ void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
+};
+
+static const ImGuiStyleVarInfo GStyleVarInfo[] =
+{
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
+ { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
+ { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
+};
+
+static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
+{
+ IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT);
+ IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT);
+ return &GStyleVarInfo[idx];
+}
+
+void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
+{
+ const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
+ if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1)
+ {
+ ImGuiContext& g = *GImGui;
+ float* pvar = (float*)var_info->GetVarPtr(&g.Style);
+ g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
+ *pvar = val;
+ return;
+ }
+ IM_ASSERT(0); // Called function with wrong-type? Variable is not a float.
+}
+
+void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
+{
+ const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
+ if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2)
+ {
+ ImGuiContext& g = *GImGui;
+ ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
+ g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
+ *pvar = val;
+ return;
+ }
+ IM_ASSERT(0); // Called function with wrong-type? Variable is not a ImVec2.
+}
+
+void ImGui::PopStyleVar(int count)
+{
+ ImGuiContext& g = *GImGui;
+ while (count > 0)
+ {
+ // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it.
+ ImGuiStyleMod& backup = g.StyleModifiers.back();
+ const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx);
+ void* data = info->GetVarPtr(&g.Style);
+ if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; }
+ else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; }
+ g.StyleModifiers.pop_back();
+ count--;
+ }
+}
+
+const char* ImGui::GetStyleColorName(ImGuiCol idx)
+{
+ // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1";
+ switch (idx)
+ {
+ case ImGuiCol_Text: return "Text";
+ case ImGuiCol_TextDisabled: return "TextDisabled";
+ case ImGuiCol_WindowBg: return "WindowBg";
+ case ImGuiCol_ChildBg: return "ChildBg";
+ case ImGuiCol_PopupBg: return "PopupBg";
+ case ImGuiCol_Border: return "Border";
+ case ImGuiCol_BorderShadow: return "BorderShadow";
+ case ImGuiCol_FrameBg: return "FrameBg";
+ case ImGuiCol_FrameBgHovered: return "FrameBgHovered";
+ case ImGuiCol_FrameBgActive: return "FrameBgActive";
+ case ImGuiCol_TitleBg: return "TitleBg";
+ case ImGuiCol_TitleBgActive: return "TitleBgActive";
+ case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
+ case ImGuiCol_MenuBarBg: return "MenuBarBg";
+ case ImGuiCol_ScrollbarBg: return "ScrollbarBg";
+ case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab";
+ case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered";
+ case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive";
+ case ImGuiCol_CheckMark: return "CheckMark";
+ case ImGuiCol_SliderGrab: return "SliderGrab";
+ case ImGuiCol_SliderGrabActive: return "SliderGrabActive";
+ case ImGuiCol_Button: return "Button";
+ case ImGuiCol_ButtonHovered: return "ButtonHovered";
+ case ImGuiCol_ButtonActive: return "ButtonActive";
+ case ImGuiCol_Header: return "Header";
+ case ImGuiCol_HeaderHovered: return "HeaderHovered";
+ case ImGuiCol_HeaderActive: return "HeaderActive";
+ case ImGuiCol_Separator: return "Separator";
+ case ImGuiCol_SeparatorHovered: return "SeparatorHovered";
+ case ImGuiCol_SeparatorActive: return "SeparatorActive";
+ case ImGuiCol_ResizeGrip: return "ResizeGrip";
+ case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered";
+ case ImGuiCol_ResizeGripActive: return "ResizeGripActive";
+ case ImGuiCol_Tab: return "Tab";
+ case ImGuiCol_TabHovered: return "TabHovered";
+ case ImGuiCol_TabActive: return "TabActive";
+ case ImGuiCol_TabUnfocused: return "TabUnfocused";
+ case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive";
+ case ImGuiCol_PlotLines: return "PlotLines";
+ case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
+ case ImGuiCol_PlotHistogram: return "PlotHistogram";
+ case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
+ case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
+ case ImGuiCol_DragDropTarget: return "DragDropTarget";
+ case ImGuiCol_NavHighlight: return "NavHighlight";
+ case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
+ case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg";
+ case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg";
+ }
+ IM_ASSERT(0);
+ return "Unknown";
+}
+
+bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent)
+{
+ if (window->RootWindow == potential_parent)
+ return true;
+ while (window != NULL)
+ {
+ if (window == potential_parent)
+ return true;
+ window = window->ParentWindow;
+ }
+ return false;
+}
+
+bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
+{
+ IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
+ ImGuiContext& g = *GImGui;
+
+ if (flags & ImGuiHoveredFlags_AnyWindow)
+ {
+ if (g.HoveredWindow == NULL)
+ return false;
+ }
+ else
+ {
+ switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows))
+ {
+ case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows:
+ if (g.HoveredRootWindow != g.CurrentWindow->RootWindow)
+ return false;
+ break;
+ case ImGuiHoveredFlags_RootWindow:
+ if (g.HoveredWindow != g.CurrentWindow->RootWindow)
+ return false;
+ break;
+ case ImGuiHoveredFlags_ChildWindows:
+ if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow))
+ return false;
+ break;
+ default:
+ if (g.HoveredWindow != g.CurrentWindow)
+ return false;
+ break;
+ }
+ }
+
+ if (!IsWindowContentHoverable(g.HoveredRootWindow, flags))
+ return false;
+ if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
+ if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId)
+ return false;
+ return true;
+}
+
+bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+
+ if (flags & ImGuiFocusedFlags_AnyWindow)
+ return g.NavWindow != NULL;
+
+ IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
+ switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
+ {
+ case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:
+ return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow;
+ case ImGuiFocusedFlags_RootWindow:
+ return g.NavWindow == g.CurrentWindow->RootWindow;
+ case ImGuiFocusedFlags_ChildWindows:
+ return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow);
+ default:
+ return g.NavWindow == g.CurrentWindow;
+ }
+}
+
+// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
+// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmaticaly.
+// If you want a window to never be focused, you may use the e.g. NoInputs flag.
+bool ImGui::IsWindowNavFocusable(ImGuiWindow* window)
+{
+ return window->Active && window == window->RootWindow && !(window->Flags & ImGuiWindowFlags_NoNavFocus);
+}
+
+float ImGui::GetWindowWidth()
+{
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->Size.x;
+}
+
+float ImGui::GetWindowHeight()
+{
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->Size.y;
+}
+
+ImVec2 ImGui::GetWindowPos()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ return window->Pos;
+}
+
+void ImGui::SetWindowScrollX(ImGuiWindow* window, float new_scroll_x)
+{
+ window->DC.CursorMaxPos.x += window->Scroll.x; // SizeContents is generally computed based on CursorMaxPos which is affected by scroll position, so we need to apply our change to it.
+ window->Scroll.x = new_scroll_x;
+ window->DC.CursorMaxPos.x -= window->Scroll.x;
+}
+
+void ImGui::SetWindowScrollY(ImGuiWindow* window, float new_scroll_y)
+{
+ window->DC.CursorMaxPos.y += window->Scroll.y; // SizeContents is generally computed based on CursorMaxPos which is affected by scroll position, so we need to apply our change to it.
+ window->Scroll.y = new_scroll_y;
+ window->DC.CursorMaxPos.y -= window->Scroll.y;
+}
+
+static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
+{
+ // Test condition (NB: bit 0 is always true) and clear flags for next time
+ if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
+ return;
+
+ IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
+ window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
+ window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX);
+
+ // Set
+ const ImVec2 old_pos = window->Pos;
+ window->Pos = ImFloor(pos);
+ window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
+ window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
+}
+
+void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ SetWindowPos(window, pos, cond);
+}
+
+void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond)
+{
+ if (ImGuiWindow* window = FindWindowByName(name))
+ SetWindowPos(window, pos, cond);
+}
+
+ImVec2 ImGui::GetWindowSize()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->Size;
+}
+
+static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond)
+{
+ // Test condition (NB: bit 0 is always true) and clear flags for next time
+ if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
+ return;
+
+ IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
+ window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
+
+ // Set
+ if (size.x > 0.0f)
+ {
+ window->AutoFitFramesX = 0;
+ window->SizeFull.x = ImFloor(size.x);
+ }
+ else
+ {
+ window->AutoFitFramesX = 2;
+ window->AutoFitOnlyGrows = false;
+ }
+ if (size.y > 0.0f)
+ {
+ window->AutoFitFramesY = 0;
+ window->SizeFull.y = ImFloor(size.y);
+ }
+ else
+ {
+ window->AutoFitFramesY = 2;
+ window->AutoFitOnlyGrows = false;
+ }
+}
+
+void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond)
+{
+ SetWindowSize(GImGui->CurrentWindow, size, cond);
+}
+
+void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond)
+{
+ if (ImGuiWindow* window = FindWindowByName(name))
+ SetWindowSize(window, size, cond);
+}
+
+static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond)
+{
+ // Test condition (NB: bit 0 is always true) and clear flags for next time
+ if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
+ return;
+ window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
+
+ // Set
+ window->Collapsed = collapsed;
+}
+
+void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond)
+{
+ SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond);
+}
+
+bool ImGui::IsWindowCollapsed()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->Collapsed;
+}
+
+bool ImGui::IsWindowAppearing()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->Appearing;
+}
+
+void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond)
+{
+ if (ImGuiWindow* window = FindWindowByName(name))
+ SetWindowCollapsed(window, collapsed, cond);
+}
+
+void ImGui::SetWindowFocus()
+{
+ FocusWindow(GImGui->CurrentWindow);
+}
+
+void ImGui::SetWindowFocus(const char* name)
+{
+ if (name)
+ {
+ if (ImGuiWindow* window = FindWindowByName(name))
+ FocusWindow(window);
+ }
+ else
+ {
+ FocusWindow(NULL);
+ }
+}
+
+void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
+ g.NextWindowData.PosVal = pos;
+ g.NextWindowData.PosPivotVal = pivot;
+ g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always;
+}
+
+void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
+ g.NextWindowData.SizeVal = size;
+ g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always;
+}
+
+void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data)
+{
+ ImGuiContext& g = *GImGui;
+ g.NextWindowData.SizeConstraintCond = ImGuiCond_Always;
+ g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max);
+ g.NextWindowData.SizeCallback = custom_callback;
+ g.NextWindowData.SizeCallbackUserData = custom_callback_user_data;
+}
+
+void ImGui::SetNextWindowContentSize(const ImVec2& size)
+{
+ ImGuiContext& g = *GImGui;
+ g.NextWindowData.ContentSizeVal = size; // In Begin() we will add the size of window decorations (title bar, menu etc.) to that to form a SizeContents value.
+ g.NextWindowData.ContentSizeCond = ImGuiCond_Always;
+}
+
+void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
+ g.NextWindowData.CollapsedVal = collapsed;
+ g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always;
+}
+
+void ImGui::SetNextWindowFocus()
+{
+ ImGuiContext& g = *GImGui;
+ g.NextWindowData.FocusCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
+}
+
+void ImGui::SetNextWindowBgAlpha(float alpha)
+{
+ ImGuiContext& g = *GImGui;
+ g.NextWindowData.BgAlphaVal = alpha;
+ g.NextWindowData.BgAlphaCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
+}
+
+// In window space (not screen space!)
+ImVec2 ImGui::GetContentRegionMax()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
+ if (window->DC.ColumnsSet)
+ mx.x = GetColumnOffset(window->DC.ColumnsSet->Current + 1) - window->WindowPadding.x;
+ return mx;
+}
+
+ImVec2 ImGui::GetContentRegionAvail()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return GetContentRegionMax() - (window->DC.CursorPos - window->Pos);
+}
+
+float ImGui::GetContentRegionAvailWidth()
+{
+ return GetContentRegionAvail().x;
+}
+
+// In window space (not screen space!)
+ImVec2 ImGui::GetWindowContentRegionMin()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->ContentsRegionRect.Min - window->Pos;
+}
+
+ImVec2 ImGui::GetWindowContentRegionMax()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->ContentsRegionRect.Max - window->Pos;
+}
+
+float ImGui::GetWindowContentRegionWidth()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->ContentsRegionRect.GetWidth();
+}
+
+float ImGui::GetTextLineHeight()
+{
+ ImGuiContext& g = *GImGui;
+ return g.FontSize;
+}
+
+float ImGui::GetTextLineHeightWithSpacing()
+{
+ ImGuiContext& g = *GImGui;
+ return g.FontSize + g.Style.ItemSpacing.y;
+}
+
+float ImGui::GetFrameHeight()
+{
+ ImGuiContext& g = *GImGui;
+ return g.FontSize + g.Style.FramePadding.y * 2.0f;
+}
+
+float ImGui::GetFrameHeightWithSpacing()
+{
+ ImGuiContext& g = *GImGui;
+ return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
+}
+
+ImDrawList* ImGui::GetWindowDrawList()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ return window->DrawList;
+}
+
+ImFont* ImGui::GetFont()
+{
+ return GImGui->Font;
+}
+
+float ImGui::GetFontSize()
+{
+ return GImGui->FontSize;
+}
+
+ImVec2 ImGui::GetFontTexUvWhitePixel()
+{
+ return GImGui->DrawListSharedData.TexUvWhitePixel;
+}
+
+void ImGui::SetWindowFontScale(float scale)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->FontWindowScale = scale;
+ g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
+}
+
+// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient.
+// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'.
+ImVec2 ImGui::GetCursorPos()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos - window->Pos + window->Scroll;
+}
+
+float ImGui::GetCursorPosX()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x;
+}
+
+float ImGui::GetCursorPosY()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y;
+}
+
+void ImGui::SetCursorPos(const ImVec2& local_pos)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos = window->Pos - window->Scroll + local_pos;
+ window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+}
+
+void ImGui::SetCursorPosX(float x)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x;
+ window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x);
+}
+
+void ImGui::SetCursorPosY(float y)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y;
+ window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
+}
+
+ImVec2 ImGui::GetCursorStartPos()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorStartPos - window->Pos;
+}
+
+ImVec2 ImGui::GetCursorScreenPos()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.CursorPos;
+}
+
+void ImGui::SetCursorScreenPos(const ImVec2& pos)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.CursorPos = pos;
+ window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+}
+
+float ImGui::GetScrollX()
+{
+ return GImGui->CurrentWindow->Scroll.x;
+}
+
+float ImGui::GetScrollY()
+{
+ return GImGui->CurrentWindow->Scroll.y;
+}
+
+float ImGui::GetScrollMaxX()
+{
+ return GetWindowScrollMaxX(GImGui->CurrentWindow);
+}
+
+float ImGui::GetScrollMaxY()
+{
+ return GetWindowScrollMaxY(GImGui->CurrentWindow);
+}
+
+void ImGui::SetScrollX(float scroll_x)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->ScrollTarget.x = scroll_x;
+ window->ScrollTargetCenterRatio.x = 0.0f;
+}
+
+void ImGui::SetScrollY(float scroll_y)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->ScrollTarget.y = scroll_y + window->TitleBarHeight() + window->MenuBarHeight(); // title bar height canceled out when using ScrollTargetRelY
+ window->ScrollTargetCenterRatio.y = 0.0f;
+}
+
+void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
+{
+ // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
+ ImGuiWindow* window = GetCurrentWindow();
+ IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
+ window->ScrollTarget.y = (float)(int)(local_y + window->Scroll.y);
+ window->ScrollTargetCenterRatio.y = center_y_ratio;
+}
+
+// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item.
+void ImGui::SetScrollHereY(float center_y_ratio)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space
+ target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (GImGui->Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line.
+ SetScrollFromPosY(target_y, center_y_ratio);
+}
+
+void ImGui::ActivateItem(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ g.NavNextActivateId = id;
+}
+
+void ImGui::SetKeyboardFocusHere(int offset)
+{
+ IM_ASSERT(offset >= -1); // -1 is allowed but not below
+ ImGuiWindow* window = GetCurrentWindow();
+ window->FocusIdxAllRequestNext = window->FocusIdxAllCounter + 1 + offset;
+ window->FocusIdxTabRequestNext = INT_MAX;
+}
+
+void ImGui::SetItemDefaultFocus()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (!window->Appearing)
+ return;
+ if (g.NavWindow == window->RootWindowForNav && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
+ {
+ g.NavInitRequest = false;
+ g.NavInitResultId = g.NavWindow->DC.LastItemId;
+ g.NavInitResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos);
+ NavUpdateAnyRequestFlag();
+ if (!IsItemVisible())
+ SetScrollHereY();
+ }
+}
+
+void ImGui::SetStateStorage(ImGuiStorage* tree)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.StateStorage = tree ? tree : &window->StateStorage;
+}
+
+ImGuiStorage* ImGui::GetStateStorage()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.StateStorage;
+}
+
+void ImGui::PushID(const char* str_id)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ window->IDStack.push_back(window->GetIDNoKeepAlive(str_id));
+}
+
+void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ window->IDStack.push_back(window->GetIDNoKeepAlive(str_id_begin, str_id_end));
+}
+
+void ImGui::PushID(const void* ptr_id)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
+}
+
+void ImGui::PushID(int int_id)
+{
+ const void* ptr_id = (void*)(intptr_t)int_id;
+ ImGuiWindow* window = GetCurrentWindowRead();
+ window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
+}
+
+void ImGui::PopID()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ window->IDStack.pop_back();
+}
+
+ImGuiID ImGui::GetID(const char* str_id)
+{
+ return GImGui->CurrentWindow->GetID(str_id);
+}
+
+ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end)
+{
+ return GImGui->CurrentWindow->GetID(str_id_begin, str_id_end);
+}
+
+ImGuiID ImGui::GetID(const void* ptr_id)
+{
+ return GImGui->CurrentWindow->GetID(ptr_id);
+}
+
+bool ImGui::IsRectVisible(const ImVec2& size)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size));
+}
+
+bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->ClipRect.Overlaps(ImRect(rect_min, rect_max));
+}
+
+// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
+void ImGui::BeginGroup()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+
+ window->DC.GroupStack.resize(window->DC.GroupStack.Size + 1);
+ ImGuiGroupData& group_data = window->DC.GroupStack.back();
+ group_data.BackupCursorPos = window->DC.CursorPos;
+ group_data.BackupCursorMaxPos = window->DC.CursorMaxPos;
+ group_data.BackupIndent = window->DC.Indent;
+ group_data.BackupGroupOffset = window->DC.GroupOffset;
+ group_data.BackupCurrentLineSize = window->DC.CurrentLineSize;
+ group_data.BackupCurrentLineTextBaseOffset = window->DC.CurrentLineTextBaseOffset;
+ group_data.BackupLogLinePosY = window->DC.LogLinePosY;
+ group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive;
+ group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive;
+ group_data.AdvanceCursor = true;
+
+ window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x;
+ window->DC.Indent = window->DC.GroupOffset;
+ window->DC.CursorMaxPos = window->DC.CursorPos;
+ window->DC.CurrentLineSize = ImVec2(0.0f, 0.0f);
+ window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; // To enforce Log carriage return
+}
+
+void ImGui::EndGroup()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+ IM_ASSERT(!window->DC.GroupStack.empty()); // Mismatched BeginGroup()/EndGroup() calls
+
+ ImGuiGroupData& group_data = window->DC.GroupStack.back();
+
+ ImRect group_bb(group_data.BackupCursorPos, window->DC.CursorMaxPos);
+ group_bb.Max = ImMax(group_bb.Min, group_bb.Max);
+
+ window->DC.CursorPos = group_data.BackupCursorPos;
+ window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
+ window->DC.Indent = group_data.BackupIndent;
+ window->DC.GroupOffset = group_data.BackupGroupOffset;
+ window->DC.CurrentLineSize = group_data.BackupCurrentLineSize;
+ window->DC.CurrentLineTextBaseOffset = group_data.BackupCurrentLineTextBaseOffset;
+ window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f; // To enforce Log carriage return
+
+ if (group_data.AdvanceCursor)
+ {
+ window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrentLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
+ ItemSize(group_bb.GetSize(), group_data.BackupCurrentLineTextBaseOffset);
+ ItemAdd(group_bb, 0);
+ }
+
+ // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
+ // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
+ // (and if you grep for LastItemId you'll notice it is only used in that context.
+ if ((group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId) // && g.ActiveIdWindow->RootWindow == window->RootWindow)
+ window->DC.LastItemId = g.ActiveId;
+ else if (!group_data.BackupActiveIdPreviousFrameIsAlive && g.ActiveIdPreviousFrameIsAlive) // && g.ActiveIdPreviousFrameWindow->RootWindow == window->RootWindow)
+ window->DC.LastItemId = g.ActiveIdPreviousFrame;
+ window->DC.LastItemRect = group_bb;
+
+ window->DC.GroupStack.pop_back();
+
+ //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug]
+}
+
+// Gets back to previous line and continue with horizontal layout
+// pos_x == 0 : follow right after previous item
+// pos_x != 0 : align to specified x position (relative to window/group left)
+// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0
+// spacing_w >= 0 : enforce spacing amount
+void ImGui::SameLine(float pos_x, float spacing_w)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ if (pos_x != 0.0f)
+ {
+ if (spacing_w < 0.0f) spacing_w = 0.0f;
+ window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + pos_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x;
+ window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
+ }
+ else
+ {
+ if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x;
+ window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w;
+ window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
+ }
+ window->DC.CurrentLineSize = window->DC.PrevLineSize;
+ window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset;
+}
+
+void ImGui::Indent(float indent_w)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
+ window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
+}
+
+void ImGui::Unindent(float indent_w)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+ window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
+ window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] TOOLTIPS
+//-----------------------------------------------------------------------------
+
+void ImGui::BeginTooltip()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.DragDropWithinSourceOrTarget)
+ {
+ // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
+ // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
+ // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do.
+ //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
+ ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
+ SetNextWindowPos(tooltip_pos);
+ SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
+ //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
+ BeginTooltipEx(0, true);
+ }
+ else
+ {
+ BeginTooltipEx(0, false);
+ }
+}
+
+// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
+void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
+{
+ ImGuiContext& g = *GImGui;
+ char window_name[16];
+ ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
+ if (override_previous_tooltip)
+ if (ImGuiWindow* window = FindWindowByName(window_name))
+ if (window->Active)
+ {
+ // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
+ window->Hidden = true;
+ window->HiddenFramesRegular = 1;
+ ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
+ }
+ ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
+ Begin(window_name, NULL, flags | extra_flags);
+}
+
+void ImGui::EndTooltip()
+{
+ IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls
+ End();
+}
+
+void ImGui::SetTooltipV(const char* fmt, va_list args)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.DragDropWithinSourceOrTarget)
+ BeginTooltip();
+ else
+ BeginTooltipEx(0, true);
+ TextV(fmt, args);
+ EndTooltip();
+}
+
+void ImGui::SetTooltip(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ SetTooltipV(fmt, args);
+ va_end(args);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] POPUPS
+//-----------------------------------------------------------------------------
+
+bool ImGui::IsPopupOpen(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id;
+}
+
+bool ImGui::IsPopupOpen(const char* str_id)
+{
+ ImGuiContext& g = *GImGui;
+ return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id);
+}
+
+ImGuiWindow* ImGui::GetFrontMostPopupModal()
+{
+ ImGuiContext& g = *GImGui;
+ for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
+ if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window)
+ if (popup->Flags & ImGuiWindowFlags_Modal)
+ return popup;
+ return NULL;
+}
+
+void ImGui::OpenPopup(const char* str_id)
+{
+ ImGuiContext& g = *GImGui;
+ OpenPopupEx(g.CurrentWindow->GetID(str_id));
+}
+
+// Mark popup as open (toggle toward open state).
+// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
+// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
+// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
+void ImGui::OpenPopupEx(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* parent_window = g.CurrentWindow;
+ int current_stack_size = g.BeginPopupStack.Size;
+ ImGuiPopupRef popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack.
+ popup_ref.PopupId = id;
+ popup_ref.Window = NULL;
+ popup_ref.ParentWindow = parent_window;
+ popup_ref.OpenFrameCount = g.FrameCount;
+ popup_ref.OpenParentId = parent_window->IDStack.back();
+ popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
+ popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
+
+ //IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id);
+ if (g.OpenPopupStack.Size < current_stack_size + 1)
+ {
+ g.OpenPopupStack.push_back(popup_ref);
+ }
+ else
+ {
+ // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui
+ // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing
+ // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand.
+ if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1)
+ {
+ g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount;
+ }
+ else
+ {
+ // Close child popups if any, then flag popup for open/reopen
+ g.OpenPopupStack.resize(current_stack_size + 1);
+ g.OpenPopupStack[current_stack_size] = popup_ref;
+ }
+
+ // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow().
+ // This is equivalent to what ClosePopupToLevel() does.
+ //if (g.OpenPopupStack[current_stack_size].PopupId == id)
+ // FocusWindow(parent_window);
+ }
+}
+
+bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
+{
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ {
+ ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
+ IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
+ OpenPopupEx(id);
+ return true;
+ }
+ return false;
+}
+
+void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.OpenPopupStack.empty())
+ return;
+
+ // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
+ // Don't close our own child popup windows.
+ int popup_count_to_keep = 0;
+ if (ref_window)
+ {
+ // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow)
+ for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++)
+ {
+ ImGuiPopupRef& popup = g.OpenPopupStack[popup_count_to_keep];
+ if (!popup.Window)
+ continue;
+ IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
+ if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
+ continue;
+
+ // Trim the stack if popups are not direct descendant of the reference window (which is often the NavWindow)
+ bool popup_or_descendent_has_focus = false;
+ for (int m = popup_count_to_keep; m < g.OpenPopupStack.Size && !popup_or_descendent_has_focus; m++)
+ if (g.OpenPopupStack[m].Window && g.OpenPopupStack[m].Window->RootWindow == ref_window->RootWindow)
+ popup_or_descendent_has_focus = true;
+ if (!popup_or_descendent_has_focus)
+ break;
+ }
+ }
+ if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
+ {
+ //IMGUI_DEBUG_LOG("ClosePopupsOverWindow(%s) -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep);
+ ClosePopupToLevel(popup_count_to_keep, false);
+ }
+}
+
+void ImGui::ClosePopupToLevel(int remaining, bool apply_focus_to_window_under)
+{
+ IM_ASSERT(remaining >= 0);
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* focus_window = (remaining > 0) ? g.OpenPopupStack[remaining-1].Window : g.OpenPopupStack[0].ParentWindow;
+ g.OpenPopupStack.resize(remaining);
+
+ // FIXME: This code is faulty and we may want to eventually to replace or remove the 'apply_focus_to_window_under=true' path completely.
+ // Instead of using g.OpenPopupStack[remaining-1].Window etc. we should find the highest root window that is behind the popups we are closing.
+ // The current code will set focus to the parent of the popup window which is incorrect.
+ // It rarely manifested until now because UpdateMouseMovingWindow() would call FocusWindow() again on the clicked window,
+ // leading to a chain of focusing A (clicked window) then B (parent window of the popup) then A again.
+ // However if the clicked window has the _NoMove flag set we would be left with B focused.
+ // For now, we have disabled this path when called from ClosePopupsOverWindow() because the users of ClosePopupsOverWindow() don't need to alter focus anyway,
+ // but we should inspect and fix this properly.
+ if (apply_focus_to_window_under)
+ {
+ if (g.NavLayer == 0)
+ focus_window = NavRestoreLastChildNavWindow(focus_window);
+ FocusWindow(focus_window);
+ }
+}
+
+// Close the popup we have begin-ed into.
+void ImGui::CloseCurrentPopup()
+{
+ ImGuiContext& g = *GImGui;
+ int popup_idx = g.BeginPopupStack.Size - 1;
+ if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId)
+ return;
+ while (popup_idx > 0 && g.OpenPopupStack[popup_idx].Window && (g.OpenPopupStack[popup_idx].Window->Flags & ImGuiWindowFlags_ChildMenu))
+ popup_idx--;
+ ClosePopupToLevel(popup_idx, true);
+
+ // A common pattern is to close a popup when selecting a menu item/selectable that will open another window.
+ // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window.
+ // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic.
+ if (ImGuiWindow* window = g.NavWindow)
+ window->DC.NavHideHighlightOneFrame = true;
+}
+
+bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (!IsPopupOpen(id))
+ {
+ g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
+ return false;
+ }
+
+ char name[20];
+ if (extra_flags & ImGuiWindowFlags_ChildMenu)
+ ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
+ else
+ ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
+
+ bool is_open = Begin(name, NULL, extra_flags | ImGuiWindowFlags_Popup);
+ if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
+ EndPopup();
+
+ return is_open;
+}
+
+bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
+ {
+ g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
+ return false;
+ }
+ flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
+ return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags);
+}
+
+// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
+// Note that popup visibility status is owned by imgui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.
+bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ const ImGuiID id = window->GetID(name);
+ if (!IsPopupOpen(id))
+ {
+ g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
+ return false;
+ }
+
+ // Center modal windows by default
+ // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
+ if (g.NextWindowData.PosCond == 0)
+ SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
+
+ flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
+ const bool is_open = Begin(name, p_open, flags);
+ if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
+ {
+ EndPopup();
+ if (is_open)
+ ClosePopupToLevel(g.BeginPopupStack.Size, true);
+ return false;
+ }
+ return is_open;
+}
+
+void ImGui::EndPopup()
+{
+ ImGuiContext& g = *GImGui; (void)g;
+ IM_ASSERT(g.CurrentWindow->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
+ IM_ASSERT(g.BeginPopupStack.Size > 0);
+
+ // Make all menus and popups wrap around for now, may need to expose that policy.
+ NavMoveRequestTryWrapping(g.CurrentWindow, ImGuiNavMoveFlags_LoopY);
+
+ End();
+}
+
+// This is a helper to handle the simplest case of associating one named popup to one given widget.
+// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
+// You can pass a NULL str_id to use the identifier of the last item.
+bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
+{
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
+ IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
+ if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ OpenPopupEx(id);
+ return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
+}
+
+bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool also_over_items)
+{
+ if (!str_id)
+ str_id = "window_context";
+ ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
+ if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ if (also_over_items || !IsAnyItemHovered())
+ OpenPopupEx(id);
+ return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
+}
+
+bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button)
+{
+ if (!str_id)
+ str_id = "void_context";
+ ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
+ if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
+ OpenPopupEx(id);
+ return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
+}
+
+ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow*)
+{
+ ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding;
+ ImRect r_screen = GetViewportRect();
+ r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f));
+ return r_screen;
+}
+
+// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.)
+// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it.
+ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy)
+{
+ ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size);
+ //GImGui->OverlayDrawList.AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255));
+ //GImGui->OverlayDrawList.AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255));
+
+ // Combo Box policy (we want a connecting edge)
+ if (policy == ImGuiPopupPositionPolicy_ComboBox)
+ {
+ const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
+ for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
+ {
+ const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
+ if (n != -1 && dir == *last_dir) // Already tried this direction?
+ continue;
+ ImVec2 pos;
+ if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default)
+ if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right
+ if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left
+ if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left
+ if (!r_outer.Contains(ImRect(pos, pos + size)))
+ continue;
+ *last_dir = dir;
+ return pos;
+ }
+ }
+
+ // Default popup policy
+ const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
+ for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
+ {
+ const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
+ if (n != -1 && dir == *last_dir) // Already tried this direction?
+ continue;
+ float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x);
+ float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y);
+ if (avail_w < size.x || avail_h < size.y)
+ continue;
+ ImVec2 pos;
+ pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x;
+ pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y;
+ *last_dir = dir;
+ return pos;
+ }
+
+ // Fallback, try to keep within display
+ *last_dir = ImGuiDir_None;
+ ImVec2 pos = ref_pos;
+ pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x);
+ pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y);
+ return pos;
+}
+
+ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+
+ ImRect r_outer = GetWindowAllowedExtentRect(window);
+ if (window->Flags & ImGuiWindowFlags_ChildMenu)
+ {
+ // Child menus typically request _any_ position within the parent menu item, and then our FindBestWindowPosForPopup() function will move the new menu outside the parent bounds.
+ // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
+ IM_ASSERT(g.CurrentWindow == window);
+ ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2];
+ float horizontal_overlap = g.Style.ItemSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x).
+ ImRect r_avoid;
+ if (parent_window->DC.MenuBarAppending)
+ r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight());
+ else
+ r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
+ return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
+ }
+ if (window->Flags & ImGuiWindowFlags_Popup)
+ {
+ ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
+ return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
+ }
+ if (window->Flags & ImGuiWindowFlags_Tooltip)
+ {
+ // Position tooltip (always follows mouse)
+ float sc = g.Style.MouseCursorScale;
+ ImVec2 ref_pos = NavCalcPreferredRefPos();
+ ImRect r_avoid;
+ if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos))
+ r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
+ else
+ r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
+ ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
+ if (window->AutoPosLastDirection == ImGuiDir_None)
+ pos = ref_pos + ImVec2(2, 2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
+ return pos;
+ }
+ IM_ASSERT(0);
+ return window->Pos;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] VIEWPORTS, PLATFORM WINDOWS
+//-----------------------------------------------------------------------------
+
+// (this section is filled in the 'viewport' and 'docking' branches)
+
+//-----------------------------------------------------------------------------
+// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
+//-----------------------------------------------------------------------------
+
+ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
+{
+ if (ImFabs(dx) > ImFabs(dy))
+ return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
+ return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
+}
+
+static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
+{
+ if (a1 < b0)
+ return a1 - b0;
+ if (b1 < a0)
+ return a0 - b1;
+ return 0.0f;
+}
+
+static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect)
+{
+ if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right)
+ {
+ r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y);
+ r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y);
+ }
+ else
+ {
+ r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x);
+ r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x);
+ }
+}
+
+// Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057
+static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.NavLayer != window->DC.NavLayerCurrent)
+ return false;
+
+ const ImRect& curr = g.NavScoringRectScreen; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
+ g.NavScoringCount++;
+
+ // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring
+ if (window->ParentWindow == g.NavWindow)
+ {
+ IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened);
+ if (!window->ClipRect.Contains(cand))
+ return false;
+ cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
+ }
+
+ // We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items)
+ // For example, this ensure that items in one column are not reached when moving vertically from items in another column.
+ NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect);
+
+ // Compute distance between boxes
+ // FIXME-NAV: Introducing biases for vertical navigation, needs to be removed.
+ float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x);
+ float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items
+ if (dby != 0.0f && dbx != 0.0f)
+ dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f);
+ float dist_box = ImFabs(dbx) + ImFabs(dby);
+
+ // Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter)
+ float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x);
+ float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y);
+ float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee)
+
+ // Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance
+ ImGuiDir quadrant;
+ float dax = 0.0f, day = 0.0f, dist_axial = 0.0f;
+ if (dbx != 0.0f || dby != 0.0f)
+ {
+ // For non-overlapping boxes, use distance between boxes
+ dax = dbx;
+ day = dby;
+ dist_axial = dist_box;
+ quadrant = ImGetDirQuadrantFromDelta(dbx, dby);
+ }
+ else if (dcx != 0.0f || dcy != 0.0f)
+ {
+ // For overlapping boxes with different centers, use distance between centers
+ dax = dcx;
+ day = dcy;
+ dist_axial = dist_center;
+ quadrant = ImGetDirQuadrantFromDelta(dcx, dcy);
+ }
+ else
+ {
+ // Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter)
+ quadrant = (window->DC.LastItemId < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right;
+ }
+
+#if IMGUI_DEBUG_NAV_SCORING
+ char buf[128];
+ if (ImGui::IsMouseHoveringRect(cand.Min, cand.Max))
+ {
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
+ ImDrawList* draw_list = ImGui::GetOverlayDrawList(window);
+ draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
+ draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
+ draw_list->AddRectFilled(cand.Max-ImVec2(4,4), cand.Max+ImGui::CalcTextSize(buf)+ImVec2(4,4), IM_COL32(40,0,0,150));
+ draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf);
+ }
+ else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
+ {
+ if (ImGui::IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; }
+ if (quadrant == g.NavMoveDir)
+ {
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
+ ImDrawList* draw_list = ImGui::GetOverlayDrawList(window);
+ draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
+ draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
+ }
+ }
+ #endif
+
+ // Is it in the quadrant we're interesting in moving to?
+ bool new_best = false;
+ if (quadrant == g.NavMoveDir)
+ {
+ // Does it beat the current best candidate?
+ if (dist_box < result->DistBox)
+ {
+ result->DistBox = dist_box;
+ result->DistCenter = dist_center;
+ return true;
+ }
+ if (dist_box == result->DistBox)
+ {
+ // Try using distance between center points to break ties
+ if (dist_center < result->DistCenter)
+ {
+ result->DistCenter = dist_center;
+ new_best = true;
+ }
+ else if (dist_center == result->DistCenter)
+ {
+ // Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items
+ // (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index),
+ // this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis.
+ if (((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance
+ new_best = true;
+ }
+ }
+ }
+
+ // Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
+ // are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
+ // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
+ // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward.
+ // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option?
+ if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match
+ if (g.NavLayer == 1 && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
+ if ((g.NavMoveDir == ImGuiDir_Left && dax < 0.0f) || (g.NavMoveDir == ImGuiDir_Right && dax > 0.0f) || (g.NavMoveDir == ImGuiDir_Up && day < 0.0f) || (g.NavMoveDir == ImGuiDir_Down && day > 0.0f))
+ {
+ result->DistAxial = dist_axial;
+ new_best = true;
+ }
+
+ return new_best;
+}
+
+// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
+static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ //if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
+ // return;
+
+ const ImGuiItemFlags item_flags = window->DC.ItemFlags;
+ const ImRect nav_bb_rel(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos);
+
+ // Process Init Request
+ if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent)
+ {
+ // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
+ if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0)
+ {
+ g.NavInitResultId = id;
+ g.NavInitResultRectRel = nav_bb_rel;
+ }
+ if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
+ {
+ g.NavInitRequest = false; // Found a match, clear request
+ NavUpdateAnyRequestFlag();
+ }
+ }
+
+ // Process Move Request (scoring for navigation)
+ // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy)
+ if ((g.NavId != id || (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & ImGuiItemFlags_NoNav))
+ {
+ ImGuiNavMoveResult* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
+#if IMGUI_DEBUG_NAV_SCORING
+ // [DEBUG] Score all items in NavWindow at all times
+ if (!g.NavMoveRequest)
+ g.NavMoveDir = g.NavMoveDirLast;
+ bool new_best = NavScoreItem(result, nav_bb) && g.NavMoveRequest;
+#else
+ bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb);
+#endif
+ if (new_best)
+ {
+ result->ID = id;
+ result->Window = window;
+ result->RectRel = nav_bb_rel;
+ }
+
+ const float VISIBLE_RATIO = 0.70f;
+ if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
+ if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
+ if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
+ {
+ result = &g.NavMoveResultLocalVisibleSet;
+ result->ID = id;
+ result->Window = window;
+ result->RectRel = nav_bb_rel;
+ }
+ }
+
+ // Update window-relative bounding box of navigated item
+ if (g.NavId == id)
+ {
+ g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window.
+ g.NavLayer = window->DC.NavLayerCurrent;
+ g.NavIdIsAlive = true;
+ g.NavIdTabCounter = window->FocusIdxTabCounter;
+ window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position)
+ }
+}
+
+bool ImGui::NavMoveRequestButNoResultYet()
+{
+ ImGuiContext& g = *GImGui;
+ return g.NavMoveRequest && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0;
+}
+
+void ImGui::NavMoveRequestCancel()
+{
+ ImGuiContext& g = *GImGui;
+ g.NavMoveRequest = false;
+ NavUpdateAnyRequestFlag();
+}
+
+void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None);
+ ImGui::NavMoveRequestCancel();
+ g.NavMoveDir = move_dir;
+ g.NavMoveClipDir = clip_dir;
+ g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
+ g.NavMoveRequestFlags = move_flags;
+ g.NavWindow->NavRectRel[g.NavLayer] = bb_rel;
+}
+
+void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NavWindow != window || !NavMoveRequestButNoResultYet() || g.NavMoveRequestForward != ImGuiNavForward_None || g.NavLayer != 0)
+ return;
+ IM_ASSERT(move_flags != 0); // No points calling this with no wrapping
+ ImRect bb_rel = window->NavRectRel[0];
+
+ ImGuiDir clip_dir = g.NavMoveDir;
+ if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
+ {
+ bb_rel.Min.x = bb_rel.Max.x = ImMax(window->SizeFull.x, window->SizeContents.x) - window->Scroll.x;
+ if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(-bb_rel.GetHeight()); clip_dir = ImGuiDir_Up; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
+ }
+ if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
+ {
+ bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x;
+ if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(+bb_rel.GetHeight()); clip_dir = ImGuiDir_Down; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
+ }
+ if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
+ {
+ bb_rel.Min.y = bb_rel.Max.y = ImMax(window->SizeFull.y, window->SizeContents.y) - window->Scroll.y;
+ if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(-bb_rel.GetWidth()); clip_dir = ImGuiDir_Left; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
+ }
+ if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
+ {
+ bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y;
+ if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(+bb_rel.GetWidth()); clip_dir = ImGuiDir_Right; }
+ NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
+ }
+}
+
+static void ImGui::NavSaveLastChildNavWindow(ImGuiWindow* nav_window)
+{
+ ImGuiWindow* parent_window = nav_window;
+ while (parent_window && (parent_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
+ parent_window = parent_window->ParentWindow;
+ if (parent_window && parent_window != nav_window)
+ parent_window->NavLastChildNavWindow = nav_window;
+}
+
+// Call when we are expected to land on Layer 0 after FocusWindow()
+static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window)
+{
+ return window->NavLastChildNavWindow ? window->NavLastChildNavWindow : window;
+}
+
+static void NavRestoreLayer(ImGuiNavLayer layer)
+{
+ ImGuiContext& g = *GImGui;
+ g.NavLayer = layer;
+ if (layer == 0)
+ g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow);
+ if (layer == 0 && g.NavWindow->NavLastIds[0] != 0)
+ ImGui::SetNavIDWithRectRel(g.NavWindow->NavLastIds[0], layer, g.NavWindow->NavRectRel[0]);
+ else
+ ImGui::NavInitWindow(g.NavWindow, true);
+}
+
+static inline void ImGui::NavUpdateAnyRequestFlag()
+{
+ ImGuiContext& g = *GImGui;
+ g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL);
+ if (g.NavAnyRequest)
+ IM_ASSERT(g.NavWindow != NULL);
+}
+
+// This needs to be called before we submit any widget (aka in or before Begin)
+void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(window == g.NavWindow);
+ bool init_for_nav = false;
+ if (!(window->Flags & ImGuiWindowFlags_NoNavInputs))
+ if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit)
+ init_for_nav = true;
+ if (init_for_nav)
+ {
+ SetNavID(0, g.NavLayer);
+ g.NavInitRequest = true;
+ g.NavInitRequestFromMove = false;
+ g.NavInitResultId = 0;
+ g.NavInitResultRectRel = ImRect();
+ NavUpdateAnyRequestFlag();
+ }
+ else
+ {
+ g.NavId = window->NavLastIds[0];
+ }
+}
+
+static ImVec2 ImGui::NavCalcPreferredRefPos()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow)
+ {
+ // Mouse (we need a fallback in case the mouse becomes invalid after being used)
+ if (IsMousePosValid(&g.IO.MousePos))
+ return g.IO.MousePos;
+ return g.LastValidMousePos;
+ }
+ else
+ {
+ // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item.
+ const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer];
+ ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
+ ImRect visible_rect = GetViewportRect();
+ return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta.
+ }
+}
+
+float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
+{
+ ImGuiContext& g = *GImGui;
+ if (mode == ImGuiInputReadMode_Down)
+ return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user)
+
+ const float t = g.IO.NavInputsDownDuration[n];
+ if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input.
+ return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f);
+ if (t < 0.0f)
+ return 0.0f;
+ if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
+ return (t == 0.0f) ? 1.0f : 0.0f;
+ if (mode == ImGuiInputReadMode_Repeat)
+ return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 0.80f, g.IO.KeyRepeatRate * 0.80f);
+ if (mode == ImGuiInputReadMode_RepeatSlow)
+ return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 1.00f, g.IO.KeyRepeatRate * 2.00f);
+ if (mode == ImGuiInputReadMode_RepeatFast)
+ return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 0.80f, g.IO.KeyRepeatRate * 0.30f);
+ return 0.0f;
+}
+
+ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor)
+{
+ ImVec2 delta(0.0f, 0.0f);
+ if (dir_sources & ImGuiNavDirSourceFlags_Keyboard)
+ delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode));
+ if (dir_sources & ImGuiNavDirSourceFlags_PadDPad)
+ delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode));
+ if (dir_sources & ImGuiNavDirSourceFlags_PadLStick)
+ delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode));
+ if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow))
+ delta *= slow_factor;
+ if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast))
+ delta *= fast_factor;
+ return delta;
+}
+
+// Scroll to keep newly navigated item fully into view
+// NB: We modify rect_rel by the amount we scrolled for, so it is immediately updated.
+static void NavScrollToBringItemIntoView(ImGuiWindow* window, const ImRect& item_rect)
+{
+ ImRect window_rect(window->InnerMainRect.Min - ImVec2(1, 1), window->InnerMainRect.Max + ImVec2(1, 1));
+ //GetOverlayDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
+ if (window_rect.Contains(item_rect))
+ return;
+
+ ImGuiContext& g = *GImGui;
+ if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
+ {
+ window->ScrollTarget.x = item_rect.Min.x - window->Pos.x + window->Scroll.x - g.Style.ItemSpacing.x;
+ window->ScrollTargetCenterRatio.x = 0.0f;
+ }
+ else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
+ {
+ window->ScrollTarget.x = item_rect.Max.x - window->Pos.x + window->Scroll.x + g.Style.ItemSpacing.x;
+ window->ScrollTargetCenterRatio.x = 1.0f;
+ }
+ if (item_rect.Min.y < window_rect.Min.y)
+ {
+ window->ScrollTarget.y = item_rect.Min.y - window->Pos.y + window->Scroll.y - g.Style.ItemSpacing.y;
+ window->ScrollTargetCenterRatio.y = 0.0f;
+ }
+ else if (item_rect.Max.y >= window_rect.Max.y)
+ {
+ window->ScrollTarget.y = item_rect.Max.y - window->Pos.y + window->Scroll.y + g.Style.ItemSpacing.y;
+ window->ScrollTargetCenterRatio.y = 1.0f;
+ }
+}
+
+static void ImGui::NavUpdate()
+{
+ ImGuiContext& g = *GImGui;
+ g.IO.WantSetMousePos = false;
+#if 0
+ if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
+#endif
+
+ // Set input source as Gamepad when buttons are pressed before we map Keyboard (some features differs when used with Gamepad vs Keyboard)
+ bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
+ bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
+ if (nav_gamepad_active)
+ if (g.IO.NavInputs[ImGuiNavInput_Activate] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Input] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Cancel] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Menu] > 0.0f)
+ g.NavInputSource = ImGuiInputSource_NavGamepad;
+
+ // Update Keyboard->Nav inputs mapping
+ if (nav_keyboard_active)
+ {
+ #define NAV_MAP_KEY(_KEY, _NAV_INPUT) if (IsKeyDown(g.IO.KeyMap[_KEY])) { g.IO.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; }
+ NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
+ NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input );
+ NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel );
+ NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ );
+ NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_);
+ NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ );
+ NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ );
+ if (g.IO.KeyCtrl) g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f;
+ if (g.IO.KeyShift) g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f;
+ if (g.IO.KeyAlt) g.IO.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f;
+ #undef NAV_MAP_KEY
+ }
+ memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration));
+ for (int i = 0; i < IM_ARRAYSIZE(g.IO.NavInputs); i++)
+ g.IO.NavInputsDownDuration[i] = (g.IO.NavInputs[i] > 0.0f) ? (g.IO.NavInputsDownDuration[i] < 0.0f ? 0.0f : g.IO.NavInputsDownDuration[i] + g.IO.DeltaTime) : -1.0f;
+
+ // Process navigation init request (select first/default focus)
+ if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove))
+ {
+ // Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
+ IM_ASSERT(g.NavWindow);
+ if (g.NavInitRequestFromMove)
+ SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
+ else
+ SetNavID(g.NavInitResultId, g.NavLayer);
+ g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
+ }
+ g.NavInitRequest = false;
+ g.NavInitRequestFromMove = false;
+ g.NavInitResultId = 0;
+ g.NavJustMovedToId = 0;
+
+ // Process navigation move request
+ if (g.NavMoveRequest)
+ NavUpdateMoveResult();
+
+ // When a forwarded move request failed, we restore the highlight that we disabled during the forward frame
+ if (g.NavMoveRequestForward == ImGuiNavForward_ForwardActive)
+ {
+ IM_ASSERT(g.NavMoveRequest);
+ if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
+ g.NavDisableHighlight = false;
+ g.NavMoveRequestForward = ImGuiNavForward_None;
+ }
+
+ // Apply application mouse position movement, after we had a chance to process move request result.
+ if (g.NavMousePosDirty && g.NavIdIsAlive)
+ {
+ // Set mouse position given our knowledge of the navigated item position from last frame
+ if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
+ {
+ if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow)
+ {
+ g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos();
+ g.IO.WantSetMousePos = true;
+ }
+ }
+ g.NavMousePosDirty = false;
+ }
+ g.NavIdIsAlive = false;
+ g.NavJustTabbedId = 0;
+ IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1);
+
+ // Store our return window (for returning from Layer 1 to Layer 0) and clear it as soon as we step back in our own Layer 0
+ if (g.NavWindow)
+ NavSaveLastChildNavWindow(g.NavWindow);
+ if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == 0)
+ g.NavWindow->NavLastChildNavWindow = NULL;
+
+ // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.)
+ NavUpdateWindowing();
+
+ // Set output flags for user application
+ g.IO.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
+ g.IO.NavVisible = (g.IO.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL) || g.NavInitRequest;
+
+ // Process NavCancel input (to close a popup, get back to parent, clear focus)
+ if (IsNavInputPressed(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed))
+ {
+ if (g.ActiveId != 0)
+ {
+ ClearActiveID();
+ }
+ else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow)
+ {
+ // Exit child window
+ ImGuiWindow* child_window = g.NavWindow;
+ ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
+ IM_ASSERT(child_window->ChildId != 0);
+ FocusWindow(parent_window);
+ SetNavID(child_window->ChildId, 0);
+ g.NavIdIsAlive = false;
+ if (g.NavDisableMouseHover)
+ g.NavMousePosDirty = true;
+ }
+ else if (g.OpenPopupStack.Size > 0)
+ {
+ // Close open popup/menu
+ if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
+ ClosePopupToLevel(g.OpenPopupStack.Size - 1, true);
+ }
+ else if (g.NavLayer != 0)
+ {
+ // Leave the "menu" layer
+ NavRestoreLayer(ImGuiNavLayer_Main);
+ }
+ else
+ {
+ // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
+ if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
+ g.NavWindow->NavLastIds[0] = 0;
+ g.NavId = 0;
+ }
+ }
+
+ // Process manual activation request
+ g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = 0;
+ if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
+ {
+ bool activate_down = IsNavInputDown(ImGuiNavInput_Activate);
+ bool activate_pressed = activate_down && IsNavInputPressed(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed);
+ if (g.ActiveId == 0 && activate_pressed)
+ g.NavActivateId = g.NavId;
+ if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down)
+ g.NavActivateDownId = g.NavId;
+ if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed)
+ g.NavActivatePressedId = g.NavId;
+ if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && IsNavInputPressed(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed))
+ g.NavInputId = g.NavId;
+ }
+ if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
+ g.NavDisableHighlight = true;
+ if (g.NavActivateId != 0)
+ IM_ASSERT(g.NavActivateDownId == g.NavActivateId);
+ g.NavMoveRequest = false;
+
+ // Process programmatic activation request
+ if (g.NavNextActivateId != 0)
+ g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId;
+ g.NavNextActivateId = 0;
+
+ // Initiate directional inputs request
+ const int allowed_dir_flags = (g.ActiveId == 0) ? ~0 : g.ActiveIdAllowNavDirFlags;
+ if (g.NavMoveRequestForward == ImGuiNavForward_None)
+ {
+ g.NavMoveDir = ImGuiDir_None;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_None;
+ if (g.NavWindow && !g.NavWindowingTarget && allowed_dir_flags && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
+ {
+ if ((allowed_dir_flags & (1<<ImGuiDir_Left)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadLeft, ImGuiNavInput_KeyLeft_, ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Left;
+ if ((allowed_dir_flags & (1<<ImGuiDir_Right)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadRight,ImGuiNavInput_KeyRight_,ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Right;
+ if ((allowed_dir_flags & (1<<ImGuiDir_Up)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadUp, ImGuiNavInput_KeyUp_, ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Up;
+ if ((allowed_dir_flags & (1<<ImGuiDir_Down)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadDown, ImGuiNavInput_KeyDown_, ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Down;
+ }
+ g.NavMoveClipDir = g.NavMoveDir;
+ }
+ else
+ {
+ // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window)
+ // (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function)
+ IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
+ IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_ForwardQueued);
+ g.NavMoveRequestForward = ImGuiNavForward_ForwardActive;
+ }
+
+ // Update PageUp/PageDown scroll
+ float nav_scoring_rect_offset_y = 0.0f;
+ if (nav_keyboard_active)
+ nav_scoring_rect_offset_y = NavUpdatePageUpPageDown(allowed_dir_flags);
+
+ // If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match
+ if (g.NavMoveDir != ImGuiDir_None)
+ {
+ g.NavMoveRequest = true;
+ g.NavMoveDirLast = g.NavMoveDir;
+ }
+ if (g.NavMoveRequest && g.NavId == 0)
+ {
+ g.NavInitRequest = g.NavInitRequestFromMove = true;
+ g.NavInitResultId = 0;
+ g.NavDisableHighlight = false;
+ }
+ NavUpdateAnyRequestFlag();
+
+ // Scrolling
+ if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget)
+ {
+ // *Fallback* manual-scroll with Nav directional keys when window has no navigable item
+ ImGuiWindow* window = g.NavWindow;
+ const float scroll_speed = ImFloor(window->CalcFontSize() * 100 * g.IO.DeltaTime + 0.5f); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
+ if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest)
+ {
+ if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right)
+ SetWindowScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
+ if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down)
+ SetWindowScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed));
+ }
+
+ // *Normal* Manual scroll with NavScrollXXX keys
+ // Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds.
+ ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f);
+ if (scroll_dir.x != 0.0f && window->ScrollbarX)
+ {
+ SetWindowScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
+ g.NavMoveFromClampedRefRect = true;
+ }
+ if (scroll_dir.y != 0.0f)
+ {
+ SetWindowScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed));
+ g.NavMoveFromClampedRefRect = true;
+ }
+ }
+
+ // Reset search results
+ g.NavMoveResultLocal.Clear();
+ g.NavMoveResultLocalVisibleSet.Clear();
+ g.NavMoveResultOther.Clear();
+
+ // When we have manually scrolled (without using navigation) and NavId becomes out of bounds, we project its bounding box to the visible area to restart navigation within visible items
+ if (g.NavMoveRequest && g.NavMoveFromClampedRefRect && g.NavLayer == 0)
+ {
+ ImGuiWindow* window = g.NavWindow;
+ ImRect window_rect_rel(window->InnerMainRect.Min - window->Pos - ImVec2(1,1), window->InnerMainRect.Max - window->Pos + ImVec2(1,1));
+ if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer]))
+ {
+ float pad = window->CalcFontSize() * 0.5f;
+ window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
+ window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
+ g.NavId = 0;
+ }
+ g.NavMoveFromClampedRefRect = false;
+ }
+
+ // For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
+ ImRect nav_rect_rel = (g.NavWindow && !g.NavWindow->NavRectRel[g.NavLayer].IsInverted()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0);
+ g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect();
+ g.NavScoringRectScreen.TranslateY(nav_scoring_rect_offset_y);
+ g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
+ g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
+ IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
+ //g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
+ g.NavScoringCount = 0;
+#if IMGUI_DEBUG_NAV_RECTS
+ if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) GetOverlayDrawList(g.NavWindow)->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
+ if (g.NavWindow) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); GetOverlayDrawList(g.NavWindow)->AddCircleFilled(p, 3.0f, col); GetOverlayDrawList(g.NavWindow)->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
+#endif
+}
+
+// Apply result from previous frame navigation directional move request
+static void ImGui::NavUpdateMoveResult()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
+ {
+ // In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
+ if (g.NavId != 0)
+ {
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
+ }
+ return;
+ }
+
+ // Select which result to use
+ ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
+
+ // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
+ if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet)
+ if (g.NavMoveResultLocalVisibleSet.ID != 0 && g.NavMoveResultLocalVisibleSet.ID != g.NavId)
+ result = &g.NavMoveResultLocalVisibleSet;
+
+ // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules.
+ if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow)
+ if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter))
+ result = &g.NavMoveResultOther;
+ IM_ASSERT(g.NavWindow && result->Window);
+
+ // Scroll to keep newly navigated item fully into view.
+ if (g.NavLayer == 0)
+ {
+ ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos);
+ NavScrollToBringItemIntoView(result->Window, rect_abs);
+
+ // Estimate upcoming scroll so we can offset our result position so mouse position can be applied immediately after in NavUpdate()
+ ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(result->Window, false);
+ ImVec2 delta_scroll = result->Window->Scroll - next_scroll;
+ result->RectRel.Translate(delta_scroll);
+
+ // Also scroll parent window to keep us into view if necessary (we could/should technically recurse back the whole the parent hierarchy).
+ if (result->Window->Flags & ImGuiWindowFlags_ChildWindow)
+ NavScrollToBringItemIntoView(result->Window->ParentWindow, ImRect(rect_abs.Min + delta_scroll, rect_abs.Max + delta_scroll));
+ }
+
+ ClearActiveID();
+ g.NavWindow = result->Window;
+ SetNavIDWithRectRel(result->ID, g.NavLayer, result->RectRel);
+ g.NavJustMovedToId = result->ID;
+ g.NavMoveFromClampedRefRect = false;
+}
+
+static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.NavMoveDir == ImGuiDir_None && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget && g.NavLayer == 0)
+ {
+ ImGuiWindow* window = g.NavWindow;
+ bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && (allowed_dir_flags & (1 << ImGuiDir_Up));
+ bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && (allowed_dir_flags & (1 << ImGuiDir_Down));
+ if ((page_up_held && !page_down_held) || (page_down_held && !page_up_held))
+ {
+ if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll)
+ {
+ // Fallback manual-scroll when window has no navigable item
+ if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
+ SetWindowScrollY(window, window->Scroll.y - window->InnerClipRect.GetHeight());
+ else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
+ SetWindowScrollY(window, window->Scroll.y + window->InnerClipRect.GetHeight());
+ }
+ else
+ {
+ const ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer];
+ const float page_offset_y = ImMax(0.0f, window->InnerClipRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight());
+ float nav_scoring_rect_offset_y = 0.0f;
+ if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
+ {
+ nav_scoring_rect_offset_y = -page_offset_y;
+ g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
+ g.NavMoveClipDir = ImGuiDir_Up;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
+ }
+ else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
+ {
+ nav_scoring_rect_offset_y = +page_offset_y;
+ g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
+ g.NavMoveClipDir = ImGuiDir_Down;
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
+ }
+ return nav_scoring_rect_offset_y;
+ }
+ }
+ }
+ return 0.0f;
+}
+
+static int FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N)
+{
+ ImGuiContext& g = *GImGui;
+ for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--)
+ if (g.WindowsFocusOrder[i] == window)
+ return i;
+ return -1;
+}
+
+static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N)
+{
+ ImGuiContext& g = *GImGui;
+ for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir)
+ if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i]))
+ return g.WindowsFocusOrder[i];
+ return NULL;
+}
+
+static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavWindowingTarget);
+ if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal)
+ return;
+
+ const int i_current = FindWindowFocusIndex(g.NavWindowingTarget);
+ ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir);
+ if (!window_target)
+ window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir);
+ if (window_target) // Don't reset windowing target if there's a single window in the list
+ g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target;
+ g.NavWindowingToggleLayer = false;
+}
+
+// Window management mode (hold to: change focus/move/resize, tap to: toggle menu layer)
+static void ImGui::NavUpdateWindowing()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* apply_focus_window = NULL;
+ bool apply_toggle_layer = false;
+
+ ImGuiWindow* modal_window = GetFrontMostPopupModal();
+ if (modal_window != NULL)
+ {
+ g.NavWindowingTarget = NULL;
+ return;
+ }
+
+ // Fade out
+ if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL)
+ {
+ g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - g.IO.DeltaTime * 10.0f, 0.0f);
+ if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
+ g.NavWindowingTargetAnim = NULL;
+ }
+
+ // Start CTRL-TAB or Square+L/R window selection
+ bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
+ bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
+ if (start_windowing_with_gamepad || start_windowing_with_keyboard)
+ if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
+ {
+ g.NavWindowingTarget = g.NavWindowingTargetAnim = window;
+ g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
+ g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true;
+ g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad;
+ }
+
+ // Gamepad update
+ g.NavWindowingTimer += g.IO.DeltaTime;
+ if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad)
+ {
+ // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise
+ g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f));
+
+ // Select window to focus
+ const int focus_change_dir = (int)IsNavInputPressed(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputPressed(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow);
+ if (focus_change_dir != 0)
+ {
+ NavUpdateWindowingHighlightWindow(focus_change_dir);
+ g.NavWindowingHighlightAlpha = 1.0f;
+ }
+
+ // Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered front-most)
+ if (!IsNavInputDown(ImGuiNavInput_Menu))
+ {
+ g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore.
+ if (g.NavWindowingToggleLayer && g.NavWindow)
+ apply_toggle_layer = true;
+ else if (!g.NavWindowingToggleLayer)
+ apply_focus_window = g.NavWindowingTarget;
+ g.NavWindowingTarget = NULL;
+ }
+ }
+
+ // Keyboard: Focus
+ if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard)
+ {
+ // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise
+ g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f
+ if (IsKeyPressedMap(ImGuiKey_Tab, true))
+ NavUpdateWindowingHighlightWindow(g.IO.KeyShift ? +1 : -1);
+ if (!g.IO.KeyCtrl)
+ apply_focus_window = g.NavWindowingTarget;
+ }
+
+ // Keyboard: Press and Release ALT to toggle menu layer
+ // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB
+ if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released))
+ if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev))
+ apply_toggle_layer = true;
+
+ // Move window
+ if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove))
+ {
+ ImVec2 move_delta;
+ if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift)
+ move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
+ if (g.NavInputSource == ImGuiInputSource_NavGamepad)
+ move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
+ if (move_delta.x != 0.0f || move_delta.y != 0.0f)
+ {
+ const float NAV_MOVE_SPEED = 800.0f;
+ const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
+ g.NavWindowingTarget->RootWindow->Pos += move_delta * move_speed;
+ g.NavDisableMouseHover = true;
+ MarkIniSettingsDirty(g.NavWindowingTarget);
+ }
+ }
+
+ // Apply final focus
+ if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow))
+ {
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
+ apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
+ ClosePopupsOverWindow(apply_focus_window);
+ FocusWindow(apply_focus_window);
+ if (apply_focus_window->NavLastIds[0] == 0)
+ NavInitWindow(apply_focus_window, false);
+
+ // If the window only has a menu layer, select it directly
+ if (apply_focus_window->DC.NavLayerActiveMask == (1 << ImGuiNavLayer_Menu))
+ g.NavLayer = ImGuiNavLayer_Menu;
+ }
+ if (apply_focus_window)
+ g.NavWindowingTarget = NULL;
+
+ // Apply menu/layer toggle
+ if (apply_toggle_layer && g.NavWindow)
+ {
+ // Move to parent menu if necessary
+ ImGuiWindow* new_nav_window = g.NavWindow;
+ while ((new_nav_window->DC.NavLayerActiveMask & (1 << 1)) == 0
+ && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0
+ && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
+ new_nav_window = new_nav_window->ParentWindow;
+ if (new_nav_window != g.NavWindow)
+ {
+ ImGuiWindow* old_nav_window = g.NavWindow;
+ FocusWindow(new_nav_window);
+ new_nav_window->NavLastChildNavWindow = old_nav_window;
+ }
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
+ NavRestoreLayer((g.NavWindow->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main);
+ }
+}
+
+// Window has already passed the IsWindowNavFocusable()
+static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window)
+{
+ if (window->Flags & ImGuiWindowFlags_Popup)
+ return "(Popup)";
+ if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0)
+ return "(Main menu bar)";
+ return "(Untitled)";
+}
+
+// Overlay displayed when using CTRL+TAB. Called by EndFrame().
+void ImGui::NavUpdateWindowingList()
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavWindowingTarget != NULL);
+
+ if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY)
+ return;
+
+ if (g.NavWindowingList == NULL)
+ g.NavWindowingList = FindWindowByName("###NavWindowingList");
+ SetNextWindowSizeConstraints(ImVec2(g.IO.DisplaySize.x * 0.20f, g.IO.DisplaySize.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
+ SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
+ PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
+ Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
+ for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
+ {
+ ImGuiWindow* window = g.WindowsFocusOrder[n];
+ if (!IsWindowNavFocusable(window))
+ continue;
+ const char* label = window->Name;
+ if (label == FindRenderedTextEnd(label))
+ label = GetFallbackWindowNameForWindowingList(window);
+ Selectable(label, g.NavWindowingTarget == window);
+ }
+ End();
+ PopStyleVar();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] COLUMNS
+// In the current version, Columns are very weak. Needs to be replaced with a more full-featured system.
+//-----------------------------------------------------------------------------
+
+void ImGui::NextColumn()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems || window->DC.ColumnsSet == NULL)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ PopItemWidth();
+ PopClipRect();
+
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
+ if (++columns->Current < columns->Count)
+ {
+ // Columns 1+ cancel out IndentX
+ window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + g.Style.ItemSpacing.x;
+ window->DrawList->ChannelsSetCurrent(columns->Current);
+ }
+ else
+ {
+ window->DC.ColumnsOffset.x = 0.0f;
+ window->DrawList->ChannelsSetCurrent(0);
+ columns->Current = 0;
+ columns->LineMinY = columns->LineMaxY;
+ }
+ window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
+ window->DC.CursorPos.y = columns->LineMinY;
+ window->DC.CurrentLineSize = ImVec2(0.0f, 0.0f);
+ window->DC.CurrentLineTextBaseOffset = 0.0f;
+
+ PushColumnClipRect();
+ PushItemWidth(GetColumnWidth() * 0.65f); // FIXME: Move on columns setup
+}
+
+int ImGui::GetColumnIndex()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.ColumnsSet ? window->DC.ColumnsSet->Current : 0;
+}
+
+int ImGui::GetColumnsCount()
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ return window->DC.ColumnsSet ? window->DC.ColumnsSet->Count : 1;
+}
+
+static float OffsetNormToPixels(const ImGuiColumnsSet* columns, float offset_norm)
+{
+ return offset_norm * (columns->MaxX - columns->MinX);
+}
+
+static float PixelsToOffsetNorm(const ImGuiColumnsSet* columns, float offset)
+{
+ return offset / (columns->MaxX - columns->MinX);
+}
+
+static inline float GetColumnsRectHalfWidth() { return 4.0f; }
+
+static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index)
+{
+ // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing
+ // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning.
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ IM_ASSERT(column_index > 0); // We are not supposed to drag column 0.
+ IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index));
+
+ float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + GetColumnsRectHalfWidth() - window->Pos.x;
+ x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
+ if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths))
+ x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
+
+ return x;
+}
+
+float ImGui::GetColumnOffset(int column_index)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ IM_ASSERT(columns != NULL);
+
+ if (column_index < 0)
+ column_index = columns->Current;
+ IM_ASSERT(column_index < columns->Columns.Size);
+
+ const float t = columns->Columns[column_index].OffsetNorm;
+ const float x_offset = ImLerp(columns->MinX, columns->MaxX, t);
+ return x_offset;
+}
+
+static float GetColumnWidthEx(ImGuiColumnsSet* columns, int column_index, bool before_resize = false)
+{
+ if (column_index < 0)
+ column_index = columns->Current;
+
+ float offset_norm;
+ if (before_resize)
+ offset_norm = columns->Columns[column_index + 1].OffsetNormBeforeResize - columns->Columns[column_index].OffsetNormBeforeResize;
+ else
+ offset_norm = columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm;
+ return OffsetNormToPixels(columns, offset_norm);
+}
+
+float ImGui::GetColumnWidth(int column_index)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ IM_ASSERT(columns != NULL);
+
+ if (column_index < 0)
+ column_index = columns->Current;
+ return OffsetNormToPixels(columns, columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm);
+}
+
+void ImGui::SetColumnOffset(int column_index, float offset)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ IM_ASSERT(columns != NULL);
+
+ if (column_index < 0)
+ column_index = columns->Current;
+ IM_ASSERT(column_index < columns->Columns.Size);
+
+ const bool preserve_width = !(columns->Flags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->Count-1);
+ const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f;
+
+ if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
+ offset = ImMin(offset, columns->MaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index));
+ columns->Columns[column_index].OffsetNorm = PixelsToOffsetNorm(columns, offset - columns->MinX);
+
+ if (preserve_width)
+ SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width));
+}
+
+void ImGui::SetColumnWidth(int column_index, float width)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ IM_ASSERT(columns != NULL);
+
+ if (column_index < 0)
+ column_index = columns->Current;
+ SetColumnOffset(column_index + 1, GetColumnOffset(column_index) + width);
+}
+
+void ImGui::PushColumnClipRect(int column_index)
+{
+ ImGuiWindow* window = GetCurrentWindowRead();
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ if (column_index < 0)
+ column_index = columns->Current;
+
+ PushClipRect(columns->Columns[column_index].ClipRect.Min, columns->Columns[column_index].ClipRect.Max, false);
+}
+
+static ImGuiColumnsSet* FindOrAddColumnsSet(ImGuiWindow* window, ImGuiID id)
+{
+ for (int n = 0; n < window->ColumnsStorage.Size; n++)
+ if (window->ColumnsStorage[n].ID == id)
+ return &window->ColumnsStorage[n];
+
+ window->ColumnsStorage.push_back(ImGuiColumnsSet());
+ ImGuiColumnsSet* columns = &window->ColumnsStorage.back();
+ columns->ID = id;
+ return columns;
+}
+
+void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+
+ IM_ASSERT(columns_count > 1);
+ IM_ASSERT(window->DC.ColumnsSet == NULL); // Nested columns are currently not supported
+
+ // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
+ // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer.
+ PushID(0x11223347 + (str_id ? 0 : columns_count));
+ ImGuiID id = window->GetID(str_id ? str_id : "columns");
+ PopID();
+
+ // Acquire storage for the columns set
+ ImGuiColumnsSet* columns = FindOrAddColumnsSet(window, id);
+ IM_ASSERT(columns->ID == id);
+ columns->Current = 0;
+ columns->Count = columns_count;
+ columns->Flags = flags;
+ window->DC.ColumnsSet = columns;
+
+ // Set state for first column
+ const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerClipRect.Max.x - window->Pos.x);
+ columns->MinX = window->DC.Indent.x - g.Style.ItemSpacing.x; // Lock our horizontal range
+ columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f);
+ columns->StartPosY = window->DC.CursorPos.y;
+ columns->StartMaxPosX = window->DC.CursorMaxPos.x;
+ columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
+ window->DC.ColumnsOffset.x = 0.0f;
+ window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
+
+ // Clear data if columns count changed
+ if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1)
+ columns->Columns.resize(0);
+
+ // Initialize defaults
+ columns->IsFirstFrame = (columns->Columns.Size == 0);
+ if (columns->Columns.Size == 0)
+ {
+ columns->Columns.reserve(columns_count + 1);
+ for (int n = 0; n < columns_count + 1; n++)
+ {
+ ImGuiColumnData column;
+ column.OffsetNorm = n / (float)columns_count;
+ columns->Columns.push_back(column);
+ }
+ }
+
+ for (int n = 0; n < columns_count; n++)
+ {
+ // Compute clipping rectangle
+ ImGuiColumnData* column = &columns->Columns[n];
+ float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n) - 1.0f);
+ float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
+ column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
+ column->ClipRect.ClipWith(window->ClipRect);
+ }
+
+ window->DrawList->ChannelsSplit(columns->Count);
+ PushColumnClipRect();
+ PushItemWidth(GetColumnWidth() * 0.65f);
+}
+
+void ImGui::EndColumns()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+ ImGuiColumnsSet* columns = window->DC.ColumnsSet;
+ IM_ASSERT(columns != NULL);
+
+ PopItemWidth();
+ PopClipRect();
+ window->DrawList->ChannelsMerge();
+
+ columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
+ window->DC.CursorPos.y = columns->LineMaxY;
+ if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
+ window->DC.CursorMaxPos.x = columns->StartMaxPosX; // Restore cursor max pos, as columns don't grow parent
+
+ // Draw columns borders and handle resize
+ bool is_being_resized = false;
+ if (!(columns->Flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
+ {
+ const float y1 = columns->StartPosY;
+ const float y2 = window->DC.CursorPos.y;
+ int dragging_column = -1;
+ for (int n = 1; n < columns->Count; n++)
+ {
+ float x = window->Pos.x + GetColumnOffset(n);
+ const ImGuiID column_id = columns->ID + ImGuiID(n);
+ const float column_hw = GetColumnsRectHalfWidth(); // Half-width for interaction
+ const ImRect column_rect(ImVec2(x - column_hw, y1), ImVec2(x + column_hw, y2));
+ KeepAliveID(column_id);
+ if (IsClippedEx(column_rect, column_id, false))
+ continue;
+
+ bool hovered = false, held = false;
+ if (!(columns->Flags & ImGuiColumnsFlags_NoResize))
+ {
+ ButtonBehavior(column_rect, column_id, &hovered, &held);
+ if (hovered || held)
+ g.MouseCursor = ImGuiMouseCursor_ResizeEW;
+ if (held && !(columns->Columns[n].Flags & ImGuiColumnsFlags_NoResize))
+ dragging_column = n;
+ }
+
+ // Draw column (we clip the Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.)
+ const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
+ const float xi = (float)(int)x;
+ window->DrawList->AddLine(ImVec2(xi, ImMax(y1 + 1.0f, window->ClipRect.Min.y)), ImVec2(xi, ImMin(y2, window->ClipRect.Max.y)), col);
+ }
+
+ // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame.
+ if (dragging_column != -1)
+ {
+ if (!columns->IsBeingResized)
+ for (int n = 0; n < columns->Count + 1; n++)
+ columns->Columns[n].OffsetNormBeforeResize = columns->Columns[n].OffsetNorm;
+ columns->IsBeingResized = is_being_resized = true;
+ float x = GetDraggedColumnOffset(columns, dragging_column);
+ SetColumnOffset(dragging_column, x);
+ }
+ }
+ columns->IsBeingResized = is_being_resized;
+
+ window->DC.ColumnsSet = NULL;
+ window->DC.ColumnsOffset.x = 0.0f;
+ window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
+}
+
+// [2018-03: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing]
+void ImGui::Columns(int columns_count, const char* id, bool border)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ IM_ASSERT(columns_count >= 1);
+
+ ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);
+ //flags |= ImGuiColumnsFlags_NoPreserveWidths; // NB: Legacy behavior
+ if (window->DC.ColumnsSet != NULL && window->DC.ColumnsSet->Count == columns_count && window->DC.ColumnsSet->Flags == flags)
+ return;
+
+ if (window->DC.ColumnsSet != NULL)
+ EndColumns();
+
+ if (columns_count != 1)
+ BeginColumns(id, columns_count, flags);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] DRAG AND DROP
+//-----------------------------------------------------------------------------
+
+void ImGui::ClearDragDrop()
+{
+ ImGuiContext& g = *GImGui;
+ g.DragDropActive = false;
+ g.DragDropPayload.Clear();
+ g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
+ g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
+ g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
+ g.DragDropAcceptFrameCount = -1;
+
+ g.DragDropPayloadBufHeap.clear();
+ memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
+}
+
+// Call when current ID is active.
+// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource()
+bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ bool source_drag_active = false;
+ ImGuiID source_id = 0;
+ ImGuiID source_parent_id = 0;
+ int mouse_button = 0;
+ if (!(flags & ImGuiDragDropFlags_SourceExtern))
+ {
+ source_id = window->DC.LastItemId;
+ if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case
+ return false;
+ if (g.IO.MouseDown[mouse_button] == false)
+ return false;
+
+ if (source_id == 0)
+ {
+ // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
+ // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
+ if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
+ {
+ IM_ASSERT(0);
+ return false;
+ }
+
+ // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
+ // We build a throwaway ID based on current ID stack + relative AABB of items in window.
+ // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
+ // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
+ bool is_hovered = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) != 0;
+ if (!is_hovered && (g.ActiveId == 0 || g.ActiveIdWindow != window))
+ return false;
+ source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect);
+ if (is_hovered)
+ SetHoveredID(source_id);
+ if (is_hovered && g.IO.MouseClicked[mouse_button])
+ {
+ SetActiveID(source_id, window);
+ FocusWindow(window);
+ }
+ if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker.
+ g.ActiveIdAllowOverlap = is_hovered;
+ }
+ else
+ {
+ g.ActiveIdAllowOverlap = false;
+ }
+ if (g.ActiveId != source_id)
+ return false;
+ source_parent_id = window->IDStack.back();
+ source_drag_active = IsMouseDragging(mouse_button);
+ }
+ else
+ {
+ window = NULL;
+ source_id = ImHash("#SourceExtern", 0);
+ source_drag_active = true;
+ }
+
+ if (source_drag_active)
+ {
+ if (!g.DragDropActive)
+ {
+ IM_ASSERT(source_id != 0);
+ ClearDragDrop();
+ ImGuiPayload& payload = g.DragDropPayload;
+ payload.SourceId = source_id;
+ payload.SourceParentId = source_parent_id;
+ g.DragDropActive = true;
+ g.DragDropSourceFlags = flags;
+ g.DragDropMouseButton = mouse_button;
+ }
+ g.DragDropSourceFrameCount = g.FrameCount;
+ g.DragDropWithinSourceOrTarget = true;
+
+ if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
+ {
+ // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
+ // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
+ BeginTooltip();
+ if (g.DragDropActive && g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
+ {
+ ImGuiWindow* tooltip_window = g.CurrentWindow;
+ tooltip_window->SkipItems = true;
+ tooltip_window->HiddenFramesRegular = 1;
+ }
+ }
+
+ if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
+ window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;
+
+ return true;
+ }
+ return false;
+}
+
+void ImGui::EndDragDropSource()
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.DragDropActive);
+ IM_ASSERT(g.DragDropWithinSourceOrTarget && "Not after a BeginDragDropSource()?");
+
+ if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
+ EndTooltip();
+
+ // Discard the drag if have not called SetDragDropPayload()
+ if (g.DragDropPayload.DataFrameCount == -1)
+ ClearDragDrop();
+ g.DragDropWithinSourceOrTarget = false;
+}
+
+// Use 'cond' to choose to submit payload on drag start or every frame
+bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiPayload& payload = g.DragDropPayload;
+ if (cond == 0)
+ cond = ImGuiCond_Always;
+
+ IM_ASSERT(type != NULL);
+ IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
+ IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
+ IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
+ IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource()
+
+ if (cond == ImGuiCond_Always || payload.DataFrameCount == -1)
+ {
+ // Copy payload
+ ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType));
+ g.DragDropPayloadBufHeap.resize(0);
+ if (data_size > sizeof(g.DragDropPayloadBufLocal))
+ {
+ // Store in heap
+ g.DragDropPayloadBufHeap.resize((int)data_size);
+ payload.Data = g.DragDropPayloadBufHeap.Data;
+ memcpy(payload.Data, data, data_size);
+ }
+ else if (data_size > 0)
+ {
+ // Store locally
+ memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
+ payload.Data = g.DragDropPayloadBufLocal;
+ memcpy(payload.Data, data, data_size);
+ }
+ else
+ {
+ payload.Data = NULL;
+ }
+ payload.DataSize = (int)data_size;
+ }
+ payload.DataFrameCount = g.FrameCount;
+
+ return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1);
+}
+
+bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.DragDropActive)
+ return false;
+
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow)
+ return false;
+ IM_ASSERT(id != 0);
+ if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
+ return false;
+ if (window->SkipItems)
+ return false;
+
+ IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
+ g.DragDropTargetRect = bb;
+ g.DragDropTargetId = id;
+ g.DragDropWithinSourceOrTarget = true;
+ return true;
+}
+
+// We don't use BeginDragDropTargetCustom() and duplicate its code because:
+// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them.
+// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
+// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
+bool ImGui::BeginDragDropTarget()
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.DragDropActive)
+ return false;
+
+ ImGuiWindow* window = g.CurrentWindow;
+ if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
+ return false;
+ if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow)
+ return false;
+
+ const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect;
+ ImGuiID id = window->DC.LastItemId;
+ if (id == 0)
+ id = window->GetIDFromRectangle(display_rect);
+ if (g.DragDropPayload.SourceId == id)
+ return false;
+
+ IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
+ g.DragDropTargetRect = display_rect;
+ g.DragDropTargetId = id;
+ g.DragDropWithinSourceOrTarget = true;
+ return true;
+}
+
+bool ImGui::IsDragDropPayloadBeingAccepted()
+{
+ ImGuiContext& g = *GImGui;
+ return g.DragDropActive && g.DragDropAcceptIdPrev != 0;
+}
+
+const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ ImGuiPayload& payload = g.DragDropPayload;
+ IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
+ IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
+ if (type != NULL && !payload.IsDataType(type))
+ return NULL;
+
+ // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints.
+ // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function!
+ const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId);
+ ImRect r = g.DragDropTargetRect;
+ float r_surface = r.GetWidth() * r.GetHeight();
+ if (r_surface < g.DragDropAcceptIdCurrRectSurface)
+ {
+ g.DragDropAcceptFlags = flags;
+ g.DragDropAcceptIdCurr = g.DragDropTargetId;
+ g.DragDropAcceptIdCurrRectSurface = r_surface;
+ }
+
+ // Render default drop visuals
+ payload.Preview = was_accepted_previously;
+ flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame)
+ if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
+ {
+ // FIXME-DRAG: Settle on a proper default visuals for drop target.
+ r.Expand(3.5f);
+ bool push_clip_rect = !window->ClipRect.Contains(r);
+ if (push_clip_rect) window->DrawList->PushClipRect(r.Min-ImVec2(1,1), r.Max+ImVec2(1,1));
+ window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f);
+ if (push_clip_rect) window->DrawList->PopClipRect();
+ }
+
+ g.DragDropAcceptFrameCount = g.FrameCount;
+ payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
+ if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery))
+ return NULL;
+
+ return &payload;
+}
+
+const ImGuiPayload* ImGui::GetDragDropPayload()
+{
+ ImGuiContext& g = *GImGui;
+ return g.DragDropActive ? &g.DragDropPayload : NULL;
+}
+
+// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
+void ImGui::EndDragDropTarget()
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.DragDropActive);
+ IM_ASSERT(g.DragDropWithinSourceOrTarget);
+ g.DragDropWithinSourceOrTarget = false;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] DOCKING
+//-----------------------------------------------------------------------------
+
+// (this section is filled in the 'docking' branch)
+
+//-----------------------------------------------------------------------------
+// [SECTION] LOGGING/CAPTURING
+//-----------------------------------------------------------------------------
+
+// Pass text data straight to log (without being displayed)
+void ImGui::LogText(const char* fmt, ...)
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.LogEnabled)
+ return;
+
+ va_list args;
+ va_start(args, fmt);
+ if (g.LogFile)
+ vfprintf(g.LogFile, fmt, args);
+ else
+ g.LogClipboard.appendfv(fmt, args);
+ va_end(args);
+}
+
+// Internal version that takes a position to decide on newline placement and pad items according to their depth.
+// We split text into individual lines to add current tree level padding
+void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (!text_end)
+ text_end = FindRenderedTextEnd(text, text_end);
+
+ const bool log_new_line = ref_pos && (ref_pos->y > window->DC.LogLinePosY + 1);
+ if (ref_pos)
+ window->DC.LogLinePosY = ref_pos->y;
+
+ const char* text_remaining = text;
+ if (g.LogStartDepth > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth
+ g.LogStartDepth = window->DC.TreeDepth;
+ const int tree_depth = (window->DC.TreeDepth - g.LogStartDepth);
+ for (;;)
+ {
+ // Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry.
+ const char* line_start = text_remaining;
+ const char* line_end = ImStreolRange(line_start, text_end);
+ const bool is_first_line = (line_start == text);
+ const bool is_last_line = (line_end == text_end);
+ if (!is_last_line || (line_start != line_end))
+ {
+ const int char_count = (int)(line_end - line_start);
+ if (log_new_line || !is_first_line)
+ LogText(IM_NEWLINE "%*s%.*s", tree_depth*4, "", char_count, line_start);
+ else
+ LogText(" %.*s", char_count, line_start);
+ }
+
+ if (is_last_line)
+ break;
+ text_remaining = line_end + 1;
+ }
+}
+
+// Start logging ImGui output to TTY
+void ImGui::LogToTTY(int max_depth)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.LogEnabled)
+ return;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ IM_ASSERT(g.LogFile == NULL);
+ g.LogFile = stdout;
+ g.LogEnabled = true;
+ g.LogStartDepth = window->DC.TreeDepth;
+ if (max_depth >= 0)
+ g.LogAutoExpandMaxDepth = max_depth;
+}
+
+// Start logging ImGui output to given file
+void ImGui::LogToFile(int max_depth, const char* filename)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.LogEnabled)
+ return;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ if (!filename)
+ {
+ filename = g.IO.LogFilename;
+ if (!filename)
+ return;
+ }
+
+ IM_ASSERT(g.LogFile == NULL);
+ g.LogFile = ImFileOpen(filename, "ab");
+ if (!g.LogFile)
+ {
+ IM_ASSERT(g.LogFile != NULL); // Consider this an error
+ return;
+ }
+ g.LogEnabled = true;
+ g.LogStartDepth = window->DC.TreeDepth;
+ if (max_depth >= 0)
+ g.LogAutoExpandMaxDepth = max_depth;
+}
+
+// Start logging ImGui output to clipboard
+void ImGui::LogToClipboard(int max_depth)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.LogEnabled)
+ return;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ IM_ASSERT(g.LogFile == NULL);
+ g.LogFile = NULL;
+ g.LogEnabled = true;
+ g.LogStartDepth = window->DC.TreeDepth;
+ if (max_depth >= 0)
+ g.LogAutoExpandMaxDepth = max_depth;
+}
+
+void ImGui::LogFinish()
+{
+ ImGuiContext& g = *GImGui;
+ if (!g.LogEnabled)
+ return;
+
+ LogText(IM_NEWLINE);
+ if (g.LogFile != NULL)
+ {
+ if (g.LogFile == stdout)
+ fflush(g.LogFile);
+ else
+ fclose(g.LogFile);
+ g.LogFile = NULL;
+ }
+ if (g.LogClipboard.size() > 1)
+ {
+ SetClipboardText(g.LogClipboard.begin());
+ g.LogClipboard.clear();
+ }
+ g.LogEnabled = false;
+}
+
+// Helper to display logging buttons
+void ImGui::LogButtons()
+{
+ ImGuiContext& g = *GImGui;
+
+ PushID("LogButtons");
+ const bool log_to_tty = Button("Log To TTY"); SameLine();
+ const bool log_to_file = Button("Log To File"); SameLine();
+ const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
+ PushItemWidth(80.0f);
+ PushAllowKeyboardFocus(false);
+ SliderInt("Depth", &g.LogAutoExpandMaxDepth, 0, 9, NULL);
+ PopAllowKeyboardFocus();
+ PopItemWidth();
+ PopID();
+
+ // Start logging at the end of the function so that the buttons don't appear in the log
+ if (log_to_tty)
+ LogToTTY(g.LogAutoExpandMaxDepth);
+ if (log_to_file)
+ LogToFile(g.LogAutoExpandMaxDepth, g.IO.LogFilename);
+ if (log_to_clipboard)
+ LogToClipboard(g.LogAutoExpandMaxDepth);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] SETTINGS
+//-----------------------------------------------------------------------------
+
+void ImGui::MarkIniSettingsDirty()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.SettingsDirtyTimer <= 0.0f)
+ g.SettingsDirtyTimer = g.IO.IniSavingRate;
+}
+
+void ImGui::MarkIniSettingsDirty(ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
+ if (g.SettingsDirtyTimer <= 0.0f)
+ g.SettingsDirtyTimer = g.IO.IniSavingRate;
+}
+
+ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
+{
+ ImGuiContext& g = *GImGui;
+ g.SettingsWindows.push_back(ImGuiWindowSettings());
+ ImGuiWindowSettings* settings = &g.SettingsWindows.back();
+ settings->Name = ImStrdup(name);
+ settings->ID = ImHash(name, 0);
+ return settings;
+}
+
+ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
+{
+ ImGuiContext& g = *GImGui;
+ for (int i = 0; i != g.SettingsWindows.Size; i++)
+ if (g.SettingsWindows[i].ID == id)
+ return &g.SettingsWindows[i];
+ return NULL;
+}
+
+void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
+{
+ size_t file_data_size = 0;
+ char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
+ if (!file_data)
+ return;
+ LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
+ ImGui::MemFree(file_data);
+}
+
+ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
+{
+ ImGuiContext& g = *GImGui;
+ const ImGuiID type_hash = ImHash(type_name, 0, 0);
+ for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
+ if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
+ return &g.SettingsHandlers[handler_n];
+ return NULL;
+}
+
+// Zero-tolerance, no error reporting, cheap .ini parsing
+void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.Initialized);
+ IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);
+
+ // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
+ // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
+ if (ini_size == 0)
+ ini_size = strlen(ini_data);
+ char* buf = (char*)ImGui::MemAlloc(ini_size + 1);
+ char* buf_end = buf + ini_size;
+ memcpy(buf, ini_data, ini_size);
+ buf[ini_size] = 0;
+
+ void* entry_data = NULL;
+ ImGuiSettingsHandler* entry_handler = NULL;
+
+ char* line_end = NULL;
+ for (char* line = buf; line < buf_end; line = line_end + 1)
+ {
+ // Skip new lines markers, then find end of the line
+ while (*line == '\n' || *line == '\r')
+ line++;
+ line_end = line;
+ while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
+ line_end++;
+ line_end[0] = 0;
+ if (line[0] == ';')
+ continue;
+ if (line[0] == '[' && line_end > line && line_end[-1] == ']')
+ {
+ // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code.
+ line_end[-1] = 0;
+ const char* name_end = line_end - 1;
+ const char* type_start = line + 1;
+ char* type_end = (char*)(intptr_t)ImStrchrRange(type_start, name_end, ']');
+ const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
+ if (!type_end || !name_start)
+ {
+ name_start = type_start; // Import legacy entries that have no type
+ type_start = "Window";
+ }
+ else
+ {
+ *type_end = 0; // Overwrite first ']'
+ name_start++; // Skip second '['
+ }
+ entry_handler = FindSettingsHandler(type_start);
+ entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL;
+ }
+ else if (entry_handler != NULL && entry_data != NULL)
+ {
+ // Let type handler parse the line
+ entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
+ }
+ }
+ ImGui::MemFree(buf);
+ g.SettingsLoaded = true;
+}
+
+void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
+{
+ ImGuiContext& g = *GImGui;
+ g.SettingsDirtyTimer = 0.0f;
+ if (!ini_filename)
+ return;
+
+ size_t ini_data_size = 0;
+ const char* ini_data = SaveIniSettingsToMemory(&ini_data_size);
+ FILE* f = ImFileOpen(ini_filename, "wt");
+ if (!f)
+ return;
+ fwrite(ini_data, sizeof(char), ini_data_size, f);
+ fclose(f);
+}
+
+// Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer
+const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
+{
+ ImGuiContext& g = *GImGui;
+ g.SettingsDirtyTimer = 0.0f;
+ g.SettingsIniData.Buf.resize(0);
+ g.SettingsIniData.Buf.push_back(0);
+ for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
+ {
+ ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n];
+ handler->WriteAllFn(&g, handler, &g.SettingsIniData);
+ }
+ if (out_size)
+ *out_size = (size_t)g.SettingsIniData.size();
+ return g.SettingsIniData.c_str();
+}
+
+static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
+{
+ ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHash(name, 0));
+ if (!settings)
+ settings = ImGui::CreateNewWindowSettings(name);
+ return (void*)settings;
+}
+
+static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line)
+{
+ ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
+ float x, y;
+ int i;
+ if (sscanf(line, "Pos=%f,%f", &x, &y) == 2) settings->Pos = ImVec2(x, y);
+ else if (sscanf(line, "Size=%f,%f", &x, &y) == 2) settings->Size = ImMax(ImVec2(x, y), GImGui->Style.WindowMinSize);
+ else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0);
+}
+
+static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
+{
+ // Gather data from windows that were active during this session
+ // (if a window wasn't opened in this session we preserve its settings)
+ ImGuiContext& g = *imgui_ctx;
+ for (int i = 0; i != g.Windows.Size; i++)
+ {
+ ImGuiWindow* window = g.Windows[i];
+ if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
+ continue;
+
+ ImGuiWindowSettings* settings = (window->SettingsIdx != -1) ? &g.SettingsWindows[window->SettingsIdx] : ImGui::FindWindowSettings(window->ID);
+ if (!settings)
+ {
+ settings = ImGui::CreateNewWindowSettings(window->Name);
+ window->SettingsIdx = g.SettingsWindows.index_from_ptr(settings);
+ }
+ IM_ASSERT(settings->ID == window->ID);
+ settings->Pos = window->Pos;
+ settings->Size = window->SizeFull;
+ settings->Collapsed = window->Collapsed;
+ }
+
+ // Write to text buffer
+ buf->reserve(buf->size() + g.SettingsWindows.Size * 96); // ballpark reserve
+ for (int i = 0; i != g.SettingsWindows.Size; i++)
+ {
+ const ImGuiWindowSettings* settings = &g.SettingsWindows[i];
+ if (settings->Pos.x == FLT_MAX)
+ continue;
+ const char* name = settings->Name;
+ if (const char* p = strstr(name, "###")) // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID()
+ name = p;
+ buf->appendf("[%s][%s]\n", handler->TypeName, name);
+ buf->appendf("Pos=%d,%d\n", (int)settings->Pos.x, (int)settings->Pos.y);
+ buf->appendf("Size=%d,%d\n", (int)settings->Size.x, (int)settings->Size.y);
+ buf->appendf("Collapsed=%d\n", settings->Collapsed);
+ buf->appendf("\n");
+ }
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] PLATFORM DEPENDENT HELPERS
+//-----------------------------------------------------------------------------
+
+#if defined(_WIN32) && !defined(_WINDOWS_) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef __MINGW32__
+#include <Windows.h>
+#else
+#include <windows.h>
+#endif
+#endif
+
+// Win32 API clipboard implementation
+#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
+
+#ifdef _MSC_VER
+#pragma comment(lib, "user32")
+#endif
+
+static const char* GetClipboardTextFn_DefaultImpl(void*)
+{
+ static ImVector<char> buf_local;
+ buf_local.clear();
+ if (!::OpenClipboard(NULL))
+ return NULL;
+ HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT);
+ if (wbuf_handle == NULL)
+ {
+ ::CloseClipboard();
+ return NULL;
+ }
+ if (ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle))
+ {
+ int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1;
+ buf_local.resize(buf_len);
+ ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL);
+ }
+ ::GlobalUnlock(wbuf_handle);
+ ::CloseClipboard();
+ return buf_local.Data;
+}
+
+static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
+{
+ if (!::OpenClipboard(NULL))
+ return;
+ const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1;
+ HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
+ if (wbuf_handle == NULL)
+ {
+ ::CloseClipboard();
+ return;
+ }
+ ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle);
+ ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL);
+ ::GlobalUnlock(wbuf_handle);
+ ::EmptyClipboard();
+ if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL)
+ ::GlobalFree(wbuf_handle);
+ ::CloseClipboard();
+}
+
+#else
+
+// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
+static const char* GetClipboardTextFn_DefaultImpl(void*)
+{
+ ImGuiContext& g = *GImGui;
+ return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin();
+}
+
+// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
+static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
+{
+ ImGuiContext& g = *GImGui;
+ g.PrivateClipboard.clear();
+ const char* text_end = text + strlen(text);
+ g.PrivateClipboard.resize((int)(text_end - text) + 1);
+ memcpy(&g.PrivateClipboard[0], text, (size_t)(text_end - text));
+ g.PrivateClipboard[(int)(text_end - text)] = 0;
+}
+
+#endif
+
+// Win32 API IME support (for Asian languages, etc.)
+#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
+
+#include <imm.h>
+#ifdef _MSC_VER
+#pragma comment(lib, "imm32")
+#endif
+
+static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y)
+{
+ // Notify OS Input Method Editor of text input position
+ if (HWND hwnd = (HWND)GImGui->IO.ImeWindowHandle)
+ if (HIMC himc = ::ImmGetContext(hwnd))
+ {
+ COMPOSITIONFORM cf;
+ cf.ptCurrentPos.x = x;
+ cf.ptCurrentPos.y = y;
+ cf.dwStyle = CFS_FORCE_POSITION;
+ ::ImmSetCompositionWindow(himc, &cf);
+ ::ImmReleaseContext(hwnd, himc);
+ }
+}
+
+#else
+
+static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
+
+#endif
+
+//-----------------------------------------------------------------------------
+// [SECTION] METRICS/DEBUG WINDOW
+//-----------------------------------------------------------------------------
+
+void ImGui::ShowMetricsWindow(bool* p_open)
+{
+ if (!ImGui::Begin("ImGui Metrics", p_open))
+ {
+ ImGui::End();
+ return;
+ }
+
+ static bool show_draw_cmd_clip_rects = true;
+ static bool show_window_begin_order = false;
+ ImGuiIO& io = ImGui::GetIO();
+ ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
+ ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
+ ImGui::Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3);
+ ImGui::Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows);
+ ImGui::Text("%d allocations", io.MetricsActiveAllocations);
+ ImGui::Checkbox("Show clipping rectangles when hovering draw commands", &show_draw_cmd_clip_rects);
+ ImGui::Checkbox("Ctrl shows window begin order", &show_window_begin_order);
+ ImGui::Separator();
+
+ struct Funcs
+ {
+ static void NodeDrawList(ImGuiWindow* window, ImDrawList* draw_list, const char* label)
+ {
+ bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size);
+ if (draw_list == ImGui::GetWindowDrawList())
+ {
+ ImGui::SameLine();
+ ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
+ if (node_open) ImGui::TreePop();
+ return;
+ }
+
+ ImDrawList* overlay_draw_list = GetOverlayDrawList(window); // Render additional visuals into the top-most draw list
+ if (window && IsItemHovered())
+ overlay_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
+ if (!node_open)
+ return;
+
+ int elem_offset = 0;
+ for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
+ {
+ if (pcmd->UserCallback == NULL && pcmd->ElemCount == 0)
+ continue;
+ if (pcmd->UserCallback)
+ {
+ ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
+ continue;
+ }
+ ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
+ bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %4d %s vtx, tex 0x%p, clip_rect (%4.0f,%4.0f)-(%4.0f,%4.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
+ if (show_draw_cmd_clip_rects && ImGui::IsItemHovered())
+ {
+ ImRect clip_rect = pcmd->ClipRect;
+ ImRect vtxs_rect;
+ for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
+ vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
+ clip_rect.Floor(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,255,0,255));
+ vtxs_rect.Floor(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,0,255,255));
+ }
+ if (!pcmd_node_open)
+ continue;
+
+ // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted.
+ ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible.
+ while (clipper.Step())
+ for (int prim = clipper.DisplayStart, vtx_i = elem_offset + clipper.DisplayStart*3; prim < clipper.DisplayEnd; prim++)
+ {
+ char buf[300];
+ char *buf_p = buf, *buf_end = buf + IM_ARRAYSIZE(buf);
+ ImVec2 triangles_pos[3];
+ for (int n = 0; n < 3; n++, vtx_i++)
+ {
+ ImDrawVert& v = draw_list->VtxBuffer[idx_buffer ? idx_buffer[vtx_i] : vtx_i];
+ triangles_pos[n] = v.pos;
+ buf_p += ImFormatString(buf_p, (int)(buf_end - buf_p), "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n", (n == 0) ? "vtx" : " ", vtx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col);
+ }
+ ImGui::Selectable(buf, false);
+ if (ImGui::IsItemHovered())
+ {
+ ImDrawListFlags backup_flags = overlay_draw_list->Flags;
+ overlay_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles.
+ overlay_draw_list->AddPolyline(triangles_pos, 3, IM_COL32(255,255,0,255), true, 1.0f);
+ overlay_draw_list->Flags = backup_flags;
+ }
+ }
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ static void NodeWindows(ImVector<ImGuiWindow*>& windows, const char* label)
+ {
+ if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
+ return;
+ for (int i = 0; i < windows.Size; i++)
+ Funcs::NodeWindow(windows[i], "Window");
+ ImGui::TreePop();
+ }
+
+ static void NodeWindow(ImGuiWindow* window, const char* label)
+ {
+ if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, window->Active || window->WasActive, window))
+ return;
+ ImGuiWindowFlags flags = window->Flags;
+ NodeDrawList(window, window->DrawList, "DrawList");
+ ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), SizeContents (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->SizeContents.x, window->SizeContents.y);
+ ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags,
+ (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
+ (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
+ (flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
+ ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, GetWindowScrollMaxX(window), window->Scroll.y, GetWindowScrollMaxY(window));
+ ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
+ ImGui::BulletText("Appearing: %d, Hidden: %d (Reg %d Resize %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesRegular, window->HiddenFramesForResize, window->SkipItems);
+ ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
+ ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
+ if (!window->NavRectRel[0].IsInverted())
+ ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y);
+ else
+ ImGui::BulletText("NavRectRel[0]: <None>");
+ if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
+ if (window->ParentWindow != NULL) NodeWindow(window->ParentWindow, "ParentWindow");
+ if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
+ if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
+ {
+ for (int n = 0; n < window->ColumnsStorage.Size; n++)
+ {
+ const ImGuiColumnsSet* columns = &window->ColumnsStorage[n];
+ if (ImGui::TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
+ {
+ ImGui::BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->MaxX - columns->MinX, columns->MinX, columns->MaxX);
+ for (int column_n = 0; column_n < columns->Columns.Size; column_n++)
+ ImGui::BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, OffsetNormToPixels(columns, columns->Columns[column_n].OffsetNorm));
+ ImGui::TreePop();
+ }
+ }
+ ImGui::TreePop();
+ }
+ ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
+ ImGui::TreePop();
+ }
+
+ static void NodeTabBar(ImGuiTabBar* tab_bar)
+ {
+ // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernable strings.
+ char buf[256];
+ char* p = buf;
+ const char* buf_end = buf + IM_ARRAYSIZE(buf);
+ p += ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s",
+ tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : "");
+ if (ImGui::TreeNode(tab_bar, "%s", buf))
+ {
+ for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
+ {
+ const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
+ ImGui::PushID(tab);
+ if (ImGui::SmallButton("<")) { TabBarQueueChangeTabOrder(tab_bar, tab, -1); } ImGui::SameLine(0, 2);
+ if (ImGui::SmallButton(">")) { TabBarQueueChangeTabOrder(tab_bar, tab, +1); } ImGui::SameLine();
+ ImGui::Text("%02d%c Tab 0x%08X", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID);
+ ImGui::PopID();
+ }
+ ImGui::TreePop();
+ }
+ }
+ };
+
+ // Access private state, we are going to display the draw lists from last frame
+ ImGuiContext& g = *GImGui;
+ Funcs::NodeWindows(g.Windows, "Windows");
+ if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.DrawDataBuilder.Layers[0].Size))
+ {
+ for (int i = 0; i < g.DrawDataBuilder.Layers[0].Size; i++)
+ Funcs::NodeDrawList(NULL, g.DrawDataBuilder.Layers[0][i], "DrawList");
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
+ {
+ for (int i = 0; i < g.OpenPopupStack.Size; i++)
+ {
+ ImGuiWindow* window = g.OpenPopupStack[i].Window;
+ ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
+ }
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.Data.Size))
+ {
+ for (int n = 0; n < g.TabBars.Data.Size; n++)
+ Funcs::NodeTabBar(g.TabBars.GetByIndex(n));
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("Internal state"))
+ {
+ const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
+ ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL");
+ ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL");
+ ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
+ ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]);
+ ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
+ ImGui::Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL");
+ ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL");
+ ImGui::Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer);
+ ImGui::Text("NavInputSource: %s", input_source_names[g.NavInputSource]);
+ ImGui::Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible);
+ ImGui::Text("NavActivateId: 0x%08X, NavInputId: 0x%08X", g.NavActivateId, g.NavInputId);
+ ImGui::Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover);
+ ImGui::Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL");
+ ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
+ ImGui::TreePop();
+ }
+
+
+ if (g.IO.KeyCtrl && show_window_begin_order)
+ {
+ for (int n = 0; n < g.Windows.Size; n++)
+ {
+ ImGuiWindow* window = g.Windows[n];
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) || !window->WasActive)
+ continue;
+ char buf[32];
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext);
+ float font_size = ImGui::GetFontSize() * 2;
+ ImDrawList* overlay_draw_list = GetOverlayDrawList(window);
+ overlay_draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
+ overlay_draw_list->AddText(NULL, font_size, window->Pos, IM_COL32(255, 255, 255, 255), buf);
+ }
+ }
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+
+// Include imgui_user.inl at the end of imgui.cpp to access private data/functions that aren't exposed.
+// Prefer just including imgui_internal.h from your code rather than using this define. If a declaration is missing from imgui_internal.h add it or request it on the github.
+#ifdef IMGUI_INCLUDE_IMGUI_USER_INL
+#include "imgui_user.inl"
+#endif
+
+//-----------------------------------------------------------------------------
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imgui.h b/Client/ThirdParty/Box2D/extern/imgui/imgui.h
new file mode 100644
index 0000000..3ac1f0e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imgui.h
@@ -0,0 +1,2130 @@
+// dear imgui, v1.67 WIP
+// (headers)
+
+// See imgui.cpp file for documentation.
+// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
+// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
+// Get latest version at https://github.com/ocornut/imgui
+
+/*
+
+Index of this file:
+// Header mess
+// Forward declarations and basic types
+// ImGui API (Dear ImGui end-user API)
+// Flags & Enumerations
+// ImVector<>
+// ImGuiStyle
+// ImGuiIO
+// Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload)
+// Obsolete functions
+// Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor)
+// Draw List API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListFlags, ImDrawList, ImDrawData)
+// Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
+
+*/
+
+#pragma once
+
+// Configuration file (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
+#ifdef IMGUI_USER_CONFIG
+#include IMGUI_USER_CONFIG
+#endif
+#if !defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H)
+#include "imconfig.h"
+#endif
+
+//-----------------------------------------------------------------------------
+// Header mess
+//-----------------------------------------------------------------------------
+
+#include <float.h> // FLT_MAX
+#include <stdarg.h> // va_list
+#include <stddef.h> // ptrdiff_t, NULL
+#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
+
+// Version
+// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY00 then bounced up to XYY01 when release tagging happens)
+#define IMGUI_VERSION "1.67 WIP"
+#define IMGUI_VERSION_NUM 16602
+#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
+
+// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
+// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h)
+#ifndef IMGUI_API
+#define IMGUI_API
+#endif
+#ifndef IMGUI_IMPL_API
+#define IMGUI_IMPL_API IMGUI_API
+#endif
+
+// Helper Macros
+#ifndef IM_ASSERT
+#include <assert.h>
+#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
+#endif
+#if defined(__clang__) || defined(__GNUC__)
+#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // Apply printf-style warnings to user functions.
+#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
+#else
+#define IM_FMTARGS(FMT)
+#define IM_FMTLIST(FMT)
+#endif
+#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
+#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++.
+
+// Warnings
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wold-style-cast"
+#elif defined(__GNUC__) && __GNUC__ >= 8
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
+
+//-----------------------------------------------------------------------------
+// Forward declarations and basic types
+//-----------------------------------------------------------------------------
+
+struct ImDrawChannel; // Temporary storage for ImDrawList ot output draw commands out of order, used by ImDrawList::ChannelsSplit()
+struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback)
+struct ImDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix.
+struct ImDrawList; // A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder)
+struct ImDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself)
+struct ImDrawVert; // A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT)
+struct ImFont; // Runtime data for a single font within a parent ImFontAtlas
+struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader
+struct ImFontConfig; // Configuration data when adding a font or merging fonts
+struct ImFontGlyph; // A single font glyph (code point + coordinates within in ImFontAtlas + offset)
+struct ImFontGlyphRangesBuilder; // Helper to build glyph ranges from text/string data
+struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 (*OBSOLETE* please avoid using)
+struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h)
+struct ImGuiIO; // Main configuration and I/O between your application and ImGui
+struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use)
+struct ImGuiListClipper; // Helper to manually clip large list of items
+struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
+struct ImGuiPayload; // User data payload for drag and drop operations
+struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
+struct ImGuiStorage; // Helper for key->value storage
+struct ImGuiStyle; // Runtime data for styling/colors
+struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
+struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbb][,ccccc]")
+
+// Typedefs and Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file)
+// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
+#ifndef ImTextureID
+typedef void* ImTextureID; // User data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
+#endif
+typedef unsigned int ImGuiID; // Unique ID used by widgets (typically hashed from a stack of string)
+typedef unsigned short ImWchar; // A single U16 character for keyboard input/display. We encode them as multi bytes UTF-8 when used in strings.
+typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
+typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for Set*()
+typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
+typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
+typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum)
+typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation
+typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
+typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
+typedef int ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect*() etc.
+typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList
+typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas
+typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags
+typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit*(), ColorPicker*()
+typedef int ImGuiColumnsFlags; // -> enum ImGuiColumnsFlags_ // Flags: for Columns(), BeginColumns()
+typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
+typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
+typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for *DragDrop*()
+typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
+typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
+typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText*()
+typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
+typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
+typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
+typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode*(),CollapsingHeader()
+typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin*()
+typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
+typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
+
+// Scalar data types
+typedef signed int ImS32; // 32-bit signed integer == int
+typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
+#if defined(_MSC_VER) && !defined(__clang__)
+typedef signed __int64 ImS64; // 64-bit signed integer (pre and post C++11 with Visual Studio)
+typedef unsigned __int64 ImU64; // 64-bit unsigned integer (pre and post C++11 with Visual Studio)
+#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100)
+#include <stdint.h>
+typedef int64_t ImS64; // 64-bit signed integer (pre C++11)
+typedef uint64_t ImU64; // 64-bit unsigned integer (pre C++11)
+#else
+typedef signed long long ImS64; // 64-bit signed integer (post C++11)
+typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11)
+#endif
+
+// 2D vector (often used to store positions, sizes, etc.)
+struct ImVec2
+{
+ float x, y;
+ ImVec2() { x = y = 0.0f; }
+ ImVec2(float _x, float _y) { x = _x; y = _y; }
+ float operator[] (size_t i) const { IM_ASSERT(i <= 1); return (&x)[i]; } // We very rarely use this [] operator, the assert overhead is fine.
+#ifdef IM_VEC2_CLASS_EXTRA
+ IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
+#endif
+};
+
+// 4D vector (often used to store floating-point colors)
+struct ImVec4
+{
+ float x, y, z, w;
+ ImVec4() { x = y = z = w = 0.0f; }
+ ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
+#ifdef IM_VEC4_CLASS_EXTRA
+ IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
+#endif
+};
+
+//-----------------------------------------------------------------------------
+// ImGui: Dear ImGui end-user API
+// (Inside a namespace so you can add extra functions in your own separate file. Please don't modify imgui.cpp/.h!)
+//-----------------------------------------------------------------------------
+
+namespace ImGui
+{
+ // Context creation and access
+ // Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts.
+ // All those functions are not reliant on the current context.
+ IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL);
+ IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
+ IMGUI_API ImGuiContext* GetCurrentContext();
+ IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
+ IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert);
+
+ // Main
+ IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
+ IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame.
+ IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until Render()/EndFrame().
+ IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), you likely don't need to call that yourself directly. If you don't need to render data (skipping rendering) you may call EndFrame() but you'll have wasted CPU already! If you don't need to render, better to not create any imgui windows and not call NewFrame() at all!
+ IMGUI_API void Render(); // ends the ImGui frame, finalize the draw data. (Obsolete: optionally call io.RenderDrawListsFn if set. Nowadays, prefer calling your render function yourself.)
+ IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render. (Obsolete: this used to be passed to your io.RenderDrawListsFn() function.)
+
+ // Demo, Debug, Information
+ IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
+ IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create about window. display Dear ImGui version, credits and build/system information.
+ IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
+ IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
+ IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
+ IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
+ IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
+ IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.23"
+
+ // Styles
+ IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); // new, recommended style (default)
+ IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); // classic imgui style
+ IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); // best used with borders and a custom, thicker font
+
+ // Windows
+ // - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
+ // - You may append multiple times to the same window during the same frame.
+ // - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
+ // which clicking will set the boolean to false when clicked.
+ // - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
+ // anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
+ // [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc.
+ // where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
+ // - Note that the bottom of window stack always contains a window called "Debug".
+ IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
+ IMGUI_API void End();
+
+ // Child Windows
+ // - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
+ // - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
+ // - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
+ // Always call a matching EndChild() for each BeginChild() call, regardless of its return value [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
+ IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
+ IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
+ IMGUI_API void EndChild();
+
+ // Windows Utilities
+ // - "current window" = the window we are appending into while inside a Begin()/End() block. "next window" = next window we will Begin() into.
+ IMGUI_API bool IsWindowAppearing();
+ IMGUI_API bool IsWindowCollapsed();
+ IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
+ IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
+ IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the window, to append your own drawing primitives
+ IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
+ IMGUI_API ImVec2 GetWindowSize(); // get current window size
+ IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
+ IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
+ IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
+ IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
+ IMGUI_API float GetContentRegionAvailWidth(); //
+ IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
+ IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
+ IMGUI_API float GetWindowContentRegionWidth(); //
+
+ IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
+ IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
+ IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
+ IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin()
+ IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
+ IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
+ IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily modify ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
+ IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
+ IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
+ IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
+ IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / front-most. prefer using SetNextWindowFocus().
+ IMGUI_API void SetWindowFontScale(float scale); // set font scale. Adjust IO.FontGlobalScale if you want to scale all windows
+ IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
+ IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
+ IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
+ IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
+
+ // Windows Scrolling
+ IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
+ IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
+ IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X
+ IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y
+ IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()]
+ IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
+ IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
+ IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
+
+ // Parameters stacks (shared)
+ IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font
+ IMGUI_API void PopFont();
+ IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col);
+ IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col);
+ IMGUI_API void PopStyleColor(int count = 1);
+ IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
+ IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
+ IMGUI_API void PopStyleVar(int count = 1);
+ IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in.
+ IMGUI_API ImFont* GetFont(); // get current font
+ IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
+ IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
+ IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier
+ IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied
+ IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied
+
+ // Parameters stacks (current window)
+ IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side)
+ IMGUI_API void PopItemWidth();
+ IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position
+ IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
+ IMGUI_API void PopTextWrapPos();
+ IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
+ IMGUI_API void PopAllowKeyboardFocus();
+ IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
+ IMGUI_API void PopButtonRepeat();
+
+ // Cursor / Layout
+ // - By "cursor" we mean the current output position.
+ // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
+ IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
+ IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates.
+ IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context.
+ IMGUI_API void Spacing(); // add vertical spacing.
+ IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.
+ IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if != 0
+ IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if != 0
+ IMGUI_API void BeginGroup(); // lock horizontal starting position
+ IMGUI_API void EndGroup(); // unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
+ IMGUI_API ImVec2 GetCursorPos(); // cursor position in window coordinates (relative to window position)
+ IMGUI_API float GetCursorPosX(); // (some functions are using window-relative coordinates, such as: GetCursorPos, GetCursorStartPos, GetContentRegionMax, GetWindowContentRegion* etc.
+ IMGUI_API float GetCursorPosY(); // other functions such as GetCursorScreenPos or everything in ImDrawList::
+ IMGUI_API void SetCursorPos(const ImVec2& local_pos); // are using the main, absolute coordinate system.
+ IMGUI_API void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.)
+ IMGUI_API void SetCursorPosY(float local_y); //
+ IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position in window coordinates
+ IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
+ IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
+ IMGUI_API void AlignTextToFramePadding(); // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item)
+ IMGUI_API float GetTextLineHeight(); // ~ FontSize
+ IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
+ IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2
+ IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
+
+ // ID stack/scopes
+ // - Read the FAQ for more details about how ID are handled in dear imgui. If you are creating widgets in a loop you most
+ // likely want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them.
+ // - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others.
+ // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed and used as an ID,
+ // whereas "str_id" denote a string that is only used as an ID and not normally displayed.
+ IMGUI_API void PushID(const char* str_id); // push string identifier into the ID stack. IDs == hash of the entire stack!
+ IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end);
+ IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack.
+ IMGUI_API void PushID(int int_id); // push integer into the ID stack.
+ IMGUI_API void PopID(); // pop from the ID stack.
+ IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
+ IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end);
+ IMGUI_API ImGuiID GetID(const void* ptr_id);
+
+ // Widgets: Text
+ IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
+ IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text
+ IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
+ IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
+ IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2);
+ IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
+ IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1);
+ IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize().
+ IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1);
+ IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets
+ IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2);
+ IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text()
+ IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1);
+
+ // Widgets: Main
+ // - Most widgets return true when the value has been changed or when pressed/selected
+ IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
+ IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
+ IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
+ IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
+ IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
+ IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
+ IMGUI_API bool Checkbox(const char* label, bool* v);
+ IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
+ IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
+ IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
+ IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL);
+ IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
+
+ // Widgets: Combo Box
+ // - The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
+ // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose.
+ IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
+ IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true!
+ IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1);
+ IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
+ IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1);
+
+ // Widgets: Drags
+ // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
+ // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
+ // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
+ // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
+ IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f); // If v_min >= v_max we have no bound
+ IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, float power = 1.0f);
+ IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d"); // If v_min >= v_max we have no bound
+ IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d");
+ IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d");
+ IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d");
+ IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL);
+ IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* v, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f);
+ IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* v, int components, float v_speed, const void* v_min = NULL, const void* v_max = NULL, const char* format = NULL, float power = 1.0f);
+
+ // Widgets: Sliders
+ // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
+ // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
+ IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for power curve sliders
+ IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg");
+ IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d");
+ IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d");
+ IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d");
+ IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d");
+ IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f);
+ IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f);
+ IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
+ IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d");
+ IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format = NULL, float power = 1.0f);
+
+ // Widgets: Input with Keyboard
+ // - If you want to use InputText() with a dynamic string type such as std::string or your own, see misc/cpp/imgui_stdlib.h
+ // - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
+ IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+ IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+ IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0f, double step_fast = 0.0f, const char* format = "%.6f", ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* v, const void* step = NULL, const void* step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* step = NULL, const void* step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0);
+
+ // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.)
+ // - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can the pass the address of a first float element out of a contiguous structure, e.g. &myvector.x
+ IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0);
+ IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0);
+ IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0);
+ IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL);
+ IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed.
+ IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls.
+
+ // Widgets: Trees
+ // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents.
+ IMGUI_API bool TreeNode(const char* label);
+ IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // helper variation to completely decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet().
+ IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // "
+ IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2);
+ IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2);
+ IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0);
+ IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
+ IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
+ IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
+ IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
+ IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired.
+ IMGUI_API void TreePush(const void* ptr_id = NULL); // "
+ IMGUI_API void TreePop(); // ~ Unindent()+PopId()
+ IMGUI_API void TreeAdvanceToLabelPos(); // advance cursor x position by GetTreeNodeToLabelSpacing()
+ IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
+ IMGUI_API void SetNextTreeNodeOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state.
+ IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().
+ IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header
+
+ // Widgets: Selectables
+ // - A selectable highlights when hovered, and can display another color when selected.
+ // - Neighbors selectable extend their highlight bounds in order to leave no gap between them.
+ IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
+ IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
+
+ // Widgets: List Boxes
+ // - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them.
+ IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
+ IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
+ IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. if the function return true, you can output elements then call ListBoxFooter() afterwards.
+ IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "
+ IMGUI_API void ListBoxFooter(); // terminate the scrolling region. only call ListBoxFooter() if ListBoxHeader() returned true!
+
+ // Widgets: Data Plotting
+ IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
+ IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
+ IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
+ IMGUI_API void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
+
+ // Widgets: Value() Helpers.
+ // - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace)
+ IMGUI_API void Value(const char* prefix, bool b);
+ IMGUI_API void Value(const char* prefix, int v);
+ IMGUI_API void Value(const char* prefix, unsigned int v);
+ IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
+
+ // Widgets: Menus
+ IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
+ IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
+ IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window).
+ IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true!
+ IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
+ IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true!
+ IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
+ IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
+
+ // Tooltips
+ IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
+ IMGUI_API void EndTooltip();
+ IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip().
+ IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
+
+ // Popups, Modals
+ // The properties of popups windows are:
+ // - They block normal mouse hovering detection outside them. (*)
+ // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
+ // - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
+ // User can manipulate the visibility state by calling OpenPopup().
+ // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
+ // Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
+ IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
+ IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true!
+ IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
+ IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, int mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window.
+ IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows).
+ IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside)
+ IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
+ IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, int mouse_button = 1); // helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). return true when just opened.
+ IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current begin-ed level of the popup stack.
+ IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.
+
+ // Columns
+ // - You can also use SameLine(pos_x) to mimic simplified columns.
+ // - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!)
+ IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
+ IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
+ IMGUI_API int GetColumnIndex(); // get current column index
+ IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column
+ IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column
+ IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f
+ IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
+ IMGUI_API int GetColumnsCount();
+
+ // Tab Bars, Tabs
+ // [BETA API] API may evolve!
+ IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
+ IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
+ IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected.
+ IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
+ IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
+
+ // Logging/Capture
+ // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
+ IMGUI_API void LogToTTY(int max_depth = -1); // start logging to tty (stdout)
+ IMGUI_API void LogToFile(int max_depth = -1, const char* filename = NULL); // start logging to file
+ IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard
+ IMGUI_API void LogFinish(); // stop logging (close file, etc.)
+ IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
+ IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed)
+
+ // Drag and Drop
+ // [BETA API] API may evolve!
+ IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
+ IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
+ IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
+ IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
+ IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
+ IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true!
+ IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type.
+
+ // Clipping
+ IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
+ IMGUI_API void PopClipRect();
+
+ // Focus, Activation
+ // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item"
+ IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window.
+ IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget.
+
+ // Item/Widgets Utilities
+ // - Most of the functions are referring to the last/previous item we submitted.
+ // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions.
+ IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options.
+ IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false)
+ IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation?
+ IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered()
+ IMGUI_API bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling)
+ IMGUI_API bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets.
+ IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing.
+ IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item).
+ IMGUI_API bool IsAnyItemHovered();
+ IMGUI_API bool IsAnyItemActive();
+ IMGUI_API bool IsAnyItemFocused();
+ IMGUI_API ImVec2 GetItemRectMin(); // get upper-left bounding rectangle of the last item (screen space)
+ IMGUI_API ImVec2 GetItemRectMax(); // get lower-right bounding rectangle of the last item (screen space)
+ IMGUI_API ImVec2 GetItemRectSize(); // get size of last item
+ IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
+
+ // Miscellaneous Utilities
+ IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
+ IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
+ IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame.
+ IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame.
+ IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text
+ IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances
+ IMGUI_API const char* GetStyleColorName(ImGuiCol idx);
+ IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
+ IMGUI_API ImGuiStorage* GetStateStorage();
+ IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
+ IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
+ IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
+ IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window)
+
+ // Color Utilities
+ IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in);
+ IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in);
+ IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
+ IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
+
+ // Inputs Utilities
+ IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
+ IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]!
+ IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
+ IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)..
+ IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
+ IMGUI_API bool IsMouseDown(int button); // is mouse button held (0=left, 1=right, 2=middle)
+ IMGUI_API bool IsAnyMouseDown(); // is any mouse button held
+ IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down) (0=left, 1=right, 2=middle)
+ IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
+ IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
+ IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
+ IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
+ IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); //
+ IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
+ IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse position at the time of opening popup we have BeginPopup() into
+ IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position. This is locked and return 0.0f until the mouse moves past a distance threshold at least once. If lock_threshold < -1.0f uses io.MouseDraggingThreshold
+ IMGUI_API void ResetMouseDragDelta(int button = 0); //
+ IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
+ IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type
+ IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
+ IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call.
+
+ // Clipboard Utilities (also see the LogToClipboard() function to capture or output text data to the clipboard)
+ IMGUI_API const char* GetClipboardText();
+ IMGUI_API void SetClipboardText(const char* text);
+
+ // Settings/.Ini Utilities
+ // - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini").
+ // - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually.
+ IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
+ IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
+ IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename);
+ IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings.
+
+ // Memory Utilities
+ // - All those functions are not reliant on the current context.
+ // - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again.
+ IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data = NULL);
+ IMGUI_API void* MemAlloc(size_t size);
+ IMGUI_API void MemFree(void* ptr);
+
+} // namespace ImGui
+
+//-----------------------------------------------------------------------------
+// Flags & Enumerations
+//-----------------------------------------------------------------------------
+
+// Flags for ImGui::Begin()
+enum ImGuiWindowFlags_
+{
+ ImGuiWindowFlags_None = 0,
+ ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar
+ ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip
+ ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window
+ ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programatically)
+ ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
+ ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it
+ ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
+ ImGuiWindowFlags_NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
+ ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
+ ImGuiWindowFlags_NoMouseInputs = 1 << 9, // Disable catching mouse, hovering test with pass through.
+ ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
+ ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
+ ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
+ ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
+ ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y)
+ ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x)
+ ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
+ ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
+ ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
+ ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
+ ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
+ ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
+ ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
+
+ // [Internal]
+ ImGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!)
+ ImGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild()
+ ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip()
+ ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
+ ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
+ ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu()
+
+ // [Obsolete]
+ //ImGuiWindowFlags_ShowBorders = 1 << 7, // --> Set style.FrameBorderSize=1.0f / style.WindowBorderSize=1.0f to enable borders around windows and items
+ //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges and make sure mouse cursors are supported by back-end (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors)
+};
+
+// Flags for ImGui::InputText()
+enum ImGuiInputTextFlags_
+{
+ ImGuiInputTextFlags_None = 0,
+ ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
+ ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
+ ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z
+ ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs
+ ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
+ ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
+ ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling)
+ ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling)
+ ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer.
+ ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
+ ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field
+ ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter).
+ ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally
+ ImGuiInputTextFlags_AlwaysInsertMode = 1 << 13, // Insert mode
+ ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode
+ ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*'
+ ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
+ ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
+ ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
+ // [Internal]
+ ImGuiInputTextFlags_Multiline = 1 << 20 // For internal use by InputTextMultiline()
+};
+
+// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*()
+enum ImGuiTreeNodeFlags_
+{
+ ImGuiTreeNodeFlags_None = 0,
+ ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected
+ ImGuiTreeNodeFlags_Framed = 1 << 1, // Full colored frame (e.g. for CollapsingHeader)
+ ImGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one
+ ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
+ ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes)
+ ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open
+ ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node
+ ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
+ ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
+ ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow
+ ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
+ //ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
+ //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
+ ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
+ ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog
+
+ // Obsolete names (will be removed)
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ , ImGuiTreeNodeFlags_AllowOverlapMode = ImGuiTreeNodeFlags_AllowItemOverlap
+#endif
+};
+
+// Flags for ImGui::Selectable()
+enum ImGuiSelectableFlags_
+{
+ ImGuiSelectableFlags_None = 0,
+ ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window
+ ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column)
+ ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
+ ImGuiSelectableFlags_Disabled = 1 << 3 // Cannot be selected, display greyed out text
+};
+
+// Flags for ImGui::BeginCombo()
+enum ImGuiComboFlags_
+{
+ ImGuiComboFlags_None = 0,
+ ImGuiComboFlags_PopupAlignLeft = 1 << 0, // Align the popup toward the left by default
+ ImGuiComboFlags_HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo()
+ ImGuiComboFlags_HeightRegular = 1 << 2, // Max ~8 items visible (default)
+ ImGuiComboFlags_HeightLarge = 1 << 3, // Max ~20 items visible
+ ImGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible
+ ImGuiComboFlags_NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button
+ ImGuiComboFlags_NoPreview = 1 << 6, // Display only a square arrow button
+ ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest
+};
+
+// Flags for ImGui::BeginTabBar()
+enum ImGuiTabBarFlags_
+{
+ ImGuiTabBarFlags_None = 0,
+ ImGuiTabBarFlags_Reorderable = 1 << 0, // Allow manually dragging tabs to re-order them + New tabs are appended at the end of list
+ ImGuiTabBarFlags_AutoSelectNewTabs = 1 << 1, // Automatically select new tabs when they appear
+ ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
+ ImGuiTabBarFlags_NoTabListPopupButton = 1 << 3,
+ ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4,
+ ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab
+ ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, // Resize tabs when they don't fit
+ ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit
+ ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll,
+ ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown
+};
+
+// Flags for ImGui::BeginTabItem()
+enum ImGuiTabItemFlags_
+{
+ ImGuiTabItemFlags_None = 0,
+ ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker.
+ ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programatically make the tab selected when calling BeginTabItem()
+ ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
+ ImGuiTabItemFlags_NoPushId = 1 << 3 // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
+};
+
+// Flags for ImGui::IsWindowFocused()
+enum ImGuiFocusedFlags_
+{
+ ImGuiFocusedFlags_None = 0,
+ ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
+ ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
+ ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use ImGui::GetIO().WantCaptureMouse instead.
+ ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
+};
+
+// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
+// Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ!
+// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls.
+enum ImGuiHoveredFlags_
+{
+ ImGuiHoveredFlags_None = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them.
+ ImGuiHoveredFlags_ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered
+ ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
+ ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered
+ ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 3, // Return true even if a popup window is normally blocking access to this item/window
+ //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 4, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
+ ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 5, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
+ ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 6, // Return true even if the position is overlapped by another window
+ ImGuiHoveredFlags_AllowWhenDisabled = 1 << 7, // Return true even if the item is disabled
+ ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
+ ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows
+};
+
+// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
+enum ImGuiDragDropFlags_
+{
+ ImGuiDragDropFlags_None = 0,
+ // BeginDragDropSource() flags
+ ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior.
+ ImGuiDragDropFlags_SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return false, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item.
+ ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item.
+ ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit.
+ ImGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously.
+ ImGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged)
+ // AcceptDragDropPayload() flags
+ ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered.
+ ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target.
+ ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site.
+ ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect // For peeking ahead and inspecting the payload before delivery.
+};
+
+// Standard Drag and Drop payload types. You can define you own payload types using short strings. Types starting with '_' are defined by Dear ImGui.
+#define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3]: Standard type for colors, without alpha. User code may use this type.
+#define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4]: Standard type for colors. User code may use this type.
+
+// A primary data type
+enum ImGuiDataType_
+{
+ ImGuiDataType_S32, // int
+ ImGuiDataType_U32, // unsigned int
+ ImGuiDataType_S64, // long long, __int64
+ ImGuiDataType_U64, // unsigned long long, unsigned __int64
+ ImGuiDataType_Float, // float
+ ImGuiDataType_Double, // double
+ ImGuiDataType_COUNT
+};
+
+// A cardinal direction
+enum ImGuiDir_
+{
+ ImGuiDir_None = -1,
+ ImGuiDir_Left = 0,
+ ImGuiDir_Right = 1,
+ ImGuiDir_Up = 2,
+ ImGuiDir_Down = 3,
+ ImGuiDir_COUNT
+};
+
+// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
+enum ImGuiKey_
+{
+ ImGuiKey_Tab,
+ ImGuiKey_LeftArrow,
+ ImGuiKey_RightArrow,
+ ImGuiKey_UpArrow,
+ ImGuiKey_DownArrow,
+ ImGuiKey_PageUp,
+ ImGuiKey_PageDown,
+ ImGuiKey_Home,
+ ImGuiKey_End,
+ ImGuiKey_Insert,
+ ImGuiKey_Delete,
+ ImGuiKey_Backspace,
+ ImGuiKey_Space,
+ ImGuiKey_Enter,
+ ImGuiKey_Escape,
+ ImGuiKey_A, // for text edit CTRL+A: select all
+ ImGuiKey_C, // for text edit CTRL+C: copy
+ ImGuiKey_V, // for text edit CTRL+V: paste
+ ImGuiKey_X, // for text edit CTRL+X: cut
+ ImGuiKey_Y, // for text edit CTRL+Y: redo
+ ImGuiKey_Z, // for text edit CTRL+Z: undo
+ ImGuiKey_COUNT
+};
+
+// Gamepad/Keyboard directional navigation
+// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
+// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
+// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW.
+enum ImGuiNavInput_
+{
+ // Gamepad Mapping
+ ImGuiNavInput_Activate, // activate / open / toggle / tweak value // e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard)
+ ImGuiNavInput_Cancel, // cancel / close / exit // e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard)
+ ImGuiNavInput_Input, // text input / on-screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard)
+ ImGuiNavInput_Menu, // tap: toggle menu / hold: focus, move, resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard)
+ ImGuiNavInput_DpadLeft, // move / tweak / resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard)
+ ImGuiNavInput_DpadRight, //
+ ImGuiNavInput_DpadUp, //
+ ImGuiNavInput_DpadDown, //
+ ImGuiNavInput_LStickLeft, // scroll / move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down
+ ImGuiNavInput_LStickRight, //
+ ImGuiNavInput_LStickUp, //
+ ImGuiNavInput_LStickDown, //
+ ImGuiNavInput_FocusPrev, // next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
+ ImGuiNavInput_FocusNext, // prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
+ ImGuiNavInput_TweakSlow, // slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
+ ImGuiNavInput_TweakFast, // faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
+
+ // [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them.
+ // Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[].
+ ImGuiNavInput_KeyMenu_, // toggle menu // = io.KeyAlt
+ ImGuiNavInput_KeyLeft_, // move left // = Arrow keys
+ ImGuiNavInput_KeyRight_, // move right
+ ImGuiNavInput_KeyUp_, // move up
+ ImGuiNavInput_KeyDown_, // move down
+ ImGuiNavInput_COUNT,
+ ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyMenu_
+};
+
+// Configuration flags stored in io.ConfigFlags. Set by user/application.
+enum ImGuiConfigFlags_
+{
+ ImGuiConfigFlags_None = 0,
+ ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeysDown[].
+ ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[]. Back-end also needs to set ImGuiBackendFlags_HasGamepad.
+ ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth.
+ ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set.
+ ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the back-end.
+ ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct back-end to not alter mouse cursor shape and visibility. Use if the back-end cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
+
+ // User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core ImGui)
+ ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
+ ImGuiConfigFlags_IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse.
+};
+
+// Back-end capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom back-end.
+enum ImGuiBackendFlags_
+{
+ ImGuiBackendFlags_None = 0,
+ ImGuiBackendFlags_HasGamepad = 1 << 0, // Back-end supports gamepad and currently has one connected.
+ ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Back-end supports honoring GetMouseCursor() value to change the OS cursor shape.
+ ImGuiBackendFlags_HasSetMousePos = 1 << 2 // Back-end supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
+};
+
+// Enumeration for PushStyleColor() / PopStyleColor()
+enum ImGuiCol_
+{
+ ImGuiCol_Text,
+ ImGuiCol_TextDisabled,
+ ImGuiCol_WindowBg, // Background of normal windows
+ ImGuiCol_ChildBg, // Background of child windows
+ ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows
+ ImGuiCol_Border,
+ ImGuiCol_BorderShadow,
+ ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input
+ ImGuiCol_FrameBgHovered,
+ ImGuiCol_FrameBgActive,
+ ImGuiCol_TitleBg,
+ ImGuiCol_TitleBgActive,
+ ImGuiCol_TitleBgCollapsed,
+ ImGuiCol_MenuBarBg,
+ ImGuiCol_ScrollbarBg,
+ ImGuiCol_ScrollbarGrab,
+ ImGuiCol_ScrollbarGrabHovered,
+ ImGuiCol_ScrollbarGrabActive,
+ ImGuiCol_CheckMark,
+ ImGuiCol_SliderGrab,
+ ImGuiCol_SliderGrabActive,
+ ImGuiCol_Button,
+ ImGuiCol_ButtonHovered,
+ ImGuiCol_ButtonActive,
+ ImGuiCol_Header,
+ ImGuiCol_HeaderHovered,
+ ImGuiCol_HeaderActive,
+ ImGuiCol_Separator,
+ ImGuiCol_SeparatorHovered,
+ ImGuiCol_SeparatorActive,
+ ImGuiCol_ResizeGrip,
+ ImGuiCol_ResizeGripHovered,
+ ImGuiCol_ResizeGripActive,
+ ImGuiCol_Tab,
+ ImGuiCol_TabHovered,
+ ImGuiCol_TabActive,
+ ImGuiCol_TabUnfocused,
+ ImGuiCol_TabUnfocusedActive,
+ ImGuiCol_PlotLines,
+ ImGuiCol_PlotLinesHovered,
+ ImGuiCol_PlotHistogram,
+ ImGuiCol_PlotHistogramHovered,
+ ImGuiCol_TextSelectedBg,
+ ImGuiCol_DragDropTarget,
+ ImGuiCol_NavHighlight, // Gamepad/keyboard: current highlighted item
+ ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
+ ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active
+ ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active
+ ImGuiCol_COUNT
+
+ // Obsolete names (will be removed)
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ , ImGuiCol_ModalWindowDarkening = ImGuiCol_ModalWindowDimBg // [renamed in 1.63]
+ , ImGuiCol_ChildWindowBg = ImGuiCol_ChildBg // [renamed in 1.53]
+ , ImGuiCol_Column = ImGuiCol_Separator, ImGuiCol_ColumnHovered = ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive = ImGuiCol_SeparatorActive // [renamed in 1.51]
+ //ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered, // [unused since 1.60+] the close button now uses regular button colors.
+ //ImGuiCol_ComboBg, // [unused since 1.53+] ComboBg has been merged with PopupBg, so a redirect isn't accurate.
+#endif
+};
+
+// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure.
+// NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly.
+// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
+enum ImGuiStyleVar_
+{
+ // Enum name ......................// Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
+ ImGuiStyleVar_Alpha, // float Alpha
+ ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
+ ImGuiStyleVar_WindowRounding, // float WindowRounding
+ ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize
+ ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize
+ ImGuiStyleVar_WindowTitleAlign, // ImVec2 WindowTitleAlign
+ ImGuiStyleVar_ChildRounding, // float ChildRounding
+ ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize
+ ImGuiStyleVar_PopupRounding, // float PopupRounding
+ ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize
+ ImGuiStyleVar_FramePadding, // ImVec2 FramePadding
+ ImGuiStyleVar_FrameRounding, // float FrameRounding
+ ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize
+ ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing
+ ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing
+ ImGuiStyleVar_IndentSpacing, // float IndentSpacing
+ ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize
+ ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding
+ ImGuiStyleVar_GrabMinSize, // float GrabMinSize
+ ImGuiStyleVar_GrabRounding, // float GrabRounding
+ ImGuiStyleVar_TabRounding, // float TabRounding
+ ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
+ ImGuiStyleVar_COUNT
+
+ // Obsolete names (will be removed)
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ , ImGuiStyleVar_Count_ = ImGuiStyleVar_COUNT, ImGuiStyleVar_ChildWindowRounding = ImGuiStyleVar_ChildRounding
+#endif
+};
+
+// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
+enum ImGuiColorEditFlags_
+{
+ ImGuiColorEditFlags_None = 0,
+ ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the input pointer).
+ ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on colored square.
+ ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
+ ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs)
+ ImGuiColorEditFlags_NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview colored square).
+ ImGuiColorEditFlags_NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview.
+ ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
+ ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
+ ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
+
+ // User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup.
+ ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
+ ImGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
+ ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque.
+ ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
+ ImGuiColorEditFlags_RGB = 1 << 20, // [Inputs] // ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using RGB/HSV/HEX.
+ ImGuiColorEditFlags_HSV = 1 << 21, // [Inputs] // "
+ ImGuiColorEditFlags_HEX = 1 << 22, // [Inputs] // "
+ ImGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255.
+ ImGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers.
+ ImGuiColorEditFlags_PickerHueBar = 1 << 25, // [PickerMode] // ColorPicker: bar for Hue, rectangle for Sat/Value.
+ ImGuiColorEditFlags_PickerHueWheel = 1 << 26, // [PickerMode] // ColorPicker: wheel for Hue, triangle for Sat/Value.
+
+ // [Internal] Masks
+ ImGuiColorEditFlags__InputsMask = ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_HSV|ImGuiColorEditFlags_HEX,
+ ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float,
+ ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
+ ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_RGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions()
+};
+
+// Enumeration for GetMouseCursor()
+// User code may request binding to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here
+enum ImGuiMouseCursor_
+{
+ ImGuiMouseCursor_None = -1,
+ ImGuiMouseCursor_Arrow = 0,
+ ImGuiMouseCursor_TextInput, // When hovering over InputText, etc.
+ ImGuiMouseCursor_ResizeAll, // (Unused by imgui functions)
+ ImGuiMouseCursor_ResizeNS, // When hovering over an horizontal border
+ ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column
+ ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window
+ ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window
+ ImGuiMouseCursor_Hand, // (Unused by imgui functions. Use for e.g. hyperlinks)
+ ImGuiMouseCursor_COUNT
+
+ // Obsolete names (will be removed)
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ , ImGuiMouseCursor_Count_ = ImGuiMouseCursor_COUNT
+#endif
+};
+
+// Enumateration for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
+// Represent a condition.
+// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
+enum ImGuiCond_
+{
+ ImGuiCond_Always = 1 << 0, // Set the variable
+ ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed)
+ ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
+ ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
+
+ // Obsolete names (will be removed)
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ , ImGuiSetCond_Always = ImGuiCond_Always, ImGuiSetCond_Once = ImGuiCond_Once, ImGuiSetCond_FirstUseEver = ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing = ImGuiCond_Appearing
+#endif
+};
+
+//-----------------------------------------------------------------------------
+// Helper: ImVector<>
+// Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug).
+// You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our data structures are relying on it.
+// Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs.
+// Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that,
+// do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset.
+//-----------------------------------------------------------------------------
+
+template<typename T>
+struct ImVector
+{
+ int Size;
+ int Capacity;
+ T* Data;
+
+ // Provide standard typedefs but we don't use them ourselves.
+ typedef T value_type;
+ typedef value_type* iterator;
+ typedef const value_type* const_iterator;
+
+ // Constructors, destructor
+ inline ImVector() { Size = Capacity = 0; Data = NULL; }
+ inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
+ inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
+ inline ~ImVector() { if (Data) ImGui::MemFree(Data); }
+
+ inline bool empty() const { return Size == 0; }
+ inline int size() const { return Size; }
+ inline int capacity() const { return Capacity; }
+ inline T& operator[](int i) { IM_ASSERT(i < Size); return Data[i]; }
+ inline const T& operator[](int i) const { IM_ASSERT(i < Size); return Data[i]; }
+
+ inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
+ inline T* begin() { return Data; }
+ inline const T* begin() const { return Data; }
+ inline T* end() { return Data + Size; }
+ inline const T* end() const { return Data + Size; }
+ inline T& front() { IM_ASSERT(Size > 0); return Data[0]; }
+ inline const T& front() const { IM_ASSERT(Size > 0); return Data[0]; }
+ inline T& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; }
+ inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
+ inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
+
+ inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; }
+ inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
+ inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
+ inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)ImGui::MemAlloc((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); ImGui::MemFree(Data); } Data = new_data; Capacity = new_capacity; }
+
+ // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden.
+ inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
+ inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
+ inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); }
+ inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; }
+ inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data+Size && it_last > it && it_last <= Data+Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; }
+ inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
+ inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
+ inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
+ inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; return (int)off; }
+};
+
+//-----------------------------------------------------------------------------
+// ImGuiStyle
+// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
+// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values,
+// and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors.
+//-----------------------------------------------------------------------------
+
+struct ImGuiStyle
+{
+ float Alpha; // Global alpha applies to everything in ImGui.
+ ImVec2 WindowPadding; // Padding within a window.
+ float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows.
+ float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
+ ImVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints().
+ ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered.
+ float ChildRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
+ float ChildBorderSize; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
+ float PopupRounding; // Radius of popup window corners rounding. (Note that tooltip windows use WindowRounding)
+ float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
+ ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets).
+ float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
+ float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
+ ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
+ ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
+ ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
+ float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
+ float ColumnsMinSpacing; // Minimum horizontal spacing between two columns.
+ float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar.
+ float ScrollbarRounding; // Radius of grab corners for scrollbar.
+ float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
+ float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
+ float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
+ float TabBorderSize; // Thickness of border around tabs.
+ ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered.
+ ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
+ ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
+ float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
+ bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
+ bool AntiAliasedFill; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
+ float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
+ ImVec4 Colors[ImGuiCol_COUNT];
+
+ IMGUI_API ImGuiStyle();
+ IMGUI_API void ScaleAllSizes(float scale_factor);
+};
+
+//-----------------------------------------------------------------------------
+// ImGuiIO
+// Communicate most settings and inputs/outputs to Dear ImGui using this structure.
+// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
+//-----------------------------------------------------------------------------
+
+struct ImGuiIO
+{
+ //------------------------------------------------------------------
+ // Configuration (fill once) // Default value
+ //------------------------------------------------------------------
+
+ ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc.
+ ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by back-end (imgui_impl_xxx files or custom back-end) to communicate features supported by the back-end.
+ ImVec2 DisplaySize; // <unset> // Main display size, in pixels. For clamping windows positions.
+ float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
+ float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
+ const char* IniFilename; // = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
+ const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
+ float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
+ float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
+ float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging.
+ int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state.
+ float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
+ float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
+ void* UserData; // = NULL // Store your own data for retrieval by callbacks.
+
+ ImFontAtlas*Fonts; // <auto> // Load, rasterize and pack one or more fonts into a single texture.
+ float FontGlobalScale; // = 1.0f // Global scale all fonts
+ bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
+ ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
+ ImVec2 DisplayFramebufferScale; // = (1.0f,1.0f) // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
+ ImVec2 DisplayVisibleMin; // <unset> // [OBSOLETE] If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
+ ImVec2 DisplayVisibleMax; // <unset> // [OBSOLETE] Just use io.DisplaySize! If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
+
+ // Miscellaneous configuration options
+ bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by back-end implementations.
+ bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl (was called io.OptMacOSXBehaviors prior to 1.63)
+ bool ConfigInputTextCursorBlink; // = true // Set to false to disable blinking cursor, for users who consider it distracting. (was called: io.OptCursorBlink prior to 1.63)
+ bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be the a per-window ImGuiWindowFlags_ResizeFromAnySide flag)
+ bool ConfigWindowsMoveFromTitleBarOnly;// = false // [BETA] Set to true to only allow moving windows when clicked+dragged from the title bar. Windows without a title bar are not affected.
+
+ //------------------------------------------------------------------
+ // Platform Functions
+ // (the imgui_impl_xxxx back-end files are setting those up for you)
+ //------------------------------------------------------------------
+
+ // Optional: Platform/Renderer back-end name (informational only! will be displayed in About Window) + User data for back-end/wrappers to store their own stuff.
+ const char* BackendPlatformName; // = NULL
+ const char* BackendRendererName; // = NULL
+ void* BackendPlatformUserData; // = NULL
+ void* BackendRendererUserData; // = NULL
+ void* BackendLanguageUserData; // = NULL
+
+ // Optional: Access OS clipboard
+ // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
+ const char* (*GetClipboardTextFn)(void* user_data);
+ void (*SetClipboardTextFn)(void* user_data, const char* text);
+ void* ClipboardUserData;
+
+ // Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
+ // (default to use native imm32 api on Windows)
+ void (*ImeSetInputScreenPosFn)(int x, int y);
+ void* ImeWindowHandle; // = NULL // (Windows) Set this to your HWND to get automatic IME cursor positioning.
+
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ // [OBSOLETE since 1.60+] Rendering function, will be automatically called in Render(). Please call your rendering function yourself now!
+ // You can obtain the ImDrawData* by calling ImGui::GetDrawData() after Render(). See example applications if you are unsure of how to implement this.
+ void (*RenderDrawListsFn)(ImDrawData* data);
+#else
+ // This is only here to keep ImGuiIO the same size/layout, so that IMGUI_DISABLE_OBSOLETE_FUNCTIONS can exceptionally be used outside of imconfig.h.
+ void* RenderDrawListsFnUnused;
+#endif
+
+ //------------------------------------------------------------------
+ // Input - Fill before calling NewFrame()
+ //------------------------------------------------------------------
+
+ ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (on another screen, etc.)
+ bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
+ float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
+ float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends.
+ bool KeyCtrl; // Keyboard modifier pressed: Control
+ bool KeyShift; // Keyboard modifier pressed: Shift
+ bool KeyAlt; // Keyboard modifier pressed: Alt
+ bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows
+ bool KeysDown[512]; // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
+ float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
+
+ // Functions
+ IMGUI_API void AddInputCharacter(ImWchar c); // Queue new character input
+ IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
+ IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
+
+ //------------------------------------------------------------------
+ // Output - Retrieve after calling NewFrame()
+ //------------------------------------------------------------------
+
+ bool WantCaptureMouse; // When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
+ bool WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
+ bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
+ bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
+ bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. IMPORTANT: You need to clear io.WantSaveIniSettings yourself.
+ bool NavActive; // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
+ bool NavVisible; // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
+ float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
+ int MetricsRenderVertices; // Vertices output during last call to Render()
+ int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
+ int MetricsRenderWindows; // Number of visible windows
+ int MetricsActiveWindows; // Number of active windows
+ int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts.
+ ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
+
+ //------------------------------------------------------------------
+ // [Internal] ImGui will maintain those fields. Forward compatibility not guaranteed!
+ //------------------------------------------------------------------
+
+ ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
+ ImVec2 MouseClickedPos[5]; // Position at time of clicking
+ double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
+ bool MouseClicked[5]; // Mouse button went from !Down to Down
+ bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
+ bool MouseReleased[5]; // Mouse button went from Down to !Down
+ bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
+ float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
+ float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
+ ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point
+ float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point
+ float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed)
+ float KeysDownDurationPrev[512]; // Previous duration the key has been down
+ float NavInputsDownDuration[ImGuiNavInput_COUNT];
+ float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
+ ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform back-end). Fill using AddInputCharacter() helper.
+
+ IMGUI_API ImGuiIO();
+};
+
+//-----------------------------------------------------------------------------
+// Misc data structures
+//-----------------------------------------------------------------------------
+
+// Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used.
+// The callback function should return 0 by default.
+// Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details)
+// - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB
+// - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows
+// - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration
+// - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
+// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
+struct ImGuiInputTextCallbackData
+{
+ ImGuiInputTextFlags EventFlag; // One ImGuiInputTextFlags_Callback* // Read-only
+ ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
+ void* UserData; // What user passed to InputText() // Read-only
+
+ // Arguments for the different callback events
+ // - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary.
+ // - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state.
+ ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
+ ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History]
+ char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
+ int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
+ int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1
+ bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always]
+ int CursorPos; // // Read-write // [Completion,History,Always]
+ int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection)
+ int SelectionEnd; // // Read-write // [Completion,History,Always]
+
+ // Helper functions for text manipulation.
+ // Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection.
+ IMGUI_API ImGuiInputTextCallbackData();
+ IMGUI_API void DeleteChars(int pos, int bytes_count);
+ IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL);
+ bool HasSelection() const { return SelectionStart != SelectionEnd; }
+};
+
+// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin().
+// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough.
+struct ImGuiSizeCallbackData
+{
+ void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints()
+ ImVec2 Pos; // Read-only. Window position, for reference.
+ ImVec2 CurrentSize; // Read-only. Current window size.
+ ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
+};
+
+// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
+struct ImGuiPayload
+{
+ // Members
+ void* Data; // Data (copied and owned by dear imgui)
+ int DataSize; // Data size
+
+ // [Internal]
+ ImGuiID SourceId; // Source item id
+ ImGuiID SourceParentId; // Source parent id (if available)
+ int DataFrameCount; // Data timestamp
+ char DataType[32+1]; // Data type tag (short user-supplied string, 32 characters max)
+ bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
+ bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
+
+ ImGuiPayload() { Clear(); }
+ void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; }
+ bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; }
+ bool IsPreview() const { return Preview; }
+ bool IsDelivery() const { return Delivery; }
+};
+
+//-----------------------------------------------------------------------------
+// Obsolete functions (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details)
+// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead.
+//-----------------------------------------------------------------------------
+
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+namespace ImGui
+{
+ // OBSOLETED in 1.66 (from Sep 2018)
+ static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); }
+ // OBSOLETED in 1.63 (between Aug 2018 and Sept 2018)
+ static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); }
+ // OBSOLETED in 1.61 (between Apr 2018 and Aug 2018)
+ IMGUI_API bool InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags = 0); // Use the 'const char* format' version instead of 'decimal_precision'!
+ IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags = 0);
+ IMGUI_API bool InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags = 0);
+ // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
+ static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
+ static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
+ static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { (void)on_edge; (void)outward; IM_ASSERT(0); return pos; }
+ // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
+ static inline void ShowTestWindow() { return ShowDemoWindow(); }
+ static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); }
+ static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); }
+ static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }
+ static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); }
+ // OBSOLETED in 1.52 (between Aug 2017 and Oct 2017)
+ IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize(size, ImGuiCond_FirstUseEver) + SetNextWindowBgAlpha() instead.
+ static inline bool IsRootWindowOrAnyChildHovered() { return IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); }
+ static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); }
+ static inline void SetNextWindowPosCenter(ImGuiCond c=0) { ImGuiIO& io = GetIO(); SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), c, ImVec2(0.5f, 0.5f)); }
+ // OBSOLETED in 1.51 (between Jun 2017 and Aug 2017)
+ static inline bool IsItemHoveredRect() { return IsItemHovered(ImGuiHoveredFlags_RectOnly); }
+ static inline bool IsPosHoveringAnyWindow(const ImVec2&) { IM_ASSERT(0); return false; } // This was misleading and partly broken. You probably want to use the ImGui::GetIO().WantCaptureMouse flag instead.
+ static inline bool IsMouseHoveringAnyWindow() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
+ static inline bool IsMouseHoveringWindow() { return IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); }
+}
+typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETE in 1.63 (from Aug 2018): made the names consistent
+typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData;
+#endif
+
+//-----------------------------------------------------------------------------
+// Helpers
+//-----------------------------------------------------------------------------
+
+// Helper: IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE() macros to call MemAlloc + Placement New, Placement Delete + MemFree
+// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
+// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
+struct ImNewDummy {};
+inline void* operator new(size_t, ImNewDummy, void* ptr) { return ptr; }
+inline void operator delete(void*, ImNewDummy, void*) {} // This is only required so we can use the symetrical new()
+#define IM_PLACEMENT_NEW(_PTR) new(ImNewDummy(), _PTR)
+#define IM_NEW(_TYPE) new(ImNewDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
+template<typename T> void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } }
+
+// Helper: Execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
+// Usage: static ImGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame");
+struct ImGuiOnceUponAFrame
+{
+ ImGuiOnceUponAFrame() { RefFrame = -1; }
+ mutable int RefFrame;
+ operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
+};
+
+// Helper: Macro for ImGuiOnceUponAFrame. Attention: The macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf; if (imgui_oaf) // OBSOLETED in 1.51, will remove!
+#endif
+
+// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
+struct ImGuiTextFilter
+{
+ IMGUI_API ImGuiTextFilter(const char* default_filter = "");
+ IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
+ IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const;
+ IMGUI_API void Build();
+ void Clear() { InputBuf[0] = 0; Build(); }
+ bool IsActive() const { return !Filters.empty(); }
+
+ // [Internal]
+ struct TextRange
+ {
+ const char* b;
+ const char* e;
+
+ TextRange() { b = e = NULL; }
+ TextRange(const char* _b, const char* _e) { b = _b; e = _e; }
+ const char* begin() const { return b; }
+ const char* end () const { return e; }
+ bool empty() const { return b == e; }
+ IMGUI_API void split(char separator, ImVector<TextRange>* out) const;
+ };
+ char InputBuf[256];
+ ImVector<TextRange> Filters;
+ int CountGrep;
+};
+
+// Helper: Growable text buffer for logging/accumulating text
+// (this could be called 'ImGuiTextBuilder' / 'ImGuiStringBuilder')
+struct ImGuiTextBuffer
+{
+ ImVector<char> Buf;
+ static char EmptyString[1];
+
+ ImGuiTextBuffer() { }
+ inline char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
+ const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; }
+ const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
+ int size() const { return Buf.Data ? Buf.Size - 1 : 0; }
+ bool empty() { return Buf.Size <= 1; }
+ void clear() { Buf.clear(); }
+ void reserve(int capacity) { Buf.reserve(capacity); }
+ const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
+ IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2);
+ IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2);
+};
+
+// Helper: Key->Value storage
+// Typically you don't have to worry about this since a storage is held within each Window.
+// We use it to e.g. store collapse state for a tree (Int 0/1)
+// This is optimized for efficient lookup (dichotomy into a contiguous buffer) and rare insertion (typically tied to user interactions aka max once a frame)
+// You can use it as custom user storage for temporary values. Declare your own storage if, for example:
+// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
+// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient)
+// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
+struct ImGuiStorage
+{
+ struct Pair
+ {
+ ImGuiID key;
+ union { int val_i; float val_f; void* val_p; };
+ Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
+ Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
+ Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
+ };
+ ImVector<Pair> Data;
+
+ // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
+ // - Set***() functions find pair, insertion on demand if missing.
+ // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
+ void Clear() { Data.clear(); }
+ IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const;
+ IMGUI_API void SetInt(ImGuiID key, int val);
+ IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const;
+ IMGUI_API void SetBool(ImGuiID key, bool val);
+ IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const;
+ IMGUI_API void SetFloat(ImGuiID key, float val);
+ IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
+ IMGUI_API void SetVoidPtr(ImGuiID key, void* val);
+
+ // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
+ // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
+ // - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct)
+ // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
+ IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0);
+ IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false);
+ IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f);
+ IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL);
+
+ // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
+ IMGUI_API void SetAllInt(int val);
+
+ // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
+ IMGUI_API void BuildSortByKey();
+};
+
+// Helper: Manually clip large list of items.
+// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all.
+// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
+// ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null.
+// Usage:
+// ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced.
+// while (clipper.Step())
+// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
+// ImGui::Text("line number %d", i);
+// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor).
+// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
+// - (Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
+// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
+struct ImGuiListClipper
+{
+ float StartPosY;
+ float ItemsHeight;
+ int ItemsCount, StepNo, DisplayStart, DisplayEnd;
+
+ // items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
+ // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
+ // If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
+ ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want).
+ ~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false.
+
+ IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
+ IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1.
+ IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
+};
+
+// Helpers macros to generate 32-bits encoded colors
+#ifdef IMGUI_USE_BGRA_PACKED_COLOR
+#define IM_COL32_R_SHIFT 16
+#define IM_COL32_G_SHIFT 8
+#define IM_COL32_B_SHIFT 0
+#define IM_COL32_A_SHIFT 24
+#define IM_COL32_A_MASK 0xFF000000
+#else
+#define IM_COL32_R_SHIFT 0
+#define IM_COL32_G_SHIFT 8
+#define IM_COL32_B_SHIFT 16
+#define IM_COL32_A_SHIFT 24
+#define IM_COL32_A_MASK 0xFF000000
+#endif
+#define IM_COL32(R,G,B,A) (((ImU32)(A)<<IM_COL32_A_SHIFT) | ((ImU32)(B)<<IM_COL32_B_SHIFT) | ((ImU32)(G)<<IM_COL32_G_SHIFT) | ((ImU32)(R)<<IM_COL32_R_SHIFT))
+#define IM_COL32_WHITE IM_COL32(255,255,255,255) // Opaque white = 0xFFFFFFFF
+#define IM_COL32_BLACK IM_COL32(0,0,0,255) // Opaque black
+#define IM_COL32_BLACK_TRANS IM_COL32(0,0,0,0) // Transparent black = 0x00000000
+
+// Helper: ImColor() implicity converts colors to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
+// Prefer using IM_COL32() macros if you want a guaranteed compile-time ImU32 for usage with ImDrawList API.
+// **Avoid storing ImColor! Store either u32 of ImVec4. This is not a full-featured color class. MAY OBSOLETE.
+// **None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either ImU32 or ImVec4 formats. Explicitly cast to ImU32 or ImVec4 if needed.
+struct ImColor
+{
+ ImVec4 Value;
+
+ ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
+ ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
+ ImColor(ImU32 rgba) { float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
+ ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
+ ImColor(const ImVec4& col) { Value = col; }
+ inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
+ inline operator ImVec4() const { return Value; }
+
+ // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
+ inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
+ static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
+};
+
+//-----------------------------------------------------------------------------
+// Draw List API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListFlags, ImDrawList, ImDrawData)
+// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList.
+//-----------------------------------------------------------------------------
+
+// Draw callbacks for advanced uses.
+// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering,
+// you can poke into the draw list for that! Draw callback may be useful for example to: A) Change your GPU render state,
+// B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc.
+// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }'
+typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
+
+// Typically, 1 command = 1 GPU draw call (unless command is a callback)
+struct ImDrawCmd
+{
+ unsigned int ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
+ ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
+ ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
+ ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
+ void* UserCallbackData; // The draw callback code can access this.
+
+ ImDrawCmd() { ElemCount = 0; ClipRect.x = ClipRect.y = ClipRect.z = ClipRect.w = 0.0f; TextureId = (ImTextureID)NULL; UserCallback = NULL; UserCallbackData = NULL; }
+};
+
+// Vertex index (override with '#define ImDrawIdx unsigned int' in imconfig.h)
+#ifndef ImDrawIdx
+typedef unsigned short ImDrawIdx;
+#endif
+
+// Vertex layout
+#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
+struct ImDrawVert
+{
+ ImVec2 pos;
+ ImVec2 uv;
+ ImU32 col;
+};
+#else
+// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
+// The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine.
+// The type has to be described within the macro (you can either declare the struct or use a typedef)
+// NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM.
+IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
+#endif
+
+// Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together.
+// You can also use them to simulate drawing layers and submit primitives in a different order than how they will be rendered.
+struct ImDrawChannel
+{
+ ImVector<ImDrawCmd> CmdBuffer;
+ ImVector<ImDrawIdx> IdxBuffer;
+};
+
+enum ImDrawCornerFlags_
+{
+ ImDrawCornerFlags_TopLeft = 1 << 0, // 0x1
+ ImDrawCornerFlags_TopRight = 1 << 1, // 0x2
+ ImDrawCornerFlags_BotLeft = 1 << 2, // 0x4
+ ImDrawCornerFlags_BotRight = 1 << 3, // 0x8
+ ImDrawCornerFlags_Top = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_TopRight, // 0x3
+ ImDrawCornerFlags_Bot = ImDrawCornerFlags_BotLeft | ImDrawCornerFlags_BotRight, // 0xC
+ ImDrawCornerFlags_Left = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft, // 0x5
+ ImDrawCornerFlags_Right = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight, // 0xA
+ ImDrawCornerFlags_All = 0xF // In your function calls you may use ~0 (= all bits sets) instead of ImDrawCornerFlags_All, as a convenience
+};
+
+enum ImDrawListFlags_
+{
+ ImDrawListFlags_None = 0,
+ ImDrawListFlags_AntiAliasedLines = 1 << 0, // Lines are anti-aliased (*2 the number of triangles for 1.0f wide line, otherwise *3 the number of triangles)
+ ImDrawListFlags_AntiAliasedFill = 1 << 1 // Filled shapes have anti-aliased edges (*2 the number of vertices)
+};
+
+// Draw command list
+// This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
+// Each ImGui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to access the current window draw list and draw custom primitives.
+// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
+// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well)
+// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects.
+struct ImDrawList
+{
+ // This is what you have to render
+ ImVector<ImDrawCmd> CmdBuffer; // Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback.
+ ImVector<ImDrawIdx> IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those
+ ImVector<ImDrawVert> VtxBuffer; // Vertex buffer.
+ ImDrawListFlags Flags; // Flags, you may poke into these to adjust anti-aliasing settings per-primitive.
+
+ // [Internal, used while building lists]
+ const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context)
+ const char* _OwnerName; // Pointer to owner window's name for debugging
+ unsigned int _VtxCurrentIdx; // [Internal] == VtxBuffer.Size
+ ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
+ ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
+ ImVector<ImVec4> _ClipRectStack; // [Internal]
+ ImVector<ImTextureID> _TextureIdStack; // [Internal]
+ ImVector<ImVec2> _Path; // [Internal] current path building
+ int _ChannelsCurrent; // [Internal] current channel number (0)
+ int _ChannelsCount; // [Internal] number of active channels (1+)
+ ImVector<ImDrawChannel> _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
+
+ // If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
+ ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); }
+ ~ImDrawList() { ClearFreeMemory(); }
+ IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
+ IMGUI_API void PushClipRectFullScreen();
+ IMGUI_API void PopClipRect();
+ IMGUI_API void PushTextureID(ImTextureID texture_id);
+ IMGUI_API void PopTextureID();
+ inline ImVec2 GetClipRectMin() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.x, cr.y); }
+ inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); }
+
+ // Primitives
+ IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
+ IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right, rounding_corners_flags: 4-bits corresponding to which corner to round
+ IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All); // a: upper-left, b: lower-right
+ IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
+ IMGUI_API void AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness = 1.0f);
+ IMGUI_API void AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col);
+ IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness = 1.0f);
+ IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
+ IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
+ IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
+ IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
+ IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
+ IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,1), ImU32 col = 0xFFFFFFFF);
+ IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,0), const ImVec2& uv_c = ImVec2(1,1), const ImVec2& uv_d = ImVec2(0,1), ImU32 col = 0xFFFFFFFF);
+ IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners = ImDrawCornerFlags_All);
+ IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness);
+ IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order.
+ IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
+
+ // Stateful path API, add points then finish with PathFillConvex() or PathStroke()
+ inline void PathClear() { _Path.Size = 0; }
+ inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
+ inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
+ inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
+ inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
+ IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
+ IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
+ IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
+ IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners_flags = ImDrawCornerFlags_All);
+
+ // Channels
+ // - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
+ // - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
+ IMGUI_API void ChannelsSplit(int channels_count);
+ IMGUI_API void ChannelsMerge();
+ IMGUI_API void ChannelsSetCurrent(int channel_index);
+
+ // Advanced
+ IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
+ IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
+ IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
+
+ // Internal helpers
+ // NB: all primitives needs to be reserved via PrimReserve() beforehand!
+ IMGUI_API void Clear();
+ IMGUI_API void ClearFreeMemory();
+ IMGUI_API void PrimReserve(int idx_count, int vtx_count);
+ IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
+ IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
+ IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
+ inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
+ inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
+ inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
+ IMGUI_API void UpdateClipRect();
+ IMGUI_API void UpdateTextureID();
+};
+
+// All draw data to render an ImGui frame
+// (NB: the style and the naming convention here is a little inconsistent but we preserve them for backward compatibility purpose)
+struct ImDrawData
+{
+ bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
+ ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here.
+ int CmdListsCount; // Number of ImDrawList* to render
+ int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
+ int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
+ ImVec2 DisplayPos; // Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
+ ImVec2 DisplaySize; // Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
+
+ // Functions
+ ImDrawData() { Valid = false; Clear(); }
+ ~ImDrawData() { Clear(); }
+ void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; DisplayPos = DisplaySize = ImVec2(0.f, 0.f); } // The ImDrawList are owned by ImGuiContext!
+ IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
+ IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
+};
+
+//-----------------------------------------------------------------------------
+// Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFontGlyphRangesBuilder, ImFont)
+//-----------------------------------------------------------------------------
+
+struct ImFontConfig
+{
+ void* FontData; // // TTF/OTF data
+ int FontDataSize; // // TTF/OTF data size
+ bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself).
+ int FontNo; // 0 // Index of font within TTF/OTF file
+ float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height).
+ int OversampleH; // 3 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
+ int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
+ bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
+ ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
+ ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input.
+ const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
+ float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
+ float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs
+ bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
+ unsigned int RasterizerFlags; // 0x00 // Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one.
+ float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
+
+ // [Internal]
+ char Name[40]; // Name (strictly to ease debugging)
+ ImFont* DstFont;
+
+ IMGUI_API ImFontConfig();
+};
+
+struct ImFontGlyph
+{
+ ImWchar Codepoint; // 0x0000..0xFFFF
+ float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
+ float X0, Y0, X1, Y1; // Glyph corners
+ float U0, V0, U1, V1; // Texture coordinates
+};
+
+// Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges().
+// This is essentially a tightly packed of vector of 64k booleans = 8KB storage.
+struct ImFontGlyphRangesBuilder
+{
+ ImVector<int> UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used)
+
+ ImFontGlyphRangesBuilder() { UsedChars.resize(0x10000 / 32); memset(UsedChars.Data, 0, 0x10000 / 32); }
+ bool GetBit(int n) const { int off = (n >> 5); int mask = 1 << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
+ void SetBit(int n) { int off = (n >> 5); int mask = 1 << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
+ void AddChar(ImWchar c) { SetBit(c); } // Add character
+ IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added)
+ IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext
+ IMGUI_API void BuildRanges(ImVector<ImWchar>* out_ranges); // Output new ranges
+};
+
+enum ImFontAtlasFlags_
+{
+ ImFontAtlasFlags_None = 0,
+ ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two
+ ImFontAtlasFlags_NoMouseCursors = 1 << 1 // Don't build software mouse cursors into the atlas
+};
+
+// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
+// - One or more fonts.
+// - Custom graphics data needed to render the shapes needed by Dear ImGui.
+// - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas).
+// It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api.
+// - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you.
+// - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
+// - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples)
+// - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API.
+// This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details.
+// Common pitfalls:
+// - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the
+// atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data.
+// - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction.
+// You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed,
+// - Even though many functions are suffixed with "TTF", OTF data is supported just as well.
+// - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future!
+struct ImFontAtlas
+{
+ IMGUI_API ImFontAtlas();
+ IMGUI_API ~ImFontAtlas();
+ IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg);
+ IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL);
+ IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL);
+ IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
+ IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
+ IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
+ IMGUI_API void ClearInputData(); // Clear input data (all ImFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts.
+ IMGUI_API void ClearTexData(); // Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory.
+ IMGUI_API void ClearFonts(); // Clear output font data (glyphs storage, UV coordinates).
+ IMGUI_API void Clear(); // Clear all input and output.
+
+ // Build atlas, retrieve pixel data.
+ // User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
+ // The pitch is always = Width * BytesPerPixels (1 or 4)
+ // Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
+ // the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
+ IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
+ IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
+ IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
+ bool IsBuilt() { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); }
+ void SetTexID(ImTextureID id) { TexID = id; }
+
+ //-------------------------------------------
+ // Glyph Ranges
+ //-------------------------------------------
+
+ // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
+ // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
+ // NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data.
+ IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
+ IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
+ IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
+ IMGUI_API const ImWchar* GetGlyphRangesChineseFull(); // Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs
+ IMGUI_API const ImWchar* GetGlyphRangesChineseSimplifiedCommon();// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese
+ IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
+ IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters
+
+ //-------------------------------------------
+ // Custom Rectangles/Glyphs API
+ //-------------------------------------------
+
+ // You can request arbitrary rectangles to be packed into the atlas, for your own purposes. After calling Build(), you can query the rectangle position and render your pixels.
+ // You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), so you can render e.g. custom colorful icons and use them as regular glyphs.
+ struct CustomRect
+ {
+ unsigned int ID; // Input // User ID. Use <0x10000 to map into a font glyph, >=0x10000 for other/internal/custom texture data.
+ unsigned short Width, Height; // Input // Desired rectangle dimension
+ unsigned short X, Y; // Output // Packed position in Atlas
+ float GlyphAdvanceX; // Input // For custom font glyphs only (ID<0x10000): glyph xadvance
+ ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID<0x10000): glyph display offset
+ ImFont* Font; // Input // For custom font glyphs only (ID<0x10000): target font
+ CustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; }
+ bool IsPacked() const { return X != 0xFFFF; }
+ };
+
+ IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
+ IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font.
+ const CustomRect* GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
+
+ // [Internal]
+ IMGUI_API void CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max);
+ IMGUI_API bool GetMouseCursorTexData(ImGuiMouseCursor cursor, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]);
+
+ //-------------------------------------------
+ // Members
+ //-------------------------------------------
+
+ bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
+ ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_)
+ ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
+ int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
+ int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1.
+
+ // [Internal]
+ // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
+ unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
+ unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
+ int TexWidth; // Texture width calculated during Build().
+ int TexHeight; // Texture height calculated during Build().
+ ImVec2 TexUvScale; // = (1.0f/TexWidth, 1.0f/TexHeight)
+ ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
+ ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
+ ImVector<CustomRect> CustomRects; // Rectangles for packing custom texture data into the atlas.
+ ImVector<ImFontConfig> ConfigData; // Internal data
+ int CustomRectIds[1]; // Identifiers of custom texture rectangle used by ImFontAtlas/ImDrawList
+
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETE 1.67+
+#endif
+};
+
+// Font runtime data and rendering
+// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
+struct ImFont
+{
+ // Members: Hot ~62/78 bytes
+ float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
+ float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
+ ImVec2 DisplayOffset; // = (0.f,0.f) // Offset font rendering by xx pixels
+ ImVector<ImFontGlyph> Glyphs; // // All glyphs.
+ ImVector<float> IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
+ ImVector<ImWchar> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
+ const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
+ float FallbackAdvanceX; // == FallbackGlyph->AdvanceX
+ ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
+
+ // Members: Cold ~18/26 bytes
+ short ConfigDataCount; // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
+ ImFontConfig* ConfigData; // // Pointer within ContainerAtlas->ConfigData
+ ImFontAtlas* ContainerAtlas; // // What we has been loaded into
+ float Ascent, Descent; // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
+ bool DirtyLookupTables;
+ int MetricsTotalSurface;// // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
+
+ // Methods
+ IMGUI_API ImFont();
+ IMGUI_API ~ImFont();
+ IMGUI_API void ClearOutputData();
+ IMGUI_API void BuildLookupTable();
+ IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
+ IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
+ IMGUI_API void SetFallbackChar(ImWchar c);
+ float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
+ bool IsLoaded() const { return ContainerAtlas != NULL; }
+ const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }
+
+ // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
+ // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
+ IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
+ IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
+ IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const;
+ IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
+
+ // [Internal]
+ IMGUI_API void GrowIndex(int new_size);
+ IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
+ IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
+
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ typedef ImFontGlyph Glyph; // OBSOLETE 1.52+
+#endif
+};
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#elif defined(__GNUC__) && __GNUC__ >= 8
+#pragma GCC diagnostic pop
+#endif
+
+// Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h)
+#ifdef IMGUI_INCLUDE_IMGUI_USER_H
+#include "imgui_user.h"
+#endif
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imgui_demo.cpp b/Client/ThirdParty/Box2D/extern/imgui/imgui_demo.cpp
new file mode 100644
index 0000000..cf1d4b3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imgui_demo.cpp
@@ -0,0 +1,4211 @@
+// dear imgui, v1.67 WIP
+// (demo code)
+
+// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
+// Do NOT remove this file from your project! Think again! It is the most useful reference code that you and other coders
+// will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available debug menu of
+// your game/app! Removing this file from your project is hindering access to documentation for everyone in your team,
+// likely leading you to poorer usage of the library.
+// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow().
+// If you want to link core Dear ImGui in your shipped builds but want an easy guarantee that the demo will not be linked,
+// you can setup your imconfig.h with #define IMGUI_DISABLE_DEMO_WINDOWS and those functions will be empty.
+// In other situation, whenever you have Dear ImGui available you probably want this to be available for reference.
+// Thank you,
+// -Your beloved friend, imgui_demo.cpp (that you won't delete)
+
+// Message to beginner C/C++ programmers about the meaning of the 'static' keyword:
+// In this demo code, we frequently we use 'static' variables inside functions. A static variable persist across calls, so it is
+// essentially like a global variable but declared inside the scope of the function. We do this as a way to gather code and data
+// in the same place, to make the demo source code faster to read, faster to write, and smaller in size.
+// It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant
+// or used in threads. This might be a pattern you will want to use in your code, but most of the real data you would be editing is
+// likely going to be stored outside your functions.
+
+/*
+
+Index of this file:
+
+// [SECTION] Forward Declarations, Helpers
+// [SECTION] Demo Window / ShowDemoWindow()
+// [SECTION] About Window / ShowAboutWindow()
+// [SECTION] Style Editor / ShowStyleEditor()
+// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
+// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
+// [SECTION] Example App: Debug Log / ShowExampleAppLog()
+// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
+// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
+// [SECTION] Example App: Long Text / ShowExampleAppLongText()
+// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
+// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize()
+// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
+// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
+// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
+// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
+
+*/
+
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "imgui.h"
+#include <ctype.h> // toupper, isprint
+#include <limits.h> // INT_MIN, INT_MAX
+#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
+#include <stdio.h> // vsnprintf, sscanf, printf
+#include <stdlib.h> // NULL, malloc, free, atoi
+#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
+#include <stddef.h> // intptr_t
+#else
+#include <stdint.h> // intptr_t
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#define vsnprintf _vsnprintf
+#endif
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
+#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
+#pragma clang diagnostic ignored "-Wformat-security" // warning : warning: format string is not a string literal
+#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
+#if __has_warning("-Wreserved-id-macro")
+#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
+#endif
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
+#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
+#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
+#if (__GNUC__ >= 6)
+#pragma GCC diagnostic ignored "-Wmisleading-indentation" // warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on GitHub.
+#endif
+#endif
+
+// Play it nice with Windows users. Notepad in 2017 still doesn't display text data with Unix-style \n.
+#ifdef _WIN32
+#define IM_NEWLINE "\r\n"
+#else
+#define IM_NEWLINE "\n"
+#endif
+
+#define IM_MAX(_A,_B) (((_A) >= (_B)) ? (_A) : (_B))
+
+//-----------------------------------------------------------------------------
+// [SECTION] Forward Declarations, Helpers
+//-----------------------------------------------------------------------------
+
+#if !defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS) && defined(IMGUI_DISABLE_TEST_WINDOWS) && !defined(IMGUI_DISABLE_DEMO_WINDOWS) // Obsolete name since 1.53, TEST->DEMO
+#define IMGUI_DISABLE_DEMO_WINDOWS
+#endif
+
+#if !defined(IMGUI_DISABLE_DEMO_WINDOWS)
+
+// Forward Declarations
+static void ShowExampleAppDocuments(bool* p_open);
+static void ShowExampleAppMainMenuBar();
+static void ShowExampleAppConsole(bool* p_open);
+static void ShowExampleAppLog(bool* p_open);
+static void ShowExampleAppLayout(bool* p_open);
+static void ShowExampleAppPropertyEditor(bool* p_open);
+static void ShowExampleAppLongText(bool* p_open);
+static void ShowExampleAppAutoResize(bool* p_open);
+static void ShowExampleAppConstrainedResize(bool* p_open);
+static void ShowExampleAppSimpleOverlay(bool* p_open);
+static void ShowExampleAppWindowTitles(bool* p_open);
+static void ShowExampleAppCustomRendering(bool* p_open);
+static void ShowExampleMenuFile();
+
+// Helper to display a little (?) mark which shows a tooltip when hovered.
+static void ShowHelpMarker(const char* desc)
+{
+ ImGui::TextDisabled("(?)");
+ if (ImGui::IsItemHovered())
+ {
+ ImGui::BeginTooltip();
+ ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
+ ImGui::TextUnformatted(desc);
+ ImGui::PopTextWrapPos();
+ ImGui::EndTooltip();
+ }
+}
+
+// Helper to display basic user controls.
+void ImGui::ShowUserGuide()
+{
+ ImGui::BulletText("Double-click on title bar to collapse window.");
+ ImGui::BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents).");
+ ImGui::BulletText("Click and drag on any empty space to move window.");
+ ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
+ ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
+ if (ImGui::GetIO().FontAllowUserScaling)
+ ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
+ ImGui::BulletText("Mouse Wheel to scroll.");
+ ImGui::BulletText("While editing text:\n");
+ ImGui::Indent();
+ ImGui::BulletText("Hold SHIFT or use mouse to select text.");
+ ImGui::BulletText("CTRL+Left/Right to word jump.");
+ ImGui::BulletText("CTRL+A or double-click to select all.");
+ ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard.");
+ ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
+ ImGui::BulletText("ESCAPE to revert.");
+ ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
+ ImGui::Unindent();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Demo Window / ShowDemoWindow()
+//-----------------------------------------------------------------------------
+
+// We split the contents of the big ShowDemoWindow() function into smaller functions (because the link time of very large functions grow non-linearly)
+static void ShowDemoWindowWidgets();
+static void ShowDemoWindowLayout();
+static void ShowDemoWindowPopups();
+static void ShowDemoWindowColumns();
+static void ShowDemoWindowMisc();
+
+// Demonstrate most Dear ImGui features (this is big function!)
+// You may execute this function to experiment with the UI and understand what it does. You may then search for keywords in the code when you are interested by a specific feature.
+void ImGui::ShowDemoWindow(bool* p_open)
+{
+ // Examples Apps (accessible from the "Examples" menu)
+ static bool show_app_documents = false;
+ static bool show_app_main_menu_bar = false;
+ static bool show_app_console = false;
+ static bool show_app_log = false;
+ static bool show_app_layout = false;
+ static bool show_app_property_editor = false;
+ static bool show_app_long_text = false;
+ static bool show_app_auto_resize = false;
+ static bool show_app_constrained_resize = false;
+ static bool show_app_simple_overlay = false;
+ static bool show_app_window_titles = false;
+ static bool show_app_custom_rendering = false;
+
+ if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); // Process the Document app next, as it may also use a DockSpace()
+ if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
+ if (show_app_console) ShowExampleAppConsole(&show_app_console);
+ if (show_app_log) ShowExampleAppLog(&show_app_log);
+ if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
+ if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor);
+ if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
+ if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
+ if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
+ if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay);
+ if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
+ if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
+
+ // Dear ImGui Apps (accessible from the "Help" menu)
+ static bool show_app_metrics = false;
+ static bool show_app_style_editor = false;
+ static bool show_app_about = false;
+
+ if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); }
+ if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); }
+ if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); }
+
+ // Demonstrate the various window flags. Typically you would just use the default!
+ static bool no_titlebar = false;
+ static bool no_scrollbar = false;
+ static bool no_menu = false;
+ static bool no_move = false;
+ static bool no_resize = false;
+ static bool no_collapse = false;
+ static bool no_close = false;
+ static bool no_nav = false;
+ static bool no_background = false;
+ static bool no_bring_to_front = false;
+
+ ImGuiWindowFlags window_flags = 0;
+ if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
+ if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
+ if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar;
+ if (no_move) window_flags |= ImGuiWindowFlags_NoMove;
+ if (no_resize) window_flags |= ImGuiWindowFlags_NoResize;
+ if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
+ if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
+ if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
+ if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
+ if (no_close) p_open = NULL; // Don't pass our bool* to Begin
+
+ // We specify a default position/size in case there's no data in the .ini file. Typically this isn't required! We only do it to make the Demo applications a little more welcoming.
+ ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver);
+
+ // Main body of the Demo window starts here.
+ if (!ImGui::Begin("ImGui Demo", p_open, window_flags))
+ {
+ // Early out if the window is collapsed, as an optimization.
+ ImGui::End();
+ return;
+ }
+ ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
+
+ // Most "big" widgets share a common width settings by default.
+ //ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default)
+ ImGui::PushItemWidth(ImGui::GetFontSize() * -12); // Use fixed width for labels (by passing a negative value), the rest goes to widgets. We choose a width proportional to our font size.
+
+ // Menu
+ if (ImGui::BeginMenuBar())
+ {
+ if (ImGui::BeginMenu("Menu"))
+ {
+ ShowExampleMenuFile();
+ ImGui::EndMenu();
+ }
+ if (ImGui::BeginMenu("Examples"))
+ {
+ ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
+ ImGui::MenuItem("Console", NULL, &show_app_console);
+ ImGui::MenuItem("Log", NULL, &show_app_log);
+ ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
+ ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
+ ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
+ ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
+ ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
+ ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
+ ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
+ ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
+ ImGui::MenuItem("Documents", NULL, &show_app_documents);
+ ImGui::EndMenu();
+ }
+ if (ImGui::BeginMenu("Help"))
+ {
+ ImGui::MenuItem("Metrics", NULL, &show_app_metrics);
+ ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
+ ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenuBar();
+ }
+
+ ImGui::Spacing();
+ if (ImGui::CollapsingHeader("Help"))
+ {
+ ImGui::Text("PROGRAMMER GUIDE:");
+ ImGui::BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
+ ImGui::BulletText("Please see the comments in imgui.cpp.");
+ ImGui::BulletText("Please see the examples/ in application.");
+ ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
+ ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
+ ImGui::Separator();
+
+ ImGui::Text("USER GUIDE:");
+ ImGui::ShowUserGuide();
+ }
+
+ if (ImGui::CollapsingHeader("Configuration"))
+ {
+ ImGuiIO& io = ImGui::GetIO();
+
+ if (ImGui::TreeNode("Configuration##2"))
+ {
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
+ ImGui::SameLine(); ShowHelpMarker("Required back-end to feed in gamepad inputs in io.NavInputs[] and set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.");
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos);
+ ImGui::SameLine(); ShowHelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos.");
+ ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouse);
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) // Create a way to restore this flag otherwise we could be stuck completely!
+ {
+ if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f)
+ {
+ ImGui::SameLine();
+ ImGui::Text("<<PRESS SPACE TO DISABLE>>");
+ }
+ if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space)))
+ io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
+ }
+ ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
+ ImGui::SameLine(); ShowHelpMarker("Instruct back-end to not alter mouse cursor shape and visibility.");
+ ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
+ ImGui::SameLine(); ShowHelpMarker("Set to false to disable blinking cursor, for users who consider it distracting");
+ ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
+ ImGui::SameLine(); ShowHelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback.");
+ ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly);
+ ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
+ ImGui::SameLine(); ShowHelpMarker("Instruct Dear ImGui to render a mouse cursor for you. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
+ ImGui::TreePop();
+ ImGui::Separator();
+ }
+
+ if (ImGui::TreeNode("Backend Flags"))
+ {
+ ImGuiBackendFlags backend_flags = io.BackendFlags; // Make a local copy to avoid modifying the back-end flags.
+ ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad);
+ ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors);
+ ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos);
+ ImGui::TreePop();
+ ImGui::Separator();
+ }
+
+ if (ImGui::TreeNode("Style"))
+ {
+ ImGui::ShowStyleEditor();
+ ImGui::TreePop();
+ ImGui::Separator();
+ }
+
+ if (ImGui::TreeNode("Capture/Logging"))
+ {
+ ImGui::TextWrapped("The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded.");
+ ShowHelpMarker("Try opening any of the contents below in this window and then click one of the \"Log To\" button.");
+ ImGui::LogButtons();
+ ImGui::TextWrapped("You can also call ImGui::LogText() to output directly to the log without a visual output.");
+ if (ImGui::Button("Copy \"Hello, world!\" to clipboard"))
+ {
+ ImGui::LogToClipboard();
+ ImGui::LogText("Hello, world!");
+ ImGui::LogFinish();
+ }
+ ImGui::TreePop();
+ }
+ }
+
+ if (ImGui::CollapsingHeader("Window options"))
+ {
+ ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150);
+ ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300);
+ ImGui::Checkbox("No menu", &no_menu);
+ ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150);
+ ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300);
+ ImGui::Checkbox("No collapse", &no_collapse);
+ ImGui::Checkbox("No close", &no_close); ImGui::SameLine(150);
+ ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300);
+ ImGui::Checkbox("No background", &no_background);
+ ImGui::Checkbox("No bring to front", &no_bring_to_front);
+ }
+
+ // All demo contents
+ ShowDemoWindowWidgets();
+ ShowDemoWindowLayout();
+ ShowDemoWindowPopups();
+ ShowDemoWindowColumns();
+ ShowDemoWindowMisc();
+
+ // End of ShowDemoWindow()
+ ImGui::End();
+}
+
+static void ShowDemoWindowWidgets()
+{
+ if (!ImGui::CollapsingHeader("Widgets"))
+ return;
+
+ if (ImGui::TreeNode("Basic"))
+ {
+ static int clicked = 0;
+ if (ImGui::Button("Button"))
+ clicked++;
+ if (clicked & 1)
+ {
+ ImGui::SameLine();
+ ImGui::Text("Thanks for clicking me!");
+ }
+
+ static bool check = true;
+ ImGui::Checkbox("checkbox", &check);
+
+ static int e = 0;
+ ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine();
+ ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine();
+ ImGui::RadioButton("radio c", &e, 2);
+
+ // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
+ for (int i = 0; i < 7; i++)
+ {
+ if (i > 0)
+ ImGui::SameLine();
+ ImGui::PushID(i);
+ ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.6f));
+ ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.7f));
+ ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i/7.0f, 0.8f, 0.8f));
+ ImGui::Button("Click");
+ ImGui::PopStyleColor(3);
+ ImGui::PopID();
+ }
+
+ // Use AlignTextToFramePadding() to align text baseline to the baseline of framed elements (otherwise a Text+SameLine+Button sequence will have the text a little too high by default)
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("Hold to repeat:");
+ ImGui::SameLine();
+
+ // Arrow buttons with Repeater
+ static int counter = 0;
+ float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
+ ImGui::PushButtonRepeat(true);
+ if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; }
+ ImGui::SameLine(0.0f, spacing);
+ if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; }
+ ImGui::PopButtonRepeat();
+ ImGui::SameLine();
+ ImGui::Text("%d", counter);
+
+ ImGui::Text("Hover over me");
+ if (ImGui::IsItemHovered())
+ ImGui::SetTooltip("I am a tooltip");
+
+ ImGui::SameLine();
+ ImGui::Text("- or me");
+ if (ImGui::IsItemHovered())
+ {
+ ImGui::BeginTooltip();
+ ImGui::Text("I am a fancy tooltip");
+ static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
+ ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
+ ImGui::EndTooltip();
+ }
+
+ ImGui::Separator();
+
+ ImGui::LabelText("label", "Value");
+
+ {
+ // Using the _simplified_ one-liner Combo() api here
+ // See "Combo" section for examples of how to use the more complete BeginCombo()/EndCombo() api.
+ const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
+ static int item_current = 0;
+ ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items));
+ ImGui::SameLine(); ShowHelpMarker("Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, and demonstration of various flags.\n");
+ }
+
+ {
+ static char str0[128] = "Hello, world!";
+ static int i0 = 123;
+ ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
+ ImGui::SameLine(); ShowHelpMarker("USER:\nHold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated in imgui_demo.cpp).");
+
+ ImGui::InputInt("input int", &i0);
+ ImGui::SameLine(); ShowHelpMarker("You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n");
+
+ static float f0 = 0.001f;
+ ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
+
+ static double d0 = 999999.00000001;
+ ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f");
+
+ static float f1 = 1.e10f;
+ ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e");
+ ImGui::SameLine(); ShowHelpMarker("You can input value using the scientific notation,\n e.g. \"1e+8\" becomes \"100000000\".\n");
+
+ static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
+ ImGui::InputFloat3("input float3", vec4a);
+ }
+
+ {
+ static int i1 = 50, i2 = 42;
+ ImGui::DragInt("drag int", &i1, 1);
+ ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.");
+
+ ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%");
+
+ static float f1=1.00f, f2=0.0067f;
+ ImGui::DragFloat("drag float", &f1, 0.005f);
+ ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
+ }
+
+ {
+ static int i1=0;
+ ImGui::SliderInt("slider int", &i1, -1, 3);
+ ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value.");
+
+ static float f1=0.123f, f2=0.0f;
+ ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
+ ImGui::SliderFloat("slider float (curve)", &f2, -10.0f, 10.0f, "%.4f", 2.0f);
+ static float angle = 0.0f;
+ ImGui::SliderAngle("slider angle", &angle);
+ }
+
+ {
+ static float col1[3] = { 1.0f,0.0f,0.2f };
+ static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
+ ImGui::ColorEdit3("color 1", col1);
+ ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nClick and hold to use drag and drop.\nRight-click on the colored square to show options.\nCTRL+click on individual component to input value.\n");
+
+ ImGui::ColorEdit4("color 2", col2);
+ }
+
+ {
+ // List box
+ const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
+ static int listbox_item_current = 1;
+ ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
+
+ //static int listbox_item_current2 = 2;
+ //ImGui::PushItemWidth(-1);
+ //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
+ //ImGui::PopItemWidth();
+ }
+
+ ImGui::TreePop();
+ }
+
+ // Testing ImGuiOnceUponAFrame helper.
+ //static ImGuiOnceUponAFrame once;
+ //for (int i = 0; i < 5; i++)
+ // if (once)
+ // ImGui::Text("This will be displayed only once.");
+
+ if (ImGui::TreeNode("Trees"))
+ {
+ if (ImGui::TreeNode("Basic trees"))
+ {
+ for (int i = 0; i < 5; i++)
+ if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
+ {
+ ImGui::Text("blah blah");
+ ImGui::SameLine();
+ if (ImGui::SmallButton("button")) { };
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Advanced, with Selectable nodes"))
+ {
+ ShowHelpMarker("This is a more standard looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open.");
+ static bool align_label_with_current_x_position = false;
+ ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
+ ImGui::Text("Hello!");
+ if (align_label_with_current_x_position)
+ ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
+
+ static int selection_mask = (1 << 2); // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit.
+ int node_clicked = -1; // Temporary storage of what node we have clicked to process selection at the end of the loop. May be a pointer to your own node type, etc.
+ ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, ImGui::GetFontSize()*3); // Increase spacing to differentiate leaves from expanded contents.
+ for (int i = 0; i < 6; i++)
+ {
+ // Disable the default open on single-click behavior and pass in Selected flag according to our selection state.
+ ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0);
+ if (i < 3)
+ {
+ // Node
+ bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
+ if (ImGui::IsItemClicked())
+ node_clicked = i;
+ if (node_open)
+ {
+ ImGui::Text("Blah blah\nBlah Blah");
+ ImGui::TreePop();
+ }
+ }
+ else
+ {
+ // Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
+ node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
+ ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
+ if (ImGui::IsItemClicked())
+ node_clicked = i;
+ }
+ }
+ if (node_clicked != -1)
+ {
+ // Update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.
+ if (ImGui::GetIO().KeyCtrl)
+ selection_mask ^= (1 << node_clicked); // CTRL+click to toggle
+ else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, this commented bit preserve selection when clicking on item that is part of the selection
+ selection_mask = (1 << node_clicked); // Click to single-select
+ }
+ ImGui::PopStyleVar();
+ if (align_label_with_current_x_position)
+ ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Collapsing Headers"))
+ {
+ static bool closable_group = true;
+ ImGui::Checkbox("Enable extra group", &closable_group);
+ if (ImGui::CollapsingHeader("Header"))
+ {
+ ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
+ for (int i = 0; i < 5; i++)
+ ImGui::Text("Some content %d", i);
+ }
+ if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
+ {
+ ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
+ for (int i = 0; i < 5; i++)
+ ImGui::Text("More content %d", i);
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Bullets"))
+ {
+ ImGui::BulletText("Bullet point 1");
+ ImGui::BulletText("Bullet point 2\nOn multiple lines");
+ ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)");
+ ImGui::Bullet(); ImGui::SmallButton("Button");
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Text"))
+ {
+ if (ImGui::TreeNode("Colored Text"))
+ {
+ // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility.
+ ImGui::TextColored(ImVec4(1.0f,0.0f,1.0f,1.0f), "Pink");
+ ImGui::TextColored(ImVec4(1.0f,1.0f,0.0f,1.0f), "Yellow");
+ ImGui::TextDisabled("Disabled");
+ ImGui::SameLine(); ShowHelpMarker("The TextDisabled color is stored in ImGuiStyle.");
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Word Wrapping"))
+ {
+ // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility.
+ ImGui::TextWrapped("This text should automatically wrap on the edge of the window. The current implementation for text wrapping follows simple rules suitable for English and possibly other languages.");
+ ImGui::Spacing();
+
+ static float wrap_width = 200.0f;
+ ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f");
+
+ ImGui::Text("Test paragraph 1:");
+ ImVec2 pos = ImGui::GetCursorScreenPos();
+ ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255));
+ ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
+ ImGui::Text("The lazy dog is a good dog. This paragraph is made to fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width);
+ ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255));
+ ImGui::PopTextWrapPos();
+
+ ImGui::Text("Test paragraph 2:");
+ pos = ImGui::GetCursorScreenPos();
+ ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255));
+ ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
+ ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
+ ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255));
+ ImGui::PopTextWrapPos();
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("UTF-8 Text"))
+ {
+ // UTF-8 test with Japanese characters
+ // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read misc/fonts/README.txt for details.)
+ // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8
+ // - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. Visual Studio save your file as 'UTF-8 without signature')
+ // - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE.
+ // Instead we are encoding a few strings with hexadecimal constants. Don't do this in your application!
+ // Please use u8"text in any language" in your application!
+ // Note that characters values are preserved even by InputText() if the font cannot be displayed, so you can safely copy & paste garbled characters into another application.
+ ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. Read misc/fonts/README.txt for details.");
+ ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
+ ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
+ static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
+ //static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis
+ ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf));
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Images"))
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ ImGui::TextWrapped("Below we are displaying the font texture (which is the only texture we have access to in this demo). Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. Hover the texture for a zoomed view!");
+
+ // Here we are grabbing the font texture because that's the only one we have access to inside the demo code.
+ // Remember that ImTextureID is just storage for whatever you want it to be, it is essentially a value that will be passed to the render function inside the ImDrawCmd structure.
+ // If you use one of the default imgui_impl_XXXX.cpp renderer, they all have comments at the top of their file to specify what they expect to be stored in ImTextureID.
+ // (for example, the imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer. The imgui_impl_glfw_gl3.cpp renderer expect a GLuint OpenGL texture identifier etc.)
+ // If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers to ImGui::Image(), and gather width/height through your own functions, etc.
+ // Using ShowMetricsWindow() as a "debugger" to inspect the draw data that are being passed to your render will help you debug issues if you are confused about this.
+ // Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage().
+ ImTextureID my_tex_id = io.Fonts->TexID;
+ float my_tex_w = (float)io.Fonts->TexWidth;
+ float my_tex_h = (float)io.Fonts->TexHeight;
+
+ ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h);
+ ImVec2 pos = ImGui::GetCursorScreenPos();
+ ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
+ if (ImGui::IsItemHovered())
+ {
+ ImGui::BeginTooltip();
+ float region_sz = 32.0f;
+ float region_x = io.MousePos.x - pos.x - region_sz * 0.5f; if (region_x < 0.0f) region_x = 0.0f; else if (region_x > my_tex_w - region_sz) region_x = my_tex_w - region_sz;
+ float region_y = io.MousePos.y - pos.y - region_sz * 0.5f; if (region_y < 0.0f) region_y = 0.0f; else if (region_y > my_tex_h - region_sz) region_y = my_tex_h - region_sz;
+ float zoom = 4.0f;
+ ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y);
+ ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz);
+ ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h);
+ ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h);
+ ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImColor(255,255,255,255), ImColor(255,255,255,128));
+ ImGui::EndTooltip();
+ }
+ ImGui::TextWrapped("And now some textured buttons..");
+ static int pressed_count = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ ImGui::PushID(i);
+ int frame_padding = -1 + i; // -1 = uses default padding
+ if (ImGui::ImageButton(my_tex_id, ImVec2(32,32), ImVec2(0,0), ImVec2(32.0f/my_tex_w,32/my_tex_h), frame_padding, ImColor(0,0,0,255)))
+ pressed_count += 1;
+ ImGui::PopID();
+ ImGui::SameLine();
+ }
+ ImGui::NewLine();
+ ImGui::Text("Pressed %d times.", pressed_count);
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Combo"))
+ {
+ // Expose flags as checkbox for the demo
+ static ImGuiComboFlags flags = 0;
+ ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", (unsigned int*)&flags, ImGuiComboFlags_PopupAlignLeft);
+ if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", (unsigned int*)&flags, ImGuiComboFlags_NoArrowButton))
+ flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both
+ if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", (unsigned int*)&flags, ImGuiComboFlags_NoPreview))
+ flags &= ~ImGuiComboFlags_NoArrowButton; // Clear the other flag, as we cannot combine both
+
+ // General BeginCombo() API, you have full control over your selection data and display type.
+ // (your selection data could be an index, a pointer to the object, an id for the object, a flag stored in the object itself, etc.)
+ const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
+ static const char* item_current = items[0]; // Here our selection is a single pointer stored outside the object.
+ if (ImGui::BeginCombo("combo 1", item_current, flags)) // The second parameter is the label previewed before opening the combo.
+ {
+ for (int n = 0; n < IM_ARRAYSIZE(items); n++)
+ {
+ bool is_selected = (item_current == items[n]);
+ if (ImGui::Selectable(items[n], is_selected))
+ item_current = items[n];
+ if (is_selected)
+ ImGui::SetItemDefaultFocus(); // Set the initial focus when opening the combo (scrolling + for keyboard navigation support in the upcoming navigation branch)
+ }
+ ImGui::EndCombo();
+ }
+
+ // Simplified one-liner Combo() API, using values packed in a single constant string
+ static int item_current_2 = 0;
+ ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
+
+ // Simplified one-liner Combo() using an array of const char*
+ static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview
+ ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
+
+ // Simplified one-liner Combo() using an accessor function
+ struct FuncHolder { static bool ItemGetter(void* data, int idx, const char** out_str) { *out_str = ((const char**)data)[idx]; return true; } };
+ static int item_current_4 = 0;
+ ImGui::Combo("combo 4 (function)", &item_current_4, &FuncHolder::ItemGetter, items, IM_ARRAYSIZE(items));
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Selectables"))
+ {
+ // Selectable() has 2 overloads:
+ // - The one taking "bool selected" as a read-only selection information. When Selectable() has been clicked is returns true and you can alter selection state accordingly.
+ // - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases)
+ // The earlier is more flexible, as in real application your selection may be stored in a different manner (in flags within objects, as an external list, etc).
+ if (ImGui::TreeNode("Basic"))
+ {
+ static bool selection[5] = { false, true, false, false, false };
+ ImGui::Selectable("1. I am selectable", &selection[0]);
+ ImGui::Selectable("2. I am selectable", &selection[1]);
+ ImGui::Text("3. I am not selectable");
+ ImGui::Selectable("4. I am selectable", &selection[3]);
+ if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
+ if (ImGui::IsMouseDoubleClicked(0))
+ selection[4] = !selection[4];
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("Selection State: Single Selection"))
+ {
+ static int selected = -1;
+ for (int n = 0; n < 5; n++)
+ {
+ char buf[32];
+ sprintf(buf, "Object %d", n);
+ if (ImGui::Selectable(buf, selected == n))
+ selected = n;
+ }
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("Selection State: Multiple Selection"))
+ {
+ ShowHelpMarker("Hold CTRL and click to select multiple items.");
+ static bool selection[5] = { false, false, false, false, false };
+ for (int n = 0; n < 5; n++)
+ {
+ char buf[32];
+ sprintf(buf, "Object %d", n);
+ if (ImGui::Selectable(buf, selection[n]))
+ {
+ if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held
+ memset(selection, 0, sizeof(selection));
+ selection[n] ^= 1;
+ }
+ }
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("Rendering more text into the same line"))
+ {
+ // Using the Selectable() override that takes "bool* p_selected" parameter and toggle your booleans automatically.
+ static bool selected[3] = { false, false, false };
+ ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
+ ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
+ ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("In columns"))
+ {
+ ImGui::Columns(3, NULL, false);
+ static bool selected[16] = { 0 };
+ for (int i = 0; i < 16; i++)
+ {
+ char label[32]; sprintf(label, "Item %d", i);
+ if (ImGui::Selectable(label, &selected[i])) {}
+ ImGui::NextColumn();
+ }
+ ImGui::Columns(1);
+ ImGui::TreePop();
+ }
+ if (ImGui::TreeNode("Grid"))
+ {
+ static bool selected[16] = { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true };
+ for (int i = 0; i < 16; i++)
+ {
+ ImGui::PushID(i);
+ if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50)))
+ {
+ int x = i % 4, y = i / 4;
+ if (x > 0) selected[i - 1] ^= 1;
+ if (x < 3) selected[i + 1] ^= 1;
+ if (y > 0) selected[i - 4] ^= 1;
+ if (y < 3) selected[i + 4] ^= 1;
+ }
+ if ((i % 4) < 3) ImGui::SameLine();
+ ImGui::PopID();
+ }
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Filtered Text Input"))
+ {
+ static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
+ static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
+ static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
+ static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
+ static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
+ struct TextFilters { static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
+ static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
+
+ ImGui::Text("Password input");
+ static char bufpass[64] = "password123";
+ ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
+ ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
+ ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Multi-line Text Input"))
+ {
+ // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
+ // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
+ static bool read_only = false;
+ static char text[1024*16] =
+ "/*\n"
+ " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
+ " the hexadecimal encoding of one offending instruction,\n"
+ " more formally, the invalid operand with locked CMPXCHG8B\n"
+ " instruction bug, is a design flaw in the majority of\n"
+ " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
+ " processors (all in the P5 microarchitecture).\n"
+ "*/\n\n"
+ "label:\n"
+ "\tlock cmpxchg8b eax\n";
+
+ ShowHelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
+ ImGui::Checkbox("Read-only", &read_only);
+ ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput | (read_only ? ImGuiInputTextFlags_ReadOnly : 0);
+ ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Plots Widgets"))
+ {
+ static bool animate = true;
+ ImGui::Checkbox("Animate", &animate);
+
+ static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
+ ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
+
+ // Create a dummy array of contiguous float values to plot
+ // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter.
+ static float values[90] = { 0 };
+ static int values_offset = 0;
+ static double refresh_time = 0.0;
+ if (!animate || refresh_time == 0.0f)
+ refresh_time = ImGui::GetTime();
+ while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo
+ {
+ static float phase = 0.0f;
+ values[values_offset] = cosf(phase);
+ values_offset = (values_offset+1) % IM_ARRAYSIZE(values);
+ phase += 0.10f*values_offset;
+ refresh_time += 1.0f/60.0f;
+ }
+ ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
+ ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0,80));
+
+ // Use functions to generate output
+ // FIXME: This is rather awkward because current plot API only pass in indices. We probably want an API passing floats and user provide sample rate/count.
+ struct Funcs
+ {
+ static float Sin(void*, int i) { return sinf(i * 0.1f); }
+ static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; }
+ };
+ static int func_type = 0, display_count = 70;
+ ImGui::Separator();
+ ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
+ ImGui::SameLine();
+ ImGui::SliderInt("Sample count", &display_count, 1, 400);
+ float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
+ ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
+ ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
+ ImGui::Separator();
+
+ // Animate a simple progress bar
+ static float progress = 0.0f, progress_dir = 1.0f;
+ if (animate)
+ {
+ progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
+ if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
+ if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
+ }
+
+ // Typically we would use ImVec2(-1.0f,0.0f) to use all available width, or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
+ ImGui::ProgressBar(progress, ImVec2(0.0f,0.0f));
+ ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
+ ImGui::Text("Progress Bar");
+
+ float progress_saturated = (progress < 0.0f) ? 0.0f : (progress > 1.0f) ? 1.0f : progress;
+ char buf[32];
+ sprintf(buf, "%d/%d", (int)(progress_saturated*1753), 1753);
+ ImGui::ProgressBar(progress, ImVec2(0.f,0.f), buf);
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Color/Picker Widgets"))
+ {
+ static ImVec4 color = ImColor(114, 144, 154, 200);
+
+ static bool alpha_preview = true;
+ static bool alpha_half_preview = false;
+ static bool drag_and_drop = true;
+ static bool options_menu = true;
+ static bool hdr = false;
+ ImGui::Checkbox("With Alpha Preview", &alpha_preview);
+ ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
+ ImGui::Checkbox("With Drag and Drop", &drag_and_drop);
+ ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options.");
+ ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
+ int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
+
+ ImGui::Text("Color widget:");
+ ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n");
+ ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
+
+ ImGui::Text("Color widget HSV with Alpha:");
+ ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_HSV | misc_flags);
+
+ ImGui::Text("Color widget with Float Display:");
+ ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
+
+ ImGui::Text("Color button with Picker:");
+ ImGui::SameLine(); ShowHelpMarker("With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\nWith the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only be used for the tooltip and picker popup.");
+ ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags);
+
+ ImGui::Text("Color button with Custom Picker Popup:");
+
+ // Generate a dummy palette
+ static bool saved_palette_inited = false;
+ static ImVec4 saved_palette[32];
+ if (!saved_palette_inited)
+ for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
+ {
+ ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
+ saved_palette[n].w = 1.0f; // Alpha
+ }
+ saved_palette_inited = true;
+
+ static ImVec4 backup_color;
+ bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
+ ImGui::SameLine();
+ open_popup |= ImGui::Button("Palette");
+ if (open_popup)
+ {
+ ImGui::OpenPopup("mypicker");
+ backup_color = color;
+ }
+ if (ImGui::BeginPopup("mypicker"))
+ {
+ // FIXME: Adding a drag and drop example here would be perfect!
+ ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
+ ImGui::Separator();
+ ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview);
+ ImGui::SameLine();
+ ImGui::BeginGroup();
+ ImGui::Text("Current");
+ ImGui::ColorButton("##current", color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40));
+ ImGui::Text("Previous");
+ if (ImGui::ColorButton("##previous", backup_color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40)))
+ color = backup_color;
+ ImGui::Separator();
+ ImGui::Text("Palette");
+ for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
+ {
+ ImGui::PushID(n);
+ if ((n % 8) != 0)
+ ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);
+ if (ImGui::ColorButton("##palette", saved_palette[n], ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip, ImVec2(20,20)))
+ color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha!
+
+ if (ImGui::BeginDragDropTarget())
+ {
+ if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
+ memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3);
+ if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
+ memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4);
+ ImGui::EndDragDropTarget();
+ }
+
+ ImGui::PopID();
+ }
+ ImGui::EndGroup();
+ ImGui::EndPopup();
+ }
+
+ ImGui::Text("Color button only:");
+ ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
+
+ ImGui::Text("Color picker:");
+ static bool alpha = true;
+ static bool alpha_bar = true;
+ static bool side_preview = true;
+ static bool ref_color = false;
+ static ImVec4 ref_color_v(1.0f,0.0f,1.0f,0.5f);
+ static int inputs_mode = 2;
+ static int picker_mode = 0;
+ ImGui::Checkbox("With Alpha", &alpha);
+ ImGui::Checkbox("With Alpha Bar", &alpha_bar);
+ ImGui::Checkbox("With Side Preview", &side_preview);
+ if (side_preview)
+ {
+ ImGui::SameLine();
+ ImGui::Checkbox("With Ref Color", &ref_color);
+ if (ref_color)
+ {
+ ImGui::SameLine();
+ ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
+ }
+ }
+ ImGui::Combo("Inputs Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0");
+ ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
+ ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode.");
+ ImGuiColorEditFlags flags = misc_flags;
+ if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
+ if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
+ if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
+ if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
+ if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
+ if (inputs_mode == 1) flags |= ImGuiColorEditFlags_NoInputs;
+ if (inputs_mode == 2) flags |= ImGuiColorEditFlags_RGB;
+ if (inputs_mode == 3) flags |= ImGuiColorEditFlags_HSV;
+ if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
+ ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
+
+ ImGui::Text("Programmatically set defaults:");
+ ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
+ if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
+ ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_PickerHueBar);
+ if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
+ ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Range Widgets"))
+ {
+ static float begin = 10, end = 90;
+ static int begin_i = 100, end_i = 1000;
+ ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
+ ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units");
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Data Types"))
+ {
+ // The DragScalar/InputScalar/SliderScalar functions allow various data types: signed/unsigned int/long long and float/double
+ // To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum to pass the type,
+ // and passing all arguments by address.
+ // This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types.
+ // In practice, if you frequently use a given type that is not covered by the normal API entry points, you can wrap it
+ // yourself inside a 1 line function which can take typed argument as value instead of void*, and then pass their address
+ // to the generic function. For example:
+ // bool MySliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld")
+ // {
+ // return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format);
+ // }
+
+ // Limits (as helper variables that we can take the address of)
+ // Note that the SliderScalar function has a maximum usable range of half the natural type maximum, hence the /2 below.
+ #ifndef LLONG_MIN
+ ImS64 LLONG_MIN = -9223372036854775807LL - 1;
+ ImS64 LLONG_MAX = 9223372036854775807LL;
+ ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1);
+ #endif
+ const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
+ const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
+ const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
+ const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
+ const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
+ const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0;
+
+ // State
+ static ImS32 s32_v = -1;
+ static ImU32 u32_v = (ImU32)-1;
+ static ImS64 s64_v = -1;
+ static ImU64 u64_v = (ImU64)-1;
+ static float f32_v = 0.123f;
+ static double f64_v = 90000.01234567890123456789;
+
+ const float drag_speed = 0.2f;
+ static bool drag_clamp = false;
+ ImGui::Text("Drags:");
+ ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); ImGui::SameLine(); ShowHelpMarker("As with every widgets in dear imgui, we never modify values unless there is a user interaction.\nYou can override the clamping limits by using CTRL+Click to input a value.");
+ ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
+ ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
+ ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
+ ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL);
+ ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 1.0f);
+ ImGui::DragScalar("drag float ^2", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 2.0f); ImGui::SameLine(); ShowHelpMarker("You can use the 'power' parameter to increase tweaking precision on one side of the range.");
+ ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams", 1.0f);
+ ImGui::DragScalar("drag double ^2", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", 2.0f);
+
+ ImGui::Text("Sliders");
+ ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
+ ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
+ ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
+ ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u");
+ ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u");
+ ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u");
+ ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%I64d");
+ ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%I64d");
+ ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%I64d");
+ ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%I64u ms");
+ ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%I64u ms");
+ ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%I64u ms");
+ ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one);
+ ImGui::SliderScalar("slider float low^2", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", 2.0f);
+ ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e");
+ ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams", 1.0f);
+ ImGui::SliderScalar("slider double low^2",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", 2.0f);
+ ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams", 1.0f);
+
+ static bool inputs_step = true;
+ ImGui::Text("Inputs");
+ ImGui::Checkbox("Show step buttons", &inputs_step);
+ ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
+ ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
+ ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
+ ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
+ ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
+ ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
+ ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
+ ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Multi-component Widgets"))
+ {
+ static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
+ static int vec4i[4] = { 1, 5, 100, 255 };
+
+ ImGui::InputFloat2("input float2", vec4f);
+ ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
+ ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
+ ImGui::InputInt2("input int2", vec4i);
+ ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
+ ImGui::SliderInt2("slider int2", vec4i, 0, 255);
+ ImGui::Spacing();
+
+ ImGui::InputFloat3("input float3", vec4f);
+ ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
+ ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
+ ImGui::InputInt3("input int3", vec4i);
+ ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
+ ImGui::SliderInt3("slider int3", vec4i, 0, 255);
+ ImGui::Spacing();
+
+ ImGui::InputFloat4("input float4", vec4f);
+ ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f);
+ ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f);
+ ImGui::InputInt4("input int4", vec4i);
+ ImGui::DragInt4("drag int4", vec4i, 1, 0, 255);
+ ImGui::SliderInt4("slider int4", vec4i, 0, 255);
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Vertical Sliders"))
+ {
+ const float spacing = 4;
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing));
+
+ static int int_value = 0;
+ ImGui::VSliderInt("##int", ImVec2(18,160), &int_value, 0, 5);
+ ImGui::SameLine();
+
+ static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f };
+ ImGui::PushID("set1");
+ for (int i = 0; i < 7; i++)
+ {
+ if (i > 0) ImGui::SameLine();
+ ImGui::PushID(i);
+ ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor::HSV(i/7.0f, 0.5f, 0.5f));
+ ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.5f));
+ ImGui::PushStyleColor(ImGuiCol_FrameBgActive, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.5f));
+ ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i/7.0f, 0.9f, 0.9f));
+ ImGui::VSliderFloat("##v", ImVec2(18,160), &values[i], 0.0f, 1.0f, "");
+ if (ImGui::IsItemActive() || ImGui::IsItemHovered())
+ ImGui::SetTooltip("%.3f", values[i]);
+ ImGui::PopStyleColor(4);
+ ImGui::PopID();
+ }
+ ImGui::PopID();
+
+ ImGui::SameLine();
+ ImGui::PushID("set2");
+ static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f };
+ const int rows = 3;
+ const ImVec2 small_slider_size(18, (160.0f-(rows-1)*spacing)/rows);
+ for (int nx = 0; nx < 4; nx++)
+ {
+ if (nx > 0) ImGui::SameLine();
+ ImGui::BeginGroup();
+ for (int ny = 0; ny < rows; ny++)
+ {
+ ImGui::PushID(nx*rows+ny);
+ ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, "");
+ if (ImGui::IsItemActive() || ImGui::IsItemHovered())
+ ImGui::SetTooltip("%.3f", values2[nx]);
+ ImGui::PopID();
+ }
+ ImGui::EndGroup();
+ }
+ ImGui::PopID();
+
+ ImGui::SameLine();
+ ImGui::PushID("set3");
+ for (int i = 0; i < 4; i++)
+ {
+ if (i > 0) ImGui::SameLine();
+ ImGui::PushID(i);
+ ImGui::PushStyleVar(ImGuiStyleVar_GrabMinSize, 40);
+ ImGui::VSliderFloat("##v", ImVec2(40,160), &values[i], 0.0f, 1.0f, "%.2f\nsec");
+ ImGui::PopStyleVar();
+ ImGui::PopID();
+ }
+ ImGui::PopID();
+ ImGui::PopStyleVar();
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Drag and Drop"))
+ {
+ {
+ // ColorEdit widgets automatically act as drag source and drag target.
+ // They are using standardized payload strings IMGUI_PAYLOAD_TYPE_COLOR_3F and IMGUI_PAYLOAD_TYPE_COLOR_4F to allow your own widgets
+ // to use colors in their drag and drop interaction. Also see the demo in Color Picker -> Palette demo.
+ ImGui::BulletText("Drag and drop in standard widgets");
+ ImGui::Indent();
+ static float col1[3] = { 1.0f,0.0f,0.2f };
+ static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
+ ImGui::ColorEdit3("color 1", col1);
+ ImGui::ColorEdit4("color 2", col2);
+ ImGui::Unindent();
+ }
+
+ {
+ ImGui::BulletText("Drag and drop to copy/swap items");
+ ImGui::Indent();
+ enum Mode
+ {
+ Mode_Copy,
+ Mode_Move,
+ Mode_Swap
+ };
+ static int mode = 0;
+ if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine();
+ if (ImGui::RadioButton("Move", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine();
+ if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; }
+ static const char* names[9] = { "Bobby", "Beatrice", "Betty", "Brianna", "Barry", "Bernard", "Bibi", "Blaine", "Bryn" };
+ for (int n = 0; n < IM_ARRAYSIZE(names); n++)
+ {
+ ImGui::PushID(n);
+ if ((n % 3) != 0)
+ ImGui::SameLine();
+ ImGui::Button(names[n], ImVec2(60,60));
+
+ // Our buttons are both drag sources and drag targets here!
+ if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
+ {
+ ImGui::SetDragDropPayload("DND_DEMO_CELL", &n, sizeof(int)); // Set payload to carry the index of our item (could be anything)
+ if (mode == Mode_Copy) { ImGui::Text("Copy %s", names[n]); } // Display preview (could be anything, e.g. when dragging an image we could decide to display the filename and a small preview of the image, etc.)
+ if (mode == Mode_Move) { ImGui::Text("Move %s", names[n]); }
+ if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); }
+ ImGui::EndDragDropSource();
+ }
+ if (ImGui::BeginDragDropTarget())
+ {
+ if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL"))
+ {
+ IM_ASSERT(payload->DataSize == sizeof(int));
+ int payload_n = *(const int*)payload->Data;
+ if (mode == Mode_Copy)
+ {
+ names[n] = names[payload_n];
+ }
+ if (mode == Mode_Move)
+ {
+ names[n] = names[payload_n];
+ names[payload_n] = "";
+ }
+ if (mode == Mode_Swap)
+ {
+ const char* tmp = names[n];
+ names[n] = names[payload_n];
+ names[payload_n] = tmp;
+ }
+ }
+ ImGui::EndDragDropTarget();
+ }
+ ImGui::PopID();
+ }
+ ImGui::Unindent();
+ }
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Querying Status (Active/Focused/Hovered etc.)"))
+ {
+ // Display the value of IsItemHovered() and other common item state functions. Note that the flags can be combined.
+ // (because BulletText is an item itself and that would affect the output of IsItemHovered() we pass all state in a single call to simplify the code).
+ static int item_type = 1;
+ static bool b = false;
+ static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
+ ImGui::RadioButton("Text", &item_type, 0);
+ ImGui::RadioButton("Button", &item_type, 1);
+ ImGui::RadioButton("CheckBox", &item_type, 2);
+ ImGui::RadioButton("SliderFloat", &item_type, 3);
+ ImGui::RadioButton("ColorEdit4", &item_type, 4);
+ ImGui::RadioButton("ListBox", &item_type, 5);
+ ImGui::Separator();
+ bool ret = false;
+ if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
+ if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
+ if (item_type == 2) { ret = ImGui::Checkbox("ITEM: CheckBox", &b); } // Testing checkbox
+ if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
+ if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
+ if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", &current, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
+ ImGui::BulletText(
+ "Return value = %d\n"
+ "IsItemFocused() = %d\n"
+ "IsItemHovered() = %d\n"
+ "IsItemHovered(_AllowWhenBlockedByPopup) = %d\n"
+ "IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n"
+ "IsItemHovered(_AllowWhenOverlapped) = %d\n"
+ "IsItemHovered(_RectOnly) = %d\n"
+ "IsItemActive() = %d\n"
+ "IsItemEdited() = %d\n"
+ "IsItemDeactivated() = %d\n"
+ "IsItemDeactivatedEdit() = %d\n"
+ "IsItemVisible() = %d\n"
+ "GetItemRectMin() = (%.1f, %.1f)\n"
+ "GetItemRectMax() = (%.1f, %.1f)\n"
+ "GetItemRectSize() = (%.1f, %.1f)",
+ ret,
+ ImGui::IsItemFocused(),
+ ImGui::IsItemHovered(),
+ ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
+ ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
+ ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped),
+ ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly),
+ ImGui::IsItemActive(),
+ ImGui::IsItemEdited(),
+ ImGui::IsItemDeactivated(),
+ ImGui::IsItemDeactivatedAfterEdit(),
+ ImGui::IsItemVisible(),
+ ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y,
+ ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y,
+ ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
+ );
+
+ static bool embed_all_inside_a_child_window = false;
+ ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
+ if (embed_all_inside_a_child_window)
+ ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20), true);
+
+ // Testing IsWindowFocused() function with its various flags. Note that the flags can be combined.
+ ImGui::BulletText(
+ "IsWindowFocused() = %d\n"
+ "IsWindowFocused(_ChildWindows) = %d\n"
+ "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n"
+ "IsWindowFocused(_RootWindow) = %d\n"
+ "IsWindowFocused(_AnyWindow) = %d\n",
+ ImGui::IsWindowFocused(),
+ ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows),
+ ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow),
+ ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow),
+ ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow));
+
+ // Testing IsWindowHovered() function with its various flags. Note that the flags can be combined.
+ ImGui::BulletText(
+ "IsWindowHovered() = %d\n"
+ "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n"
+ "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
+ "IsWindowHovered(_ChildWindows) = %d\n"
+ "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
+ "IsWindowHovered(_RootWindow) = %d\n"
+ "IsWindowHovered(_AnyWindow) = %d\n",
+ ImGui::IsWindowHovered(),
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows),
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow),
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow));
+
+ ImGui::BeginChild("child", ImVec2(0, 50), true);
+ ImGui::Text("This is another child window for testing the _ChildWindows flag.");
+ ImGui::EndChild();
+ if (embed_all_inside_a_child_window)
+ ImGui::EndChild();
+
+ // Calling IsItemHovered() after begin returns the hovered status of the title bar.
+ // This is useful in particular if you want to create a context menu (with BeginPopupContextItem) associated to the title bar of a window.
+ static bool test_window = false;
+ ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
+ if (test_window)
+ {
+ ImGui::Begin("Title bar Hovered/Active tests", &test_window);
+ if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
+ {
+ if (ImGui::MenuItem("Close")) { test_window = false; }
+ ImGui::EndPopup();
+ }
+ ImGui::Text(
+ "IsItemHovered() after begin = %d (== is title bar hovered)\n"
+ "IsItemActive() after begin = %d (== is window being clicked/moved)\n",
+ ImGui::IsItemHovered(), ImGui::IsItemActive());
+ ImGui::End();
+ }
+
+ ImGui::TreePop();
+ }
+}
+
+static void ShowDemoWindowLayout()
+{
+ if (!ImGui::CollapsingHeader("Layout"))
+ return;
+
+ if (ImGui::TreeNode("Child windows"))
+ {
+ ShowHelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window.");
+ static bool disable_mouse_wheel = false;
+ static bool disable_menu = false;
+ ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel);
+ ImGui::Checkbox("Disable Menu", &disable_menu);
+
+ static int line = 50;
+ bool goto_line = ImGui::Button("Goto");
+ ImGui::SameLine();
+ ImGui::PushItemWidth(100);
+ goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
+ ImGui::PopItemWidth();
+
+ // Child 1: no border, enable horizontal scrollbar
+ {
+ ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar | (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0);
+ ImGui::BeginChild("Child1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
+ for (int i = 0; i < 100; i++)
+ {
+ ImGui::Text("%04d: scrollable region", i);
+ if (goto_line && line == i)
+ ImGui::SetScrollHereY();
+ }
+ if (goto_line && line >= 100)
+ ImGui::SetScrollHereY();
+ ImGui::EndChild();
+ }
+
+ ImGui::SameLine();
+
+ // Child 2: rounded border
+ {
+ ImGuiWindowFlags window_flags = (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0) | (disable_menu ? 0 : ImGuiWindowFlags_MenuBar);
+ ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
+ ImGui::BeginChild("Child2", ImVec2(0, 260), true, window_flags);
+ if (!disable_menu && ImGui::BeginMenuBar())
+ {
+ if (ImGui::BeginMenu("Menu"))
+ {
+ ShowExampleMenuFile();
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenuBar();
+ }
+ ImGui::Columns(2);
+ for (int i = 0; i < 100; i++)
+ {
+ char buf[32];
+ sprintf(buf, "%03d", i);
+ ImGui::Button(buf, ImVec2(-1.0f, 0.0f));
+ ImGui::NextColumn();
+ }
+ ImGui::EndChild();
+ ImGui::PopStyleVar();
+ }
+
+ ImGui::Separator();
+
+ // Demonstrate a few extra things
+ // - Changing ImGuiCol_ChildBg (which is transparent black in default styles)
+ // - Using SetCursorPos() to position the child window (because the child window is an item from the POV of the parent window)
+ // You can also call SetNextWindowPos() to position the child window. The parent window will effectively layout from this position.
+ // - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from the POV of the parent window)
+ // See "Widgets" -> "Querying Status (Active/Focused/Hovered etc.)" section for more details about this.
+ {
+ ImGui::SetCursorPosX(50);
+ ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100));
+ ImGui::BeginChild("blah", ImVec2(200, 100), true, ImGuiWindowFlags_None);
+ for (int n = 0; n < 50; n++)
+ ImGui::Text("Some test %d", n);
+ ImGui::EndChild();
+ ImVec2 child_rect_min = ImGui::GetItemRectMin();
+ ImVec2 child_rect_max = ImGui::GetItemRectMax();
+ ImGui::PopStyleColor();
+ ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y);
+ }
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Widgets Width"))
+ {
+ static float f = 0.0f;
+ ImGui::Text("PushItemWidth(100)");
+ ImGui::SameLine(); ShowHelpMarker("Fixed width.");
+ ImGui::PushItemWidth(100);
+ ImGui::DragFloat("float##1", &f);
+ ImGui::PopItemWidth();
+
+ ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)");
+ ImGui::SameLine(); ShowHelpMarker("Half of window width.");
+ ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
+ ImGui::DragFloat("float##2", &f);
+ ImGui::PopItemWidth();
+
+ ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
+ ImGui::SameLine(); ShowHelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
+ ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
+ ImGui::DragFloat("float##3", &f);
+ ImGui::PopItemWidth();
+
+ ImGui::Text("PushItemWidth(-100)");
+ ImGui::SameLine(); ShowHelpMarker("Align to right edge minus 100");
+ ImGui::PushItemWidth(-100);
+ ImGui::DragFloat("float##4", &f);
+ ImGui::PopItemWidth();
+
+ ImGui::Text("PushItemWidth(-1)");
+ ImGui::SameLine(); ShowHelpMarker("Align to right edge");
+ ImGui::PushItemWidth(-1);
+ ImGui::DragFloat("float##5", &f);
+ ImGui::PopItemWidth();
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Basic Horizontal Layout"))
+ {
+ ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)");
+
+ // Text
+ ImGui::Text("Two items: Hello"); ImGui::SameLine();
+ ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
+
+ // Adjust spacing
+ ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
+ ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
+
+ // Button
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("Normal buttons"); ImGui::SameLine();
+ ImGui::Button("Banana"); ImGui::SameLine();
+ ImGui::Button("Apple"); ImGui::SameLine();
+ ImGui::Button("Corniflower");
+
+ // Button
+ ImGui::Text("Small buttons"); ImGui::SameLine();
+ ImGui::SmallButton("Like this one"); ImGui::SameLine();
+ ImGui::Text("can fit within a text block.");
+
+ // Aligned to arbitrary position. Easy/cheap column.
+ ImGui::Text("Aligned");
+ ImGui::SameLine(150); ImGui::Text("x=150");
+ ImGui::SameLine(300); ImGui::Text("x=300");
+ ImGui::Text("Aligned");
+ ImGui::SameLine(150); ImGui::SmallButton("x=150");
+ ImGui::SameLine(300); ImGui::SmallButton("x=300");
+
+ // Checkbox
+ static bool c1 = false, c2 = false, c3 = false, c4 = false;
+ ImGui::Checkbox("My", &c1); ImGui::SameLine();
+ ImGui::Checkbox("Tailor", &c2); ImGui::SameLine();
+ ImGui::Checkbox("Is", &c3); ImGui::SameLine();
+ ImGui::Checkbox("Rich", &c4);
+
+ // Various
+ static float f0 = 1.0f, f1 = 2.0f, f2 = 3.0f;
+ ImGui::PushItemWidth(80);
+ const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" };
+ static int item = -1;
+ ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
+ ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine();
+ ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine();
+ ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f);
+ ImGui::PopItemWidth();
+
+ ImGui::PushItemWidth(80);
+ ImGui::Text("Lists:");
+ static int selection[4] = { 0, 1, 2, 3 };
+ for (int i = 0; i < 4; i++)
+ {
+ if (i > 0) ImGui::SameLine();
+ ImGui::PushID(i);
+ ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
+ ImGui::PopID();
+ //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
+ }
+ ImGui::PopItemWidth();
+
+ // Dummy
+ ImVec2 button_sz(40, 40);
+ ImGui::Button("A", button_sz); ImGui::SameLine();
+ ImGui::Dummy(button_sz); ImGui::SameLine();
+ ImGui::Button("B", button_sz);
+
+ // Manually wrapping (we should eventually provide this as an automatic layout feature, but for now you can do it manually)
+ ImGui::Text("Manually wrapping:");
+ ImGuiStyle& style = ImGui::GetStyle();
+ int buttons_count = 20;
+ float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
+ for (int n = 0; n < buttons_count; n++)
+ {
+ ImGui::PushID(n);
+ ImGui::Button("Box", button_sz);
+ float last_button_x2 = ImGui::GetItemRectMax().x;
+ float next_button_x2 = last_button_x2 + style.ItemSpacing.x + button_sz.x; // Expected position if next button was on same line
+ if (n + 1 < buttons_count && next_button_x2 < window_visible_x2)
+ ImGui::SameLine();
+ ImGui::PopID();
+ }
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Tabs"))
+ {
+ if (ImGui::TreeNode("Basic"))
+ {
+ ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
+ if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
+ {
+ if (ImGui::BeginTabItem("Avocado"))
+ {
+ ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah");
+ ImGui::EndTabItem();
+ }
+ if (ImGui::BeginTabItem("Broccoli"))
+ {
+ ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
+ ImGui::EndTabItem();
+ }
+ if (ImGui::BeginTabItem("Cucumber"))
+ {
+ ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah");
+ ImGui::EndTabItem();
+ }
+ ImGui::EndTabBar();
+ }
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Advanced & Close Button"))
+ {
+ // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).
+ static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable;
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_Reorderable);
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
+ ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
+ if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
+ tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
+ if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
+ tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
+ if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
+ tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
+
+ // Tab Bar
+ const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" };
+ static bool opened[4] = { true, true, true, true }; // Persistent user state
+ for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
+ {
+ if (n > 0) { ImGui::SameLine(); }
+ ImGui::Checkbox(names[n], &opened[n]);
+ }
+
+ // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): the underlying bool will be set to false when the tab is closed.
+ if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
+ {
+ for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
+ if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n]))
+ {
+ ImGui::Text("This is the %s tab!", names[n]);
+ if (n & 1)
+ ImGui::Text("I am an odd tab.");
+ ImGui::EndTabItem();
+ }
+ ImGui::EndTabBar();
+ }
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Groups"))
+ {
+ ShowHelpMarker("Using ImGui::BeginGroup()/EndGroup() to layout items. BeginGroup() basically locks the horizontal position. EndGroup() bundles the whole group so that you can use functions such as IsItemHovered() on it.");
+ ImGui::BeginGroup();
+ {
+ ImGui::BeginGroup();
+ ImGui::Button("AAA");
+ ImGui::SameLine();
+ ImGui::Button("BBB");
+ ImGui::SameLine();
+ ImGui::BeginGroup();
+ ImGui::Button("CCC");
+ ImGui::Button("DDD");
+ ImGui::EndGroup();
+ ImGui::SameLine();
+ ImGui::Button("EEE");
+ ImGui::EndGroup();
+ if (ImGui::IsItemHovered())
+ ImGui::SetTooltip("First group hovered");
+ }
+ // Capture the group size and create widgets using the same size
+ ImVec2 size = ImGui::GetItemRectSize();
+ const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f };
+ ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size);
+
+ ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
+ ImGui::SameLine();
+ ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
+ ImGui::EndGroup();
+ ImGui::SameLine();
+
+ ImGui::Button("LEVERAGE\nBUZZWORD", size);
+ ImGui::SameLine();
+
+ if (ImGui::ListBoxHeader("List", size))
+ {
+ ImGui::Selectable("Selected", true);
+ ImGui::Selectable("Not Selected", false);
+ ImGui::ListBoxFooter();
+ }
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Text Baseline Alignment"))
+ {
+ ShowHelpMarker("This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets.");
+
+ ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("Banana");
+
+ ImGui::Text("Banana"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("One\nTwo\nThree");
+
+ ImGui::Button("HOP##1"); ImGui::SameLine();
+ ImGui::Text("Banana"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("Banana");
+
+ ImGui::Button("HOP##2"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("Banana");
+
+ ImGui::Button("TEST##1"); ImGui::SameLine();
+ ImGui::Text("TEST"); ImGui::SameLine();
+ ImGui::SmallButton("TEST##2");
+
+ ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
+ ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
+ ImGui::Button("Widget##1"); ImGui::SameLine();
+ ImGui::Text("Widget"); ImGui::SameLine();
+ ImGui::SmallButton("Widget##2"); ImGui::SameLine();
+ ImGui::Button("Widget##3");
+
+ // Tree
+ const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
+ ImGui::Button("Button##1");
+ ImGui::SameLine(0.0f, spacing);
+ if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+
+ ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
+ bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
+ ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
+ if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+
+ // Bullet
+ ImGui::Button("Button##3");
+ ImGui::SameLine(0.0f, spacing);
+ ImGui::BulletText("Bullet text");
+
+ ImGui::AlignTextToFramePadding();
+ ImGui::BulletText("Node");
+ ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Scrolling"))
+ {
+ ShowHelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given position.");
+
+ static bool track = true;
+ static int track_line = 50, scroll_to_px = 200;
+ ImGui::Checkbox("Track", &track);
+ ImGui::PushItemWidth(100);
+ ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %d");
+ bool scroll_to = ImGui::Button("Scroll To Pos");
+ ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %d px");
+ ImGui::PopItemWidth();
+ if (scroll_to) track = false;
+
+ for (int i = 0; i < 5; i++)
+ {
+ if (i > 0) ImGui::SameLine();
+ ImGui::BeginGroup();
+ ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
+ ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
+ if (scroll_to)
+ ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
+ for (int line = 0; line < 100; line++)
+ {
+ if (track && line == track_line)
+ {
+ ImGui::TextColored(ImVec4(1,1,0,1), "Line %d", line);
+ ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
+ }
+ else
+ {
+ ImGui::Text("Line %d", line);
+ }
+ }
+ float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY();
+ ImGui::EndChild();
+ ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y);
+ ImGui::EndGroup();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Horizontal Scrolling"))
+ {
+ ShowHelpMarker("Horizontal scrolling for a window has to be enabled explicitly via the ImGuiWindowFlags_HorizontalScrollbar flag.\n\nYou may want to explicitly specify content width by calling SetNextWindowContentWidth() before Begin().");
+ static int lines = 7;
+ ImGui::SliderInt("Lines", &lines, 1, 15);
+ ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
+ ImGui::BeginChild("scrolling", ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30), true, ImGuiWindowFlags_HorizontalScrollbar);
+ for (int line = 0; line < lines; line++)
+ {
+ // Display random stuff (for the sake of this trivial demo we are using basic Button+SameLine. If you want to create your own time line for a real application you may be better off
+ // manipulating the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets yourself. You may also want to use the lower-level ImDrawList API)
+ int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
+ for (int n = 0; n < num_buttons; n++)
+ {
+ if (n > 0) ImGui::SameLine();
+ ImGui::PushID(n + line * 1000);
+ char num_buf[16];
+ sprintf(num_buf, "%d", n);
+ const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : num_buf;
+ float hue = n*0.05f;
+ ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f));
+ ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f));
+ ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(hue, 0.8f, 0.8f));
+ ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f));
+ ImGui::PopStyleColor(3);
+ ImGui::PopID();
+ }
+ }
+ float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX();
+ ImGui::EndChild();
+ ImGui::PopStyleVar(2);
+ float scroll_x_delta = 0.0f;
+ ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
+ ImGui::Text("Scroll from code"); ImGui::SameLine();
+ ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
+ ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
+ if (scroll_x_delta != 0.0f)
+ {
+ ImGui::BeginChild("scrolling"); // Demonstrate a trick: you can use Begin to set yourself in the context of another window (here we are already out of your child window)
+ ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
+ ImGui::End();
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Clipping"))
+ {
+ static ImVec2 size(100, 100), offset(50, 20);
+ ImGui::TextWrapped("On a per-widget basis we are occasionally clipping text CPU-side if it won't fit in its frame. Otherwise we are doing coarser clipping + passing a scissor rectangle to the renderer. The system is designed to try minimizing both execution and CPU/GPU rendering cost.");
+ ImGui::DragFloat2("size", (float*)&size, 0.5f, 1.0f, 200.0f, "%.0f");
+ ImGui::TextWrapped("(Click and drag)");
+ ImVec2 pos = ImGui::GetCursorScreenPos();
+ ImVec4 clip_rect(pos.x, pos.y, pos.x + size.x, pos.y + size.y);
+ ImGui::InvisibleButton("##dummy", size);
+ if (ImGui::IsItemActive() && ImGui::IsMouseDragging()) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; }
+ ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y), IM_COL32(90, 90, 120, 255));
+ ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x + offset.x, pos.y + offset.y), IM_COL32(255, 255, 255, 255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
+ ImGui::TreePop();
+ }
+}
+
+static void ShowDemoWindowPopups()
+{
+ if (!ImGui::CollapsingHeader("Popups & Modal windows"))
+ return;
+
+ // The properties of popups windows are:
+ // - They block normal mouse hovering detection outside them. (*)
+ // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
+ // - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
+ // User can manipulate the visibility state by calling OpenPopup().
+ // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
+ // Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
+
+ // Typical use for regular windows:
+ // bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End();
+ // Typical use for popups:
+ // if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); }
+
+ // With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state.
+ // This may be a bit confusing at first but it should quickly make sense. Follow on the examples below.
+
+ if (ImGui::TreeNode("Popups"))
+ {
+ ImGui::TextWrapped("When a popup is active, it inhibits interacting with windows that are behind the popup. Clicking outside the popup closes it.");
+
+ static int selected_fish = -1;
+ const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" };
+ static bool toggles[] = { true, false, false, false, false };
+
+ // Simple selection popup
+ // (If you want to show the current selection inside the Button itself, you may want to build a string using the "###" operator to preserve a constant ID with a variable label)
+ if (ImGui::Button("Select.."))
+ ImGui::OpenPopup("my_select_popup");
+ ImGui::SameLine();
+ ImGui::TextUnformatted(selected_fish == -1 ? "<None>" : names[selected_fish]);
+ if (ImGui::BeginPopup("my_select_popup"))
+ {
+ ImGui::Text("Aquarium");
+ ImGui::Separator();
+ for (int i = 0; i < IM_ARRAYSIZE(names); i++)
+ if (ImGui::Selectable(names[i]))
+ selected_fish = i;
+ ImGui::EndPopup();
+ }
+
+ // Showing a menu with toggles
+ if (ImGui::Button("Toggle.."))
+ ImGui::OpenPopup("my_toggle_popup");
+ if (ImGui::BeginPopup("my_toggle_popup"))
+ {
+ for (int i = 0; i < IM_ARRAYSIZE(names); i++)
+ ImGui::MenuItem(names[i], "", &toggles[i]);
+ if (ImGui::BeginMenu("Sub-menu"))
+ {
+ ImGui::MenuItem("Click me");
+ ImGui::EndMenu();
+ }
+
+ ImGui::Separator();
+ ImGui::Text("Tooltip here");
+ if (ImGui::IsItemHovered())
+ ImGui::SetTooltip("I am a tooltip over a popup");
+
+ if (ImGui::Button("Stacked Popup"))
+ ImGui::OpenPopup("another popup");
+ if (ImGui::BeginPopup("another popup"))
+ {
+ for (int i = 0; i < IM_ARRAYSIZE(names); i++)
+ ImGui::MenuItem(names[i], "", &toggles[i]);
+ if (ImGui::BeginMenu("Sub-menu"))
+ {
+ ImGui::MenuItem("Click me");
+ ImGui::EndMenu();
+ }
+ ImGui::EndPopup();
+ }
+ ImGui::EndPopup();
+ }
+
+ // Call the more complete ShowExampleMenuFile which we use in various places of this demo
+ if (ImGui::Button("File Menu.."))
+ ImGui::OpenPopup("my_file_popup");
+ if (ImGui::BeginPopup("my_file_popup"))
+ {
+ ShowExampleMenuFile();
+ ImGui::EndPopup();
+ }
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Context menus"))
+ {
+ // BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing:
+ // if (IsItemHovered() && IsMouseReleased(0))
+ // OpenPopup(id);
+ // return BeginPopup(id);
+ // For more advanced uses you may want to replicate and cuztomize this code. This the comments inside BeginPopupContextItem() implementation.
+ static float value = 0.5f;
+ ImGui::Text("Value = %.3f (<-- right-click here)", value);
+ if (ImGui::BeginPopupContextItem("item context menu"))
+ {
+ if (ImGui::Selectable("Set to zero")) value = 0.0f;
+ if (ImGui::Selectable("Set to PI")) value = 3.1415f;
+ ImGui::PushItemWidth(-1);
+ ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
+ ImGui::PopItemWidth();
+ ImGui::EndPopup();
+ }
+
+ // We can also use OpenPopupOnItemClick() which is the same as BeginPopupContextItem() but without the Begin call.
+ // So here we will make it that clicking on the text field with the right mouse button (1) will toggle the visibility of the popup above.
+ ImGui::Text("(You can also right-click me to the same popup as above.)");
+ ImGui::OpenPopupOnItemClick("item context menu", 1);
+
+ // When used after an item that has an ID (here the Button), we can skip providing an ID to BeginPopupContextItem().
+ // BeginPopupContextItem() will use the last item ID as the popup ID.
+ // In addition here, we want to include your editable label inside the button label. We use the ### operator to override the ID (read FAQ about ID for details)
+ static char name[32] = "Label1";
+ char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label
+ ImGui::Button(buf);
+ if (ImGui::BeginPopupContextItem())
+ {
+ ImGui::Text("Edit name:");
+ ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
+ if (ImGui::Button("Close"))
+ ImGui::CloseCurrentPopup();
+ ImGui::EndPopup();
+ }
+ ImGui::SameLine(); ImGui::Text("(<-- right-click here)");
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Modals"))
+ {
+ ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window.");
+
+ if (ImGui::Button("Delete.."))
+ ImGui::OpenPopup("Delete?");
+
+ if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize))
+ {
+ ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
+ ImGui::Separator();
+
+ //static int dummy_i = 0;
+ //ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0");
+
+ static bool dont_ask_me_next_time = false;
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
+ ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
+ ImGui::PopStyleVar();
+
+ if (ImGui::Button("OK", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
+ ImGui::SetItemDefaultFocus();
+ ImGui::SameLine();
+ if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
+ ImGui::EndPopup();
+ }
+
+ if (ImGui::Button("Stacked modals.."))
+ ImGui::OpenPopup("Stacked 1");
+ if (ImGui::BeginPopupModal("Stacked 1"))
+ {
+ ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it.");
+ static int item = 1;
+ ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
+ static float color[4] = { 0.4f,0.7f,0.0f,0.5f };
+ ImGui::ColorEdit4("color", color); // This is to test behavior of stacked regular popups over a modal
+
+ if (ImGui::Button("Add another modal.."))
+ ImGui::OpenPopup("Stacked 2");
+
+ // Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which will close the popup.
+ // Note that the visibility state of popups is owned by imgui, so the input value of the bool actually doesn't matter here.
+ bool dummy_open = true;
+ if (ImGui::BeginPopupModal("Stacked 2", &dummy_open))
+ {
+ ImGui::Text("Hello from Stacked The Second!");
+ if (ImGui::Button("Close"))
+ ImGui::CloseCurrentPopup();
+ ImGui::EndPopup();
+ }
+
+ if (ImGui::Button("Close"))
+ ImGui::CloseCurrentPopup();
+ ImGui::EndPopup();
+ }
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Menus inside a regular window"))
+ {
+ ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
+ ImGui::Separator();
+ // NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
+ // To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
+ // would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
+ ImGui::PushID("foo");
+ ImGui::MenuItem("Menu item", "CTRL+M");
+ if (ImGui::BeginMenu("Menu inside a regular window"))
+ {
+ ShowExampleMenuFile();
+ ImGui::EndMenu();
+ }
+ ImGui::PopID();
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+}
+
+static void ShowDemoWindowColumns()
+{
+ if (!ImGui::CollapsingHeader("Columns"))
+ return;
+
+ ImGui::PushID("Columns");
+
+ // Basic columns
+ if (ImGui::TreeNode("Basic"))
+ {
+ ImGui::Text("Without border:");
+ ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
+ ImGui::Separator();
+ for (int n = 0; n < 14; n++)
+ {
+ char label[32];
+ sprintf(label, "Item %d", n);
+ if (ImGui::Selectable(label)) {}
+ //if (ImGui::Button(label, ImVec2(-1,0))) {}
+ ImGui::NextColumn();
+ }
+ ImGui::Columns(1);
+ ImGui::Separator();
+
+ ImGui::Text("With border:");
+ ImGui::Columns(4, "mycolumns"); // 4-ways, with border
+ ImGui::Separator();
+ ImGui::Text("ID"); ImGui::NextColumn();
+ ImGui::Text("Name"); ImGui::NextColumn();
+ ImGui::Text("Path"); ImGui::NextColumn();
+ ImGui::Text("Hovered"); ImGui::NextColumn();
+ ImGui::Separator();
+ const char* names[3] = { "One", "Two", "Three" };
+ const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
+ static int selected = -1;
+ for (int i = 0; i < 3; i++)
+ {
+ char label[32];
+ sprintf(label, "%04d", i);
+ if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
+ selected = i;
+ bool hovered = ImGui::IsItemHovered();
+ ImGui::NextColumn();
+ ImGui::Text(names[i]); ImGui::NextColumn();
+ ImGui::Text(paths[i]); ImGui::NextColumn();
+ ImGui::Text("%d", hovered); ImGui::NextColumn();
+ }
+ ImGui::Columns(1);
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ // Create multiple items in a same cell before switching to next column
+ if (ImGui::TreeNode("Mixed items"))
+ {
+ ImGui::Columns(3, "mixed");
+ ImGui::Separator();
+
+ ImGui::Text("Hello");
+ ImGui::Button("Banana");
+ ImGui::NextColumn();
+
+ ImGui::Text("ImGui");
+ ImGui::Button("Apple");
+ static float foo = 1.0f;
+ ImGui::InputFloat("red", &foo, 0.05f, 0, "%.3f");
+ ImGui::Text("An extra line here.");
+ ImGui::NextColumn();
+
+ ImGui::Text("Sailor");
+ ImGui::Button("Corniflower");
+ static float bar = 1.0f;
+ ImGui::InputFloat("blue", &bar, 0.05f, 0, "%.3f");
+ ImGui::NextColumn();
+
+ if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
+ if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
+ if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
+ ImGui::Columns(1);
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ // Word wrapping
+ if (ImGui::TreeNode("Word-wrapping"))
+ {
+ ImGui::Columns(2, "word-wrapping");
+ ImGui::Separator();
+ ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
+ ImGui::TextWrapped("Hello Left");
+ ImGui::NextColumn();
+ ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
+ ImGui::TextWrapped("Hello Right");
+ ImGui::Columns(1);
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Borders"))
+ {
+ // NB: Future columns API should allow automatic horizontal borders.
+ static bool h_borders = true;
+ static bool v_borders = true;
+ ImGui::Checkbox("horizontal", &h_borders);
+ ImGui::SameLine();
+ ImGui::Checkbox("vertical", &v_borders);
+ ImGui::Columns(4, NULL, v_borders);
+ for (int i = 0; i < 4*3; i++)
+ {
+ if (h_borders && ImGui::GetColumnIndex() == 0)
+ ImGui::Separator();
+ ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
+ ImGui::Text("Width %.2f\nOffset %.2f", ImGui::GetColumnWidth(), ImGui::GetColumnOffset());
+ ImGui::NextColumn();
+ }
+ ImGui::Columns(1);
+ if (h_borders)
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+
+ // Scrolling columns
+ /*
+ if (ImGui::TreeNode("Vertical Scrolling"))
+ {
+ ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
+ ImGui::Columns(3);
+ ImGui::Text("ID"); ImGui::NextColumn();
+ ImGui::Text("Name"); ImGui::NextColumn();
+ ImGui::Text("Path"); ImGui::NextColumn();
+ ImGui::Columns(1);
+ ImGui::Separator();
+ ImGui::EndChild();
+ ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
+ ImGui::Columns(3);
+ for (int i = 0; i < 10; i++)
+ {
+ ImGui::Text("%04d", i); ImGui::NextColumn();
+ ImGui::Text("Foobar"); ImGui::NextColumn();
+ ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
+ }
+ ImGui::Columns(1);
+ ImGui::EndChild();
+ ImGui::TreePop();
+ }
+ */
+
+ if (ImGui::TreeNode("Horizontal Scrolling"))
+ {
+ ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f));
+ ImGui::BeginChild("##ScrollingRegion", ImVec2(0, ImGui::GetFontSize() * 20), false, ImGuiWindowFlags_HorizontalScrollbar);
+ ImGui::Columns(10);
+ int ITEMS_COUNT = 2000;
+ ImGuiListClipper clipper(ITEMS_COUNT); // Also demonstrate using the clipper for large list
+ while (clipper.Step())
+ {
+ for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
+ for (int j = 0; j < 10; j++)
+ {
+ ImGui::Text("Line %d Column %d...", i, j);
+ ImGui::NextColumn();
+ }
+ }
+ ImGui::Columns(1);
+ ImGui::EndChild();
+ ImGui::TreePop();
+ }
+
+ bool node_open = ImGui::TreeNode("Tree within single cell");
+ ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell.");
+ if (node_open)
+ {
+ ImGui::Columns(2, "tree items");
+ ImGui::Separator();
+ if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
+ if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
+ ImGui::Columns(1);
+ ImGui::Separator();
+ ImGui::TreePop();
+ }
+ ImGui::PopID();
+}
+
+static void ShowDemoWindowMisc()
+{
+ if (ImGui::CollapsingHeader("Filtering"))
+ {
+ static ImGuiTextFilter filter;
+ ImGui::Text("Filter usage:\n"
+ " \"\" display all lines\n"
+ " \"xxx\" display lines containing \"xxx\"\n"
+ " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n"
+ " \"-xxx\" hide lines containing \"xxx\"");
+ filter.Draw();
+ const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" };
+ for (int i = 0; i < IM_ARRAYSIZE(lines); i++)
+ if (filter.PassFilter(lines[i]))
+ ImGui::BulletText("%s", lines[i]);
+ }
+
+ if (ImGui::CollapsingHeader("Inputs, Navigation & Focus"))
+ {
+ ImGuiIO& io = ImGui::GetIO();
+
+ ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse);
+ ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
+ ImGui::Text("WantTextInput: %d", io.WantTextInput);
+ ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos);
+ ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible);
+
+ if (ImGui::TreeNode("Keyboard, Mouse & Navigation State"))
+ {
+ if (ImGui::IsMousePosValid())
+ ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
+ else
+ ImGui::Text("Mouse pos: <INVALID>");
+ ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y);
+ ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
+ ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
+ ImGui::Text("Mouse dbl-clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
+ ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
+ ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
+
+ ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (%.02f secs)", i, io.KeysDownDuration[i]); }
+ ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
+ ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
+ ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
+
+ ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputs[i]); }
+ ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
+ ImGui::Text("NavInputs duration:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputsDownDuration[i]); }
+
+ ImGui::Button("Hovering me sets the\nkeyboard capture flag");
+ if (ImGui::IsItemHovered())
+ ImGui::CaptureKeyboardFromApp(true);
+ ImGui::SameLine();
+ ImGui::Button("Holding me clears the\nthe keyboard capture flag");
+ if (ImGui::IsItemActive())
+ ImGui::CaptureKeyboardFromApp(false);
+
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Tabbing"))
+ {
+ ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields.");
+ static char buf[32] = "dummy";
+ ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
+ ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
+ ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
+ ImGui::PushAllowKeyboardFocus(false);
+ ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf));
+ //ImGui::SameLine(); ShowHelperMarker("Use ImGui::PushAllowKeyboardFocus(bool)\nto disable tabbing through certain widgets.");
+ ImGui::PopAllowKeyboardFocus();
+ ImGui::InputText("5", buf, IM_ARRAYSIZE(buf));
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Focus from code"))
+ {
+ bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine();
+ bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine();
+ bool focus_3 = ImGui::Button("Focus on 3");
+ int has_focus = 0;
+ static char buf[128] = "click on a button to set focus";
+
+ if (focus_1) ImGui::SetKeyboardFocusHere();
+ ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
+ if (ImGui::IsItemActive()) has_focus = 1;
+
+ if (focus_2) ImGui::SetKeyboardFocusHere();
+ ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
+ if (ImGui::IsItemActive()) has_focus = 2;
+
+ ImGui::PushAllowKeyboardFocus(false);
+ if (focus_3) ImGui::SetKeyboardFocusHere();
+ ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
+ if (ImGui::IsItemActive()) has_focus = 3;
+ ImGui::PopAllowKeyboardFocus();
+
+ if (has_focus)
+ ImGui::Text("Item with focus: %d", has_focus);
+ else
+ ImGui::Text("Item with focus: <none>");
+
+ // Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item
+ static float f3[3] = { 0.0f, 0.0f, 0.0f };
+ int focus_ahead = -1;
+ if (ImGui::Button("Focus on X")) focus_ahead = 0; ImGui::SameLine();
+ if (ImGui::Button("Focus on Y")) focus_ahead = 1; ImGui::SameLine();
+ if (ImGui::Button("Focus on Z")) focus_ahead = 2;
+ if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead);
+ ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f);
+
+ ImGui::TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code.");
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Dragging"))
+ {
+ ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
+ for (int button = 0; button < 3; button++)
+ ImGui::Text("IsMouseDragging(%d):\n w/ default threshold: %d,\n w/ zero threshold: %d\n w/ large threshold: %d",
+ button, ImGui::IsMouseDragging(button), ImGui::IsMouseDragging(button, 0.0f), ImGui::IsMouseDragging(button, 20.0f));
+ ImGui::Button("Drag Me");
+ if (ImGui::IsItemActive())
+ {
+ // Draw a line between the button and the mouse cursor
+ ImDrawList* draw_list = ImGui::GetWindowDrawList();
+ draw_list->PushClipRectFullScreen();
+ draw_list->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f);
+ draw_list->PopClipRect();
+
+ // Drag operations gets "unlocked" when the mouse has moved past a certain threshold (the default threshold is stored in io.MouseDragThreshold)
+ // You can request a lower or higher threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta()
+ ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
+ ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
+ ImVec2 mouse_delta = io.MouseDelta;
+ ImGui::SameLine(); ImGui::Text("Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f)", value_raw.x, value_raw.y, value_with_lock_threshold.x, value_with_lock_threshold.y, mouse_delta.x, mouse_delta.y);
+ }
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Mouse cursors"))
+ {
+ const char* mouse_cursors_names[] = { "Arrow", "TextInput", "Move", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand" };
+ IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT);
+
+ ImGui::Text("Current mouse cursor = %d: %s", ImGui::GetMouseCursor(), mouse_cursors_names[ImGui::GetMouseCursor()]);
+ ImGui::Text("Hover to see mouse cursors:");
+ ImGui::SameLine(); ShowHelpMarker("Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, otherwise your backend needs to handle it.");
+ for (int i = 0; i < ImGuiMouseCursor_COUNT; i++)
+ {
+ char label[32];
+ sprintf(label, "Mouse cursor %d: %s", i, mouse_cursors_names[i]);
+ ImGui::Bullet(); ImGui::Selectable(label, false);
+ if (ImGui::IsItemHovered() || ImGui::IsItemFocused())
+ ImGui::SetMouseCursor(i);
+ }
+ ImGui::TreePop();
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] About Window / ShowAboutWindow()
+// Access from ImGui Demo -> Help -> About
+//-----------------------------------------------------------------------------
+
+void ImGui::ShowAboutWindow(bool* p_open)
+{
+ if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize))
+ {
+ ImGui::End();
+ return;
+ }
+ ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
+ ImGui::Separator();
+ ImGui::Text("By Omar Cornut and all dear imgui contributors.");
+ ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");
+
+ static bool show_config_info = false;
+ ImGui::Checkbox("Config/Build Information", &show_config_info);
+ if (show_config_info)
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ ImGuiStyle& style = ImGui::GetStyle();
+
+ bool copy_to_clipboard = ImGui::Button("Copy to clipboard");
+ ImGui::BeginChildFrame(ImGui::GetID("cfginfos"), ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18), ImGuiWindowFlags_NoMove);
+ if (copy_to_clipboard)
+ ImGui::LogToClipboard();
+
+ ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
+ ImGui::Separator();
+ ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert));
+ ImGui::Text("define: __cplusplus=%d", (int)__cplusplus);
+#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_MATH_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_MATH_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_DEFAULT_ALLOCATORS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS");
+#endif
+#ifdef IMGUI_USE_BGRA_PACKED_COLOR
+ ImGui::Text("define: IMGUI_USE_BGRA_PACKED_COLOR");
+#endif
+#ifdef _WIN32
+ ImGui::Text("define: _WIN32");
+#endif
+#ifdef _WIN64
+ ImGui::Text("define: _WIN64");
+#endif
+#ifdef __linux__
+ ImGui::Text("define: __linux__");
+#endif
+#ifdef __APPLE__
+ ImGui::Text("define: __APPLE__");
+#endif
+#ifdef _MSC_VER
+ ImGui::Text("define: _MSC_VER=%d", _MSC_VER);
+#endif
+#ifdef __MINGW32__
+ ImGui::Text("define: __MINGW32__");
+#endif
+#ifdef __MINGW64__
+ ImGui::Text("define: __MINGW64__");
+#endif
+#ifdef __GNUC__
+ ImGui::Text("define: __GNUC__=%d", (int)__GNUC__);
+#endif
+#ifdef __clang_version__
+ ImGui::Text("define: __clang_version__=%s", __clang_version__);
+#endif
+ ImGui::Separator();
+ ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
+ ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL");
+ ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags);
+ if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard");
+ if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad");
+ if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos");
+ if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
+ if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
+ if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
+ if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
+ if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
+ if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
+ if (io.ConfigWindowsMoveFromTitleBarOnly) ImGui::Text("io.ConfigWindowsMoveFromTitleBarOnly");
+ ImGui::Text("io.BackendFlags: 0x%08X", io.BackendFlags);
+ if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
+ if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
+ if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
+ ImGui::Separator();
+ ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight);
+ ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
+ ImGui::Separator();
+ ImGui::Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y);
+ ImGui::Text("style.WindowBorderSize: %.2f", style.WindowBorderSize);
+ ImGui::Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y);
+ ImGui::Text("style.FrameRounding: %.2f", style.FrameRounding);
+ ImGui::Text("style.FrameBorderSize: %.2f", style.FrameBorderSize);
+ ImGui::Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y);
+ ImGui::Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y);
+
+ if (copy_to_clipboard)
+ ImGui::LogFinish();
+ ImGui::EndChildFrame();
+ }
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Style Editor / ShowStyleEditor()
+//-----------------------------------------------------------------------------
+
+// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
+// Here we use the simplified Combo() api that packs items into a single literal string. Useful for quick combo boxes where the choices are known locally.
+bool ImGui::ShowStyleSelector(const char* label)
+{
+ static int style_idx = -1;
+ if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0"))
+ {
+ switch (style_idx)
+ {
+ case 0: ImGui::StyleColorsClassic(); break;
+ case 1: ImGui::StyleColorsDark(); break;
+ case 2: ImGui::StyleColorsLight(); break;
+ }
+ return true;
+ }
+ return false;
+}
+
+// Demo helper function to select among loaded fonts.
+// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
+void ImGui::ShowFontSelector(const char* label)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ ImFont* font_current = ImGui::GetFont();
+ if (ImGui::BeginCombo(label, font_current->GetDebugName()))
+ {
+ for (int n = 0; n < io.Fonts->Fonts.Size; n++)
+ if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current))
+ io.FontDefault = io.Fonts->Fonts[n];
+ ImGui::EndCombo();
+ }
+ ImGui::SameLine();
+ ShowHelpMarker(
+ "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
+ "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
+ "- Read FAQ and documentation in misc/fonts/ for more details.\n"
+ "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
+}
+
+void ImGui::ShowStyleEditor(ImGuiStyle* ref)
+{
+ // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to an internally stored reference)
+ ImGuiStyle& style = ImGui::GetStyle();
+ static ImGuiStyle ref_saved_style;
+
+ // Default to using internal storage as reference
+ static bool init = true;
+ if (init && ref == NULL)
+ ref_saved_style = style;
+ init = false;
+ if (ref == NULL)
+ ref = &ref_saved_style;
+
+ ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f);
+
+ if (ImGui::ShowStyleSelector("Colors##Selector"))
+ ref_saved_style = style;
+ ImGui::ShowFontSelector("Fonts##Selector");
+
+ // Simplified Settings
+ if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
+ style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding
+ { bool window_border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; }
+ ImGui::SameLine();
+ { bool frame_border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &frame_border)) style.FrameBorderSize = frame_border ? 1.0f : 0.0f; }
+ ImGui::SameLine();
+ { bool popup_border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &popup_border)) style.PopupBorderSize = popup_border ? 1.0f : 0.0f; }
+
+ // Save/Revert button
+ if (ImGui::Button("Save Ref"))
+ *ref = ref_saved_style = style;
+ ImGui::SameLine();
+ if (ImGui::Button("Revert Ref"))
+ style = *ref;
+ ImGui::SameLine();
+ ShowHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.");
+
+ ImGui::Separator();
+
+ if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None))
+ {
+ if (ImGui::BeginTabItem("Sizes"))
+ {
+ ImGui::Text("Main");
+ ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
+ ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 16.0f, "%.0f");
+ ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
+ ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
+ ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
+ ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
+ ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
+ ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
+ ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
+ ImGui::Text("Borders");
+ ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
+ ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
+ ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
+ ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
+ ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
+ ImGui::Text("Rounding");
+ ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 14.0f, "%.0f");
+ ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 16.0f, "%.0f");
+ ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
+ ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
+ ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
+ ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
+ ImGui::Text("Alignment");
+ ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
+ ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); ShowHelpMarker("Alignment applies when a button is larger than its text content.");
+ ImGui::Text("Safe Area Padding"); ImGui::SameLine(); ShowHelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
+ ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f");
+ ImGui::EndTabItem();
+ }
+
+ if (ImGui::BeginTabItem("Colors"))
+ {
+ static int output_dest = 0;
+ static bool output_only_modified = true;
+ if (ImGui::Button("Export Unsaved"))
+ {
+ if (output_dest == 0)
+ ImGui::LogToClipboard();
+ else
+ ImGui::LogToTTY();
+ ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
+ for (int i = 0; i < ImGuiCol_COUNT; i++)
+ {
+ const ImVec4& col = style.Colors[i];
+ const char* name = ImGui::GetStyleColorName(i);
+ if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0)
+ ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
+ }
+ ImGui::LogFinish();
+ }
+ ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
+ ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
+
+ static ImGuiTextFilter filter;
+ filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
+
+ static ImGuiColorEditFlags alpha_flags = 0;
+ ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
+ ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine();
+ ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::SameLine();
+ ShowHelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu.");
+
+ ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
+ ImGui::PushItemWidth(-160);
+ for (int i = 0; i < ImGuiCol_COUNT; i++)
+ {
+ const char* name = ImGui::GetStyleColorName(i);
+ if (!filter.PassFilter(name))
+ continue;
+ ImGui::PushID(i);
+ ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
+ if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
+ {
+ // Tips: in a real user application, you may want to merge and use an icon font into the main font, so instead of "Save"/"Revert" you'd use icons.
+ // Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy and super convenient!
+ ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i];
+ ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i];
+ }
+ ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
+ ImGui::TextUnformatted(name);
+ ImGui::PopID();
+ }
+ ImGui::PopItemWidth();
+ ImGui::EndChild();
+
+ ImGui::EndTabItem();
+ }
+
+ if (ImGui::BeginTabItem("Fonts"))
+ {
+ ImFontAtlas* atlas = ImGui::GetIO().Fonts;
+ ShowHelpMarker("Read FAQ and misc/fonts/README.txt for details on font loading.");
+ ImGui::PushItemWidth(120);
+ for (int i = 0; i < atlas->Fonts.Size; i++)
+ {
+ ImFont* font = atlas->Fonts[i];
+ ImGui::PushID(font);
+ bool font_details_opened = ImGui::TreeNode(font, "Font %d: \"%s\"\n%.2f px, %d glyphs, %d file(s)", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
+ ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font;
+ if (font_details_opened)
+ {
+ ImGui::PushFont(font);
+ ImGui::Text("The quick brown fox jumps over the lazy dog");
+ ImGui::PopFont();
+ ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
+ ImGui::SameLine(); ShowHelpMarker("Note than the default embedded font is NOT meant to be scaled.\n\nFont are currently rendered into bitmaps at a given size at the time of building the atlas. You may oversample them to get some flexibility with scaling. You can also render at multiple sizes and select which one to use at runtime.\n\n(Glimmer of hope: the atlas system should hopefully be rewritten in the future to make scaling more natural and automatic.)");
+ ImGui::InputFloat("Font offset", &font->DisplayOffset.y, 1, 1, "%.0f");
+ ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
+ ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
+ ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)sqrtf((float)font->MetricsTotalSurface), (int)sqrtf((float)font->MetricsTotalSurface));
+ for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
+ if (ImFontConfig* cfg = &font->ConfigData[config_i])
+ ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
+ if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
+ {
+ // Display all glyphs of the fonts in separate pages of 256 characters
+ for (int base = 0; base < 0x10000; base += 256)
+ {
+ int count = 0;
+ for (int n = 0; n < 256; n++)
+ count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0;
+ if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
+ {
+ float cell_size = font->FontSize * 1;
+ float cell_spacing = style.ItemSpacing.y;
+ ImVec2 base_pos = ImGui::GetCursorScreenPos();
+ ImDrawList* draw_list = ImGui::GetWindowDrawList();
+ for (int n = 0; n < 256; n++)
+ {
+ ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
+ ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
+ const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
+ draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
+ if (glyph)
+ font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base + n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
+ if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
+ {
+ ImGui::BeginTooltip();
+ ImGui::Text("Codepoint: U+%04X", base + n);
+ ImGui::Separator();
+ ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
+ ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
+ ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
+ ImGui::EndTooltip();
+ }
+ }
+ ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
+ ImGui::TreePop();
+ }
+ }
+ ImGui::TreePop();
+ }
+ ImGui::TreePop();
+ }
+ ImGui::PopID();
+ }
+ if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
+ {
+ ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
+ ImGui::TreePop();
+ }
+
+ static float window_scale = 1.0f;
+ if (ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f")) // scale only this window
+ ImGui::SetWindowFontScale(window_scale);
+ ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything
+ ImGui::PopItemWidth();
+
+ ImGui::EndTabItem();
+ }
+
+ if (ImGui::BeginTabItem("Rendering"))
+ {
+ ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.");
+ ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
+ ImGui::PushItemWidth(100);
+ ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f);
+ if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
+ ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
+ ImGui::PopItemWidth();
+
+ ImGui::EndTabItem();
+ }
+
+ ImGui::EndTabBar();
+ }
+
+ ImGui::PopItemWidth();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
+//-----------------------------------------------------------------------------
+
+// Demonstrate creating a fullscreen menu bar and populating it.
+static void ShowExampleAppMainMenuBar()
+{
+ if (ImGui::BeginMainMenuBar())
+ {
+ if (ImGui::BeginMenu("File"))
+ {
+ ShowExampleMenuFile();
+ ImGui::EndMenu();
+ }
+ if (ImGui::BeginMenu("Edit"))
+ {
+ if (ImGui::MenuItem("Undo", "CTRL+Z")) {}
+ if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item
+ ImGui::Separator();
+ if (ImGui::MenuItem("Cut", "CTRL+X")) {}
+ if (ImGui::MenuItem("Copy", "CTRL+C")) {}
+ if (ImGui::MenuItem("Paste", "CTRL+V")) {}
+ ImGui::EndMenu();
+ }
+ ImGui::EndMainMenuBar();
+ }
+}
+
+static void ShowExampleMenuFile()
+{
+ ImGui::MenuItem("(dummy menu)", NULL, false, false);
+ if (ImGui::MenuItem("New")) {}
+ if (ImGui::MenuItem("Open", "Ctrl+O")) {}
+ if (ImGui::BeginMenu("Open Recent"))
+ {
+ ImGui::MenuItem("fish_hat.c");
+ ImGui::MenuItem("fish_hat.inl");
+ ImGui::MenuItem("fish_hat.h");
+ if (ImGui::BeginMenu("More.."))
+ {
+ ImGui::MenuItem("Hello");
+ ImGui::MenuItem("Sailor");
+ if (ImGui::BeginMenu("Recurse.."))
+ {
+ ShowExampleMenuFile();
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenu();
+ }
+ if (ImGui::MenuItem("Save", "Ctrl+S")) {}
+ if (ImGui::MenuItem("Save As..")) {}
+ ImGui::Separator();
+ if (ImGui::BeginMenu("Options"))
+ {
+ static bool enabled = true;
+ ImGui::MenuItem("Enabled", "", &enabled);
+ ImGui::BeginChild("child", ImVec2(0, 60), true);
+ for (int i = 0; i < 10; i++)
+ ImGui::Text("Scrolling Text %d", i);
+ ImGui::EndChild();
+ static float f = 0.5f;
+ static int n = 0;
+ static bool b = true;
+ ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
+ ImGui::InputFloat("Input", &f, 0.1f);
+ ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0");
+ ImGui::Checkbox("Check", &b);
+ ImGui::EndMenu();
+ }
+ if (ImGui::BeginMenu("Colors"))
+ {
+ float sz = ImGui::GetTextLineHeight();
+ for (int i = 0; i < ImGuiCol_COUNT; i++)
+ {
+ const char* name = ImGui::GetStyleColorName((ImGuiCol)i);
+ ImVec2 p = ImGui::GetCursorScreenPos();
+ ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x+sz, p.y+sz), ImGui::GetColorU32((ImGuiCol)i));
+ ImGui::Dummy(ImVec2(sz, sz));
+ ImGui::SameLine();
+ ImGui::MenuItem(name);
+ }
+ ImGui::EndMenu();
+ }
+ if (ImGui::BeginMenu("Disabled", false)) // Disabled
+ {
+ IM_ASSERT(0);
+ }
+ if (ImGui::MenuItem("Checked", NULL, true)) {}
+ if (ImGui::MenuItem("Quit", "Alt+F4")) {}
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
+//-----------------------------------------------------------------------------
+
+// Demonstrate creating a simple console window, with scrolling, filtering, completion and history.
+// For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions.
+struct ExampleAppConsole
+{
+ char InputBuf[256];
+ ImVector<char*> Items;
+ bool ScrollToBottom;
+ ImVector<char*> History;
+ int HistoryPos; // -1: new line, 0..History.Size-1 browsing history.
+ ImVector<const char*> Commands;
+
+ ExampleAppConsole()
+ {
+ ClearLog();
+ memset(InputBuf, 0, sizeof(InputBuf));
+ HistoryPos = -1;
+ Commands.push_back("HELP");
+ Commands.push_back("HISTORY");
+ Commands.push_back("CLEAR");
+ Commands.push_back("CLASSIFY"); // "classify" is only here to provide an example of "C"+[tab] completing to "CL" and displaying matches.
+ AddLog("Welcome to Dear ImGui!");
+ }
+ ~ExampleAppConsole()
+ {
+ ClearLog();
+ for (int i = 0; i < History.Size; i++)
+ free(History[i]);
+ }
+
+ // Portable helpers
+ static int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; }
+ static int Strnicmp(const char* str1, const char* str2, int n) { int d = 0; while (n > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; n--; } return d; }
+ static char* Strdup(const char *str) { size_t len = strlen(str) + 1; void* buff = malloc(len); return (char*)memcpy(buff, (const void*)str, len); }
+ static void Strtrim(char* str) { char* str_end = str + strlen(str); while (str_end > str && str_end[-1] == ' ') str_end--; *str_end = 0; }
+
+ void ClearLog()
+ {
+ for (int i = 0; i < Items.Size; i++)
+ free(Items[i]);
+ Items.clear();
+ ScrollToBottom = true;
+ }
+
+ void AddLog(const char* fmt, ...) IM_FMTARGS(2)
+ {
+ // FIXME-OPT
+ char buf[1024];
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
+ buf[IM_ARRAYSIZE(buf)-1] = 0;
+ va_end(args);
+ Items.push_back(Strdup(buf));
+ ScrollToBottom = true;
+ }
+
+ void Draw(const char* title, bool* p_open)
+ {
+ ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver);
+ if (!ImGui::Begin(title, p_open))
+ {
+ ImGui::End();
+ return;
+ }
+
+ // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. So e.g. IsItemHovered() will return true when hovering the title bar.
+ // Here we create a context menu only available from the title bar.
+ if (ImGui::BeginPopupContextItem())
+ {
+ if (ImGui::MenuItem("Close Console"))
+ *p_open = false;
+ ImGui::EndPopup();
+ }
+
+ ImGui::TextWrapped("This example implements a console with basic coloring, completion and history. A more elaborate implementation may want to store entries along with extra data such as timestamp, emitter, etc.");
+ ImGui::TextWrapped("Enter 'HELP' for help, press TAB to use text completion.");
+
+ // TODO: display items starting from the bottom
+
+ if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
+ if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
+ if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
+ bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
+ if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
+ //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
+
+ ImGui::Separator();
+
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
+ static ImGuiTextFilter filter;
+ filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180);
+ ImGui::PopStyleVar();
+ ImGui::Separator();
+
+ const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); // 1 separator, 1 input text
+ ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); // Leave room for 1 separator + 1 InputText
+ if (ImGui::BeginPopupContextWindow())
+ {
+ if (ImGui::Selectable("Clear")) ClearLog();
+ ImGui::EndPopup();
+ }
+
+ // Display every line as a separate entry so we can change their color or add custom widgets. If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end());
+ // NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping to only process visible items.
+ // You can seek and display only the lines that are visible using the ImGuiListClipper helper, if your elements are evenly spaced and you have cheap random access to the elements.
+ // To use the clipper we could replace the 'for (int i = 0; i < Items.Size; i++)' loop with:
+ // ImGuiListClipper clipper(Items.Size);
+ // while (clipper.Step())
+ // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
+ // However, note that you can not use this code as is if a filter is active because it breaks the 'cheap random-access' property. We would need random-access on the post-filtered list.
+ // A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices that passed the filtering test, recomputing this array when user changes the filter,
+ // and appending newly elements as they are inserted. This is left as a task to the user until we can manage to improve this example code!
+ // If your items are of variable size you may want to implement code similar to what ImGuiListClipper does. Or split your data into fixed height items to allow random-seeking into your list.
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing
+ if (copy_to_clipboard)
+ ImGui::LogToClipboard();
+ ImVec4 col_default_text = ImGui::GetStyleColorVec4(ImGuiCol_Text);
+ for (int i = 0; i < Items.Size; i++)
+ {
+ const char* item = Items[i];
+ if (!filter.PassFilter(item))
+ continue;
+ ImVec4 col = col_default_text;
+ if (strstr(item, "[error]")) col = ImColor(1.0f,0.4f,0.4f,1.0f);
+ else if (strncmp(item, "# ", 2) == 0) col = ImColor(1.0f,0.78f,0.58f,1.0f);
+ ImGui::PushStyleColor(ImGuiCol_Text, col);
+ ImGui::TextUnformatted(item);
+ ImGui::PopStyleColor();
+ }
+ if (copy_to_clipboard)
+ ImGui::LogFinish();
+ if (ScrollToBottom)
+ ImGui::SetScrollHereY(1.0f);
+ ScrollToBottom = false;
+ ImGui::PopStyleVar();
+ ImGui::EndChild();
+ ImGui::Separator();
+
+ // Command-line
+ bool reclaim_focus = false;
+ if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this))
+ {
+ char* s = InputBuf;
+ Strtrim(s);
+ if (s[0])
+ ExecCommand(s);
+ strcpy(s, "");
+ reclaim_focus = true;
+ }
+
+ // Auto-focus on window apparition
+ ImGui::SetItemDefaultFocus();
+ if (reclaim_focus)
+ ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
+
+ ImGui::End();
+ }
+
+ void ExecCommand(const char* command_line)
+ {
+ AddLog("# %s\n", command_line);
+
+ // Insert into history. First find match and delete it so it can be pushed to the back. This isn't trying to be smart or optimal.
+ HistoryPos = -1;
+ for (int i = History.Size-1; i >= 0; i--)
+ if (Stricmp(History[i], command_line) == 0)
+ {
+ free(History[i]);
+ History.erase(History.begin() + i);
+ break;
+ }
+ History.push_back(Strdup(command_line));
+
+ // Process command
+ if (Stricmp(command_line, "CLEAR") == 0)
+ {
+ ClearLog();
+ }
+ else if (Stricmp(command_line, "HELP") == 0)
+ {
+ AddLog("Commands:");
+ for (int i = 0; i < Commands.Size; i++)
+ AddLog("- %s", Commands[i]);
+ }
+ else if (Stricmp(command_line, "HISTORY") == 0)
+ {
+ int first = History.Size - 10;
+ for (int i = first > 0 ? first : 0; i < History.Size; i++)
+ AddLog("%3d: %s\n", i, History[i]);
+ }
+ else
+ {
+ AddLog("Unknown command: '%s'\n", command_line);
+ }
+ }
+
+ static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) // In C++11 you are better off using lambdas for this sort of forwarding callbacks
+ {
+ ExampleAppConsole* console = (ExampleAppConsole*)data->UserData;
+ return console->TextEditCallback(data);
+ }
+
+ int TextEditCallback(ImGuiInputTextCallbackData* data)
+ {
+ //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd);
+ switch (data->EventFlag)
+ {
+ case ImGuiInputTextFlags_CallbackCompletion:
+ {
+ // Example of TEXT COMPLETION
+
+ // Locate beginning of current word
+ const char* word_end = data->Buf + data->CursorPos;
+ const char* word_start = word_end;
+ while (word_start > data->Buf)
+ {
+ const char c = word_start[-1];
+ if (c == ' ' || c == '\t' || c == ',' || c == ';')
+ break;
+ word_start--;
+ }
+
+ // Build a list of candidates
+ ImVector<const char*> candidates;
+ for (int i = 0; i < Commands.Size; i++)
+ if (Strnicmp(Commands[i], word_start, (int)(word_end-word_start)) == 0)
+ candidates.push_back(Commands[i]);
+
+ if (candidates.Size == 0)
+ {
+ // No match
+ AddLog("No match for \"%.*s\"!\n", (int)(word_end-word_start), word_start);
+ }
+ else if (candidates.Size == 1)
+ {
+ // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing
+ data->DeleteChars((int)(word_start-data->Buf), (int)(word_end-word_start));
+ data->InsertChars(data->CursorPos, candidates[0]);
+ data->InsertChars(data->CursorPos, " ");
+ }
+ else
+ {
+ // Multiple matches. Complete as much as we can, so inputing "C" will complete to "CL" and display "CLEAR" and "CLASSIFY"
+ int match_len = (int)(word_end - word_start);
+ for (;;)
+ {
+ int c = 0;
+ bool all_candidates_matches = true;
+ for (int i = 0; i < candidates.Size && all_candidates_matches; i++)
+ if (i == 0)
+ c = toupper(candidates[i][match_len]);
+ else if (c == 0 || c != toupper(candidates[i][match_len]))
+ all_candidates_matches = false;
+ if (!all_candidates_matches)
+ break;
+ match_len++;
+ }
+
+ if (match_len > 0)
+ {
+ data->DeleteChars((int)(word_start - data->Buf), (int)(word_end-word_start));
+ data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
+ }
+
+ // List matches
+ AddLog("Possible matches:\n");
+ for (int i = 0; i < candidates.Size; i++)
+ AddLog("- %s\n", candidates[i]);
+ }
+
+ break;
+ }
+ case ImGuiInputTextFlags_CallbackHistory:
+ {
+ // Example of HISTORY
+ const int prev_history_pos = HistoryPos;
+ if (data->EventKey == ImGuiKey_UpArrow)
+ {
+ if (HistoryPos == -1)
+ HistoryPos = History.Size - 1;
+ else if (HistoryPos > 0)
+ HistoryPos--;
+ }
+ else if (data->EventKey == ImGuiKey_DownArrow)
+ {
+ if (HistoryPos != -1)
+ if (++HistoryPos >= History.Size)
+ HistoryPos = -1;
+ }
+
+ // A better implementation would preserve the data on the current input line along with cursor position.
+ if (prev_history_pos != HistoryPos)
+ {
+ const char* history_str = (HistoryPos >= 0) ? History[HistoryPos] : "";
+ data->DeleteChars(0, data->BufTextLen);
+ data->InsertChars(0, history_str);
+ }
+ }
+ }
+ return 0;
+ }
+};
+
+static void ShowExampleAppConsole(bool* p_open)
+{
+ static ExampleAppConsole console;
+ console.Draw("Example: Console", p_open);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Debug Log / ShowExampleAppLog()
+//-----------------------------------------------------------------------------
+
+// Usage:
+// static ExampleAppLog my_log;
+// my_log.AddLog("Hello %d world\n", 123);
+// my_log.Draw("title");
+struct ExampleAppLog
+{
+ ImGuiTextBuffer Buf;
+ ImGuiTextFilter Filter;
+ ImVector<int> LineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
+ bool ScrollToBottom;
+
+ void Clear()
+ {
+ Buf.clear();
+ LineOffsets.clear();
+ LineOffsets.push_back(0);
+ }
+
+ void AddLog(const char* fmt, ...) IM_FMTARGS(2)
+ {
+ int old_size = Buf.size();
+ va_list args;
+ va_start(args, fmt);
+ Buf.appendfv(fmt, args);
+ va_end(args);
+ for (int new_size = Buf.size(); old_size < new_size; old_size++)
+ if (Buf[old_size] == '\n')
+ LineOffsets.push_back(old_size + 1);
+ ScrollToBottom = true;
+ }
+
+ void Draw(const char* title, bool* p_open = NULL)
+ {
+ if (!ImGui::Begin(title, p_open))
+ {
+ ImGui::End();
+ return;
+ }
+ if (ImGui::Button("Clear")) Clear();
+ ImGui::SameLine();
+ bool copy = ImGui::Button("Copy");
+ ImGui::SameLine();
+ Filter.Draw("Filter", -100.0f);
+ ImGui::Separator();
+ ImGui::BeginChild("scrolling", ImVec2(0,0), false, ImGuiWindowFlags_HorizontalScrollbar);
+ if (copy)
+ ImGui::LogToClipboard();
+
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
+ const char* buf = Buf.begin();
+ const char* buf_end = Buf.end();
+ if (Filter.IsActive())
+ {
+ for (int line_no = 0; line_no < LineOffsets.Size; line_no++)
+ {
+ const char* line_start = buf + LineOffsets[line_no];
+ const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end;
+ if (Filter.PassFilter(line_start, line_end))
+ ImGui::TextUnformatted(line_start, line_end);
+ }
+ }
+ else
+ {
+ // The simplest and easy way to display the entire buffer:
+ // ImGui::TextUnformatted(buf_begin, buf_end);
+ // And it'll just work. TextUnformatted() has specialization for large blob of text and will fast-forward to skip non-visible lines.
+ // Here we instead demonstrate using the clipper to only process lines that are within the visible area.
+ // If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them on your side is recommended.
+ // Using ImGuiListClipper requires A) random access into your data, and B) items all being the same height,
+ // both of which we can handle since we an array pointing to the beginning of each line of text.
+ // When using the filter (in the block of code above) we don't have random access into the data to display anymore, which is why we don't use the clipper.
+ // Storing or skimming through the search result would make it possible (and would be recommended if you want to search through tens of thousands of entries)
+ ImGuiListClipper clipper;
+ clipper.Begin(LineOffsets.Size);
+ while (clipper.Step())
+ {
+ for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++)
+ {
+ const char* line_start = buf + LineOffsets[line_no];
+ const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end;
+ ImGui::TextUnformatted(line_start, line_end);
+ }
+ }
+ clipper.End();
+ }
+ ImGui::PopStyleVar();
+
+ if (ScrollToBottom)
+ ImGui::SetScrollHereY(1.0f);
+ ScrollToBottom = false;
+ ImGui::EndChild();
+ ImGui::End();
+ }
+};
+
+// Demonstrate creating a simple log window with basic filtering.
+static void ShowExampleAppLog(bool* p_open)
+{
+ static ExampleAppLog log;
+
+ // For the demo: add a debug button before the normal log window contents
+ // We take advantage of the fact that multiple calls to Begin()/End() are appending to the same window.
+ ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
+ ImGui::Begin("Example: Log", p_open);
+ if (ImGui::SmallButton("Add 5 entries"))
+ {
+ static int counter = 0;
+ for (int n = 0; n < 5; n++)
+ {
+ const char* categories[3] = { "info", "warn", "error" };
+ const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" };
+ log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n",
+ ImGui::GetFrameCount(), categories[counter % IM_ARRAYSIZE(categories)], ImGui::GetTime(), words[counter % IM_ARRAYSIZE(words)]);
+ counter++;
+ }
+ }
+ ImGui::End();
+
+ log.Draw("Example: Log", p_open);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
+//-----------------------------------------------------------------------------
+
+// Demonstrate create a window with multiple child windows.
+static void ShowExampleAppLayout(bool* p_open)
+{
+ ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
+ {
+ if (ImGui::BeginMenuBar())
+ {
+ if (ImGui::BeginMenu("File"))
+ {
+ if (ImGui::MenuItem("Close")) *p_open = false;
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenuBar();
+ }
+
+ // left
+ static int selected = 0;
+ ImGui::BeginChild("left pane", ImVec2(150, 0), true);
+ for (int i = 0; i < 100; i++)
+ {
+ char label[128];
+ sprintf(label, "MyObject %d", i);
+ if (ImGui::Selectable(label, selected == i))
+ selected = i;
+ }
+ ImGui::EndChild();
+ ImGui::SameLine();
+
+ // right
+ ImGui::BeginGroup();
+ ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
+ ImGui::Text("MyObject: %d", selected);
+ ImGui::Separator();
+ if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
+ {
+ if (ImGui::BeginTabItem("Description"))
+ {
+ ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
+ ImGui::EndTabItem();
+ }
+ if (ImGui::BeginTabItem("Details"))
+ {
+ ImGui::Text("ID: 0123456789");
+ ImGui::EndTabItem();
+ }
+ ImGui::EndTabBar();
+ }
+ ImGui::EndChild();
+ if (ImGui::Button("Revert")) {}
+ ImGui::SameLine();
+ if (ImGui::Button("Save")) {}
+ ImGui::EndGroup();
+ }
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
+//-----------------------------------------------------------------------------
+
+// Demonstrate create a simple property editor.
+static void ShowExampleAppPropertyEditor(bool* p_open)
+{
+ ImGui::SetNextWindowSize(ImVec2(430,450), ImGuiCond_FirstUseEver);
+ if (!ImGui::Begin("Example: Property editor", p_open))
+ {
+ ImGui::End();
+ return;
+ }
+
+ ShowHelpMarker("This example shows how you may implement a property editor using two columns.\nAll objects/fields data are dummies here.\nRemember that in many simple cases, you can use ImGui::SameLine(xxx) to position\nyour cursor horizontally instead of using the Columns() API.");
+
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2,2));
+ ImGui::Columns(2);
+ ImGui::Separator();
+
+ struct funcs
+ {
+ static void ShowDummyObject(const char* prefix, int uid)
+ {
+ ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
+ ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
+ bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
+ ImGui::NextColumn();
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("my sailor is rich");
+ ImGui::NextColumn();
+ if (node_open)
+ {
+ static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
+ for (int i = 0; i < 8; i++)
+ {
+ ImGui::PushID(i); // Use field index as identifier.
+ if (i < 2)
+ {
+ ShowDummyObject("Child", 424242);
+ }
+ else
+ {
+ // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well)
+ ImGui::AlignTextToFramePadding();
+ ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
+ ImGui::NextColumn();
+ ImGui::PushItemWidth(-1);
+ if (i >= 5)
+ ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
+ else
+ ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
+ ImGui::PopItemWidth();
+ ImGui::NextColumn();
+ }
+ ImGui::PopID();
+ }
+ ImGui::TreePop();
+ }
+ ImGui::PopID();
+ }
+ };
+
+ // Iterate dummy objects with dummy members (all the same data)
+ for (int obj_i = 0; obj_i < 3; obj_i++)
+ funcs::ShowDummyObject("Object", obj_i);
+
+ ImGui::Columns(1);
+ ImGui::Separator();
+ ImGui::PopStyleVar();
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Long Text / ShowExampleAppLongText()
+//-----------------------------------------------------------------------------
+
+// Demonstrate/test rendering huge amount of text, and the incidence of clipping.
+static void ShowExampleAppLongText(bool* p_open)
+{
+ ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver);
+ if (!ImGui::Begin("Example: Long text display", p_open))
+ {
+ ImGui::End();
+ return;
+ }
+
+ static int test_type = 0;
+ static ImGuiTextBuffer log;
+ static int lines = 0;
+ ImGui::Text("Printing unusually long amount of text.");
+ ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped (slow)\0");
+ ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
+ if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
+ ImGui::SameLine();
+ if (ImGui::Button("Add 1000 lines"))
+ {
+ for (int i = 0; i < 1000; i++)
+ log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines+i);
+ lines += 1000;
+ }
+ ImGui::BeginChild("Log");
+ switch (test_type)
+ {
+ case 0:
+ // Single call to TextUnformatted() with a big buffer
+ ImGui::TextUnformatted(log.begin(), log.end());
+ break;
+ case 1:
+ {
+ // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
+ ImGuiListClipper clipper(lines);
+ while (clipper.Step())
+ for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
+ ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
+ ImGui::PopStyleVar();
+ break;
+ }
+ case 2:
+ // Multiple calls to Text(), not clipped (slow)
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
+ for (int i = 0; i < lines; i++)
+ ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
+ ImGui::PopStyleVar();
+ break;
+ }
+ ImGui::EndChild();
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
+//-----------------------------------------------------------------------------
+
+// Demonstrate creating a window which gets auto-resized according to its content.
+static void ShowExampleAppAutoResize(bool* p_open)
+{
+ if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
+ {
+ ImGui::End();
+ return;
+ }
+
+ static int lines = 10;
+ ImGui::Text("Window will resize every-frame to the size of its content.\nNote that you probably don't want to query the window size to\noutput your content because that would create a feedback loop.");
+ ImGui::SliderInt("Number of lines", &lines, 1, 20);
+ for (int i = 0; i < lines; i++)
+ ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize()
+//-----------------------------------------------------------------------------
+
+// Demonstrate creating a window with custom resize constraints.
+static void ShowExampleAppConstrainedResize(bool* p_open)
+{
+ struct CustomConstraints // Helper functions to demonstrate programmatic constraints
+ {
+ static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize = ImVec2(IM_MAX(data->DesiredSize.x, data->DesiredSize.y), IM_MAX(data->DesiredSize.x, data->DesiredSize.y)); }
+ static void Step(ImGuiSizeCallbackData* data) { float step = (float)(int)(intptr_t)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); }
+ };
+
+ static bool auto_resize = false;
+ static int type = 0;
+ static int display_lines = 10;
+ if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
+ if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
+ if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
+ if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500
+ if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500
+ if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
+ if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)100);// Fixed Step
+
+ ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0;
+ if (ImGui::Begin("Example: Constrained Resize", p_open, flags))
+ {
+ const char* desc[] =
+ {
+ "Resize vertical only",
+ "Resize horizontal only",
+ "Width > 100, Height > 100",
+ "Width 400-500",
+ "Height 400-500",
+ "Custom: Always Square",
+ "Custom: Fixed Steps (100)",
+ };
+ if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
+ if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
+ if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
+ ImGui::PushItemWidth(200);
+ ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
+ ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
+ ImGui::PopItemWidth();
+ ImGui::Checkbox("Auto-resize", &auto_resize);
+ for (int i = 0; i < display_lines; i++)
+ ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
+ }
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
+//-----------------------------------------------------------------------------
+
+// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
+static void ShowExampleAppSimpleOverlay(bool* p_open)
+{
+ const float DISTANCE = 10.0f;
+ static int corner = 0;
+ ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE);
+ ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
+ if (corner != -1)
+ ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
+ ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
+ if (ImGui::Begin("Example: Simple overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
+ {
+ ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
+ ImGui::Separator();
+ if (ImGui::IsMousePosValid())
+ ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
+ else
+ ImGui::Text("Mouse Position: <invalid>");
+ if (ImGui::BeginPopupContextWindow())
+ {
+ if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
+ if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
+ if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
+ if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
+ if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
+ if (p_open && ImGui::MenuItem("Close")) *p_open = false;
+ ImGui::EndPopup();
+ }
+ }
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
+//-----------------------------------------------------------------------------
+
+// Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
+// This apply to all regular items as well. Read FAQ section "How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs." for details.
+static void ShowExampleAppWindowTitles(bool*)
+{
+ // By default, Windows are uniquely identified by their title.
+ // You can use the "##" and "###" markers to manipulate the display/ID.
+
+ // Using "##" to display same title but have unique identifier.
+ ImGui::SetNextWindowPos(ImVec2(100, 100), ImGuiCond_FirstUseEver);
+ ImGui::Begin("Same title as another window##1");
+ ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
+ ImGui::End();
+
+ ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_FirstUseEver);
+ ImGui::Begin("Same title as another window##2");
+ ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
+ ImGui::End();
+
+ // Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
+ char buf[128];
+ sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
+ ImGui::SetNextWindowPos(ImVec2(100, 300), ImGuiCond_FirstUseEver);
+ ImGui::Begin(buf);
+ ImGui::Text("This window has a changing title.");
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
+//-----------------------------------------------------------------------------
+
+// Demonstrate using the low-level ImDrawList to draw custom shapes.
+static void ShowExampleAppCustomRendering(bool* p_open)
+{
+ ImGui::SetNextWindowSize(ImVec2(350, 560), ImGuiCond_FirstUseEver);
+ if (!ImGui::Begin("Example: Custom rendering", p_open))
+ {
+ ImGui::End();
+ return;
+ }
+
+ // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of overloaded operators, etc.
+ // Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your types and ImVec2/ImVec4.
+ // ImGui defines overloaded operators but they are internal to imgui.cpp and not exposed outside (to avoid messing with your types)
+ // In this example we are not using the maths operators!
+ ImDrawList* draw_list = ImGui::GetWindowDrawList();
+
+ // Primitives
+ ImGui::Text("Primitives");
+ static float sz = 36.0f;
+ static float thickness = 4.0f;
+ static ImVec4 col = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
+ ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
+ ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
+ ImGui::ColorEdit3("Color", &col.x);
+ {
+ const ImVec2 p = ImGui::GetCursorScreenPos();
+ const ImU32 col32 = ImColor(col);
+ float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
+ for (int n = 0; n < 2; n++)
+ {
+ float curr_thickness = (n == 0) ? 1.0f : thickness;
+ draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, curr_thickness); x += sz+spacing;
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, curr_thickness); x += sz+spacing;
+ draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, curr_thickness); x += sz+spacing;
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, curr_thickness); x += sz+spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, curr_thickness); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, curr_thickness); x += sz+spacing; // Diagonal line
+ draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, curr_thickness);
+ x = p.x + 4;
+ y += sz+spacing;
+ }
+ draw_list->AddCircleFilled(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight); x += sz+spacing;
+ draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+thickness), col32); x += sz+spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+thickness, y+sz), col32); x += spacing+spacing; // Vertical line (faster than AddLine, but only handle integer thickness)
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+1, y+1), col32); x += sz; // Pixel (faster than AddLine)
+ draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), IM_COL32(0,0,0,255), IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255));
+ ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
+ }
+ ImGui::Separator();
+ {
+ static ImVector<ImVec2> points;
+ static bool adding_line = false;
+ ImGui::Text("Canvas example");
+ if (ImGui::Button("Clear")) points.clear();
+ if (points.Size >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } }
+ ImGui::Text("Left-click and drag to add lines,\nRight-click to undo");
+
+ // Here we are using InvisibleButton() as a convenience to 1) advance the cursor and 2) allows us to use IsItemHovered()
+ // But you can also draw directly and poll mouse/keyboard by yourself. You can manipulate the cursor using GetCursorPos() and SetCursorPos().
+ // If you only use the ImDrawList API, you can notify the owner window of its extends by using SetCursorPos(max).
+ ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
+ ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
+ if (canvas_size.x < 50.0f) canvas_size.x = 50.0f;
+ if (canvas_size.y < 50.0f) canvas_size.y = 50.0f;
+ draw_list->AddRectFilledMultiColor(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), IM_COL32(50, 50, 50, 255), IM_COL32(50, 50, 60, 255), IM_COL32(60, 60, 70, 255), IM_COL32(50, 50, 60, 255));
+ draw_list->AddRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), IM_COL32(255, 255, 255, 255));
+
+ bool adding_preview = false;
+ ImGui::InvisibleButton("canvas", canvas_size);
+ ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y);
+ if (adding_line)
+ {
+ adding_preview = true;
+ points.push_back(mouse_pos_in_canvas);
+ if (!ImGui::IsMouseDown(0))
+ adding_line = adding_preview = false;
+ }
+ if (ImGui::IsItemHovered())
+ {
+ if (!adding_line && ImGui::IsMouseClicked(0))
+ {
+ points.push_back(mouse_pos_in_canvas);
+ adding_line = true;
+ }
+ if (ImGui::IsMouseClicked(1) && !points.empty())
+ {
+ adding_line = adding_preview = false;
+ points.pop_back();
+ points.pop_back();
+ }
+ }
+ draw_list->PushClipRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), true); // clip lines within the canvas (if we resize it, etc.)
+ for (int i = 0; i < points.Size - 1; i += 2)
+ draw_list->AddLine(ImVec2(canvas_pos.x + points[i].x, canvas_pos.y + points[i].y), ImVec2(canvas_pos.x + points[i + 1].x, canvas_pos.y + points[i + 1].y), IM_COL32(255, 255, 0, 255), 2.0f);
+ draw_list->PopClipRect();
+ if (adding_preview)
+ points.pop_back();
+ }
+ ImGui::End();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
+//-----------------------------------------------------------------------------
+
+// Simplified structure to mimic a Document model
+struct MyDocument
+{
+ const char* Name; // Document title
+ bool Open; // Set when the document is open (in this demo, we keep an array of all available documents to simplify the demo)
+ bool OpenPrev; // Copy of Open from last update.
+ bool Dirty; // Set when the document has been modified
+ bool WantClose; // Set when the document
+ ImVec4 Color; // An arbitrary variable associated to the document
+
+ MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f,1.0f,1.0f,1.0f))
+ {
+ Name = name;
+ Open = OpenPrev = open;
+ Dirty = false;
+ WantClose = false;
+ Color = color;
+ }
+ void DoOpen() { Open = true; }
+ void DoQueueClose() { WantClose = true; }
+ void DoForceClose() { Open = false; Dirty = false; }
+ void DoSave() { Dirty = false; }
+
+ // Display dummy contents for the Document
+ static void DisplayContents(MyDocument* doc)
+ {
+ ImGui::PushID(doc);
+ ImGui::Text("Document \"%s\"", doc->Name);
+ ImGui::PushStyleColor(ImGuiCol_Text, doc->Color);
+ ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
+ ImGui::PopStyleColor();
+ if (ImGui::Button("Modify", ImVec2(100, 0)))
+ doc->Dirty = true;
+ ImGui::SameLine();
+ if (ImGui::Button("Save", ImVec2(100, 0)))
+ doc->DoSave();
+ ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior.
+ ImGui::PopID();
+ }
+
+ // Display context menu for the Document
+ static void DisplayContextMenu(MyDocument* doc)
+ {
+ if (!ImGui::BeginPopupContextItem())
+ return;
+
+ char buf[256];
+ sprintf(buf, "Save %s", doc->Name);
+ if (ImGui::MenuItem(buf, "CTRL+S", false, doc->Open))
+ doc->DoSave();
+ if (ImGui::MenuItem("Close", "CTRL+W", false, doc->Open))
+ doc->DoQueueClose();
+ ImGui::EndPopup();
+ }
+};
+
+struct ExampleAppDocuments
+{
+ ImVector<MyDocument> Documents;
+
+ ExampleAppDocuments()
+ {
+ Documents.push_back(MyDocument("Lettuce", true, ImVec4(0.4f, 0.8f, 0.4f, 1.0f)));
+ Documents.push_back(MyDocument("Eggplant", true, ImVec4(0.8f, 0.5f, 1.0f, 1.0f)));
+ Documents.push_back(MyDocument("Carrot", true, ImVec4(1.0f, 0.8f, 0.5f, 1.0f)));
+ Documents.push_back(MyDocument("Tomato", false, ImVec4(1.0f, 0.3f, 0.4f, 1.0f)));
+ Documents.push_back(MyDocument("A Rather Long Title", false));
+ Documents.push_back(MyDocument("Some Document", false));
+ }
+};
+
+// [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface.
+// If a tab has been closed programmatically (aka closed from another source such as the Checkbox() in the demo, as opposed
+// to clicking on the regular tab closing button) and stops being submitted, it will take a frame for the tab bar to notice its absence.
+// During this frame there will be a gap in the tab bar, and if the tab that has disappeared was the selected one, the tab bar
+// will report no selected tab during the frame. This will effectively give the impression of a flicker for one frame.
+// We call SetTabItemClosed() to manually notify the Tab Bar or Docking system of removed tabs to avoid this glitch.
+// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag.
+static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments& app)
+{
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ {
+ MyDocument* doc = &app.Documents[doc_n];
+ if (!doc->Open && doc->OpenPrev)
+ ImGui::SetTabItemClosed(doc->Name);
+ doc->OpenPrev = doc->Open;
+ }
+}
+
+void ShowExampleAppDocuments(bool* p_open)
+{
+ static ExampleAppDocuments app;
+
+ if (!ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar))
+ {
+ ImGui::End();
+ return;
+ }
+
+ // Options
+ static bool opt_reorderable = true;
+ static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
+
+ // Menu
+ if (ImGui::BeginMenuBar())
+ {
+ if (ImGui::BeginMenu("File"))
+ {
+ int open_count = 0;
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ open_count += app.Documents[doc_n].Open ? 1 : 0;
+
+ if (ImGui::BeginMenu("Open", open_count < app.Documents.Size))
+ {
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ {
+ MyDocument* doc = &app.Documents[doc_n];
+ if (!doc->Open)
+ if (ImGui::MenuItem(doc->Name))
+ doc->DoOpen();
+ }
+ ImGui::EndMenu();
+ }
+ if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ app.Documents[doc_n].DoQueueClose();
+ if (ImGui::MenuItem("Exit", "Alt+F4")) {}
+ ImGui::EndMenu();
+ }
+ ImGui::EndMenuBar();
+ }
+
+ // [Debug] List documents with one checkbox for each
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ {
+ MyDocument* doc = &app.Documents[doc_n];
+ if (doc_n > 0)
+ ImGui::SameLine();
+ ImGui::PushID(doc);
+ if (ImGui::Checkbox(doc->Name, &doc->Open))
+ if (!doc->Open)
+ doc->DoForceClose();
+ ImGui::PopID();
+ }
+
+ ImGui::Separator();
+
+ // Submit Tab Bar and Tabs
+ {
+ ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
+ if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
+ {
+ if (opt_reorderable)
+ NotifyOfDocumentsClosedElsewhere(app);
+
+ // [DEBUG] Stress tests
+ //if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
+ //if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
+
+ // Submit Tabs
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ {
+ MyDocument* doc = &app.Documents[doc_n];
+ if (!doc->Open)
+ continue;
+
+ ImGuiTabItemFlags tab_flags = (doc->Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0);
+ bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags);
+
+ // Cancel attempt to close when unsaved add to save queue so we can display a popup.
+ if (!doc->Open && doc->Dirty)
+ {
+ doc->Open = true;
+ doc->DoQueueClose();
+ }
+
+ MyDocument::DisplayContextMenu(doc);
+ if (visible)
+ {
+ MyDocument::DisplayContents(doc);
+ ImGui::EndTabItem();
+ }
+ }
+
+ ImGui::EndTabBar();
+ }
+ }
+
+ // Update closing queue
+ static ImVector<MyDocument*> close_queue;
+ if (close_queue.empty())
+ {
+ // Close queue is locked once we started a popup
+ for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
+ {
+ MyDocument* doc = &app.Documents[doc_n];
+ if (doc->WantClose)
+ {
+ doc->WantClose = false;
+ close_queue.push_back(doc);
+ }
+ }
+ }
+
+ // Display closing confirmation UI
+ if (!close_queue.empty())
+ {
+ int close_queue_unsaved_documents = 0;
+ for (int n = 0; n < close_queue.Size; n++)
+ if (close_queue[n]->Dirty)
+ close_queue_unsaved_documents++;
+
+ if (close_queue_unsaved_documents == 0)
+ {
+ // Close documents when all are unsaved
+ for (int n = 0; n < close_queue.Size; n++)
+ close_queue[n]->DoForceClose();
+ close_queue.clear();
+ }
+ else
+ {
+ if (!ImGui::IsPopupOpen("Save?"))
+ ImGui::OpenPopup("Save?");
+ if (ImGui::BeginPopupModal("Save?"))
+ {
+ ImGui::Text("Save change to the following items?");
+ ImGui::PushItemWidth(-1.0f);
+ ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6);
+ for (int n = 0; n < close_queue.Size; n++)
+ if (close_queue[n]->Dirty)
+ ImGui::Text("%s", close_queue[n]->Name);
+ ImGui::ListBoxFooter();
+
+ if (ImGui::Button("Yes", ImVec2(80, 0)))
+ {
+ for (int n = 0; n < close_queue.Size; n++)
+ {
+ if (close_queue[n]->Dirty)
+ close_queue[n]->DoSave();
+ close_queue[n]->DoForceClose();
+ }
+ close_queue.clear();
+ ImGui::CloseCurrentPopup();
+ }
+ ImGui::SameLine();
+ if (ImGui::Button("No", ImVec2(80, 0)))
+ {
+ for (int n = 0; n < close_queue.Size; n++)
+ close_queue[n]->DoForceClose();
+ close_queue.clear();
+ ImGui::CloseCurrentPopup();
+ }
+ ImGui::SameLine();
+ if (ImGui::Button("Cancel", ImVec2(80, 0)))
+ {
+ close_queue.clear();
+ ImGui::CloseCurrentPopup();
+ }
+ ImGui::EndPopup();
+ }
+ }
+ }
+
+ ImGui::End();
+}
+
+// End of Demo code
+#else
+
+void ImGui::ShowAboutWindow(bool*) {}
+void ImGui::ShowDemoWindow(bool*) {}
+void ImGui::ShowUserGuide() {}
+void ImGui::ShowStyleEditor(ImGuiStyle*) {}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imgui_draw.cpp b/Client/ThirdParty/Box2D/extern/imgui/imgui_draw.cpp
new file mode 100644
index 0000000..9833590
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imgui_draw.cpp
@@ -0,0 +1,3199 @@
+// dear imgui, v1.67 WIP
+// (drawing and font code)
+
+/*
+
+Index of this file:
+
+// [SECTION] STB libraries implementation
+// [SECTION] Style functions
+// [SECTION] ImDrawList
+// [SECTION] ImDrawData
+// [SECTION] Helpers ShadeVertsXXX functions
+// [SECTION] ImFontConfig
+// [SECTION] ImFontAtlas
+// [SECTION] ImFontAtlas glyph ranges helpers
+// [SECTION] ImFontGlyphRangesBuilder
+// [SECTION] ImFont
+// [SECTION] Internal Render Helpers
+// [SECTION] Decompression code
+// [SECTION] Default font data (ProggyClean.ttf)
+
+*/
+
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "imgui.h"
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
+#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
+#include "imgui_internal.h"
+
+#include <stdio.h> // vsnprintf, sscanf, printf
+#if !defined(alloca)
+#if defined(__GLIBC__) || defined(__sun) || defined(__CYGWIN__) || defined(__APPLE__)
+#include <alloca.h> // alloca (glibc uses <alloca.h>. Note that Cygwin may have _WIN32 defined, so the order matters here)
+#elif defined(_WIN32)
+#include <malloc.h> // alloca
+#if !defined(alloca)
+#define alloca _alloca // for clang with MS Codegen
+#endif
+#else
+#include <stdlib.h> // alloca
+#endif
+#endif
+
+// Visual Studio warnings
+#ifdef _MSC_VER
+#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#endif
+
+// Clang/GCC warnings with -Weverything
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
+#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
+#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it.
+#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
+#if __has_warning("-Wcomma")
+#pragma clang diagnostic ignored "-Wcomma" // warning : possible misuse of comma operator here //
+#endif
+#if __has_warning("-Wreserved-id-macro")
+#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
+#endif
+#if __has_warning("-Wdouble-promotion")
+#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#endif
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
+#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
+#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
+#if __GNUC__ >= 8
+#pragma GCC diagnostic ignored "-Wclass-memaccess" // warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
+#endif
+#endif
+
+//-------------------------------------------------------------------------
+// [SECTION] STB libraries implementation
+//-------------------------------------------------------------------------
+
+// Compile time options:
+//#define IMGUI_STB_NAMESPACE ImGuiStb
+//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
+//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
+//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
+//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
+
+#ifdef IMGUI_STB_NAMESPACE
+namespace IMGUI_STB_NAMESPACE
+{
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (push)
+#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#pragma clang diagnostic ignored "-Wmissing-prototypes"
+#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
+#pragma clang diagnostic ignored "-Wcast-qual" // warning : cast from 'const xxxx *' to 'xxx *' drops const qualifier //
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits]
+#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers
+#endif
+
+#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
+#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
+#define STBRP_STATIC
+#define STBRP_ASSERT(x) IM_ASSERT(x)
+#define STBRP_SORT ImQsort
+#define STB_RECT_PACK_IMPLEMENTATION
+#endif
+#ifdef IMGUI_STB_RECT_PACK_FILENAME
+#include IMGUI_STB_RECT_PACK_FILENAME
+#else
+#include "imstb_rectpack.h"
+#endif
+#endif
+
+#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
+#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
+#define STBTT_malloc(x,u) ((void)(u), ImGui::MemAlloc(x))
+#define STBTT_free(x,u) ((void)(u), ImGui::MemFree(x))
+#define STBTT_assert(x) IM_ASSERT(x)
+#define STBTT_fmod(x,y) ImFmod(x,y)
+#define STBTT_sqrt(x) ImSqrt(x)
+#define STBTT_pow(x,y) ImPow(x,y)
+#define STBTT_fabs(x) ImFabs(x)
+#define STBTT_ifloor(x) ((int)ImFloorStd(x))
+#define STBTT_iceil(x) ((int)ImCeil(x))
+#define STBTT_STATIC
+#define STB_TRUETYPE_IMPLEMENTATION
+#else
+#define STBTT_DEF extern
+#endif
+#ifdef IMGUI_STB_TRUETYPE_FILENAME
+#include IMGUI_STB_TRUETYPE_FILENAME
+#else
+#include "imstb_truetype.h"
+#endif
+#endif
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (pop)
+#endif
+
+#ifdef IMGUI_STB_NAMESPACE
+} // namespace ImGuiStb
+using namespace IMGUI_STB_NAMESPACE;
+#endif
+
+//-----------------------------------------------------------------------------
+// [SECTION] Style functions
+//-----------------------------------------------------------------------------
+
+void ImGui::StyleColorsDark(ImGuiStyle* dst)
+{
+ ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
+ ImVec4* colors = style->Colors;
+
+ colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
+ colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
+ colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
+ colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
+ colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
+ colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f);
+ colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
+ colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
+ colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
+ colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f);
+ colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
+ colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
+ colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
+ colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f);
+ colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
+ colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f);
+ colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f);
+ colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
+ colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
+ colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
+ colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
+ colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_Separator] = colors[ImGuiCol_Border];
+ colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
+ colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
+ colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f);
+ colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
+ colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
+ colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
+ colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
+ colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
+ colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
+ colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
+ colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
+ colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
+ colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
+ colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
+ colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
+ colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
+ colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
+ colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
+ colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
+}
+
+void ImGui::StyleColorsClassic(ImGuiStyle* dst)
+{
+ ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
+ ImVec4* colors = style->Colors;
+
+ colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
+ colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
+ colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.70f);
+ colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f);
+ colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f);
+ colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f);
+ colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f);
+ colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.41f, 0.64f, 0.69f);
+ colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f);
+ colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f);
+ colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
+ colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
+ colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
+ colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
+ colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f);
+ colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f);
+ colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
+ colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
+ colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f);
+ colors[ImGuiCol_Button] = ImVec4(0.35f, 0.40f, 0.61f, 0.62f);
+ colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.48f, 0.71f, 0.79f);
+ colors[ImGuiCol_ButtonActive] = ImVec4(0.46f, 0.54f, 0.80f, 1.00f);
+ colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
+ colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
+ colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
+ colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
+ colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
+ colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
+ colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.16f);
+ colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f);
+ colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f);
+ colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
+ colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
+ colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
+ colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
+ colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
+ colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
+ colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
+ colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
+ colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
+ colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
+ colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
+ colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered];
+ colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
+ colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
+ colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
+}
+
+// Those light colors are better suited with a thicker font than the default one + FrameBorder
+void ImGui::StyleColorsLight(ImGuiStyle* dst)
+{
+ ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
+ ImVec4* colors = style->Colors;
+
+ colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
+ colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
+ colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f);
+ colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f);
+ colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f);
+ colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
+ colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
+ colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
+ colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
+ colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f);
+ colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f);
+ colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f);
+ colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f);
+ colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f);
+ colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f);
+ colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f);
+ colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f);
+ colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f);
+ colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f);
+ colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
+ colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
+ colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
+ colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
+ colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
+ colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
+ colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f);
+ colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f);
+ colors[ImGuiCol_ResizeGrip] = ImVec4(0.80f, 0.80f, 0.80f, 0.56f);
+ colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
+ colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
+ colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f);
+ colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
+ colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
+ colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
+ colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
+ colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
+ colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
+ colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
+ colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.45f, 0.00f, 1.00f);
+ colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
+ colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
+ colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered];
+ colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f);
+ colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f);
+ colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
+}
+
+//-----------------------------------------------------------------------------
+// ImDrawList
+//-----------------------------------------------------------------------------
+
+ImDrawListSharedData::ImDrawListSharedData()
+{
+ Font = NULL;
+ FontSize = 0.0f;
+ CurveTessellationTol = 0.0f;
+ ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f);
+
+ // Const data
+ for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++)
+ {
+ const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(CircleVtx12);
+ CircleVtx12[i] = ImVec2(ImCos(a), ImSin(a));
+ }
+}
+
+void ImDrawList::Clear()
+{
+ CmdBuffer.resize(0);
+ IdxBuffer.resize(0);
+ VtxBuffer.resize(0);
+ Flags = ImDrawListFlags_AntiAliasedLines | ImDrawListFlags_AntiAliasedFill;
+ _VtxCurrentIdx = 0;
+ _VtxWritePtr = NULL;
+ _IdxWritePtr = NULL;
+ _ClipRectStack.resize(0);
+ _TextureIdStack.resize(0);
+ _Path.resize(0);
+ _ChannelsCurrent = 0;
+ _ChannelsCount = 1;
+ // NB: Do not clear channels so our allocations are re-used after the first frame.
+}
+
+void ImDrawList::ClearFreeMemory()
+{
+ CmdBuffer.clear();
+ IdxBuffer.clear();
+ VtxBuffer.clear();
+ _VtxCurrentIdx = 0;
+ _VtxWritePtr = NULL;
+ _IdxWritePtr = NULL;
+ _ClipRectStack.clear();
+ _TextureIdStack.clear();
+ _Path.clear();
+ _ChannelsCurrent = 0;
+ _ChannelsCount = 1;
+ for (int i = 0; i < _Channels.Size; i++)
+ {
+ if (i == 0) memset(&_Channels[0], 0, sizeof(_Channels[0])); // channel 0 is a copy of CmdBuffer/IdxBuffer, don't destruct again
+ _Channels[i].CmdBuffer.clear();
+ _Channels[i].IdxBuffer.clear();
+ }
+ _Channels.clear();
+}
+
+ImDrawList* ImDrawList::CloneOutput() const
+{
+ ImDrawList* dst = IM_NEW(ImDrawList(NULL));
+ dst->CmdBuffer = CmdBuffer;
+ dst->IdxBuffer = IdxBuffer;
+ dst->VtxBuffer = VtxBuffer;
+ dst->Flags = Flags;
+ return dst;
+}
+
+// Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds
+#define GetCurrentClipRect() (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1] : _Data->ClipRectFullscreen)
+#define GetCurrentTextureId() (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : NULL)
+
+void ImDrawList::AddDrawCmd()
+{
+ ImDrawCmd draw_cmd;
+ draw_cmd.ClipRect = GetCurrentClipRect();
+ draw_cmd.TextureId = GetCurrentTextureId();
+
+ IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
+ CmdBuffer.push_back(draw_cmd);
+}
+
+void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
+{
+ ImDrawCmd* current_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL;
+ if (!current_cmd || current_cmd->ElemCount != 0 || current_cmd->UserCallback != NULL)
+ {
+ AddDrawCmd();
+ current_cmd = &CmdBuffer.back();
+ }
+ current_cmd->UserCallback = callback;
+ current_cmd->UserCallbackData = callback_data;
+
+ AddDrawCmd(); // Force a new command after us (see comment below)
+}
+
+// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
+// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
+void ImDrawList::UpdateClipRect()
+{
+ // If current command is used with different settings we need to add a new command
+ const ImVec4 curr_clip_rect = GetCurrentClipRect();
+ ImDrawCmd* curr_cmd = CmdBuffer.Size > 0 ? &CmdBuffer.Data[CmdBuffer.Size-1] : NULL;
+ if (!curr_cmd || (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) != 0) || curr_cmd->UserCallback != NULL)
+ {
+ AddDrawCmd();
+ return;
+ }
+
+ // Try to merge with previous command if it matches, else use current command
+ ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
+ if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL)
+ CmdBuffer.pop_back();
+ else
+ curr_cmd->ClipRect = curr_clip_rect;
+}
+
+void ImDrawList::UpdateTextureID()
+{
+ // If current command is used with different settings we need to add a new command
+ const ImTextureID curr_texture_id = GetCurrentTextureId();
+ ImDrawCmd* curr_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL;
+ if (!curr_cmd || (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != curr_texture_id) || curr_cmd->UserCallback != NULL)
+ {
+ AddDrawCmd();
+ return;
+ }
+
+ // Try to merge with previous command if it matches, else use current command
+ ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
+ if (curr_cmd->ElemCount == 0 && prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL)
+ CmdBuffer.pop_back();
+ else
+ curr_cmd->TextureId = curr_texture_id;
+}
+
+#undef GetCurrentClipRect
+#undef GetCurrentTextureId
+
+// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
+void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect)
+{
+ ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y);
+ if (intersect_with_current_clip_rect && _ClipRectStack.Size)
+ {
+ ImVec4 current = _ClipRectStack.Data[_ClipRectStack.Size-1];
+ if (cr.x < current.x) cr.x = current.x;
+ if (cr.y < current.y) cr.y = current.y;
+ if (cr.z > current.z) cr.z = current.z;
+ if (cr.w > current.w) cr.w = current.w;
+ }
+ cr.z = ImMax(cr.x, cr.z);
+ cr.w = ImMax(cr.y, cr.w);
+
+ _ClipRectStack.push_back(cr);
+ UpdateClipRect();
+}
+
+void ImDrawList::PushClipRectFullScreen()
+{
+ PushClipRect(ImVec2(_Data->ClipRectFullscreen.x, _Data->ClipRectFullscreen.y), ImVec2(_Data->ClipRectFullscreen.z, _Data->ClipRectFullscreen.w));
+}
+
+void ImDrawList::PopClipRect()
+{
+ IM_ASSERT(_ClipRectStack.Size > 0);
+ _ClipRectStack.pop_back();
+ UpdateClipRect();
+}
+
+void ImDrawList::PushTextureID(ImTextureID texture_id)
+{
+ _TextureIdStack.push_back(texture_id);
+ UpdateTextureID();
+}
+
+void ImDrawList::PopTextureID()
+{
+ IM_ASSERT(_TextureIdStack.Size > 0);
+ _TextureIdStack.pop_back();
+ UpdateTextureID();
+}
+
+void ImDrawList::ChannelsSplit(int channels_count)
+{
+ IM_ASSERT(_ChannelsCurrent == 0 && _ChannelsCount == 1);
+ int old_channels_count = _Channels.Size;
+ if (old_channels_count < channels_count)
+ _Channels.resize(channels_count);
+ _ChannelsCount = channels_count;
+
+ // _Channels[] (24/32 bytes each) hold storage that we'll swap with this->_CmdBuffer/_IdxBuffer
+ // The content of _Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to.
+ // When we switch to the next channel, we'll copy _CmdBuffer/_IdxBuffer into _Channels[0] and then _Channels[1] into _CmdBuffer/_IdxBuffer
+ memset(&_Channels[0], 0, sizeof(ImDrawChannel));
+ for (int i = 1; i < channels_count; i++)
+ {
+ if (i >= old_channels_count)
+ {
+ IM_PLACEMENT_NEW(&_Channels[i]) ImDrawChannel();
+ }
+ else
+ {
+ _Channels[i].CmdBuffer.resize(0);
+ _Channels[i].IdxBuffer.resize(0);
+ }
+ if (_Channels[i].CmdBuffer.Size == 0)
+ {
+ ImDrawCmd draw_cmd;
+ draw_cmd.ClipRect = _ClipRectStack.back();
+ draw_cmd.TextureId = _TextureIdStack.back();
+ _Channels[i].CmdBuffer.push_back(draw_cmd);
+ }
+ }
+}
+
+void ImDrawList::ChannelsMerge()
+{
+ // Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
+ if (_ChannelsCount <= 1)
+ return;
+
+ ChannelsSetCurrent(0);
+ if (CmdBuffer.Size && CmdBuffer.back().ElemCount == 0)
+ CmdBuffer.pop_back();
+
+ int new_cmd_buffer_count = 0, new_idx_buffer_count = 0;
+ for (int i = 1; i < _ChannelsCount; i++)
+ {
+ ImDrawChannel& ch = _Channels[i];
+ if (ch.CmdBuffer.Size && ch.CmdBuffer.back().ElemCount == 0)
+ ch.CmdBuffer.pop_back();
+ new_cmd_buffer_count += ch.CmdBuffer.Size;
+ new_idx_buffer_count += ch.IdxBuffer.Size;
+ }
+ CmdBuffer.resize(CmdBuffer.Size + new_cmd_buffer_count);
+ IdxBuffer.resize(IdxBuffer.Size + new_idx_buffer_count);
+
+ ImDrawCmd* cmd_write = CmdBuffer.Data + CmdBuffer.Size - new_cmd_buffer_count;
+ _IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size - new_idx_buffer_count;
+ for (int i = 1; i < _ChannelsCount; i++)
+ {
+ ImDrawChannel& ch = _Channels[i];
+ if (int sz = ch.CmdBuffer.Size) { memcpy(cmd_write, ch.CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; }
+ if (int sz = ch.IdxBuffer.Size) { memcpy(_IdxWritePtr, ch.IdxBuffer.Data, sz * sizeof(ImDrawIdx)); _IdxWritePtr += sz; }
+ }
+ UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
+ _ChannelsCount = 1;
+}
+
+void ImDrawList::ChannelsSetCurrent(int idx)
+{
+ IM_ASSERT(idx < _ChannelsCount);
+ if (_ChannelsCurrent == idx) return;
+ memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 bytes, four times
+ memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer));
+ _ChannelsCurrent = idx;
+ memcpy(&CmdBuffer, &_Channels.Data[_ChannelsCurrent].CmdBuffer, sizeof(CmdBuffer));
+ memcpy(&IdxBuffer, &_Channels.Data[_ChannelsCurrent].IdxBuffer, sizeof(IdxBuffer));
+ _IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size;
+}
+
+// NB: this can be called with negative count for removing primitives (as long as the result does not underflow)
+void ImDrawList::PrimReserve(int idx_count, int vtx_count)
+{
+ ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1];
+ draw_cmd.ElemCount += idx_count;
+
+ int vtx_buffer_old_size = VtxBuffer.Size;
+ VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
+ _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size;
+
+ int idx_buffer_old_size = IdxBuffer.Size;
+ IdxBuffer.resize(idx_buffer_old_size + idx_count);
+ _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
+}
+
+// Fully unrolled with inline call to keep our debug builds decently fast.
+void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
+{
+ ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel);
+ ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
+ _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
+ _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3);
+ _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
+ _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
+ _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
+ _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
+ _VtxWritePtr += 4;
+ _VtxCurrentIdx += 4;
+ _IdxWritePtr += 6;
+}
+
+void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col)
+{
+ ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y);
+ ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
+ _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
+ _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3);
+ _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col;
+ _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col;
+ _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col;
+ _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col;
+ _VtxWritePtr += 4;
+ _VtxCurrentIdx += 4;
+ _IdxWritePtr += 6;
+}
+
+void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col)
+{
+ ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
+ _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
+ _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3);
+ _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col;
+ _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col;
+ _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col;
+ _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col;
+ _VtxWritePtr += 4;
+ _VtxCurrentIdx += 4;
+ _IdxWritePtr += 6;
+}
+
+// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds.
+// Those macros expects l-values.
+#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } }
+#define IM_NORMALIZE2F_OVER_EPSILON_CLAMP(VX,VY,EPS,INVLENMAX) { float d2 = VX*VX + VY*VY; if (d2 > EPS) { float inv_len = 1.0f / ImSqrt(d2); if (inv_len > INVLENMAX) inv_len = INVLENMAX; VX *= inv_len; VY *= inv_len; } }
+
+// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
+// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
+void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed, float thickness)
+{
+ if (points_count < 2)
+ return;
+
+ const ImVec2 uv = _Data->TexUvWhitePixel;
+
+ int count = points_count;
+ if (!closed)
+ count = points_count-1;
+
+ const bool thick_line = thickness > 1.0f;
+ if (Flags & ImDrawListFlags_AntiAliasedLines)
+ {
+ // Anti-aliased stroke
+ const float AA_SIZE = 1.0f;
+ const ImU32 col_trans = col & ~IM_COL32_A_MASK;
+
+ const int idx_count = thick_line ? count*18 : count*12;
+ const int vtx_count = thick_line ? points_count*4 : points_count*3;
+ PrimReserve(idx_count, vtx_count);
+
+ // Temporary buffer
+ ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2));
+ ImVec2* temp_points = temp_normals + points_count;
+
+ for (int i1 = 0; i1 < count; i1++)
+ {
+ const int i2 = (i1+1) == points_count ? 0 : i1+1;
+ float dx = points[i2].x - points[i1].x;
+ float dy = points[i2].y - points[i1].y;
+ IM_NORMALIZE2F_OVER_ZERO(dx, dy);
+ temp_normals[i1].x = dy;
+ temp_normals[i1].y = -dx;
+ }
+ if (!closed)
+ temp_normals[points_count-1] = temp_normals[points_count-2];
+
+ if (!thick_line)
+ {
+ if (!closed)
+ {
+ temp_points[0] = points[0] + temp_normals[0] * AA_SIZE;
+ temp_points[1] = points[0] - temp_normals[0] * AA_SIZE;
+ temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * AA_SIZE;
+ temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * AA_SIZE;
+ }
+
+ // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
+ unsigned int idx1 = _VtxCurrentIdx;
+ for (int i1 = 0; i1 < count; i1++)
+ {
+ const int i2 = (i1+1) == points_count ? 0 : i1+1;
+ unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+3;
+
+ // Average normals
+ float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
+ float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
+ IM_NORMALIZE2F_OVER_EPSILON_CLAMP(dm_x, dm_y, 0.000001f, 100.0f)
+ dm_x *= AA_SIZE;
+ dm_y *= AA_SIZE;
+
+ // Add temporary vertexes
+ ImVec2* out_vtx = &temp_points[i2*2];
+ out_vtx[0].x = points[i2].x + dm_x;
+ out_vtx[0].y = points[i2].y + dm_y;
+ out_vtx[1].x = points[i2].x - dm_x;
+ out_vtx[1].y = points[i2].y - dm_y;
+
+ // Add indexes
+ _IdxWritePtr[0] = (ImDrawIdx)(idx2+0); _IdxWritePtr[1] = (ImDrawIdx)(idx1+0); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2);
+ _IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+0);
+ _IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0);
+ _IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10]= (ImDrawIdx)(idx2+0); _IdxWritePtr[11]= (ImDrawIdx)(idx2+1);
+ _IdxWritePtr += 12;
+
+ idx1 = idx2;
+ }
+
+ // Add vertexes
+ for (int i = 0; i < points_count; i++)
+ {
+ _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
+ _VtxWritePtr[1].pos = temp_points[i*2+0]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans;
+ _VtxWritePtr[2].pos = temp_points[i*2+1]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col_trans;
+ _VtxWritePtr += 3;
+ }
+ }
+ else
+ {
+ const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
+ if (!closed)
+ {
+ temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE);
+ temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness);
+ temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness);
+ temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE);
+ temp_points[(points_count-1)*4+0] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE);
+ temp_points[(points_count-1)*4+1] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness);
+ temp_points[(points_count-1)*4+2] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness);
+ temp_points[(points_count-1)*4+3] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE);
+ }
+
+ // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
+ unsigned int idx1 = _VtxCurrentIdx;
+ for (int i1 = 0; i1 < count; i1++)
+ {
+ const int i2 = (i1+1) == points_count ? 0 : i1+1;
+ unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+4;
+
+ // Average normals
+ float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
+ float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
+ IM_NORMALIZE2F_OVER_EPSILON_CLAMP(dm_x, dm_y, 0.000001f, 100.0f);
+ float dm_out_x = dm_x * (half_inner_thickness + AA_SIZE);
+ float dm_out_y = dm_y * (half_inner_thickness + AA_SIZE);
+ float dm_in_x = dm_x * half_inner_thickness;
+ float dm_in_y = dm_y * half_inner_thickness;
+
+ // Add temporary vertexes
+ ImVec2* out_vtx = &temp_points[i2*4];
+ out_vtx[0].x = points[i2].x + dm_out_x;
+ out_vtx[0].y = points[i2].y + dm_out_y;
+ out_vtx[1].x = points[i2].x + dm_in_x;
+ out_vtx[1].y = points[i2].y + dm_in_y;
+ out_vtx[2].x = points[i2].x - dm_in_x;
+ out_vtx[2].y = points[i2].y - dm_in_y;
+ out_vtx[3].x = points[i2].x - dm_out_x;
+ out_vtx[3].y = points[i2].y - dm_out_y;
+
+ // Add indexes
+ _IdxWritePtr[0] = (ImDrawIdx)(idx2+1); _IdxWritePtr[1] = (ImDrawIdx)(idx1+1); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2);
+ _IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+1);
+ _IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0);
+ _IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10] = (ImDrawIdx)(idx2+0); _IdxWritePtr[11] = (ImDrawIdx)(idx2+1);
+ _IdxWritePtr[12] = (ImDrawIdx)(idx2+2); _IdxWritePtr[13] = (ImDrawIdx)(idx1+2); _IdxWritePtr[14] = (ImDrawIdx)(idx1+3);
+ _IdxWritePtr[15] = (ImDrawIdx)(idx1+3); _IdxWritePtr[16] = (ImDrawIdx)(idx2+3); _IdxWritePtr[17] = (ImDrawIdx)(idx2+2);
+ _IdxWritePtr += 18;
+
+ idx1 = idx2;
+ }
+
+ // Add vertexes
+ for (int i = 0; i < points_count; i++)
+ {
+ _VtxWritePtr[0].pos = temp_points[i*4+0]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col_trans;
+ _VtxWritePtr[1].pos = temp_points[i*4+1]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
+ _VtxWritePtr[2].pos = temp_points[i*4+2]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
+ _VtxWritePtr[3].pos = temp_points[i*4+3]; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col_trans;
+ _VtxWritePtr += 4;
+ }
+ }
+ _VtxCurrentIdx += (ImDrawIdx)vtx_count;
+ }
+ else
+ {
+ // Non Anti-aliased Stroke
+ const int idx_count = count*6;
+ const int vtx_count = count*4; // FIXME-OPT: Not sharing edges
+ PrimReserve(idx_count, vtx_count);
+
+ for (int i1 = 0; i1 < count; i1++)
+ {
+ const int i2 = (i1+1) == points_count ? 0 : i1+1;
+ const ImVec2& p1 = points[i1];
+ const ImVec2& p2 = points[i2];
+
+ float dx = p2.x - p1.x;
+ float dy = p2.y - p1.y;
+ IM_NORMALIZE2F_OVER_ZERO(dx, dy);
+ dx *= (thickness * 0.5f);
+ dy *= (thickness * 0.5f);
+
+ _VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
+ _VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
+ _VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
+ _VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
+ _VtxWritePtr += 4;
+
+ _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
+ _IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
+ _IdxWritePtr += 6;
+ _VtxCurrentIdx += 4;
+ }
+ }
+}
+
+// We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds.
+void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col)
+{
+ if (points_count < 3)
+ return;
+
+ const ImVec2 uv = _Data->TexUvWhitePixel;
+
+ if (Flags & ImDrawListFlags_AntiAliasedFill)
+ {
+ // Anti-aliased Fill
+ const float AA_SIZE = 1.0f;
+ const ImU32 col_trans = col & ~IM_COL32_A_MASK;
+ const int idx_count = (points_count-2)*3 + points_count*6;
+ const int vtx_count = (points_count*2);
+ PrimReserve(idx_count, vtx_count);
+
+ // Add indexes for fill
+ unsigned int vtx_inner_idx = _VtxCurrentIdx;
+ unsigned int vtx_outer_idx = _VtxCurrentIdx+1;
+ for (int i = 2; i < points_count; i++)
+ {
+ _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1));
+ _IdxWritePtr += 3;
+ }
+
+ // Compute normals
+ ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2));
+ for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
+ {
+ const ImVec2& p0 = points[i0];
+ const ImVec2& p1 = points[i1];
+ float dx = p1.x - p0.x;
+ float dy = p1.y - p0.y;
+ IM_NORMALIZE2F_OVER_ZERO(dx, dy);
+ temp_normals[i0].x = dy;
+ temp_normals[i0].y = -dx;
+ }
+
+ for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
+ {
+ // Average normals
+ const ImVec2& n0 = temp_normals[i0];
+ const ImVec2& n1 = temp_normals[i1];
+ float dm_x = (n0.x + n1.x) * 0.5f;
+ float dm_y = (n0.y + n1.y) * 0.5f;
+ IM_NORMALIZE2F_OVER_EPSILON_CLAMP(dm_x, dm_y, 0.000001f, 100.0f);
+ dm_x *= AA_SIZE * 0.5f;
+ dm_y *= AA_SIZE * 0.5f;
+
+ // Add vertices
+ _VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner
+ _VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer
+ _VtxWritePtr += 2;
+
+ // Add indexes for fringes
+ _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1));
+ _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1));
+ _IdxWritePtr += 6;
+ }
+ _VtxCurrentIdx += (ImDrawIdx)vtx_count;
+ }
+ else
+ {
+ // Non Anti-aliased Fill
+ const int idx_count = (points_count-2)*3;
+ const int vtx_count = points_count;
+ PrimReserve(idx_count, vtx_count);
+ for (int i = 0; i < vtx_count; i++)
+ {
+ _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
+ _VtxWritePtr++;
+ }
+ for (int i = 2; i < points_count; i++)
+ {
+ _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
+ _IdxWritePtr += 3;
+ }
+ _VtxCurrentIdx += (ImDrawIdx)vtx_count;
+ }
+}
+
+void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12)
+{
+ if (radius == 0.0f || a_min_of_12 > a_max_of_12)
+ {
+ _Path.push_back(centre);
+ return;
+ }
+ _Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
+ for (int a = a_min_of_12; a <= a_max_of_12; a++)
+ {
+ const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)];
+ _Path.push_back(ImVec2(centre.x + c.x * radius, centre.y + c.y * radius));
+ }
+}
+
+void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments)
+{
+ if (radius == 0.0f)
+ {
+ _Path.push_back(centre);
+ return;
+ }
+ _Path.reserve(_Path.Size + (num_segments + 1));
+ for (int i = 0; i <= num_segments; i++)
+ {
+ const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
+ _Path.push_back(ImVec2(centre.x + ImCos(a) * radius, centre.y + ImSin(a) * radius));
+ }
+}
+
+static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
+{
+ float dx = x4 - x1;
+ float dy = y4 - y1;
+ float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
+ float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
+ d2 = (d2 >= 0) ? d2 : -d2;
+ d3 = (d3 >= 0) ? d3 : -d3;
+ if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
+ {
+ path->push_back(ImVec2(x4, y4));
+ }
+ else if (level < 10)
+ {
+ float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f;
+ float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f;
+ float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f;
+ float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
+ float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
+ float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
+
+ PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
+ PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
+ }
+}
+
+void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments)
+{
+ ImVec2 p1 = _Path.back();
+ if (num_segments == 0)
+ {
+ // Auto-tessellated
+ PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0);
+ }
+ else
+ {
+ float t_step = 1.0f / (float)num_segments;
+ for (int i_step = 1; i_step <= num_segments; i_step++)
+ {
+ float t = t_step * i_step;
+ float u = 1.0f - t;
+ float w1 = u*u*u;
+ float w2 = 3*u*u*t;
+ float w3 = 3*u*t*t;
+ float w4 = t*t*t;
+ _Path.push_back(ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y));
+ }
+ }
+}
+
+void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
+{
+ rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
+ rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
+
+ if (rounding <= 0.0f || rounding_corners == 0)
+ {
+ PathLineTo(a);
+ PathLineTo(ImVec2(b.x, a.y));
+ PathLineTo(b);
+ PathLineTo(ImVec2(a.x, b.y));
+ }
+ else
+ {
+ const float rounding_tl = (rounding_corners & ImDrawCornerFlags_TopLeft) ? rounding : 0.0f;
+ const float rounding_tr = (rounding_corners & ImDrawCornerFlags_TopRight) ? rounding : 0.0f;
+ const float rounding_br = (rounding_corners & ImDrawCornerFlags_BotRight) ? rounding : 0.0f;
+ const float rounding_bl = (rounding_corners & ImDrawCornerFlags_BotLeft) ? rounding : 0.0f;
+ PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9);
+ PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12);
+ PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3);
+ PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6);
+ }
+}
+
+void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+ PathLineTo(a + ImVec2(0.5f,0.5f));
+ PathLineTo(b + ImVec2(0.5f,0.5f));
+ PathStroke(col, false, thickness);
+}
+
+// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly.
+void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners_flags, float thickness)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+ if (Flags & ImDrawListFlags_AntiAliasedLines)
+ PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.50f,0.50f), rounding, rounding_corners_flags);
+ else
+ PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.49f,0.49f), rounding, rounding_corners_flags); // Better looking lower-right corner and rounded non-AA shapes.
+ PathStroke(col, true, thickness);
+}
+
+void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners_flags)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+ if (rounding > 0.0f)
+ {
+ PathRect(a, b, rounding, rounding_corners_flags);
+ PathFillConvex(col);
+ }
+ else
+ {
+ PrimReserve(6, 4);
+ PrimRect(a, b, col);
+ }
+}
+
+void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
+{
+ if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
+ return;
+
+ const ImVec2 uv = _Data->TexUvWhitePixel;
+ PrimReserve(6, 4);
+ PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
+ PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
+ PrimWriteVtx(a, uv, col_upr_left);
+ PrimWriteVtx(ImVec2(c.x, a.y), uv, col_upr_right);
+ PrimWriteVtx(c, uv, col_bot_right);
+ PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left);
+}
+
+void ImDrawList::AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ PathLineTo(a);
+ PathLineTo(b);
+ PathLineTo(c);
+ PathLineTo(d);
+ PathStroke(col, true, thickness);
+}
+
+void ImDrawList::AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ PathLineTo(a);
+ PathLineTo(b);
+ PathLineTo(c);
+ PathLineTo(d);
+ PathFillConvex(col);
+}
+
+void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ PathLineTo(a);
+ PathLineTo(b);
+ PathLineTo(c);
+ PathStroke(col, true, thickness);
+}
+
+void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ PathLineTo(a);
+ PathLineTo(b);
+ PathLineTo(c);
+ PathFillConvex(col);
+}
+
+void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments, float thickness)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
+ PathArcTo(centre, radius-0.5f, 0.0f, a_max, num_segments);
+ PathStroke(col, true, thickness);
+}
+
+void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
+ PathArcTo(centre, radius, 0.0f, a_max, num_segments);
+ PathFillConvex(col);
+}
+
+void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ PathLineTo(pos0);
+ PathBezierCurveTo(cp0, cp1, pos1, num_segments);
+ PathStroke(col, false, thickness);
+}
+
+void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ if (text_end == NULL)
+ text_end = text_begin + strlen(text_begin);
+ if (text_begin == text_end)
+ return;
+
+ // Pull default font/size from the shared ImDrawListSharedData instance
+ if (font == NULL)
+ font = _Data->Font;
+ if (font_size == 0.0f)
+ font_size = _Data->FontSize;
+
+ IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
+
+ ImVec4 clip_rect = _ClipRectStack.back();
+ if (cpu_fine_clip_rect)
+ {
+ clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x);
+ clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y);
+ clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
+ clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
+ }
+ font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL);
+}
+
+void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
+{
+ AddText(NULL, 0.0f, pos, col, text_begin, text_end);
+}
+
+void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
+ if (push_texture_id)
+ PushTextureID(user_texture_id);
+
+ PrimReserve(6, 4);
+ PrimRectUV(a, b, uv_a, uv_b, col);
+
+ if (push_texture_id)
+ PopTextureID();
+}
+
+void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
+ if (push_texture_id)
+ PushTextureID(user_texture_id);
+
+ PrimReserve(6, 4);
+ PrimQuadUV(a, b, c, d, uv_a, uv_b, uv_c, uv_d, col);
+
+ if (push_texture_id)
+ PopTextureID();
+}
+
+void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners)
+{
+ if ((col & IM_COL32_A_MASK) == 0)
+ return;
+
+ if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0)
+ {
+ AddImage(user_texture_id, a, b, uv_a, uv_b, col);
+ return;
+ }
+
+ const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
+ if (push_texture_id)
+ PushTextureID(user_texture_id);
+
+ int vert_start_idx = VtxBuffer.Size;
+ PathRect(a, b, rounding, rounding_corners);
+ PathFillConvex(col);
+ int vert_end_idx = VtxBuffer.Size;
+ ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, a, b, uv_a, uv_b, true);
+
+ if (push_texture_id)
+ PopTextureID();
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImDrawData
+//-----------------------------------------------------------------------------
+
+// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
+void ImDrawData::DeIndexAllBuffers()
+{
+ ImVector<ImDrawVert> new_vtx_buffer;
+ TotalVtxCount = TotalIdxCount = 0;
+ for (int i = 0; i < CmdListsCount; i++)
+ {
+ ImDrawList* cmd_list = CmdLists[i];
+ if (cmd_list->IdxBuffer.empty())
+ continue;
+ new_vtx_buffer.resize(cmd_list->IdxBuffer.Size);
+ for (int j = 0; j < cmd_list->IdxBuffer.Size; j++)
+ new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]];
+ cmd_list->VtxBuffer.swap(new_vtx_buffer);
+ cmd_list->IdxBuffer.resize(0);
+ TotalVtxCount += cmd_list->VtxBuffer.Size;
+ }
+}
+
+// Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
+void ImDrawData::ScaleClipRects(const ImVec2& scale)
+{
+ for (int i = 0; i < CmdListsCount; i++)
+ {
+ ImDrawList* cmd_list = CmdLists[i];
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
+ cmd->ClipRect = ImVec4(cmd->ClipRect.x * scale.x, cmd->ClipRect.y * scale.y, cmd->ClipRect.z * scale.x, cmd->ClipRect.w * scale.y);
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Helpers ShadeVertsXXX functions
+//-----------------------------------------------------------------------------
+
+// Generic linear color gradient, write to RGB fields, leave A untouched.
+void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
+{
+ ImVec2 gradient_extent = gradient_p1 - gradient_p0;
+ float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
+ ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
+ ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
+ for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
+ {
+ float d = ImDot(vert->pos - gradient_p0, gradient_extent);
+ float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
+ int r = ImLerp((int)(col0 >> IM_COL32_R_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_R_SHIFT) & 0xFF, t);
+ int g = ImLerp((int)(col0 >> IM_COL32_G_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_G_SHIFT) & 0xFF, t);
+ int b = ImLerp((int)(col0 >> IM_COL32_B_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_B_SHIFT) & 0xFF, t);
+ vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK);
+ }
+}
+
+// Distribute UV over (a, b) rectangle
+void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp)
+{
+ const ImVec2 size = b - a;
+ const ImVec2 uv_size = uv_b - uv_a;
+ const ImVec2 scale = ImVec2(
+ size.x != 0.0f ? (uv_size.x / size.x) : 0.0f,
+ size.y != 0.0f ? (uv_size.y / size.y) : 0.0f);
+
+ ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
+ ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
+ if (clamp)
+ {
+ const ImVec2 min = ImMin(uv_a, uv_b);
+ const ImVec2 max = ImMax(uv_a, uv_b);
+ for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
+ vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max);
+ }
+ else
+ {
+ for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
+ vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImFontConfig
+//-----------------------------------------------------------------------------
+
+ImFontConfig::ImFontConfig()
+{
+ FontData = NULL;
+ FontDataSize = 0;
+ FontDataOwnedByAtlas = true;
+ FontNo = 0;
+ SizePixels = 0.0f;
+ OversampleH = 3;
+ OversampleV = 1;
+ PixelSnapH = false;
+ GlyphExtraSpacing = ImVec2(0.0f, 0.0f);
+ GlyphOffset = ImVec2(0.0f, 0.0f);
+ GlyphRanges = NULL;
+ GlyphMinAdvanceX = 0.0f;
+ GlyphMaxAdvanceX = FLT_MAX;
+ MergeMode = false;
+ RasterizerFlags = 0x00;
+ RasterizerMultiply = 1.0f;
+ memset(Name, 0, sizeof(Name));
+ DstFont = NULL;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImFontAtlas
+//-----------------------------------------------------------------------------
+
+// A work of art lies ahead! (. = white layer, X = black layer, others are blank)
+// The white texels on the top left are the ones we'll use everywhere in ImGui to render filled shapes.
+const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
+const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
+const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000;
+static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
+{
+ "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
+ "..- -X.....X- X.X - X.X -X.....X - X.....X- X..X "
+ "--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X "
+ "X - X.X - X.....X - X.....X -X...X - X...X- X..X "
+ "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X "
+ "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX "
+ "X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX "
+ "X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX "
+ "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X "
+ "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X"
+ "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X"
+ "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X"
+ "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X"
+ "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X"
+ "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X"
+ "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X"
+ "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X "
+ "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X "
+ "X.X X..X - -X.......X- X.......X - XX XX - - X..........X "
+ "XX X..X - - X.....X - X.....X - X.X X.X - - X........X "
+ " X..X - X...X - X...X - X..X X..X - - X........X "
+ " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX "
+ "------------ - X - X -X.....................X- ------------------"
+ " ----------------------------------- X...XXXXXXXXXXXXX...X - "
+ " - X..X X..X - "
+ " - X.X X.X - "
+ " - XX XX - "
+};
+
+static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] =
+{
+ // Pos ........ Size ......... Offset ......
+ { ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow
+ { ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) }, // ImGuiMouseCursor_TextInput
+ { ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_ResizeAll
+ { ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) }, // ImGuiMouseCursor_ResizeNS
+ { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) }, // ImGuiMouseCursor_ResizeEW
+ { ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNESW
+ { ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNWSE
+ { ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand
+};
+
+ImFontAtlas::ImFontAtlas()
+{
+ Locked = false;
+ Flags = ImFontAtlasFlags_None;
+ TexID = (ImTextureID)NULL;
+ TexDesiredWidth = 0;
+ TexGlyphPadding = 1;
+
+ TexPixelsAlpha8 = NULL;
+ TexPixelsRGBA32 = NULL;
+ TexWidth = TexHeight = 0;
+ TexUvScale = ImVec2(0.0f, 0.0f);
+ TexUvWhitePixel = ImVec2(0.0f, 0.0f);
+ for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
+ CustomRectIds[n] = -1;
+}
+
+ImFontAtlas::~ImFontAtlas()
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ Clear();
+}
+
+void ImFontAtlas::ClearInputData()
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ for (int i = 0; i < ConfigData.Size; i++)
+ if (ConfigData[i].FontData && ConfigData[i].FontDataOwnedByAtlas)
+ {
+ ImGui::MemFree(ConfigData[i].FontData);
+ ConfigData[i].FontData = NULL;
+ }
+
+ // When clearing this we lose access to the font name and other information used to build the font.
+ for (int i = 0; i < Fonts.Size; i++)
+ if (Fonts[i]->ConfigData >= ConfigData.Data && Fonts[i]->ConfigData < ConfigData.Data + ConfigData.Size)
+ {
+ Fonts[i]->ConfigData = NULL;
+ Fonts[i]->ConfigDataCount = 0;
+ }
+ ConfigData.clear();
+ CustomRects.clear();
+ for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
+ CustomRectIds[n] = -1;
+}
+
+void ImFontAtlas::ClearTexData()
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ if (TexPixelsAlpha8)
+ ImGui::MemFree(TexPixelsAlpha8);
+ if (TexPixelsRGBA32)
+ ImGui::MemFree(TexPixelsRGBA32);
+ TexPixelsAlpha8 = NULL;
+ TexPixelsRGBA32 = NULL;
+}
+
+void ImFontAtlas::ClearFonts()
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ for (int i = 0; i < Fonts.Size; i++)
+ IM_DELETE(Fonts[i]);
+ Fonts.clear();
+}
+
+void ImFontAtlas::Clear()
+{
+ ClearInputData();
+ ClearTexData();
+ ClearFonts();
+}
+
+void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel)
+{
+ // Build atlas on demand
+ if (TexPixelsAlpha8 == NULL)
+ {
+ if (ConfigData.empty())
+ AddFontDefault();
+ Build();
+ }
+
+ *out_pixels = TexPixelsAlpha8;
+ if (out_width) *out_width = TexWidth;
+ if (out_height) *out_height = TexHeight;
+ if (out_bytes_per_pixel) *out_bytes_per_pixel = 1;
+}
+
+void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel)
+{
+ // Convert to RGBA32 format on demand
+ // Although it is likely to be the most commonly used format, our font rendering is 1 channel / 8 bpp
+ if (!TexPixelsRGBA32)
+ {
+ unsigned char* pixels = NULL;
+ GetTexDataAsAlpha8(&pixels, NULL, NULL);
+ if (pixels)
+ {
+ TexPixelsRGBA32 = (unsigned int*)ImGui::MemAlloc((size_t)(TexWidth * TexHeight * 4));
+ const unsigned char* src = pixels;
+ unsigned int* dst = TexPixelsRGBA32;
+ for (int n = TexWidth * TexHeight; n > 0; n--)
+ *dst++ = IM_COL32(255, 255, 255, (unsigned int)(*src++));
+ }
+ }
+
+ *out_pixels = (unsigned char*)TexPixelsRGBA32;
+ if (out_width) *out_width = TexWidth;
+ if (out_height) *out_height = TexHeight;
+ if (out_bytes_per_pixel) *out_bytes_per_pixel = 4;
+}
+
+ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ IM_ASSERT(font_cfg->FontData != NULL && font_cfg->FontDataSize > 0);
+ IM_ASSERT(font_cfg->SizePixels > 0.0f);
+
+ // Create new font
+ if (!font_cfg->MergeMode)
+ Fonts.push_back(IM_NEW(ImFont));
+ else
+ IM_ASSERT(!Fonts.empty()); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font.
+
+ ConfigData.push_back(*font_cfg);
+ ImFontConfig& new_font_cfg = ConfigData.back();
+ if (!new_font_cfg.DstFont)
+ new_font_cfg.DstFont = Fonts.back();
+ if (!new_font_cfg.FontDataOwnedByAtlas)
+ {
+ new_font_cfg.FontData = ImGui::MemAlloc(new_font_cfg.FontDataSize);
+ new_font_cfg.FontDataOwnedByAtlas = true;
+ memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize);
+ }
+
+ // Invalidate texture
+ ClearTexData();
+ return new_font_cfg.DstFont;
+}
+
+// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
+static unsigned int stb_decompress_length(const unsigned char *input);
+static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length);
+static const char* GetDefaultCompressedFontDataTTFBase85();
+static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
+static void Decode85(const unsigned char* src, unsigned char* dst)
+{
+ while (*src)
+ {
+ unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4]))));
+ dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
+ src += 5;
+ dst += 4;
+ }
+}
+
+// Load embedded ProggyClean.ttf at size 13, disable oversampling
+ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
+{
+ ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
+ if (!font_cfg_template)
+ {
+ font_cfg.OversampleH = font_cfg.OversampleV = 1;
+ font_cfg.PixelSnapH = true;
+ }
+ if (font_cfg.Name[0] == '\0') strcpy(font_cfg.Name, "ProggyClean.ttf, 13px");
+ if (font_cfg.SizePixels <= 0.0f) font_cfg.SizePixels = 13.0f;
+
+ const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
+ const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
+ ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges);
+ font->DisplayOffset.y = 1.0f;
+ return font;
+}
+
+ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ size_t data_size = 0;
+ void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
+ if (!data)
+ {
+ IM_ASSERT(0); // Could not load file.
+ return NULL;
+ }
+ ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
+ if (font_cfg.Name[0] == '\0')
+ {
+ // Store a short copy of filename into into the font name for convenience
+ const char* p;
+ for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
+ ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels);
+ }
+ return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges);
+}
+
+// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
+ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
+ IM_ASSERT(font_cfg.FontData == NULL);
+ font_cfg.FontData = ttf_data;
+ font_cfg.FontDataSize = ttf_size;
+ font_cfg.SizePixels = size_pixels;
+ if (glyph_ranges)
+ font_cfg.GlyphRanges = glyph_ranges;
+ return AddFont(&font_cfg);
+}
+
+ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
+{
+ const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
+ unsigned char* buf_decompressed_data = (unsigned char *)ImGui::MemAlloc(buf_decompressed_size);
+ stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
+
+ ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
+ IM_ASSERT(font_cfg.FontData == NULL);
+ font_cfg.FontDataOwnedByAtlas = true;
+ return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges);
+}
+
+ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
+{
+ int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4;
+ void* compressed_ttf = ImGui::MemAlloc((size_t)compressed_ttf_size);
+ Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
+ ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges);
+ ImGui::MemFree(compressed_ttf);
+ return font;
+}
+
+int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
+{
+ IM_ASSERT(id >= 0x10000);
+ IM_ASSERT(width > 0 && width <= 0xFFFF);
+ IM_ASSERT(height > 0 && height <= 0xFFFF);
+ CustomRect r;
+ r.ID = id;
+ r.Width = (unsigned short)width;
+ r.Height = (unsigned short)height;
+ CustomRects.push_back(r);
+ return CustomRects.Size - 1; // Return index
+}
+
+int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset)
+{
+ IM_ASSERT(font != NULL);
+ IM_ASSERT(width > 0 && width <= 0xFFFF);
+ IM_ASSERT(height > 0 && height <= 0xFFFF);
+ CustomRect r;
+ r.ID = id;
+ r.Width = (unsigned short)width;
+ r.Height = (unsigned short)height;
+ r.GlyphAdvanceX = advance_x;
+ r.GlyphOffset = offset;
+ r.Font = font;
+ CustomRects.push_back(r);
+ return CustomRects.Size - 1; // Return index
+}
+
+void ImFontAtlas::CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max)
+{
+ IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates
+ IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed
+ *out_uv_min = ImVec2((float)rect->X * TexUvScale.x, (float)rect->Y * TexUvScale.y);
+ *out_uv_max = ImVec2((float)(rect->X + rect->Width) * TexUvScale.x, (float)(rect->Y + rect->Height) * TexUvScale.y);
+}
+
+bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2])
+{
+ if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT)
+ return false;
+ if (Flags & ImFontAtlasFlags_NoMouseCursors)
+ return false;
+
+ IM_ASSERT(CustomRectIds[0] != -1);
+ ImFontAtlas::CustomRect& r = CustomRects[CustomRectIds[0]];
+ IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
+ ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
+ ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
+ *out_size = size;
+ *out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2];
+ out_uv_border[0] = (pos) * TexUvScale;
+ out_uv_border[1] = (pos + size) * TexUvScale;
+ pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1;
+ out_uv_fill[0] = (pos) * TexUvScale;
+ out_uv_fill[1] = (pos + size) * TexUvScale;
+ return true;
+}
+
+bool ImFontAtlas::Build()
+{
+ IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
+ return ImFontAtlasBuildWithStbTruetype(this);
+}
+
+void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor)
+{
+ for (unsigned int i = 0; i < 256; i++)
+ {
+ unsigned int value = (unsigned int)(i * in_brighten_factor);
+ out_table[i] = value > 255 ? 255 : (value & 0xFF);
+ }
+}
+
+void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride)
+{
+ unsigned char* data = pixels + x + y * stride;
+ for (int j = h; j > 0; j--, data += stride)
+ for (int i = 0; i < w; i++)
+ data[i] = table[data[i]];
+}
+
+bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
+{
+ IM_ASSERT(atlas->ConfigData.Size > 0);
+
+ ImFontAtlasBuildRegisterDefaultCustomRects(atlas);
+
+ atlas->TexID = (ImTextureID)NULL;
+ atlas->TexWidth = atlas->TexHeight = 0;
+ atlas->TexUvScale = ImVec2(0.0f, 0.0f);
+ atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f);
+ atlas->ClearTexData();
+
+ // Count glyphs/ranges
+ int total_glyphs_count = 0;
+ int total_ranges_count = 0;
+ for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++)
+ {
+ ImFontConfig& cfg = atlas->ConfigData[input_i];
+ if (!cfg.GlyphRanges)
+ cfg.GlyphRanges = atlas->GetGlyphRangesDefault();
+ for (const ImWchar* in_range = cfg.GlyphRanges; in_range[0] && in_range[1]; in_range += 2, total_ranges_count++)
+ total_glyphs_count += (in_range[1] - in_range[0]) + 1;
+ }
+
+ // We need a width for the skyline algorithm. Using a dumb heuristic here to decide of width. User can override TexDesiredWidth and TexGlyphPadding if they wish.
+ // Width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height.
+ atlas->TexWidth = (atlas->TexDesiredWidth > 0) ? atlas->TexDesiredWidth : (total_glyphs_count > 4000) ? 4096 : (total_glyphs_count > 2000) ? 2048 : (total_glyphs_count > 1000) ? 1024 : 512;
+ atlas->TexHeight = 0;
+
+ // Start packing
+ const int max_tex_height = 1024*32;
+ stbtt_pack_context spc = {};
+ if (!stbtt_PackBegin(&spc, NULL, atlas->TexWidth, max_tex_height, 0, atlas->TexGlyphPadding, NULL))
+ return false;
+ stbtt_PackSetOversampling(&spc, 1, 1);
+
+ // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
+ ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info);
+
+ // Initialize font information (so we can error without any cleanup)
+ struct ImFontTempBuildData
+ {
+ stbtt_fontinfo FontInfo;
+ stbrp_rect* Rects;
+ int RectsCount;
+ stbtt_pack_range* Ranges;
+ int RangesCount;
+ };
+ ImFontTempBuildData* tmp_array = (ImFontTempBuildData*)ImGui::MemAlloc((size_t)atlas->ConfigData.Size * sizeof(ImFontTempBuildData));
+ for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++)
+ {
+ ImFontConfig& cfg = atlas->ConfigData[input_i];
+ ImFontTempBuildData& tmp = tmp_array[input_i];
+ IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas));
+
+ const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo);
+ IM_ASSERT(font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found.");
+ if (!stbtt_InitFont(&tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset))
+ {
+ atlas->TexWidth = atlas->TexHeight = 0; // Reset output on failure
+ ImGui::MemFree(tmp_array);
+ return false;
+ }
+ }
+
+ // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0)
+ int buf_packedchars_n = 0, buf_rects_n = 0, buf_ranges_n = 0;
+ stbtt_packedchar* buf_packedchars = (stbtt_packedchar*)ImGui::MemAlloc(total_glyphs_count * sizeof(stbtt_packedchar));
+ stbrp_rect* buf_rects = (stbrp_rect*)ImGui::MemAlloc(total_glyphs_count * sizeof(stbrp_rect));
+ stbtt_pack_range* buf_ranges = (stbtt_pack_range*)ImGui::MemAlloc(total_ranges_count * sizeof(stbtt_pack_range));
+ memset(buf_packedchars, 0, total_glyphs_count * sizeof(stbtt_packedchar));
+ memset(buf_rects, 0, total_glyphs_count * sizeof(stbrp_rect)); // Unnecessary but let's clear this for the sake of sanity.
+ memset(buf_ranges, 0, total_ranges_count * sizeof(stbtt_pack_range));
+
+ // First font pass: pack all glyphs (no rendering at this point, we are working with rectangles in an infinitely tall texture at this point)
+ for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++)
+ {
+ ImFontConfig& cfg = atlas->ConfigData[input_i];
+ ImFontTempBuildData& tmp = tmp_array[input_i];
+
+ // Setup ranges
+ int font_glyphs_count = 0;
+ int font_ranges_count = 0;
+ for (const ImWchar* in_range = cfg.GlyphRanges; in_range[0] && in_range[1]; in_range += 2, font_ranges_count++)
+ font_glyphs_count += (in_range[1] - in_range[0]) + 1;
+ tmp.Ranges = buf_ranges + buf_ranges_n;
+ tmp.RangesCount = font_ranges_count;
+ buf_ranges_n += font_ranges_count;
+ for (int i = 0; i < font_ranges_count; i++)
+ {
+ const ImWchar* in_range = &cfg.GlyphRanges[i * 2];
+ stbtt_pack_range& range = tmp.Ranges[i];
+ range.font_size = cfg.SizePixels;
+ range.first_unicode_codepoint_in_range = in_range[0];
+ range.num_chars = (in_range[1] - in_range[0]) + 1;
+ range.chardata_for_range = buf_packedchars + buf_packedchars_n;
+ buf_packedchars_n += range.num_chars;
+ }
+
+ // Gather the sizes of all rectangle we need
+ tmp.Rects = buf_rects + buf_rects_n;
+ tmp.RectsCount = font_glyphs_count;
+ buf_rects_n += font_glyphs_count;
+ stbtt_PackSetOversampling(&spc, cfg.OversampleH, cfg.OversampleV);
+ int n = stbtt_PackFontRangesGatherRects(&spc, &tmp.FontInfo, tmp.Ranges, tmp.RangesCount, tmp.Rects);
+ IM_ASSERT(n == font_glyphs_count);
+
+ // Detect missing glyphs and replace them with a zero-sized box instead of relying on the default glyphs
+ // This allows us merging overlapping icon fonts more easily.
+ int rect_i = 0;
+ for (int range_i = 0; range_i < tmp.RangesCount; range_i++)
+ for (int char_i = 0; char_i < tmp.Ranges[range_i].num_chars; char_i++, rect_i++)
+ if (stbtt_FindGlyphIndex(&tmp.FontInfo, tmp.Ranges[range_i].first_unicode_codepoint_in_range + char_i) == 0)
+ tmp.Rects[rect_i].w = tmp.Rects[rect_i].h = 0;
+
+ // Pack
+ stbrp_pack_rects((stbrp_context*)spc.pack_info, tmp.Rects, n);
+
+ // Extend texture height
+ // Also mark missing glyphs as non-packed so we don't attempt to render into them
+ for (int i = 0; i < n; i++)
+ {
+ if (tmp.Rects[i].w == 0 && tmp.Rects[i].h == 0)
+ tmp.Rects[i].was_packed = 0;
+ if (tmp.Rects[i].was_packed)
+ atlas->TexHeight = ImMax(atlas->TexHeight, tmp.Rects[i].y + tmp.Rects[i].h);
+ }
+ }
+ IM_ASSERT(buf_rects_n == total_glyphs_count);
+ IM_ASSERT(buf_packedchars_n == total_glyphs_count);
+ IM_ASSERT(buf_ranges_n == total_ranges_count);
+
+ // Create texture
+ atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight);
+ atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight);
+ atlas->TexPixelsAlpha8 = (unsigned char*)ImGui::MemAlloc(atlas->TexWidth * atlas->TexHeight);
+ memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight);
+ spc.pixels = atlas->TexPixelsAlpha8;
+ spc.height = atlas->TexHeight;
+
+ // Second pass: render font characters
+ for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++)
+ {
+ ImFontConfig& cfg = atlas->ConfigData[input_i];
+ ImFontTempBuildData& tmp = tmp_array[input_i];
+ stbtt_PackSetOversampling(&spc, cfg.OversampleH, cfg.OversampleV);
+ stbtt_PackFontRangesRenderIntoRects(&spc, &tmp.FontInfo, tmp.Ranges, tmp.RangesCount, tmp.Rects);
+ if (cfg.RasterizerMultiply != 1.0f)
+ {
+ unsigned char multiply_table[256];
+ ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply);
+ for (const stbrp_rect* r = tmp.Rects; r != tmp.Rects + tmp.RectsCount; r++)
+ if (r->was_packed)
+ ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, spc.pixels, r->x, r->y, r->w, r->h, spc.stride_in_bytes);
+ }
+ tmp.Rects = NULL;
+ }
+
+ // End packing
+ stbtt_PackEnd(&spc);
+ ImGui::MemFree(buf_rects);
+ buf_rects = NULL;
+
+ // Third pass: setup ImFont and glyphs for runtime
+ for (int input_i = 0; input_i < atlas->ConfigData.Size; input_i++)
+ {
+ ImFontConfig& cfg = atlas->ConfigData[input_i];
+ ImFontTempBuildData& tmp = tmp_array[input_i];
+ ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true)
+ if (cfg.MergeMode)
+ dst_font->BuildLookupTable();
+
+ const float font_scale = stbtt_ScaleForPixelHeight(&tmp.FontInfo, cfg.SizePixels);
+ int unscaled_ascent, unscaled_descent, unscaled_line_gap;
+ stbtt_GetFontVMetrics(&tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
+
+ const float ascent = ImFloor(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1));
+ const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
+ ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
+ const float font_off_x = cfg.GlyphOffset.x;
+ const float font_off_y = cfg.GlyphOffset.y + (float)(int)(dst_font->Ascent + 0.5f);
+
+ for (int i = 0; i < tmp.RangesCount; i++)
+ {
+ stbtt_pack_range& range = tmp.Ranges[i];
+ for (int char_idx = 0; char_idx < range.num_chars; char_idx += 1)
+ {
+ const stbtt_packedchar& pc = range.chardata_for_range[char_idx];
+ if (!pc.x0 && !pc.x1 && !pc.y0 && !pc.y1)
+ continue;
+
+ const int codepoint = range.first_unicode_codepoint_in_range + char_idx;
+ if (cfg.MergeMode && dst_font->FindGlyphNoFallback((ImWchar)codepoint))
+ continue;
+
+ float char_advance_x_org = pc.xadvance;
+ float char_advance_x_mod = ImClamp(char_advance_x_org, cfg.GlyphMinAdvanceX, cfg.GlyphMaxAdvanceX);
+ float char_off_x = font_off_x;
+ if (char_advance_x_org != char_advance_x_mod)
+ char_off_x += cfg.PixelSnapH ? (float)(int)((char_advance_x_mod - char_advance_x_org) * 0.5f) : (char_advance_x_mod - char_advance_x_org) * 0.5f;
+
+ stbtt_aligned_quad q;
+ float dummy_x = 0.0f, dummy_y = 0.0f;
+ stbtt_GetPackedQuad(range.chardata_for_range, atlas->TexWidth, atlas->TexHeight, char_idx, &dummy_x, &dummy_y, &q, 0);
+ dst_font->AddGlyph((ImWchar)codepoint, q.x0 + char_off_x, q.y0 + font_off_y, q.x1 + char_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, char_advance_x_mod);
+ }
+ }
+ }
+
+ // Cleanup temporaries
+ ImGui::MemFree(buf_packedchars);
+ ImGui::MemFree(buf_ranges);
+ ImGui::MemFree(tmp_array);
+
+ ImFontAtlasBuildFinish(atlas);
+
+ return true;
+}
+
+void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
+{
+ if (atlas->CustomRectIds[0] >= 0)
+ return;
+ if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
+ atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
+ else
+ atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2);
+}
+
+void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
+{
+ if (!font_config->MergeMode)
+ {
+ font->ClearOutputData();
+ font->FontSize = font_config->SizePixels;
+ font->ConfigData = font_config;
+ font->ContainerAtlas = atlas;
+ font->Ascent = ascent;
+ font->Descent = descent;
+ }
+ font->ConfigDataCount++;
+}
+
+void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaque)
+{
+ stbrp_context* pack_context = (stbrp_context*)pack_context_opaque;
+
+ ImVector<ImFontAtlas::CustomRect>& user_rects = atlas->CustomRects;
+ IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
+
+ ImVector<stbrp_rect> pack_rects;
+ pack_rects.resize(user_rects.Size);
+ memset(pack_rects.Data, 0, sizeof(stbrp_rect) * user_rects.Size);
+ for (int i = 0; i < user_rects.Size; i++)
+ {
+ pack_rects[i].w = user_rects[i].Width;
+ pack_rects[i].h = user_rects[i].Height;
+ }
+ stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size);
+ for (int i = 0; i < pack_rects.Size; i++)
+ if (pack_rects[i].was_packed)
+ {
+ user_rects[i].X = pack_rects[i].x;
+ user_rects[i].Y = pack_rects[i].y;
+ IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height);
+ atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h);
+ }
+}
+
+static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
+{
+ IM_ASSERT(atlas->CustomRectIds[0] >= 0);
+ IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
+ ImFontAtlas::CustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
+ IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
+ IM_ASSERT(r.IsPacked());
+
+ const int w = atlas->TexWidth;
+ if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
+ {
+ // Render/copy pixels
+ IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * 2 + 1 && r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H);
+ for (int y = 0, n = 0; y < FONT_ATLAS_DEFAULT_TEX_DATA_H; y++)
+ for (int x = 0; x < FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF; x++, n++)
+ {
+ const int offset0 = (int)(r.X + x) + (int)(r.Y + y) * w;
+ const int offset1 = offset0 + FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1;
+ atlas->TexPixelsAlpha8[offset0] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == '.' ? 0xFF : 0x00;
+ atlas->TexPixelsAlpha8[offset1] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == 'X' ? 0xFF : 0x00;
+ }
+ }
+ else
+ {
+ IM_ASSERT(r.Width == 2 && r.Height == 2);
+ const int offset = (int)(r.X) + (int)(r.Y) * w;
+ atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF;
+ }
+ atlas->TexUvWhitePixel = ImVec2((r.X + 0.5f) * atlas->TexUvScale.x, (r.Y + 0.5f) * atlas->TexUvScale.y);
+}
+
+void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
+{
+ // Render into our custom data block
+ ImFontAtlasBuildRenderDefaultTexData(atlas);
+
+ // Register custom rectangle glyphs
+ for (int i = 0; i < atlas->CustomRects.Size; i++)
+ {
+ const ImFontAtlas::CustomRect& r = atlas->CustomRects[i];
+ if (r.Font == NULL || r.ID > 0x10000)
+ continue;
+
+ IM_ASSERT(r.Font->ContainerAtlas == atlas);
+ ImVec2 uv0, uv1;
+ atlas->CalcCustomRectUV(&r, &uv0, &uv1);
+ r.Font->AddGlyph((ImWchar)r.ID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX);
+ }
+
+ // Build all fonts lookup tables
+ for (int i = 0; i < atlas->Fonts.Size; i++)
+ if (atlas->Fonts[i]->DirtyLookupTables)
+ atlas->Fonts[i]->BuildLookupTable();
+}
+
+// Retrieve list of range (2 int per range, values are inclusive)
+const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
+{
+ static const ImWchar ranges[] =
+ {
+ 0x0020, 0x00FF, // Basic Latin + Latin Supplement
+ 0,
+ };
+ return &ranges[0];
+}
+
+const ImWchar* ImFontAtlas::GetGlyphRangesKorean()
+{
+ static const ImWchar ranges[] =
+ {
+ 0x0020, 0x00FF, // Basic Latin + Latin Supplement
+ 0x3131, 0x3163, // Korean alphabets
+ 0xAC00, 0xD79D, // Korean characters
+ 0,
+ };
+ return &ranges[0];
+}
+
+const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull()
+{
+ static const ImWchar ranges[] =
+ {
+ 0x0020, 0x00FF, // Basic Latin + Latin Supplement
+ 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana
+ 0x31F0, 0x31FF, // Katakana Phonetic Extensions
+ 0xFF00, 0xFFEF, // Half-width characters
+ 0x4e00, 0x9FAF, // CJK Ideograms
+ 0,
+ };
+ return &ranges[0];
+}
+
+static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges)
+{
+ for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2)
+ {
+ out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]);
+ base_codepoint += accumulative_offsets[n];
+ }
+ out_ranges[0] = 0;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] ImFontAtlas glyph ranges helpers
+//-------------------------------------------------------------------------
+
+const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon()
+{
+ // Store 2500 regularly used characters for Simplified Chinese.
+ // Sourced from https://zh.wiktionary.org/wiki/%E9%99%84%E5%BD%95:%E7%8E%B0%E4%BB%A3%E6%B1%89%E8%AF%AD%E5%B8%B8%E7%94%A8%E5%AD%97%E8%A1%A8
+ // This table covers 97.97% of all characters used during the month in July, 1987.
+ // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters.
+ // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.)
+ static const short accumulative_offsets_from_0x4E00[] =
+ {
+ 0,1,2,4,1,1,1,1,2,1,3,2,1,2,2,1,1,1,1,1,5,2,1,2,3,3,3,2,2,4,1,1,1,2,1,5,2,3,1,2,1,2,1,1,2,1,1,2,2,1,4,1,1,1,1,5,10,1,2,19,2,1,2,1,2,1,2,1,2,
+ 1,5,1,6,3,2,1,2,2,1,1,1,4,8,5,1,1,4,1,1,3,1,2,1,5,1,2,1,1,1,10,1,1,5,2,4,6,1,4,2,2,2,12,2,1,1,6,1,1,1,4,1,1,4,6,5,1,4,2,2,4,10,7,1,1,4,2,4,
+ 2,1,4,3,6,10,12,5,7,2,14,2,9,1,1,6,7,10,4,7,13,1,5,4,8,4,1,1,2,28,5,6,1,1,5,2,5,20,2,2,9,8,11,2,9,17,1,8,6,8,27,4,6,9,20,11,27,6,68,2,2,1,1,
+ 1,2,1,2,2,7,6,11,3,3,1,1,3,1,2,1,1,1,1,1,3,1,1,8,3,4,1,5,7,2,1,4,4,8,4,2,1,2,1,1,4,5,6,3,6,2,12,3,1,3,9,2,4,3,4,1,5,3,3,1,3,7,1,5,1,1,1,1,2,
+ 3,4,5,2,3,2,6,1,1,2,1,7,1,7,3,4,5,15,2,2,1,5,3,22,19,2,1,1,1,1,2,5,1,1,1,6,1,1,12,8,2,9,18,22,4,1,1,5,1,16,1,2,7,10,15,1,1,6,2,4,1,2,4,1,6,
+ 1,1,3,2,4,1,6,4,5,1,2,1,1,2,1,10,3,1,3,2,1,9,3,2,5,7,2,19,4,3,6,1,1,1,1,1,4,3,2,1,1,1,2,5,3,1,1,1,2,2,1,1,2,1,1,2,1,3,1,1,1,3,7,1,4,1,1,2,1,
+ 1,2,1,2,4,4,3,8,1,1,1,2,1,3,5,1,3,1,3,4,6,2,2,14,4,6,6,11,9,1,15,3,1,28,5,2,5,5,3,1,3,4,5,4,6,14,3,2,3,5,21,2,7,20,10,1,2,19,2,4,28,28,2,3,
+ 2,1,14,4,1,26,28,42,12,40,3,52,79,5,14,17,3,2,2,11,3,4,6,3,1,8,2,23,4,5,8,10,4,2,7,3,5,1,1,6,3,1,2,2,2,5,28,1,1,7,7,20,5,3,29,3,17,26,1,8,4,
+ 27,3,6,11,23,5,3,4,6,13,24,16,6,5,10,25,35,7,3,2,3,3,14,3,6,2,6,1,4,2,3,8,2,1,1,3,3,3,4,1,1,13,2,2,4,5,2,1,14,14,1,2,2,1,4,5,2,3,1,14,3,12,
+ 3,17,2,16,5,1,2,1,8,9,3,19,4,2,2,4,17,25,21,20,28,75,1,10,29,103,4,1,2,1,1,4,2,4,1,2,3,24,2,2,2,1,1,2,1,3,8,1,1,1,2,1,1,3,1,1,1,6,1,5,3,1,1,
+ 1,3,4,1,1,5,2,1,5,6,13,9,16,1,1,1,1,3,2,3,2,4,5,2,5,2,2,3,7,13,7,2,2,1,1,1,1,2,3,3,2,1,6,4,9,2,1,14,2,14,2,1,18,3,4,14,4,11,41,15,23,15,23,
+ 176,1,3,4,1,1,1,1,5,3,1,2,3,7,3,1,1,2,1,2,4,4,6,2,4,1,9,7,1,10,5,8,16,29,1,1,2,2,3,1,3,5,2,4,5,4,1,1,2,2,3,3,7,1,6,10,1,17,1,44,4,6,2,1,1,6,
+ 5,4,2,10,1,6,9,2,8,1,24,1,2,13,7,8,8,2,1,4,1,3,1,3,3,5,2,5,10,9,4,9,12,2,1,6,1,10,1,1,7,7,4,10,8,3,1,13,4,3,1,6,1,3,5,2,1,2,17,16,5,2,16,6,
+ 1,4,2,1,3,3,6,8,5,11,11,1,3,3,2,4,6,10,9,5,7,4,7,4,7,1,1,4,2,1,3,6,8,7,1,6,11,5,5,3,24,9,4,2,7,13,5,1,8,82,16,61,1,1,1,4,2,2,16,10,3,8,1,1,
+ 6,4,2,1,3,1,1,1,4,3,8,4,2,2,1,1,1,1,1,6,3,5,1,1,4,6,9,2,1,1,1,2,1,7,2,1,6,1,5,4,4,3,1,8,1,3,3,1,3,2,2,2,2,3,1,6,1,2,1,2,1,3,7,1,8,2,1,2,1,5,
+ 2,5,3,5,10,1,2,1,1,3,2,5,11,3,9,3,5,1,1,5,9,1,2,1,5,7,9,9,8,1,3,3,3,6,8,2,3,2,1,1,32,6,1,2,15,9,3,7,13,1,3,10,13,2,14,1,13,10,2,1,3,10,4,15,
+ 2,15,15,10,1,3,9,6,9,32,25,26,47,7,3,2,3,1,6,3,4,3,2,8,5,4,1,9,4,2,2,19,10,6,2,3,8,1,2,2,4,2,1,9,4,4,4,6,4,8,9,2,3,1,1,1,1,3,5,5,1,3,8,4,6,
+ 2,1,4,12,1,5,3,7,13,2,5,8,1,6,1,2,5,14,6,1,5,2,4,8,15,5,1,23,6,62,2,10,1,1,8,1,2,2,10,4,2,2,9,2,1,1,3,2,3,1,5,3,3,2,1,3,8,1,1,1,11,3,1,1,4,
+ 3,7,1,14,1,2,3,12,5,2,5,1,6,7,5,7,14,11,1,3,1,8,9,12,2,1,11,8,4,4,2,6,10,9,13,1,1,3,1,5,1,3,2,4,4,1,18,2,3,14,11,4,29,4,2,7,1,3,13,9,2,2,5,
+ 3,5,20,7,16,8,5,72,34,6,4,22,12,12,28,45,36,9,7,39,9,191,1,1,1,4,11,8,4,9,2,3,22,1,1,1,1,4,17,1,7,7,1,11,31,10,2,4,8,2,3,2,1,4,2,16,4,32,2,
+ 3,19,13,4,9,1,5,2,14,8,1,1,3,6,19,6,5,1,16,6,2,10,8,5,1,2,3,1,5,5,1,11,6,6,1,3,3,2,6,3,8,1,1,4,10,7,5,7,7,5,8,9,2,1,3,4,1,1,3,1,3,3,2,6,16,
+ 1,4,6,3,1,10,6,1,3,15,2,9,2,10,25,13,9,16,6,2,2,10,11,4,3,9,1,2,6,6,5,4,30,40,1,10,7,12,14,33,6,3,6,7,3,1,3,1,11,14,4,9,5,12,11,49,18,51,31,
+ 140,31,2,2,1,5,1,8,1,10,1,4,4,3,24,1,10,1,3,6,6,16,3,4,5,2,1,4,2,57,10,6,22,2,22,3,7,22,6,10,11,36,18,16,33,36,2,5,5,1,1,1,4,10,1,4,13,2,7,
+ 5,2,9,3,4,1,7,43,3,7,3,9,14,7,9,1,11,1,1,3,7,4,18,13,1,14,1,3,6,10,73,2,2,30,6,1,11,18,19,13,22,3,46,42,37,89,7,3,16,34,2,2,3,9,1,7,1,1,1,2,
+ 2,4,10,7,3,10,3,9,5,28,9,2,6,13,7,3,1,3,10,2,7,2,11,3,6,21,54,85,2,1,4,2,2,1,39,3,21,2,2,5,1,1,1,4,1,1,3,4,15,1,3,2,4,4,2,3,8,2,20,1,8,7,13,
+ 4,1,26,6,2,9,34,4,21,52,10,4,4,1,5,12,2,11,1,7,2,30,12,44,2,30,1,1,3,6,16,9,17,39,82,2,2,24,7,1,7,3,16,9,14,44,2,1,2,1,2,3,5,2,4,1,6,7,5,3,
+ 2,6,1,11,5,11,2,1,18,19,8,1,3,24,29,2,1,3,5,2,2,1,13,6,5,1,46,11,3,5,1,1,5,8,2,10,6,12,6,3,7,11,2,4,16,13,2,5,1,1,2,2,5,2,28,5,2,23,10,8,4,
+ 4,22,39,95,38,8,14,9,5,1,13,5,4,3,13,12,11,1,9,1,27,37,2,5,4,4,63,211,95,2,2,2,1,3,5,2,1,1,2,2,1,1,1,3,2,4,1,2,1,1,5,2,2,1,1,2,3,1,3,1,1,1,
+ 3,1,4,2,1,3,6,1,1,3,7,15,5,3,2,5,3,9,11,4,2,22,1,6,3,8,7,1,4,28,4,16,3,3,25,4,4,27,27,1,4,1,2,2,7,1,3,5,2,28,8,2,14,1,8,6,16,25,3,3,3,14,3,
+ 3,1,1,2,1,4,6,3,8,4,1,1,1,2,3,6,10,6,2,3,18,3,2,5,5,4,3,1,5,2,5,4,23,7,6,12,6,4,17,11,9,5,1,1,10,5,12,1,1,11,26,33,7,3,6,1,17,7,1,5,12,1,11,
+ 2,4,1,8,14,17,23,1,2,1,7,8,16,11,9,6,5,2,6,4,16,2,8,14,1,11,8,9,1,1,1,9,25,4,11,19,7,2,15,2,12,8,52,7,5,19,2,16,4,36,8,1,16,8,24,26,4,6,2,9,
+ 5,4,36,3,28,12,25,15,37,27,17,12,59,38,5,32,127,1,2,9,17,14,4,1,2,1,1,8,11,50,4,14,2,19,16,4,17,5,4,5,26,12,45,2,23,45,104,30,12,8,3,10,2,2,
+ 3,3,1,4,20,7,2,9,6,15,2,20,1,3,16,4,11,15,6,134,2,5,59,1,2,2,2,1,9,17,3,26,137,10,211,59,1,2,4,1,4,1,1,1,2,6,2,3,1,1,2,3,2,3,1,3,4,4,2,3,3,
+ 1,4,3,1,7,2,2,3,1,2,1,3,3,3,2,2,3,2,1,3,14,6,1,3,2,9,6,15,27,9,34,145,1,1,2,1,1,1,1,2,1,1,1,1,2,2,2,3,1,2,1,1,1,2,3,5,8,3,5,2,4,1,3,2,2,2,12,
+ 4,1,1,1,10,4,5,1,20,4,16,1,15,9,5,12,2,9,2,5,4,2,26,19,7,1,26,4,30,12,15,42,1,6,8,172,1,1,4,2,1,1,11,2,2,4,2,1,2,1,10,8,1,2,1,4,5,1,2,5,1,8,
+ 4,1,3,4,2,1,6,2,1,3,4,1,2,1,1,1,1,12,5,7,2,4,3,1,1,1,3,3,6,1,2,2,3,3,3,2,1,2,12,14,11,6,6,4,12,2,8,1,7,10,1,35,7,4,13,15,4,3,23,21,28,52,5,
+ 26,5,6,1,7,10,2,7,53,3,2,1,1,1,2,163,532,1,10,11,1,3,3,4,8,2,8,6,2,2,23,22,4,2,2,4,2,1,3,1,3,3,5,9,8,2,1,2,8,1,10,2,12,21,20,15,105,2,3,1,1,
+ 3,2,3,1,1,2,5,1,4,15,11,19,1,1,1,1,5,4,5,1,1,2,5,3,5,12,1,2,5,1,11,1,1,15,9,1,4,5,3,26,8,2,1,3,1,1,15,19,2,12,1,2,5,2,7,2,19,2,20,6,26,7,5,
+ 2,2,7,34,21,13,70,2,128,1,1,2,1,1,2,1,1,3,2,2,2,15,1,4,1,3,4,42,10,6,1,49,85,8,1,2,1,1,4,4,2,3,6,1,5,7,4,3,211,4,1,2,1,2,5,1,2,4,2,2,6,5,6,
+ 10,3,4,48,100,6,2,16,296,5,27,387,2,2,3,7,16,8,5,38,15,39,21,9,10,3,7,59,13,27,21,47,5,21,6
+ };
+ static ImWchar base_ranges[] = // not zero-terminated
+ {
+ 0x0020, 0x00FF, // Basic Latin + Latin Supplement
+ 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana
+ 0x31F0, 0x31FF, // Katakana Phonetic Extensions
+ 0xFF00, 0xFFEF, // Half-width characters
+ };
+ static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 };
+ if (!full_ranges[0])
+ {
+ memcpy(full_ranges, base_ranges, sizeof(base_ranges));
+ UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges));
+ }
+ return &full_ranges[0];
+}
+
+const ImWchar* ImFontAtlas::GetGlyphRangesJapanese()
+{
+ // 1946 common ideograms code points for Japanese
+ // Sourced from http://theinstructionlimit.com/common-kanji-character-ranges-for-xna-spritefont-rendering
+ // FIXME: Source a list of the revised 2136 Joyo Kanji list from 2010 and rebuild this.
+ // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters.
+ // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.)
+ static const short accumulative_offsets_from_0x4E00[] =
+ {
+ 0,1,2,4,1,1,1,1,2,1,6,2,2,1,8,5,7,11,1,2,10,10,8,2,4,20,2,11,8,2,1,2,1,6,2,1,7,5,3,7,1,1,13,7,9,1,4,6,1,2,1,10,1,1,9,2,2,4,5,6,14,1,1,9,3,18,
+ 5,4,2,2,10,7,1,1,1,3,2,4,3,23,2,10,12,2,14,2,4,13,1,6,10,3,1,7,13,6,4,13,5,2,3,17,2,2,5,7,6,4,1,7,14,16,6,13,9,15,1,1,7,16,4,7,1,19,9,2,7,15,
+ 2,6,5,13,25,4,14,13,11,25,1,1,1,2,1,2,2,3,10,11,3,3,1,1,4,4,2,1,4,9,1,4,3,5,5,2,7,12,11,15,7,16,4,5,16,2,1,1,6,3,3,1,1,2,7,6,6,7,1,4,7,6,1,1,
+ 2,1,12,3,3,9,5,8,1,11,1,2,3,18,20,4,1,3,6,1,7,3,5,5,7,2,2,12,3,1,4,2,3,2,3,11,8,7,4,17,1,9,25,1,1,4,2,2,4,1,2,7,1,1,1,3,1,2,6,16,1,2,1,1,3,12,
+ 20,2,5,20,8,7,6,2,1,1,1,1,6,2,1,2,10,1,1,6,1,3,1,2,1,4,1,12,4,1,3,1,1,1,1,1,10,4,7,5,13,1,15,1,1,30,11,9,1,15,38,14,1,32,17,20,1,9,31,2,21,9,
+ 4,49,22,2,1,13,1,11,45,35,43,55,12,19,83,1,3,2,3,13,2,1,7,3,18,3,13,8,1,8,18,5,3,7,25,24,9,24,40,3,17,24,2,1,6,2,3,16,15,6,7,3,12,1,9,7,3,3,
+ 3,15,21,5,16,4,5,12,11,11,3,6,3,2,31,3,2,1,1,23,6,6,1,4,2,6,5,2,1,1,3,3,22,2,6,2,3,17,3,2,4,5,1,9,5,1,1,6,15,12,3,17,2,14,2,8,1,23,16,4,2,23,
+ 8,15,23,20,12,25,19,47,11,21,65,46,4,3,1,5,6,1,2,5,26,2,1,1,3,11,1,1,1,2,1,2,3,1,1,10,2,3,1,1,1,3,6,3,2,2,6,6,9,2,2,2,6,2,5,10,2,4,1,2,1,2,2,
+ 3,1,1,3,1,2,9,23,9,2,1,1,1,1,5,3,2,1,10,9,6,1,10,2,31,25,3,7,5,40,1,15,6,17,7,27,180,1,3,2,2,1,1,1,6,3,10,7,1,3,6,17,8,6,2,2,1,3,5,5,8,16,14,
+ 15,1,1,4,1,2,1,1,1,3,2,7,5,6,2,5,10,1,4,2,9,1,1,11,6,1,44,1,3,7,9,5,1,3,1,1,10,7,1,10,4,2,7,21,15,7,2,5,1,8,3,4,1,3,1,6,1,4,2,1,4,10,8,1,4,5,
+ 1,5,10,2,7,1,10,1,1,3,4,11,10,29,4,7,3,5,2,3,33,5,2,19,3,1,4,2,6,31,11,1,3,3,3,1,8,10,9,12,11,12,8,3,14,8,6,11,1,4,41,3,1,2,7,13,1,5,6,2,6,12,
+ 12,22,5,9,4,8,9,9,34,6,24,1,1,20,9,9,3,4,1,7,2,2,2,6,2,28,5,3,6,1,4,6,7,4,2,1,4,2,13,6,4,4,3,1,8,8,3,2,1,5,1,2,2,3,1,11,11,7,3,6,10,8,6,16,16,
+ 22,7,12,6,21,5,4,6,6,3,6,1,3,2,1,2,8,29,1,10,1,6,13,6,6,19,31,1,13,4,4,22,17,26,33,10,4,15,12,25,6,67,10,2,3,1,6,10,2,6,2,9,1,9,4,4,1,2,16,2,
+ 5,9,2,3,8,1,8,3,9,4,8,6,4,8,11,3,2,1,1,3,26,1,7,5,1,11,1,5,3,5,2,13,6,39,5,1,5,2,11,6,10,5,1,15,5,3,6,19,21,22,2,4,1,6,1,8,1,4,8,2,4,2,2,9,2,
+ 1,1,1,4,3,6,3,12,7,1,14,2,4,10,2,13,1,17,7,3,2,1,3,2,13,7,14,12,3,1,29,2,8,9,15,14,9,14,1,3,1,6,5,9,11,3,38,43,20,7,7,8,5,15,12,19,15,81,8,7,
+ 1,5,73,13,37,28,8,8,1,15,18,20,165,28,1,6,11,8,4,14,7,15,1,3,3,6,4,1,7,14,1,1,11,30,1,5,1,4,14,1,4,2,7,52,2,6,29,3,1,9,1,21,3,5,1,26,3,11,14,
+ 11,1,17,5,1,2,1,3,2,8,1,2,9,12,1,1,2,3,8,3,24,12,7,7,5,17,3,3,3,1,23,10,4,4,6,3,1,16,17,22,3,10,21,16,16,6,4,10,2,1,1,2,8,8,6,5,3,3,3,39,25,
+ 15,1,1,16,6,7,25,15,6,6,12,1,22,13,1,4,9,5,12,2,9,1,12,28,8,3,5,10,22,60,1,2,40,4,61,63,4,1,13,12,1,4,31,12,1,14,89,5,16,6,29,14,2,5,49,18,18,
+ 5,29,33,47,1,17,1,19,12,2,9,7,39,12,3,7,12,39,3,1,46,4,12,3,8,9,5,31,15,18,3,2,2,66,19,13,17,5,3,46,124,13,57,34,2,5,4,5,8,1,1,1,4,3,1,17,5,
+ 3,5,3,1,8,5,6,3,27,3,26,7,12,7,2,17,3,7,18,78,16,4,36,1,2,1,6,2,1,39,17,7,4,13,4,4,4,1,10,4,2,4,6,3,10,1,19,1,26,2,4,33,2,73,47,7,3,8,2,4,15,
+ 18,1,29,2,41,14,1,21,16,41,7,39,25,13,44,2,2,10,1,13,7,1,7,3,5,20,4,8,2,49,1,10,6,1,6,7,10,7,11,16,3,12,20,4,10,3,1,2,11,2,28,9,2,4,7,2,15,1,
+ 27,1,28,17,4,5,10,7,3,24,10,11,6,26,3,2,7,2,2,49,16,10,16,15,4,5,27,61,30,14,38,22,2,7,5,1,3,12,23,24,17,17,3,3,2,4,1,6,2,7,5,1,1,5,1,1,9,4,
+ 1,3,6,1,8,2,8,4,14,3,5,11,4,1,3,32,1,19,4,1,13,11,5,2,1,8,6,8,1,6,5,13,3,23,11,5,3,16,3,9,10,1,24,3,198,52,4,2,2,5,14,5,4,22,5,20,4,11,6,41,
+ 1,5,2,2,11,5,2,28,35,8,22,3,18,3,10,7,5,3,4,1,5,3,8,9,3,6,2,16,22,4,5,5,3,3,18,23,2,6,23,5,27,8,1,33,2,12,43,16,5,2,3,6,1,20,4,2,9,7,1,11,2,
+ 10,3,14,31,9,3,25,18,20,2,5,5,26,14,1,11,17,12,40,19,9,6,31,83,2,7,9,19,78,12,14,21,76,12,113,79,34,4,1,1,61,18,85,10,2,2,13,31,11,50,6,33,159,
+ 179,6,6,7,4,4,2,4,2,5,8,7,20,32,22,1,3,10,6,7,28,5,10,9,2,77,19,13,2,5,1,4,4,7,4,13,3,9,31,17,3,26,2,6,6,5,4,1,7,11,3,4,2,1,6,2,20,4,1,9,2,6,
+ 3,7,1,1,1,20,2,3,1,6,2,3,6,2,4,8,1,5,13,8,4,11,23,1,10,6,2,1,3,21,2,2,4,24,31,4,10,10,2,5,192,15,4,16,7,9,51,1,2,1,1,5,1,1,2,1,3,5,3,1,3,4,1,
+ 3,1,3,3,9,8,1,2,2,2,4,4,18,12,92,2,10,4,3,14,5,25,16,42,4,14,4,2,21,5,126,30,31,2,1,5,13,3,22,5,6,6,20,12,1,14,12,87,3,19,1,8,2,9,9,3,3,23,2,
+ 3,7,6,3,1,2,3,9,1,3,1,6,3,2,1,3,11,3,1,6,10,3,2,3,1,2,1,5,1,1,11,3,6,4,1,7,2,1,2,5,5,34,4,14,18,4,19,7,5,8,2,6,79,1,5,2,14,8,2,9,2,1,36,28,16,
+ 4,1,1,1,2,12,6,42,39,16,23,7,15,15,3,2,12,7,21,64,6,9,28,8,12,3,3,41,59,24,51,55,57,294,9,9,2,6,2,15,1,2,13,38,90,9,9,9,3,11,7,1,1,1,5,6,3,2,
+ 1,2,2,3,8,1,4,4,1,5,7,1,4,3,20,4,9,1,1,1,5,5,17,1,5,2,6,2,4,1,4,5,7,3,18,11,11,32,7,5,4,7,11,127,8,4,3,3,1,10,1,1,6,21,14,1,16,1,7,1,3,6,9,65,
+ 51,4,3,13,3,10,1,1,12,9,21,110,3,19,24,1,1,10,62,4,1,29,42,78,28,20,18,82,6,3,15,6,84,58,253,15,155,264,15,21,9,14,7,58,40,39,
+ };
+ static ImWchar base_ranges[] = // not zero-terminated
+ {
+ 0x0020, 0x00FF, // Basic Latin + Latin Supplement
+ 0x3000, 0x30FF, // Punctuations, Hiragana, Katakana
+ 0x31F0, 0x31FF, // Katakana Phonetic Extensions
+ 0xFF00, 0xFFEF, // Half-width characters
+ };
+ static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 };
+ if (!full_ranges[0])
+ {
+ memcpy(full_ranges, base_ranges, sizeof(base_ranges));
+ UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges));
+ }
+ return &full_ranges[0];
+}
+
+const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic()
+{
+ static const ImWchar ranges[] =
+ {
+ 0x0020, 0x00FF, // Basic Latin + Latin Supplement
+ 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement
+ 0x2DE0, 0x2DFF, // Cyrillic Extended-A
+ 0xA640, 0xA69F, // Cyrillic Extended-B
+ 0,
+ };
+ return &ranges[0];
+}
+
+const ImWchar* ImFontAtlas::GetGlyphRangesThai()
+{
+ static const ImWchar ranges[] =
+ {
+ 0x0020, 0x00FF, // Basic Latin
+ 0x2010, 0x205E, // Punctuations
+ 0x0E00, 0x0E7F, // Thai
+ 0,
+ };
+ return &ranges[0];
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImFontGlyphRangesBuilder
+//-----------------------------------------------------------------------------
+
+void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end)
+{
+ while (text_end ? (text < text_end) : *text)
+ {
+ unsigned int c = 0;
+ int c_len = ImTextCharFromUtf8(&c, text, text_end);
+ text += c_len;
+ if (c_len == 0)
+ break;
+ if (c < 0x10000)
+ AddChar((ImWchar)c);
+ }
+}
+
+void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
+{
+ for (; ranges[0]; ranges += 2)
+ for (ImWchar c = ranges[0]; c <= ranges[1]; c++)
+ AddChar(c);
+}
+
+void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
+{
+ for (int n = 0; n < 0x10000; n++)
+ if (GetBit(n))
+ {
+ out_ranges->push_back((ImWchar)n);
+ while (n < 0x10000 && GetBit(n + 1))
+ n++;
+ out_ranges->push_back((ImWchar)n);
+ }
+ out_ranges->push_back(0);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] ImFont
+//-----------------------------------------------------------------------------
+
+ImFont::ImFont()
+{
+ Scale = 1.0f;
+ FallbackChar = (ImWchar)'?';
+ DisplayOffset = ImVec2(0.0f, 0.0f);
+ ClearOutputData();
+}
+
+ImFont::~ImFont()
+{
+ // Invalidate active font so that the user gets a clear crash instead of a dangling pointer.
+ // If you want to delete fonts you need to do it between Render() and NewFrame().
+ // FIXME-CLEANUP
+ /*
+ ImGuiContext& g = *GImGui;
+ if (g.Font == this)
+ g.Font = NULL;
+ */
+ ClearOutputData();
+}
+
+void ImFont::ClearOutputData()
+{
+ FontSize = 0.0f;
+ Glyphs.clear();
+ IndexAdvanceX.clear();
+ IndexLookup.clear();
+ FallbackGlyph = NULL;
+ FallbackAdvanceX = 0.0f;
+ ConfigDataCount = 0;
+ ConfigData = NULL;
+ ContainerAtlas = NULL;
+ Ascent = Descent = 0.0f;
+ DirtyLookupTables = true;
+ MetricsTotalSurface = 0;
+}
+
+void ImFont::BuildLookupTable()
+{
+ int max_codepoint = 0;
+ for (int i = 0; i != Glyphs.Size; i++)
+ max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
+
+ IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
+ IndexAdvanceX.clear();
+ IndexLookup.clear();
+ DirtyLookupTables = false;
+ GrowIndex(max_codepoint + 1);
+ for (int i = 0; i < Glyphs.Size; i++)
+ {
+ int codepoint = (int)Glyphs[i].Codepoint;
+ IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX;
+ IndexLookup[codepoint] = (ImWchar)i;
+ }
+
+ // Create a glyph to handle TAB
+ // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
+ if (FindGlyph((ImWchar)' '))
+ {
+ if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times
+ Glyphs.resize(Glyphs.Size + 1);
+ ImFontGlyph& tab_glyph = Glyphs.back();
+ tab_glyph = *FindGlyph((ImWchar)' ');
+ tab_glyph.Codepoint = '\t';
+ tab_glyph.AdvanceX *= 4;
+ IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
+ IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
+ }
+
+ FallbackGlyph = FindGlyphNoFallback(FallbackChar);
+ FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
+ for (int i = 0; i < max_codepoint + 1; i++)
+ if (IndexAdvanceX[i] < 0.0f)
+ IndexAdvanceX[i] = FallbackAdvanceX;
+}
+
+void ImFont::SetFallbackChar(ImWchar c)
+{
+ FallbackChar = c;
+ BuildLookupTable();
+}
+
+void ImFont::GrowIndex(int new_size)
+{
+ IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size);
+ if (new_size <= IndexLookup.Size)
+ return;
+ IndexAdvanceX.resize(new_size, -1.0f);
+ IndexLookup.resize(new_size, (ImWchar)-1);
+}
+
+// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero.
+// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis).
+void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x)
+{
+ Glyphs.resize(Glyphs.Size + 1);
+ ImFontGlyph& glyph = Glyphs.back();
+ glyph.Codepoint = (ImWchar)codepoint;
+ glyph.X0 = x0;
+ glyph.Y0 = y0;
+ glyph.X1 = x1;
+ glyph.Y1 = y1;
+ glyph.U0 = u0;
+ glyph.V0 = v0;
+ glyph.U1 = u1;
+ glyph.V1 = v1;
+ glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX
+
+ if (ConfigData->PixelSnapH)
+ glyph.AdvanceX = (float)(int)(glyph.AdvanceX + 0.5f);
+
+ // Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
+ DirtyLookupTables = true;
+ MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f);
+}
+
+void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
+{
+ IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
+ int index_size = IndexLookup.Size;
+
+ if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists
+ return;
+ if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op
+ return;
+
+ GrowIndex(dst + 1);
+ IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1;
+ IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f;
+}
+
+const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
+{
+ if (c >= IndexLookup.Size)
+ return FallbackGlyph;
+ const ImWchar i = IndexLookup.Data[c];
+ if (i == (ImWchar)-1)
+ return FallbackGlyph;
+ return &Glyphs.Data[i];
+}
+
+const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
+{
+ if (c >= IndexLookup.Size)
+ return NULL;
+ const ImWchar i = IndexLookup.Data[c];
+ if (i == (ImWchar)-1)
+ return NULL;
+ return &Glyphs.Data[i];
+}
+
+const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const
+{
+ // Simple word-wrapping for English, not full-featured. Please submit failing cases!
+ // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.)
+
+ // For references, possible wrap point marked with ^
+ // "aaa bbb, ccc,ddd. eee fff. ggg!"
+ // ^ ^ ^ ^ ^__ ^ ^
+
+ // List of hardcoded separators: .,;!?'"
+
+ // Skip extra blanks after a line returns (that includes not counting them in width computation)
+ // e.g. "Hello world" --> "Hello" "World"
+
+ // Cut words that cannot possibly fit within one line.
+ // e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish"
+
+ float line_width = 0.0f;
+ float word_width = 0.0f;
+ float blank_width = 0.0f;
+ wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters
+
+ const char* word_end = text;
+ const char* prev_word_end = NULL;
+ bool inside_word = true;
+
+ const char* s = text;
+ while (s < text_end)
+ {
+ unsigned int c = (unsigned int)*s;
+ const char* next_s;
+ if (c < 0x80)
+ next_s = s + 1;
+ else
+ next_s = s + ImTextCharFromUtf8(&c, s, text_end);
+ if (c == 0)
+ break;
+
+ if (c < 32)
+ {
+ if (c == '\n')
+ {
+ line_width = word_width = blank_width = 0.0f;
+ inside_word = true;
+ s = next_s;
+ continue;
+ }
+ if (c == '\r')
+ {
+ s = next_s;
+ continue;
+ }
+ }
+
+ const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX);
+ if (ImCharIsBlankW(c))
+ {
+ if (inside_word)
+ {
+ line_width += blank_width;
+ blank_width = 0.0f;
+ word_end = s;
+ }
+ blank_width += char_width;
+ inside_word = false;
+ }
+ else
+ {
+ word_width += char_width;
+ if (inside_word)
+ {
+ word_end = next_s;
+ }
+ else
+ {
+ prev_word_end = word_end;
+ line_width += word_width + blank_width;
+ word_width = blank_width = 0.0f;
+ }
+
+ // Allow wrapping after punctuation.
+ inside_word = !(c == '.' || c == ',' || c == ';' || c == '!' || c == '?' || c == '\"');
+ }
+
+ // We ignore blank width at the end of the line (they can be skipped)
+ if (line_width + word_width >= wrap_width)
+ {
+ // Words that cannot possibly fit within an entire line will be cut anywhere.
+ if (word_width < wrap_width)
+ s = prev_word_end ? prev_word_end : word_end;
+ break;
+ }
+
+ s = next_s;
+ }
+
+ return s;
+}
+
+ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const
+{
+ if (!text_end)
+ text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this.
+
+ const float line_height = size;
+ const float scale = size / FontSize;
+
+ ImVec2 text_size = ImVec2(0,0);
+ float line_width = 0.0f;
+
+ const bool word_wrap_enabled = (wrap_width > 0.0f);
+ const char* word_wrap_eol = NULL;
+
+ const char* s = text_begin;
+ while (s < text_end)
+ {
+ if (word_wrap_enabled)
+ {
+ // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
+ if (!word_wrap_eol)
+ {
+ word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width);
+ if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
+ word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
+ }
+
+ if (s >= word_wrap_eol)
+ {
+ if (text_size.x < line_width)
+ text_size.x = line_width;
+ text_size.y += line_height;
+ line_width = 0.0f;
+ word_wrap_eol = NULL;
+
+ // Wrapping skips upcoming blanks
+ while (s < text_end)
+ {
+ const char c = *s;
+ if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
+ }
+ continue;
+ }
+ }
+
+ // Decode and advance source
+ const char* prev_s = s;
+ unsigned int c = (unsigned int)*s;
+ if (c < 0x80)
+ {
+ s += 1;
+ }
+ else
+ {
+ s += ImTextCharFromUtf8(&c, s, text_end);
+ if (c == 0) // Malformed UTF-8?
+ break;
+ }
+
+ if (c < 32)
+ {
+ if (c == '\n')
+ {
+ text_size.x = ImMax(text_size.x, line_width);
+ text_size.y += line_height;
+ line_width = 0.0f;
+ continue;
+ }
+ if (c == '\r')
+ continue;
+ }
+
+ const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX) * scale;
+ if (line_width + char_width >= max_width)
+ {
+ s = prev_s;
+ break;
+ }
+
+ line_width += char_width;
+ }
+
+ if (text_size.x < line_width)
+ text_size.x = line_width;
+
+ if (line_width > 0 || text_size.y == 0.0f)
+ text_size.y += line_height;
+
+ if (remaining)
+ *remaining = s;
+
+ return text_size;
+}
+
+void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
+{
+ if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
+ return;
+ if (const ImFontGlyph* glyph = FindGlyph(c))
+ {
+ float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
+ pos.x = (float)(int)pos.x + DisplayOffset.x;
+ pos.y = (float)(int)pos.y + DisplayOffset.y;
+ draw_list->PrimReserve(6, 4);
+ draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
+ }
+}
+
+void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
+{
+ if (!text_end)
+ text_end = text_begin + strlen(text_begin); // ImGui functions generally already provides a valid text_end, so this is merely to handle direct calls.
+
+ // Align to be pixel perfect
+ pos.x = (float)(int)pos.x + DisplayOffset.x;
+ pos.y = (float)(int)pos.y + DisplayOffset.y;
+ float x = pos.x;
+ float y = pos.y;
+ if (y > clip_rect.w)
+ return;
+
+ const float scale = size / FontSize;
+ const float line_height = FontSize * scale;
+ const bool word_wrap_enabled = (wrap_width > 0.0f);
+ const char* word_wrap_eol = NULL;
+
+ // Fast-forward to first visible line
+ const char* s = text_begin;
+ if (y + line_height < clip_rect.y && !word_wrap_enabled)
+ while (y + line_height < clip_rect.y && s < text_end)
+ {
+ s = (const char*)memchr(s, '\n', text_end - s);
+ s = s ? s + 1 : text_end;
+ y += line_height;
+ }
+
+ // For large text, scan for the last visible line in order to avoid over-reserving in the call to PrimReserve()
+ // Note that very large horizontal line will still be affected by the issue (e.g. a one megabyte string buffer without a newline will likely crash atm)
+ if (text_end - s > 10000 && !word_wrap_enabled)
+ {
+ const char* s_end = s;
+ float y_end = y;
+ while (y_end < clip_rect.w && s_end < text_end)
+ {
+ s_end = (const char*)memchr(s_end, '\n', text_end - s_end);
+ s_end = s_end ? s_end + 1 : text_end;
+ y_end += line_height;
+ }
+ text_end = s_end;
+ }
+ if (s == text_end)
+ return;
+
+ // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized)
+ const int vtx_count_max = (int)(text_end - s) * 4;
+ const int idx_count_max = (int)(text_end - s) * 6;
+ const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max;
+ draw_list->PrimReserve(idx_count_max, vtx_count_max);
+
+ ImDrawVert* vtx_write = draw_list->_VtxWritePtr;
+ ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
+ unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx;
+
+ while (s < text_end)
+ {
+ if (word_wrap_enabled)
+ {
+ // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
+ if (!word_wrap_eol)
+ {
+ word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x));
+ if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
+ word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
+ }
+
+ if (s >= word_wrap_eol)
+ {
+ x = pos.x;
+ y += line_height;
+ word_wrap_eol = NULL;
+
+ // Wrapping skips upcoming blanks
+ while (s < text_end)
+ {
+ const char c = *s;
+ if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; }
+ }
+ continue;
+ }
+ }
+
+ // Decode and advance source
+ unsigned int c = (unsigned int)*s;
+ if (c < 0x80)
+ {
+ s += 1;
+ }
+ else
+ {
+ s += ImTextCharFromUtf8(&c, s, text_end);
+ if (c == 0) // Malformed UTF-8?
+ break;
+ }
+
+ if (c < 32)
+ {
+ if (c == '\n')
+ {
+ x = pos.x;
+ y += line_height;
+ if (y > clip_rect.w)
+ break; // break out of main loop
+ continue;
+ }
+ if (c == '\r')
+ continue;
+ }
+
+ float char_width = 0.0f;
+ if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c))
+ {
+ char_width = glyph->AdvanceX * scale;
+
+ // Arbitrarily assume that both space and tabs are empty glyphs as an optimization
+ if (c != ' ' && c != '\t')
+ {
+ // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
+ float x1 = x + glyph->X0 * scale;
+ float x2 = x + glyph->X1 * scale;
+ float y1 = y + glyph->Y0 * scale;
+ float y2 = y + glyph->Y1 * scale;
+ if (x1 <= clip_rect.z && x2 >= clip_rect.x)
+ {
+ // Render a character
+ float u1 = glyph->U0;
+ float v1 = glyph->V0;
+ float u2 = glyph->U1;
+ float v2 = glyph->V1;
+
+ // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
+ if (cpu_fine_clip)
+ {
+ if (x1 < clip_rect.x)
+ {
+ u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1);
+ x1 = clip_rect.x;
+ }
+ if (y1 < clip_rect.y)
+ {
+ v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1);
+ y1 = clip_rect.y;
+ }
+ if (x2 > clip_rect.z)
+ {
+ u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1);
+ x2 = clip_rect.z;
+ }
+ if (y2 > clip_rect.w)
+ {
+ v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1);
+ y2 = clip_rect.w;
+ }
+ if (y1 >= y2)
+ {
+ x += char_width;
+ continue;
+ }
+ }
+
+ // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here:
+ {
+ idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
+ idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
+ vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
+ vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
+ vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
+ vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2;
+ vtx_write += 4;
+ vtx_current_idx += 4;
+ idx_write += 6;
+ }
+ }
+ }
+ }
+
+ x += char_width;
+ }
+
+ // Give back unused vertices
+ draw_list->VtxBuffer.resize((int)(vtx_write - draw_list->VtxBuffer.Data));
+ draw_list->IdxBuffer.resize((int)(idx_write - draw_list->IdxBuffer.Data));
+ draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
+ draw_list->_VtxWritePtr = vtx_write;
+ draw_list->_IdxWritePtr = idx_write;
+ draw_list->_VtxCurrentIdx = (unsigned int)draw_list->VtxBuffer.Size;
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Internal Render Helpers
+// (progressively moved from imgui.cpp to here when they are redesigned to stop accessing ImGui global state)
+//-----------------------------------------------------------------------------
+// - RenderMouseCursor()
+// - RenderArrowPointingAt()
+// - RenderRectFilledRangeH()
+// - RenderPixelEllipsis()
+//-----------------------------------------------------------------------------
+
+void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor)
+{
+ if (mouse_cursor == ImGuiMouseCursor_None)
+ return;
+ IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
+
+ const ImU32 col_shadow = IM_COL32(0, 0, 0, 48);
+ const ImU32 col_border = IM_COL32(0, 0, 0, 255); // Black
+ const ImU32 col_fill = IM_COL32(255, 255, 255, 255); // White
+
+ ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas;
+ ImVec2 offset, size, uv[4];
+ if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
+ {
+ pos -= offset;
+ const ImTextureID tex_id = font_atlas->TexID;
+ draw_list->PushTextureID(tex_id);
+ draw_list->AddImage(tex_id, pos + ImVec2(1,0)*scale, pos + ImVec2(1,0)*scale + size*scale, uv[2], uv[3], col_shadow);
+ draw_list->AddImage(tex_id, pos + ImVec2(2,0)*scale, pos + ImVec2(2,0)*scale + size*scale, uv[2], uv[3], col_shadow);
+ draw_list->AddImage(tex_id, pos, pos + size*scale, uv[2], uv[3], col_border);
+ draw_list->AddImage(tex_id, pos, pos + size*scale, uv[0], uv[1], col_fill);
+ draw_list->PopTextureID();
+ }
+}
+
+// Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side.
+void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col)
+{
+ switch (direction)
+ {
+ case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return;
+ case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
+ case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
+ case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
+ case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings
+ }
+}
+
+static inline float ImAcos01(float x)
+{
+ if (x <= 0.0f) return IM_PI * 0.5f;
+ if (x >= 1.0f) return 0.0f;
+ return ImAcos(x);
+ //return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do.
+}
+
+// FIXME: Cleanup and move code to ImDrawList.
+void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding)
+{
+ if (x_end_norm == x_start_norm)
+ return;
+ if (x_start_norm > x_end_norm)
+ ImSwap(x_start_norm, x_end_norm);
+
+ ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y);
+ ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y);
+ if (rounding == 0.0f)
+ {
+ draw_list->AddRectFilled(p0, p1, col, 0.0f);
+ return;
+ }
+
+ rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding);
+ const float inv_rounding = 1.0f / rounding;
+ const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding);
+ const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding);
+ const float x0 = ImMax(p0.x, rect.Min.x + rounding);
+ if (arc0_b == arc0_e)
+ {
+ draw_list->PathLineTo(ImVec2(x0, p1.y));
+ draw_list->PathLineTo(ImVec2(x0, p0.y));
+ }
+ else if (arc0_b == 0.0f && arc0_e == IM_PI*0.5f)
+ {
+ draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL
+ draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR
+ }
+ else
+ {
+ draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL
+ draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR
+ }
+ if (p1.x > rect.Min.x + rounding)
+ {
+ const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding);
+ const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding);
+ const float x1 = ImMin(p1.x, rect.Max.x - rounding);
+ if (arc1_b == arc1_e)
+ {
+ draw_list->PathLineTo(ImVec2(x1, p0.y));
+ draw_list->PathLineTo(ImVec2(x1, p1.y));
+ }
+ else if (arc1_b == 0.0f && arc1_e == IM_PI*0.5f)
+ {
+ draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR
+ draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR
+ }
+ else
+ {
+ draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR
+ draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR
+ }
+ }
+ draw_list->PathFillConvex(col);
+}
+
+// FIXME: Rendering an ellipsis "..." is a surprisingly tricky problem for us... we cannot rely on font glyph having it,
+// and regular dot are typically too wide. If we render a dot/shape ourselves it comes with the risk that it wouldn't match
+// the boldness or positioning of what the font uses...
+void ImGui::RenderPixelEllipsis(ImDrawList* draw_list, ImVec2 pos, int count, ImU32 col)
+{
+ ImFont* font = draw_list->_Data->Font;
+ pos.y += (float)(int)(font->DisplayOffset.y + font->Ascent + 0.5f - 1.0f);
+ for (int dot_n = 0; dot_n < count; dot_n++)
+ draw_list->AddRectFilled(ImVec2(pos.x + dot_n * 2.0f, pos.y), ImVec2(pos.x + dot_n * 2.0f + 1.0f, pos.y + 1.0f), col);
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Decompression code
+//-----------------------------------------------------------------------------
+// Compressed with stb_compress() then converted to a C array and encoded as base85.
+// Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file.
+// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
+// Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h
+//-----------------------------------------------------------------------------
+
+static unsigned int stb_decompress_length(const unsigned char *input)
+{
+ return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11];
+}
+
+static unsigned char *stb__barrier_out_e, *stb__barrier_out_b;
+static const unsigned char *stb__barrier_in_b;
+static unsigned char *stb__dout;
+static void stb__match(const unsigned char *data, unsigned int length)
+{
+ // INVERSE of memmove... write each byte before copying the next...
+ IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
+ if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
+ if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; }
+ while (length--) *stb__dout++ = *data++;
+}
+
+static void stb__lit(const unsigned char *data, unsigned int length)
+{
+ IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
+ if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
+ if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; }
+ memcpy(stb__dout, data, length);
+ stb__dout += length;
+}
+
+#define stb__in2(x) ((i[x] << 8) + i[(x)+1])
+#define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1))
+#define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1))
+
+static const unsigned char *stb_decompress_token(const unsigned char *i)
+{
+ if (*i >= 0x20) { // use fewer if's for cases that expand small
+ if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2;
+ else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3;
+ else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
+ } else { // more ifs for cases that expand large, since overhead is amortized
+ if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4;
+ else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5;
+ else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1);
+ else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1);
+ else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5;
+ else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6;
+ }
+ return i;
+}
+
+static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen)
+{
+ const unsigned long ADLER_MOD = 65521;
+ unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
+ unsigned long blocklen, i;
+
+ blocklen = buflen % 5552;
+ while (buflen) {
+ for (i=0; i + 7 < blocklen; i += 8) {
+ s1 += buffer[0], s2 += s1;
+ s1 += buffer[1], s2 += s1;
+ s1 += buffer[2], s2 += s1;
+ s1 += buffer[3], s2 += s1;
+ s1 += buffer[4], s2 += s1;
+ s1 += buffer[5], s2 += s1;
+ s1 += buffer[6], s2 += s1;
+ s1 += buffer[7], s2 += s1;
+
+ buffer += 8;
+ }
+
+ for (; i < blocklen; ++i)
+ s1 += *buffer++, s2 += s1;
+
+ s1 %= ADLER_MOD, s2 %= ADLER_MOD;
+ buflen -= blocklen;
+ blocklen = 5552;
+ }
+ return (unsigned int)(s2 << 16) + (unsigned int)s1;
+}
+
+static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/)
+{
+ unsigned int olen;
+ if (stb__in4(0) != 0x57bC0000) return 0;
+ if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
+ olen = stb_decompress_length(i);
+ stb__barrier_in_b = i;
+ stb__barrier_out_e = output + olen;
+ stb__barrier_out_b = output;
+ i += 16;
+
+ stb__dout = output;
+ for (;;) {
+ const unsigned char *old_i = i;
+ i = stb_decompress_token(i);
+ if (i == old_i) {
+ if (*i == 0x05 && i[1] == 0xfa) {
+ IM_ASSERT(stb__dout == output + olen);
+ if (stb__dout != output + olen) return 0;
+ if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2))
+ return 0;
+ return olen;
+ } else {
+ IM_ASSERT(0); /* NOTREACHED */
+ return 0;
+ }
+ }
+ IM_ASSERT(stb__dout <= output + olen);
+ if (stb__dout > output + olen)
+ return 0;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// [SECTION] Default font data (ProggyClean.ttf)
+//-----------------------------------------------------------------------------
+// ProggyClean.ttf
+// Copyright (c) 2004, 2005 Tristan Grimmer
+// MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip)
+// Download and more information at http://upperbounds.net
+//-----------------------------------------------------------------------------
+// File: 'ProggyClean.ttf' (41208 bytes)
+// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
+// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
+//-----------------------------------------------------------------------------
+static const char proggy_clean_ttf_compressed_data_base85[11980+1] =
+ "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
+ "2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
+ "`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
+ "i@^rMl9t=cWq6##weg>$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;-<nLENhvx>-VsM.M0rJfLH2eTM`*oJMHRC`N"
+ "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`&#0j@'DbG&#^$PG.Ll+DNa<XCMKEV*N)LN/N"
+ "*b=%Q6pia-Xg8I$<MR&,VdJe$<(7G;Ckl'&hF;;$<_=X(b.RS%%)###MPBuuE1V:v&cX&#2m#(&cV]`k9OhLMbn%s$G2,B$BfD3X*sp5#l,$R#]x_X1xKX%b5U*[r5iMfUo9U`N99hG)"
+ "tm+/Us9pG)XPu`<0s-)WTt(gCRxIg(%6sfh=ktMKn3j)<6<b5Sk_/0(^]AaN#(p/L>&VZ>1i%h1S9u5o@YaaW$e+b<TWFn/Z:Oh(Cx2$lNEoN^e)#CFY@@I;BOQ*sRwZtZxRcU7uW6CX"
+ "ow0i(?$Q[cjOd[P4d)]>ROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc."
+ "x]Ip.PH^'/aqUO/$1WxLoW0[iLA<QT;5HKD+@qQ'NQ(3_PLhE48R.qAPSwQ0/WK?Z,[x?-J;jQTWA0X@KJ(_Y8N-:/M74:/-ZpKrUss?d#dZq]DAbkU*JqkL+nwX@@47`5>w=4h(9.`G"
+ "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?G<Nald$qs]@]L<J7bR*>gv:[7MI2k).'2($5FNP&EQ(,)"
+ "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#"
+ "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM"
+ "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0<q-]L_?^)1vw'.,MRsqVr.L;aN&#/EgJ)PBc[-f>+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu"
+ "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/"
+ "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[K<L"
+ "%a2E-grWVM3@2=-k22tL]4$##6We'8UJCKE[d_=%wI;'6X-GsLX4j^SgJ$##R*w,vP3wK#iiW&#*h^D&R?jp7+/u&#(AP##XU8c$fSYW-J95_-Dp[g9wcO&#M-h1OcJlc-*vpw0xUX&#"
+ "OQFKNX@QI'IoPp7nb,QU//MQ&ZDkKP)X<WSVL(68uVl&#c'[0#(s1X&xm$Y%B7*K:eDA323j998GXbA#pwMs-jgD$9QISB-A_(aN4xoFM^@C58D0+Q+q3n0#3U1InDjF682-SjMXJK)("
+ "h$hxua_K]ul92%'BOU&#BRRh-slg8KDlr:%L71Ka:.A;%YULjDPmL<LYs8i#XwJOYaKPKc1h:'9Ke,g)b),78=I39B;xiY$bgGw-&.Zi9InXDuYa%G*f2Bq7mn9^#p1vv%#(Wi-;/Z5h"
+ "o;#2:;%d&#x9v68C5g?ntX0X)pT`;%pB3q7mgGN)3%(P8nTd5L7GeA-GL@+%J3u2:(Yf>et`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO"
+ "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J<j$UpK<Q4a1]MupW^-"
+ "sj_$%[HK%'F####QRZJ::Y3EGl4'@%FkiAOg#p[##O`gukTfBHagL<LHw%q&OV0##F=6/:chIm0@eCP8X]:kFI%hl8hgO@RcBhS-@Qb$%+m=hPDLg*%K8ln(wcf3/'DW-$.lR?n[nCH-"
+ "eXOONTJlh:.RYF%3'p6sq:UIMA945&^HFS87@$EP2iG<-lCO$%c`uKGD3rC$x0BL8aFn--`ke%#HMP'vh1/R&O_J9'um,.<tx[@%wsJk&bUT2`0uMv7gg#qp/ij.L56'hl;.s5CUrxjO"
+ "M7-##.l+Au'A&O:-T72L]P`&=;ctp'XScX*rU.>-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%"
+ "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$M<Jnq79VsJW/mWS*PUiq76;]/NM_>hLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]"
+ "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et"
+ "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$<M-SGZ':+Q_k+uvOSLiEo(<aD/K<CCc`'Lx>'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:"
+ "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VB<HFF*qL("
+ "$/V,;(kXZejWO`<[5?\?ewY(*9=%wDc;,u<'9t3W-(H1th3+G]ucQ]kLs7df($/*JL]@*t7Bu_G3_7mp7<iaQjO@.kLg;x3B0lqp7Hf,^Ze7-##@/c58Mo(3;knp0%)A7?-W+eI'o8)b<"
+ "nKnw'Ho8C=Y>pqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<<aG/1N$#FX$0V5Y6x'aErI3I$7x%E`v<-BY,)%-?Psf*l?%C3.mM(=/M0:JxG'?"
+ "7WhH%o'a<-80g0NBxoO(GH<dM]n.+%q@jH?f.UsJ2Ggs&4<-e47&Kl+f//9@`b+?.TeN_&B8Ss?v;^Trk;f#YvJkl&w$]>-+k?'(<S:68tq*WoDfZu';mM?8X[ma8W%*`-=;D.(nc7/;"
+ ")g:T1=^J$&BRV(-lTmNB6xqB[@0*o.erM*<SWF]u2=st-*(6v>^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M"
+ "D?@f&1'BW-)Ju<L25gl8uhVm1hL$##*8###'A3/LkKW+(^rWX?5W_8g)a(m&K8P>#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX("
+ "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs"
+ "bIu)'Z,*[>br5fX^:FPAWr-m2KgL<LUN098kTF&#lvo58=/vjDo;.;)Ka*hLR#/k=rKbxuV`>Q_nN6'8uTG&#1T5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q"
+ "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aeg<Z'<$#4H)6,>e0jT6'N#(q%.O=?2S]u*(m<-"
+ "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i"
+ "sZ88+dKQ)W6>J%CL<KE>`.d*(B`-n8D9oK<Up]c$X$(,)M8Zt7/[rdkqTgl-0cuGMv'?>-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P&#9r+$%CE=68>K8r0=dSC%%(@p7"
+ ".m7jilQ02'0-VWAg<a/''3u.=4L$Y)6k/K:_[3=&jvL<L0C/2'v:^;-DIBW,B4E68:kZ;%?8(Q8BH=kO65BW?xSG&#@uU,DS*,?.+(o(#1vCS8#CHF>TlGW'b)Tq7VT9q^*^$$.:&N@@"
+ "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*"
+ "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u"
+ "@-W$U%VEQ/,,>>#)D<h#`)h0:<Q6909ua+&VU%n2:cG3FJ-%@Bj-DgLr`Hw&HAKjKjseK</xKT*)B,N9X3]krc12t'pgTV(Lv-tL[xg_%=M_q7a^x?7Ubd>#%8cY#YZ?=,`Wdxu/ae&#"
+ "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$s<Eh#c&)q.MXI%#v9ROa5FZO%sF7q7Nwb&#ptUJ:aqJe$Sl68%.D###EC><?-aF&#RNQv>o8lKN%5/$(vdfq7+ebA#"
+ "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(<c`Q8N)jEIF*+?P2a8g%)$q]o2aH8C&<SibC/q,(e:v;-b#6[$NtDZ84Je2KNvB#$P5?tQ3nt(0"
+ "d=j.LQf./Ll33+(;q3L-w=8dX$#WF&uIJ@-bfI>%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoF&#4DoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8"
+ "6e%B/:=>)N4xeW.*wft-;$'58-ESqr<b?UI(_%@[P46>#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#"
+ "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjL<Lni;''X.`$#8+1GD"
+ ":k$YUWsbn8ogh6rxZ2Z9]%nd+>V#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#<NEdtg(n'=S1A(Q1/I&4([%dM`,Iu'1:_hL>SfD07&6D<fp8dHM7/g+"
+ "tlPN9J*rKaPct&?'uBCem^jn%9_K)<,C5K3s=5g&GmJb*[SYq7K;TRLGCsM-$$;S%:Y@r7AK0pprpL<Lrh,q7e/%KWK:50I^+m'vi`3?%Zp+<-d+$L-Sv:@.o19n$s0&39;kn;S%BSq*"
+ "$3WoJSCLweV[aZ'MQIjO<7;X-X;&+dMLvu#^UsGEC9WEc[X(wI7#2.(F0jV*eZf<-Qv3J-c+J5AlrB#$p(H68LvEA'q3n0#m,[`*8Ft)FcYgEud]CWfm68,(aLA$@EFTgLXoBq/UPlp7"
+ ":d[/;r_ix=:TF`S5H-b<LI&HY(K=h#)]Lk$K14lVfm:x$H<3^Ql<M`$OhapBnkup'D#L$Pb_`N*g]2e;X/Dtg,bsj&K#2[-:iYr'_wgH)NUIR8a1n#S?Yej'h8^58UbZd+^FKD*T@;6A"
+ "7aQC[K8d-(v6GI$x:T<&'Gp5Uf>@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-<aN((^7('#Z0wK#5GX@7"
+ "u][`*S^43933A4rl][`*O4CgLEl]v$1Q3AeF37dbXk,.)vj#x'd`;qgbQR%FW,2(?LO=s%Sc68%NP'##Aotl8x=BE#j1UD([3$M(]UI2LX3RpKN@;/#f'f/&_mt&F)XdF<9t4)Qa.*kT"
+ "LwQ'(TTB9.xH'>#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5<N?)NBS)QN*_I,?&)2'IM%L3I)X((e/dl2&8'<M"
+ ":^#M*Q+[T.Xri.LYS3v%fF`68h;b-X[/En'CR.q7E)p'/kle2HM,u;^%OKC-N+Ll%F9CF<Nf'^#t2L,;27W:0O@6##U6W7:$rJfLWHj$#)woqBefIZ.PK<b*t7ed;p*_m;4ExK#h@&]>"
+ "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%"
+ "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;"
+ "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmL<LD)F^%[tC'8;+9E#C$g%#5Y>q9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:"
+ "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3<n-&%H%b<FDj2M<hH=&Eh<2Len$b*aTX=-8QxN)k11IM1c^j%"
+ "9s<L<NFSo)B?+<-(GxsF,^-Eh@$4dXhN$+#rxK8'je'D7k`e;)2pYwPA'_p9&@^18ml1^[@g4t*[JOa*[=Qp7(qJ_oOL^('7fB&Hq-:sf,sNj8xq^>$U4O]GKx'm9)b@p7YsvK3w^YR-"
+ "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*"
+ "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdF<TddF<9Ah-6&9tWoDlh]&1SpGMq>Ti1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IX<N+T+0MlMBPQ*Vj>SsD<U4JHY"
+ "8kD2)2fU/M#$e.)T4,_=8hLim[&);?UkK'-x?'(:siIfL<$pFM`i<?%W(mGDHM%>iWP,##P`%/L<eXi:@Z9C.7o=@(pXdAO/NLQ8lPl+HPOQa8wD8=^GlPa8TKI1CjhsCTSLJM'/Wl>-"
+ "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n<bhPmUkMw>%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL<LoNs'6,'85`"
+ "0?t/'_U59@]ddF<#LdF<eWdF<OuN/45rY<-L@&#+fm>69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdF<gR@2L=FNU-<b[(9c/ML3m;Z[$oF3g)GAWqpARc=<ROu7cL5l;-[A]%/"
+ "+fsd;l#SafT/f*W]0=O'$(Tb<[)*@e775R-:Yob%g*>l*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj"
+ "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#<IGe;__.thjZl<%w(Wk2xmp4Q@I#I9,DF]u7-P=.-_:YJ]aS@V"
+ "?6*C()dOp7:WL,b&3Rg/.cmM9&r^>$(>.Z-I&J(Q0Hd5Q%7Co-b`-c<N(6r@ip+AurK<m86QIth*#v;-OBqi+L7wDE-Ir8K['m+DDSLwK&/.?-V%U_%3:qKNu$_b*B-kp7NaD'QdWQPK"
+ "Yq[@>P)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8<FfNkgg^oIbah*#8/Qt$F&:K*-(N/'+1vMB,u()-a.VUU*#[e%gAAO(S>WlA2);Sa"
+ ">gXm8YB`1d@K#n]76-a$U,mF<fX]idqd)<3,]J7JmW4`6]uks=4-72L(jEk+:bJ0M^q-8Dm_Z?0olP1C9Sa&H[d&c$ooQUj]Exd*3ZM@-WGW2%s',B-_M%>%Ul:#/'xoFM9QX-$.QN'>"
+ "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B</R90;eZ]%Ncq;-Tl]#F>2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I"
+ "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1<Vc52=u`3^o-n1'g4v58Hj&6_t7$##?M)c<$bgQ_'SY((-xkA#"
+ "Y(,p'H9rIVY-b,'%bCPF7.J<Up^,(dU1VY*5#WkTU>h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-u<Hp,3@e^9UB1J+ak9-TN/mhKPg+AJYd$"
+ "MlvAF_jCK*.O-^(63adMT->W%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)"
+ "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo"
+ "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P"
+ "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*<h`e-GI7)?OK2A.d7_c)?wQ5AS@DL3r#7fSkgl6-++D:'A,uq7SvlB$pcpH'q3n0#_%dY#xCpr-l<F0NR@-##FEV6NTF6##$l84N1w?AO>'IAO"
+ "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#"
+ ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T<XoIB&hx=T1PcDaB&;HH+-AFr?(m9HZV)FKS8JCw;SD=6[^/DZUL`EUDf]GGlG&>"
+ "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#<xU?#@.i?#D:%@#HF7@#LRI@#P_[@#Tkn@#Xw*A#]-=A#a9OA#"
+ "d<F&#*;G##.GY##2Sl##6`($#:l:$#>xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4&#3^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4"
+ "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#"
+ "/QHC#3^ZC#7jmC#;v)D#?,<D#C8ND#GDaD#KPsD#O]/E#g1A5#KA*1#gC17#MGd;#8(02#L-d3#rWM4#Hga1#,<w0#T.j<#O#'2#CYN1#qa^:#_4m3#o@/=#eG8=#t8J5#`+78#4uI-#"
+ "m3B2#SB[8#Q0@8#i[*9#iOn8#1Nm;#^sN9#qh<9#:=x-#P;K2#$%X9#bC+.#Rg;<#mN=.#MTF.#RZO.#2?)4#Y#(/#[)1/#b;L/#dAU/#0Sv;#lY$0#n`-0#sf60#(F24#wrH0#%/e0#"
+ "TmD<#%JSMFove:CTBEXI:<eh2g)B,3h2^G3i;#d3jD>)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP"
+ "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
+ "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
+
+static const char* GetDefaultCompressedFontDataTTFBase85()
+{
+ return proggy_clean_ttf_compressed_data_base85;
+}
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imgui_internal.h b/Client/ThirdParty/Box2D/extern/imgui/imgui_internal.h
new file mode 100644
index 0000000..51f3a3f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imgui_internal.h
@@ -0,0 +1,1466 @@
+// dear imgui, v1.67 WIP
+// (internal structures/api)
+
+// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
+// Set:
+// #define IMGUI_DEFINE_MATH_OPERATORS
+// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
+
+/*
+
+Index of this file:
+// Header mess
+// Forward declarations
+// STB libraries includes
+// Context pointer
+// Generic helpers
+// Misc data structures
+// Main imgui context
+// Tab bar, tab item
+// Internal API
+
+*/
+
+#pragma once
+
+//-----------------------------------------------------------------------------
+// Header mess
+//-----------------------------------------------------------------------------
+
+#ifndef IMGUI_VERSION
+#error Must include imgui.h before imgui_internal.h
+#endif
+
+#include <stdio.h> // FILE*
+#include <stdlib.h> // NULL, malloc, free, qsort, atoi, atof
+#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
+#include <limits.h> // INT_MIN, INT_MAX
+
+#ifdef _MSC_VER
+#pragma warning (push)
+#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
+#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
+#pragma clang diagnostic ignored "-Wold-style-cast"
+#endif
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+
+struct ImRect; // An axis-aligned rectangle (2 points)
+struct ImDrawDataBuilder; // Helper to build a ImDrawData instance
+struct ImDrawListSharedData; // Data shared between all ImDrawList instances
+struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it
+struct ImGuiColumnData; // Storage data for a single column
+struct ImGuiColumnsSet; // Storage data for a columns set
+struct ImGuiContext; // Main imgui context
+struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
+struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
+struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
+struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
+struct ImGuiNavMoveResult; // Result of a directional navigation move query result
+struct ImGuiNextWindowData; // Storage for SetNexWindow** functions
+struct ImGuiPopupRef; // Storage for current popup stack
+struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
+struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
+struct ImGuiTabBar; // Storage for a tab bar
+struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
+struct ImGuiWindow; // Storage for one window
+struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
+struct ImGuiWindowSettings; // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
+
+// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
+typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
+typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior()
+typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag()
+typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags
+typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
+typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d()
+typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests
+typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for Separator() - internal
+typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for SliderBehavior()
+typedef int ImGuiDragFlags; // -> enum ImGuiDragFlags_ // Flags: for DragBehavior()
+
+//-------------------------------------------------------------------------
+// STB libraries includes
+//-------------------------------------------------------------------------
+
+namespace ImGuiStb
+{
+
+#undef STB_TEXTEDIT_STRING
+#undef STB_TEXTEDIT_CHARTYPE
+#define STB_TEXTEDIT_STRING ImGuiInputTextState
+#define STB_TEXTEDIT_CHARTYPE ImWchar
+#define STB_TEXTEDIT_GETWIDTH_NEWLINE -1.0f
+#include "imstb_textedit.h"
+
+} // namespace ImGuiStb
+
+//-----------------------------------------------------------------------------
+// Context pointer
+//-----------------------------------------------------------------------------
+
+#ifndef GImGui
+extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointer
+#endif
+
+//-----------------------------------------------------------------------------
+// Generic helpers
+//-----------------------------------------------------------------------------
+
+#define IM_PI 3.14159265358979323846f
+#ifdef _WIN32
+#define IM_NEWLINE "\r\n" // Play it nice with Windows users (2018/05 news: Microsoft announced that Notepad will finally display Unix-style carriage returns!)
+#else
+#define IM_NEWLINE "\n"
+#endif
+#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
+#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
+#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
+#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
+
+// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
+#ifdef _MSC_VER
+#define IMGUI_CDECL __cdecl
+#else
+#define IMGUI_CDECL
+#endif
+
+// Helpers: UTF-8 <> wchar
+IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
+IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
+IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
+IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
+IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
+IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
+
+// Helpers: Misc
+IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
+IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
+IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
+static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
+static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
+static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
+static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
+#define ImQsort qsort
+
+// Helpers: Geometry
+IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
+IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
+IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
+IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
+IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy);
+
+// Helpers: String
+IMGUI_API int ImStricmp(const char* str1, const char* str2);
+IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
+IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
+IMGUI_API char* ImStrdup(const char* str);
+IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
+IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c);
+IMGUI_API int ImStrlenW(const ImWchar* str);
+IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line
+IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
+IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
+IMGUI_API void ImStrTrimBlanks(char* str);
+IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
+IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
+IMGUI_API const char* ImParseFormatFindStart(const char* format);
+IMGUI_API const char* ImParseFormatFindEnd(const char* format);
+IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, int buf_size);
+IMGUI_API int ImParseFormatPrecision(const char* format, int default_value);
+
+// Helpers: ImVec2/ImVec4 operators
+// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
+// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
+#ifdef IMGUI_DEFINE_MATH_OPERATORS
+static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
+static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
+static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
+static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
+static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
+static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
+static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
+static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
+static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
+static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
+static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
+static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
+static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
+#endif
+
+// Helpers: Maths
+// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
+#ifndef IMGUI_DISABLE_MATH_FUNCTIONS
+static inline float ImFabs(float x) { return fabsf(x); }
+static inline float ImSqrt(float x) { return sqrtf(x); }
+static inline float ImPow(float x, float y) { return powf(x, y); }
+static inline double ImPow(double x, double y) { return pow(x, y); }
+static inline float ImFmod(float x, float y) { return fmodf(x, y); }
+static inline double ImFmod(double x, double y) { return fmod(x, y); }
+static inline float ImCos(float x) { return cosf(x); }
+static inline float ImSin(float x) { return sinf(x); }
+static inline float ImAcos(float x) { return acosf(x); }
+static inline float ImAtan2(float y, float x) { return atan2f(y, x); }
+static inline double ImAtof(const char* s) { return atof(s); }
+static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
+static inline float ImCeil(float x) { return ceilf(x); }
+#endif
+// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double, using templates here but we could also redefine them 6 times
+template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
+template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
+template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
+template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
+template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
+// - Misc maths helpers
+static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
+static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
+static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
+static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
+static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
+static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
+static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
+static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
+static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
+static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; }
+static inline float ImFloor(float f) { return (float)(int)f; }
+static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
+static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
+static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
+static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
+static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
+
+// Helper: ImPool<>. Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
+// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
+typedef int ImPoolIdx;
+template<typename T>
+struct IMGUI_API ImPool
+{
+ ImVector<T> Data; // Contiguous data
+ ImGuiStorage Map; // ID->Index
+ ImPoolIdx FreeIdx; // Next free idx to use
+
+ ImPool() { FreeIdx = 0; }
+ ~ImPool() { Clear(); }
+ T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
+ T* GetByIndex(ImPoolIdx n) { return &Data[n]; }
+ ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
+ T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
+ void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); } Map.Clear(); Data.clear(); FreeIdx = 0; }
+ T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
+ void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
+ void Remove(ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
+ void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
+ int GetSize() const { return Data.Size; }
+};
+
+//-----------------------------------------------------------------------------
+// Misc data structures
+//-----------------------------------------------------------------------------
+
+// 1D vector (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
+struct ImVec1
+{
+ float x;
+ ImVec1() { x = 0.0f; }
+ ImVec1(float _x) { x = _x; }
+};
+
+enum ImGuiButtonFlags_
+{
+ ImGuiButtonFlags_None = 0,
+ ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
+ ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
+ ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
+ ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release)
+ ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release)
+ ImGuiButtonFlags_FlattenChildren = 1 << 5, // allow interactions even if a child window is overlapping
+ ImGuiButtonFlags_AllowItemOverlap = 1 << 6, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
+ ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
+ ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
+ ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
+ ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held
+ ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
+ ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12, // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
+ ImGuiButtonFlags_NoNavFocus = 1 << 13 // don't override navigation focus when activated
+};
+
+enum ImGuiSliderFlags_
+{
+ ImGuiSliderFlags_None = 0,
+ ImGuiSliderFlags_Vertical = 1 << 0
+};
+
+enum ImGuiDragFlags_
+{
+ ImGuiDragFlags_None = 0,
+ ImGuiDragFlags_Vertical = 1 << 0
+};
+
+enum ImGuiColumnsFlags_
+{
+ // Default: 0
+ ImGuiColumnsFlags_None = 0,
+ ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers
+ ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
+ ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
+ ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window
+ ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
+};
+
+enum ImGuiSelectableFlagsPrivate_
+{
+ // NB: need to be in sync with last value of ImGuiSelectableFlags_
+ ImGuiSelectableFlags_NoHoldingActiveID = 1 << 10,
+ ImGuiSelectableFlags_PressedOnClick = 1 << 11,
+ ImGuiSelectableFlags_PressedOnRelease = 1 << 12,
+ ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13
+};
+
+enum ImGuiSeparatorFlags_
+{
+ ImGuiSeparatorFlags_None = 0,
+ ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
+ ImGuiSeparatorFlags_Vertical = 1 << 1
+};
+
+// Storage for LastItem data
+enum ImGuiItemStatusFlags_
+{
+ ImGuiItemStatusFlags_None = 0,
+ ImGuiItemStatusFlags_HoveredRect = 1 << 0,
+ ImGuiItemStatusFlags_HasDisplayRect = 1 << 1,
+ ImGuiItemStatusFlags_Edited = 1 << 2 // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
+
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+ , // [imgui-test only]
+ ImGuiItemStatusFlags_Openable = 1 << 10, //
+ ImGuiItemStatusFlags_Opened = 1 << 11, //
+ ImGuiItemStatusFlags_Checkable = 1 << 12, //
+ ImGuiItemStatusFlags_Checked = 1 << 13 //
+#endif
+};
+
+// FIXME: this is in development, not exposed/functional as a generic feature yet.
+enum ImGuiLayoutType_
+{
+ ImGuiLayoutType_Vertical = 0,
+ ImGuiLayoutType_Horizontal = 1
+};
+
+enum ImGuiAxis
+{
+ ImGuiAxis_None = -1,
+ ImGuiAxis_X = 0,
+ ImGuiAxis_Y = 1
+};
+
+enum ImGuiPlotType
+{
+ ImGuiPlotType_Lines,
+ ImGuiPlotType_Histogram
+};
+
+enum ImGuiInputSource
+{
+ ImGuiInputSource_None = 0,
+ ImGuiInputSource_Mouse,
+ ImGuiInputSource_Nav,
+ ImGuiInputSource_NavKeyboard, // Only used occasionally for storage, not tested/handled by most code
+ ImGuiInputSource_NavGamepad, // "
+ ImGuiInputSource_COUNT
+};
+
+// FIXME-NAV: Clarify/expose various repeat delay/rate
+enum ImGuiInputReadMode
+{
+ ImGuiInputReadMode_Down,
+ ImGuiInputReadMode_Pressed,
+ ImGuiInputReadMode_Released,
+ ImGuiInputReadMode_Repeat,
+ ImGuiInputReadMode_RepeatSlow,
+ ImGuiInputReadMode_RepeatFast
+};
+
+enum ImGuiNavHighlightFlags_
+{
+ ImGuiNavHighlightFlags_None = 0,
+ ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
+ ImGuiNavHighlightFlags_TypeThin = 1 << 1,
+ ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2,
+ ImGuiNavHighlightFlags_NoRounding = 1 << 3
+};
+
+enum ImGuiNavDirSourceFlags_
+{
+ ImGuiNavDirSourceFlags_None = 0,
+ ImGuiNavDirSourceFlags_Keyboard = 1 << 0,
+ ImGuiNavDirSourceFlags_PadDPad = 1 << 1,
+ ImGuiNavDirSourceFlags_PadLStick = 1 << 2
+};
+
+enum ImGuiNavMoveFlags_
+{
+ ImGuiNavMoveFlags_None = 0,
+ ImGuiNavMoveFlags_LoopX = 1 << 0, // On failed request, restart from opposite side
+ ImGuiNavMoveFlags_LoopY = 1 << 1,
+ ImGuiNavMoveFlags_WrapX = 1 << 2, // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
+ ImGuiNavMoveFlags_WrapY = 1 << 3, // This is not super useful for provided for completeness
+ ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4, // Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place)
+ ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5 // Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible.
+};
+
+enum ImGuiNavForward
+{
+ ImGuiNavForward_None,
+ ImGuiNavForward_ForwardQueued,
+ ImGuiNavForward_ForwardActive
+};
+
+enum ImGuiNavLayer
+{
+ ImGuiNavLayer_Main = 0, // Main scrolling layer
+ ImGuiNavLayer_Menu = 1, // Menu layer (access with Alt/ImGuiNavInput_Menu)
+ ImGuiNavLayer_COUNT
+};
+
+enum ImGuiPopupPositionPolicy
+{
+ ImGuiPopupPositionPolicy_Default,
+ ImGuiPopupPositionPolicy_ComboBox
+};
+
+// 2D axis aligned bounding-box
+// NB: we can't rely on ImVec2 math operators being available here
+struct IMGUI_API ImRect
+{
+ ImVec2 Min; // Upper-left
+ ImVec2 Max; // Lower-right
+
+ ImRect() : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX) {}
+ ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
+ ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
+ ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
+
+ ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
+ ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
+ float GetWidth() const { return Max.x - Min.x; }
+ float GetHeight() const { return Max.y - Min.y; }
+ ImVec2 GetTL() const { return Min; } // Top-left
+ ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right
+ ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left
+ ImVec2 GetBR() const { return Max; } // Bottom-right
+ bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; }
+ bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; }
+ bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; }
+ void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; }
+ void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; }
+ void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
+ void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
+ void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
+ void TranslateX(float dx) { Min.x += dx; Max.x += dx; }
+ void TranslateY(float dy) { Min.y += dy; Max.y += dy; }
+ void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
+ void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
+ void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
+ bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
+};
+
+// Stacked color modifier, backup of modified data so we can restore it
+struct ImGuiColorMod
+{
+ ImGuiCol Col;
+ ImVec4 BackupValue;
+};
+
+// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
+struct ImGuiStyleMod
+{
+ ImGuiStyleVar VarIdx;
+ union { int BackupInt[2]; float BackupFloat[2]; };
+ ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; }
+ ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; }
+ ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
+};
+
+// Stacked storage data for BeginGroup()/EndGroup()
+struct ImGuiGroupData
+{
+ ImVec2 BackupCursorPos;
+ ImVec2 BackupCursorMaxPos;
+ ImVec1 BackupIndent;
+ ImVec1 BackupGroupOffset;
+ ImVec2 BackupCurrentLineSize;
+ float BackupCurrentLineTextBaseOffset;
+ float BackupLogLinePosY;
+ ImGuiID BackupActiveIdIsAlive;
+ bool BackupActiveIdPreviousFrameIsAlive;
+ bool AdvanceCursor;
+};
+
+// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
+struct IMGUI_API ImGuiMenuColumns
+{
+ int Count;
+ float Spacing;
+ float Width, NextWidth;
+ float Pos[4], NextWidths[4];
+
+ ImGuiMenuColumns();
+ void Update(int count, float spacing, bool clear);
+ float DeclColumns(float w0, float w1, float w2);
+ float CalcExtraSpace(float avail_w);
+};
+
+// Internal state of the currently focused/edited text input box
+struct IMGUI_API ImGuiInputTextState
+{
+ ImGuiID ID; // widget id owning the text state
+ ImVector<ImWchar> TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
+ ImVector<char> InitialText; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
+ ImVector<char> TempBuffer; // temporary buffer for callback and other other operations. size=capacity.
+ int CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format.
+ int BufCapacityA; // end-user buffer capacity
+ float ScrollX;
+ ImGuiStb::STB_TexteditState StbState;
+ float CursorAnim;
+ bool CursorFollow;
+ bool SelectedAllMouseLock;
+
+ // Temporarily set when active
+ ImGuiInputTextFlags UserFlags;
+ ImGuiInputTextCallback UserCallback;
+ void* UserCallbackData;
+
+ ImGuiInputTextState() { memset(this, 0, sizeof(*this)); }
+ void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
+ void CursorClamp() { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); }
+ bool HasSelection() const { return StbState.select_start != StbState.select_end; }
+ void ClearSelection() { StbState.select_start = StbState.select_end = StbState.cursor; }
+ void SelectAll() { StbState.select_start = 0; StbState.cursor = StbState.select_end = CurLenW; StbState.has_preferred_x = false; }
+ void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
+};
+
+// Windows data saved in imgui.ini file
+struct ImGuiWindowSettings
+{
+ char* Name;
+ ImGuiID ID;
+ ImVec2 Pos;
+ ImVec2 Size;
+ bool Collapsed;
+
+ ImGuiWindowSettings() { Name = NULL; ID = 0; Pos = Size = ImVec2(0,0); Collapsed = false; }
+};
+
+struct ImGuiSettingsHandler
+{
+ const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
+ ImGuiID TypeHash; // == ImHash(TypeName, 0, 0)
+ void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
+ void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
+ void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
+ void* UserData;
+
+ ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); }
+};
+
+// Storage for current popup stack
+struct ImGuiPopupRef
+{
+ ImGuiID PopupId; // Set on OpenPopup()
+ ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
+ ImGuiWindow* ParentWindow; // Set on OpenPopup()
+ int OpenFrameCount; // Set on OpenPopup()
+ ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
+ ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
+ ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup
+};
+
+struct ImGuiColumnData
+{
+ float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
+ float OffsetNormBeforeResize;
+ ImGuiColumnsFlags Flags; // Not exposed
+ ImRect ClipRect;
+
+ ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; }
+};
+
+struct ImGuiColumnsSet
+{
+ ImGuiID ID;
+ ImGuiColumnsFlags Flags;
+ bool IsFirstFrame;
+ bool IsBeingResized;
+ int Current;
+ int Count;
+ float MinX, MaxX;
+ float LineMinY, LineMaxY;
+ float StartPosY; // Copy of CursorPos
+ float StartMaxPosX; // Copy of CursorMaxPos
+ ImVector<ImGuiColumnData> Columns;
+
+ ImGuiColumnsSet() { Clear(); }
+ void Clear()
+ {
+ ID = 0;
+ Flags = 0;
+ IsFirstFrame = false;
+ IsBeingResized = false;
+ Current = 0;
+ Count = 1;
+ MinX = MaxX = 0.0f;
+ LineMinY = LineMaxY = 0.0f;
+ StartPosY = 0.0f;
+ StartMaxPosX = 0.0f;
+ Columns.clear();
+ }
+};
+
+// Data shared between all ImDrawList instances
+struct IMGUI_API ImDrawListSharedData
+{
+ ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
+ ImFont* Font; // Current/default font (optional, for simplified AddText overload)
+ float FontSize; // Current/default font size (optional, for simplified AddText overload)
+ float CurveTessellationTol;
+ ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
+
+ // Const data
+ // FIXME: Bake rounded corners fill/borders in atlas
+ ImVec2 CircleVtx12[12];
+
+ ImDrawListSharedData();
+};
+
+struct ImDrawDataBuilder
+{
+ ImVector<ImDrawList*> Layers[2]; // Global layers for: regular, tooltip
+
+ void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
+ void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
+ IMGUI_API void FlattenIntoSingleLayer();
+};
+
+struct ImGuiNavMoveResult
+{
+ ImGuiID ID; // Best candidate
+ ImGuiWindow* Window; // Best candidate window
+ float DistBox; // Best candidate box distance to current NavId
+ float DistCenter; // Best candidate center distance to current NavId
+ float DistAxial;
+ ImRect RectRel; // Best candidate bounding box in window relative space
+
+ ImGuiNavMoveResult() { Clear(); }
+ void Clear() { ID = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
+};
+
+// Storage for SetNexWindow** functions
+struct ImGuiNextWindowData
+{
+ ImGuiCond PosCond;
+ ImGuiCond SizeCond;
+ ImGuiCond ContentSizeCond;
+ ImGuiCond CollapsedCond;
+ ImGuiCond SizeConstraintCond;
+ ImGuiCond FocusCond;
+ ImGuiCond BgAlphaCond;
+ ImVec2 PosVal;
+ ImVec2 PosPivotVal;
+ ImVec2 SizeVal;
+ ImVec2 ContentSizeVal;
+ bool CollapsedVal;
+ ImRect SizeConstraintRect;
+ ImGuiSizeCallback SizeCallback;
+ void* SizeCallbackUserData;
+ float BgAlphaVal;
+ ImVec2 MenuBarOffsetMinVal; // This is not exposed publicly, so we don't clear it.
+
+ ImGuiNextWindowData()
+ {
+ PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
+ PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
+ ContentSizeVal = ImVec2(0.0f, 0.0f);
+ CollapsedVal = false;
+ SizeConstraintRect = ImRect();
+ SizeCallback = NULL;
+ SizeCallbackUserData = NULL;
+ BgAlphaVal = FLT_MAX;
+ MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
+ }
+
+ void Clear()
+ {
+ PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
+ }
+};
+
+struct ImGuiTabBarSortItem
+{
+ int Index;
+ float Width;
+};
+
+//-----------------------------------------------------------------------------
+// Main imgui context
+//-----------------------------------------------------------------------------
+
+struct ImGuiContext
+{
+ bool Initialized;
+ bool FrameScopeActive; // Set by NewFrame(), cleared by EndFrame()
+ bool FrameScopePushedImplicitWindow; // Set by NewFrame(), cleared by EndFrame()
+ bool FontAtlasOwnedByContext; // Io.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
+ ImGuiIO IO;
+ ImGuiStyle Style;
+ ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
+ float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
+ float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
+ ImDrawListSharedData DrawListSharedData;
+
+ double Time;
+ int FrameCount;
+ int FrameCountEnded;
+ int FrameCountRendered;
+ ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
+ ImVector<ImGuiWindow*> WindowsFocusOrder; // Windows, sorted in focus order, back to front
+ ImVector<ImGuiWindow*> WindowsSortBuffer;
+ ImVector<ImGuiWindow*> CurrentWindowStack;
+ ImGuiStorage WindowsById;
+ int WindowsActiveCount;
+ ImGuiWindow* CurrentWindow; // Being drawn into
+ ImGuiWindow* HoveredWindow; // Will catch mouse inputs
+ ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
+ ImGuiID HoveredId; // Hovered widget
+ bool HoveredIdAllowOverlap;
+ ImGuiID HoveredIdPreviousFrame;
+ float HoveredIdTimer; // Measure contiguous hovering time
+ float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
+ ImGuiID ActiveId; // Active widget
+ ImGuiID ActiveIdPreviousFrame;
+ ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
+ float ActiveIdTimer;
+ bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
+ bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
+ bool ActiveIdHasBeenEdited; // Was the value associated to the widget Edited over the course of the Active state.
+ bool ActiveIdPreviousFrameIsAlive;
+ bool ActiveIdPreviousFrameHasBeenEdited;
+ int ActiveIdAllowNavDirFlags; // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
+ ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
+ ImGuiWindow* ActiveIdWindow;
+ ImGuiWindow* ActiveIdPreviousFrameWindow;
+ ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
+ ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
+ float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
+ ImVec2 LastValidMousePos;
+ ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
+ ImVector<ImGuiColorMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
+ ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
+ ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
+ ImVector<ImGuiPopupRef> OpenPopupStack; // Which popups are open (persistent)
+ ImVector<ImGuiPopupRef> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
+ ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
+ bool NextTreeNodeOpenVal; // Storage for SetNextTreeNode** functions
+ ImGuiCond NextTreeNodeOpenCond;
+
+ // Navigation data (for gamepad/keyboard)
+ ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow'
+ ImGuiID NavId; // Focused item for navigation
+ ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem()
+ ImGuiID NavActivateDownId; // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0
+ ImGuiID NavActivatePressedId; // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0
+ ImGuiID NavInputId; // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0
+ ImGuiID NavJustTabbedId; // Just tabbed to this id.
+ ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest)
+ ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame
+ ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
+ ImRect NavScoringRectScreen; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
+ int NavScoringCount; // Metrics for debugging
+ ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed front-most.
+ ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
+ ImGuiWindow* NavWindowingList;
+ float NavWindowingTimer;
+ float NavWindowingHighlightAlpha;
+ bool NavWindowingToggleLayer;
+ ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
+ int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
+ bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid
+ bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
+ bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
+ bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
+ bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest
+ bool NavInitRequest; // Init request for appearing window to select first item
+ bool NavInitRequestFromMove;
+ ImGuiID NavInitResultId;
+ ImRect NavInitResultRectRel;
+ bool NavMoveFromClampedRefRect; // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
+ bool NavMoveRequest; // Move request for this frame
+ ImGuiNavMoveFlags NavMoveRequestFlags;
+ ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
+ ImGuiDir NavMoveDir, NavMoveDirLast; // Direction of the move request (left/right/up/down), direction of the previous move request
+ ImGuiDir NavMoveClipDir;
+ ImGuiNavMoveResult NavMoveResultLocal; // Best move request candidate within NavWindow
+ ImGuiNavMoveResult NavMoveResultLocalVisibleSet; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
+ ImGuiNavMoveResult NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
+
+ // Render
+ ImDrawData DrawData; // Main ImDrawData instance to pass render information to the user
+ ImDrawDataBuilder DrawDataBuilder;
+ float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
+ ImDrawList OverlayDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
+ ImGuiMouseCursor MouseCursor;
+
+ // Drag and Drop
+ bool DragDropActive;
+ bool DragDropWithinSourceOrTarget;
+ ImGuiDragDropFlags DragDropSourceFlags;
+ int DragDropSourceFrameCount;
+ int DragDropMouseButton;
+ ImGuiPayload DragDropPayload;
+ ImRect DragDropTargetRect;
+ ImGuiID DragDropTargetId;
+ ImGuiDragDropFlags DragDropAcceptFlags;
+ float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
+ ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
+ ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
+ int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source
+ ImVector<unsigned char> DragDropPayloadBufHeap; // We don't expose the ImVector<> directly
+ unsigned char DragDropPayloadBufLocal[8]; // Local buffer for small payloads
+
+ // Tab bars
+ ImPool<ImGuiTabBar> TabBars;
+ ImVector<ImGuiTabBar*> CurrentTabBar;
+ ImVector<ImGuiTabBarSortItem> TabSortByWidthBuffer;
+
+ // Widget state
+ ImGuiInputTextState InputTextState;
+ ImFont InputTextPasswordFont;
+ ImGuiID ScalarAsInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
+ ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
+ ImVec4 ColorPickerRef;
+ bool DragCurrentAccumDirty;
+ float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
+ float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
+ ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
+ int TooltipOverrideCount;
+ ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
+
+ // Platform support
+ ImVec2 PlatformImePos, PlatformImeLastPos; // Cursor position request & last passed to the OS Input Method Editor
+
+ // Settings
+ bool SettingsLoaded;
+ float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
+ ImGuiTextBuffer SettingsIniData; // In memory .ini settings
+ ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
+ ImVector<ImGuiWindowSettings> SettingsWindows; // ImGuiWindow .ini settings entries (parsed from the last loaded .ini file and maintained on saving)
+
+ // Logging
+ bool LogEnabled;
+ FILE* LogFile; // If != NULL log to stdout/ file
+ ImGuiTextBuffer LogClipboard; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
+ int LogStartDepth;
+ int LogAutoExpandMaxDepth;
+
+ // Misc
+ float FramerateSecPerFrame[120]; // Calculate estimate of framerate for user over the last 2 seconds.
+ int FramerateSecPerFrameIdx;
+ float FramerateSecPerFrameAccum;
+ int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
+ int WantCaptureKeyboardNextFrame;
+ int WantTextInputNextFrame;
+ char TempBuffer[1024*3+1]; // Temporary text buffer
+
+ ImGuiContext(ImFontAtlas* shared_font_atlas) : OverlayDrawList(NULL)
+ {
+ Initialized = false;
+ FrameScopeActive = FrameScopePushedImplicitWindow = false;
+ Font = NULL;
+ FontSize = FontBaseSize = 0.0f;
+ FontAtlasOwnedByContext = shared_font_atlas ? false : true;
+ IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
+
+ Time = 0.0f;
+ FrameCount = 0;
+ FrameCountEnded = FrameCountRendered = -1;
+ WindowsActiveCount = 0;
+ CurrentWindow = NULL;
+ HoveredWindow = NULL;
+ HoveredRootWindow = NULL;
+ HoveredId = 0;
+ HoveredIdAllowOverlap = false;
+ HoveredIdPreviousFrame = 0;
+ HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
+ ActiveId = 0;
+ ActiveIdPreviousFrame = 0;
+ ActiveIdIsAlive = 0;
+ ActiveIdTimer = 0.0f;
+ ActiveIdIsJustActivated = false;
+ ActiveIdAllowOverlap = false;
+ ActiveIdHasBeenEdited = false;
+ ActiveIdPreviousFrameIsAlive = false;
+ ActiveIdPreviousFrameHasBeenEdited = false;
+ ActiveIdAllowNavDirFlags = 0;
+ ActiveIdClickOffset = ImVec2(-1,-1);
+ ActiveIdWindow = ActiveIdPreviousFrameWindow = NULL;
+ ActiveIdSource = ImGuiInputSource_None;
+ LastActiveId = 0;
+ LastActiveIdTimer = 0.0f;
+ LastValidMousePos = ImVec2(0.0f, 0.0f);
+ MovingWindow = NULL;
+ NextTreeNodeOpenVal = false;
+ NextTreeNodeOpenCond = 0;
+
+ NavWindow = NULL;
+ NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
+ NavJustTabbedId = NavJustMovedToId = NavNextActivateId = 0;
+ NavInputSource = ImGuiInputSource_None;
+ NavScoringRectScreen = ImRect();
+ NavScoringCount = 0;
+ NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
+ NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
+ NavWindowingToggleLayer = false;
+ NavLayer = ImGuiNavLayer_Main;
+ NavIdTabCounter = INT_MAX;
+ NavIdIsAlive = false;
+ NavMousePosDirty = false;
+ NavDisableHighlight = true;
+ NavDisableMouseHover = false;
+ NavAnyRequest = false;
+ NavInitRequest = false;
+ NavInitRequestFromMove = false;
+ NavInitResultId = 0;
+ NavMoveFromClampedRefRect = false;
+ NavMoveRequest = false;
+ NavMoveRequestFlags = 0;
+ NavMoveRequestForward = ImGuiNavForward_None;
+ NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
+
+ DimBgRatio = 0.0f;
+ OverlayDrawList._Data = &DrawListSharedData;
+ OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
+ MouseCursor = ImGuiMouseCursor_Arrow;
+
+ DragDropActive = DragDropWithinSourceOrTarget = false;
+ DragDropSourceFlags = 0;
+ DragDropSourceFrameCount = -1;
+ DragDropMouseButton = -1;
+ DragDropTargetId = 0;
+ DragDropAcceptFlags = 0;
+ DragDropAcceptIdCurrRectSurface = 0.0f;
+ DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
+ DragDropAcceptFrameCount = -1;
+ memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal));
+
+ ScalarAsInputTextId = 0;
+ ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
+ DragCurrentAccumDirty = false;
+ DragCurrentAccum = 0.0f;
+ DragSpeedDefaultRatio = 1.0f / 100.0f;
+ ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
+ TooltipOverrideCount = 0;
+ PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
+
+ SettingsLoaded = false;
+ SettingsDirtyTimer = 0.0f;
+
+ LogEnabled = false;
+ LogFile = NULL;
+ LogStartDepth = 0;
+ LogAutoExpandMaxDepth = 2;
+
+ memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
+ FramerateSecPerFrameIdx = 0;
+ FramerateSecPerFrameAccum = 0.0f;
+ WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
+ memset(TempBuffer, 0, sizeof(TempBuffer));
+ }
+};
+
+// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
+// This is going to be exposed in imgui.h when stabilized enough.
+enum ImGuiItemFlags_
+{
+ ImGuiItemFlags_NoTabStop = 1 << 0, // false
+ ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
+ ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
+ ImGuiItemFlags_NoNav = 1 << 3, // false
+ ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
+ ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
+ ImGuiItemFlags_Default_ = 0
+};
+
+// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
+// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
+struct IMGUI_API ImGuiWindowTempData
+{
+ ImVec2 CursorPos;
+ ImVec2 CursorPosPrevLine;
+ ImVec2 CursorStartPos; // Initial position in client area with padding
+ ImVec2 CursorMaxPos; // Used to implicitly calculate the size of our contents, always growing during the frame. Turned into window->SizeContents at the beginning of next frame
+ ImVec2 CurrentLineSize;
+ float CurrentLineTextBaseOffset;
+ ImVec2 PrevLineSize;
+ float PrevLineTextBaseOffset;
+ float LogLinePosY;
+ int TreeDepth;
+ ImU32 TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31
+ ImGuiID LastItemId;
+ ImGuiItemStatusFlags LastItemStatusFlags;
+ ImRect LastItemRect; // Interaction rect
+ ImRect LastItemDisplayRect; // End-user display rect (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
+ ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
+ int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
+ int NavLayerActiveMask; // Which layer have been written to (result from previous frame)
+ int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
+ bool NavHideHighlightOneFrame;
+ bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
+ bool MenuBarAppending; // FIXME: Remove this
+ ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs.
+ ImVector<ImGuiWindow*> ChildWindows;
+ ImGuiStorage* StateStorage;
+ ImGuiLayoutType LayoutType;
+ ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
+
+ // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
+ ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
+ float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
+ float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
+ ImVector<ImGuiItemFlags>ItemFlagsStack;
+ ImVector<float> ItemWidthStack;
+ ImVector<float> TextWrapPosStack;
+ ImVector<ImGuiGroupData>GroupStack;
+ short StackSizesBackup[6]; // Store size of various stacks for asserting
+
+ ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
+ ImVec1 GroupOffset;
+ ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
+ ImGuiColumnsSet* ColumnsSet; // Current columns set
+
+ ImGuiWindowTempData()
+ {
+ CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
+ CurrentLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
+ CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
+ LogLinePosY = -1.0f;
+ TreeDepth = 0;
+ TreeDepthMayJumpToParentOnPop = 0x00;
+ LastItemId = 0;
+ LastItemStatusFlags = 0;
+ LastItemRect = LastItemDisplayRect = ImRect();
+ NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
+ NavLayerCurrent = ImGuiNavLayer_Main;
+ NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
+ NavHideHighlightOneFrame = false;
+ NavHasScroll = false;
+ MenuBarAppending = false;
+ MenuBarOffset = ImVec2(0.0f, 0.0f);
+ StateStorage = NULL;
+ LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
+ ItemWidth = 0.0f;
+ ItemFlags = ImGuiItemFlags_Default_;
+ TextWrapPos = -1.0f;
+ memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
+
+ Indent = ImVec1(0.0f);
+ GroupOffset = ImVec1(0.0f);
+ ColumnsOffset = ImVec1(0.0f);
+ ColumnsSet = NULL;
+ }
+};
+
+// Storage for one window
+struct IMGUI_API ImGuiWindow
+{
+ char* Name;
+ ImGuiID ID; // == ImHash(Name)
+ ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
+ ImVec2 Pos; // Position (always rounded-up to nearest pixel)
+ ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
+ ImVec2 SizeFull; // Size when non collapsed
+ ImVec2 SizeFullAtLastBegin; // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars.
+ ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame. Include decoration, window title, border, menu, etc.
+ ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
+ ImVec2 WindowPadding; // Window padding at the time of begin.
+ float WindowRounding; // Window rounding at the time of begin.
+ float WindowBorderSize; // Window border size at the time of begin.
+ int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)!
+ ImGuiID MoveId; // == window->GetID("#MOVE")
+ ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window)
+ ImVec2 Scroll;
+ ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
+ ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
+ ImVec2 ScrollbarSizes; // Size taken by scrollbars on each axis
+ bool ScrollbarX, ScrollbarY;
+ bool Active; // Set to true on Begin(), unless Collapsed
+ bool WasActive;
+ bool WriteAccessed; // Set to true when any widget access the current window
+ bool Collapsed; // Set when collapsing window to become only title-bar
+ bool WantCollapseToggle;
+ bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
+ bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
+ bool Hidden; // Do not display (== (HiddenFramesForResize > 0) ||
+ bool HasCloseButton; // Set when the window has a close button (p_open != NULL)
+ short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
+ short BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
+ short BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues.
+ ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
+ int AutoFitFramesX, AutoFitFramesY;
+ bool AutoFitOnlyGrows;
+ int AutoFitChildAxises;
+ ImGuiDir AutoPosLastDirection;
+ int HiddenFramesRegular; // Hide the window for N frames
+ int HiddenFramesForResize; // Hide the window for N frames while allowing items to be submitted so we can measure their size
+ ImGuiCond SetWindowPosAllowFlags; // store acceptable condition flags for SetNextWindowPos() use.
+ ImGuiCond SetWindowSizeAllowFlags; // store acceptable condition flags for SetNextWindowSize() use.
+ ImGuiCond SetWindowCollapsedAllowFlags; // store acceptable condition flags for SetNextWindowCollapsed() use.
+ ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
+ ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
+
+ ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
+ ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
+ ImRect ClipRect; // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
+ ImRect OuterRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
+ ImRect InnerMainRect, InnerClipRect;
+ ImRect ContentsRegionRect; // FIXME: This is currently confusing/misleading. Maximum visible content position ~~ Pos + (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
+ int LastFrameActive; // Last frame number the window was Active.
+ float ItemWidthDefault;
+ ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items
+ ImGuiStorage StateStorage;
+ ImVector<ImGuiColumnsSet> ColumnsStorage;
+ float FontWindowScale; // User scale multiplier per-window
+ int SettingsIdx; // Index into SettingsWindow[] (indices are always valid as we only grow the array from the back)
+
+ ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
+ ImDrawList DrawListInst;
+ ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
+ ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window.
+ ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
+ ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
+
+ ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
+ ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
+ ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space
+
+ // Navigation / Focus
+ // FIXME-NAV: Merge all this with the new Nav system, at least the request variables should be moved to ImGuiContext
+ int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
+ int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through)
+ int FocusIdxAllRequestCurrent; // Item being requested for focus
+ int FocusIdxTabRequestCurrent; // Tab-able item being requested for focus
+ int FocusIdxAllRequestNext; // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
+ int FocusIdxTabRequestNext; // "
+
+public:
+ ImGuiWindow(ImGuiContext* context, const char* name);
+ ~ImGuiWindow();
+
+ ImGuiID GetID(const char* str, const char* str_end = NULL);
+ ImGuiID GetID(const void* ptr);
+ ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
+ ImGuiID GetIDNoKeepAlive(const void* ptr);
+ ImGuiID GetIDFromRectangle(const ImRect& r_abs);
+
+ // We don't use g.FontSize because the window may be != g.CurrentWidow.
+ ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
+ float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
+ float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
+ ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
+ float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
+ ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
+};
+
+// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
+struct ImGuiItemHoveredDataBackup
+{
+ ImGuiID LastItemId;
+ ImGuiItemStatusFlags LastItemStatusFlags;
+ ImRect LastItemRect;
+ ImRect LastItemDisplayRect;
+
+ ImGuiItemHoveredDataBackup() { Backup(); }
+ void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
+ void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
+};
+
+//-----------------------------------------------------------------------------
+// Tab bar, tab item
+//-----------------------------------------------------------------------------
+
+enum ImGuiTabBarFlagsPrivate_
+{
+ ImGuiTabBarFlags_DockNode = 1 << 20, // [Docking: Unused in Master Branch] Part of a dock node
+ ImGuiTabBarFlags_DockNodeIsDockSpace = 1 << 21, // [Docking: Unused in Master Branch] Part of an explicit dockspace node node
+ ImGuiTabBarFlags_IsFocused = 1 << 22,
+ ImGuiTabBarFlags_SaveSettings = 1 << 23 // FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs
+};
+
+// Storage for one active tab item (sizeof() 26~32 bytes)
+struct ImGuiTabItem
+{
+ ImGuiID ID;
+ ImGuiTabItemFlags Flags;
+ int LastFrameVisible;
+ int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
+ float Offset; // Position relative to beginning of tab
+ float Width; // Width currently displayed
+ float WidthContents; // Width of actual contents, stored during BeginTabItem() call
+
+ ImGuiTabItem() { ID = Flags = 0; LastFrameVisible = LastFrameSelected = -1; Offset = Width = WidthContents = 0.0f; }
+};
+
+// Storage for a tab bar (sizeof() 92~96 bytes)
+struct ImGuiTabBar
+{
+ ImVector<ImGuiTabItem> Tabs;
+ ImGuiID ID; // Zero for tab-bars used by docking
+ ImGuiID SelectedTabId; // Selected tab
+ ImGuiID NextSelectedTabId;
+ ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
+ int CurrFrameVisible;
+ int PrevFrameVisible;
+ ImRect BarRect;
+ float ContentsHeight;
+ float OffsetMax; // Distance from BarRect.Min.x, locked during layout
+ float OffsetNextTab; // Distance from BarRect.Min.x, incremented with each BeginTabItem() call, not used if ImGuiTabBarFlags_Reorderable if set.
+ float ScrollingAnim;
+ float ScrollingTarget;
+ ImGuiTabBarFlags Flags;
+ ImGuiID ReorderRequestTabId;
+ int ReorderRequestDir;
+ bool WantLayout;
+ bool VisibleTabWasSubmitted;
+ short LastTabItemIdx; // For BeginTabItem()/EndTabItem()
+
+ ImGuiTabBar();
+ int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
+};
+
+//-----------------------------------------------------------------------------
+// Internal API
+// No guarantee of forward compatibility here.
+//-----------------------------------------------------------------------------
+
+namespace ImGui
+{
+ // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
+ // If this ever crash because g.CurrentWindow is NULL it means that either
+ // - ImGui::NewFrame() has never been called, which is illegal.
+ // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
+ inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
+ inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
+ IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
+ IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
+ IMGUI_API void FocusWindow(ImGuiWindow* window);
+ IMGUI_API void FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window);
+ IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window);
+ IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window);
+ IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window);
+ IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
+ IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window);
+ IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
+ IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
+ IMGUI_API void SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
+ IMGUI_API void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
+ IMGUI_API float GetWindowScrollMaxX(ImGuiWindow* window);
+ IMGUI_API float GetWindowScrollMaxY(ImGuiWindow* window);
+ IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window);
+
+ IMGUI_API void SetCurrentFont(ImFont* font);
+ inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
+
+ // Init
+ IMGUI_API void Initialize(ImGuiContext* context);
+ IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
+
+ // NewFrame
+ IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
+ IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
+ IMGUI_API void UpdateMouseMovingWindowNewFrame();
+ IMGUI_API void UpdateMouseMovingWindowEndFrame();
+
+ // Settings
+ IMGUI_API void MarkIniSettingsDirty();
+ IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
+ IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name);
+ IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
+ IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
+
+ // Basic Accessors
+ inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
+ inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
+ inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; }
+ IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
+ IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window);
+ IMGUI_API void ClearActiveID();
+ IMGUI_API ImGuiID GetHoveredID();
+ IMGUI_API void SetHoveredID(ImGuiID id);
+ IMGUI_API void KeepAliveID(ImGuiID id);
+ IMGUI_API void MarkItemEdited(ImGuiID id);
+
+ // Basic Helpers for widget code
+ IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
+ IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
+ IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
+ IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
+ IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
+ IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested
+ IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
+ IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
+ IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
+ IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f);
+ IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
+ IMGUI_API void PopItemFlag();
+
+ // Popups, Modals, Tooltips
+ IMGUI_API void OpenPopupEx(ImGuiID id);
+ IMGUI_API void ClosePopupToLevel(int remaining, bool apply_focus_to_window_under);
+ IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window);
+ IMGUI_API bool IsPopupOpen(ImGuiID id); // Test for id within current popup stack level (currently begin-ed into); this doesn't scan the whole popup stack!
+ IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
+ IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
+ IMGUI_API ImGuiWindow* GetFrontMostPopupModal();
+ IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
+ IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default);
+
+ // Navigation
+ IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
+ IMGUI_API bool NavMoveRequestButNoResultYet();
+ IMGUI_API void NavMoveRequestCancel();
+ IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags);
+ IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
+ IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
+ IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
+ IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
+ IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
+ IMGUI_API void SetNavID(ImGuiID id, int nav_layer);
+ IMGUI_API void SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel);
+
+ // Inputs
+ inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
+ inline bool IsNavInputDown(ImGuiNavInput n) { return GImGui->IO.NavInputs[n] > 0.0f; }
+ inline bool IsNavInputPressed(ImGuiNavInput n, ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; }
+ inline bool IsNavInputPressedAnyOfTwo(ImGuiNavInput n1, ImGuiNavInput n2, ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; }
+
+ // Drag and Drop
+ IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
+ IMGUI_API void ClearDragDrop();
+ IMGUI_API bool IsDragDropPayloadBeingAccepted();
+
+ // New Columns API (FIXME-WIP)
+ IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
+ IMGUI_API void EndColumns(); // close columns
+ IMGUI_API void PushColumnClipRect(int column_index = -1);
+
+ // Tab Bars
+ IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
+ IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
+ IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
+ IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
+ IMGUI_API void TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
+ IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
+ IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button);
+ IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
+ IMGUI_API bool TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, const char* label, ImGuiID tab_id, ImGuiID close_button_id);
+
+ // Render helpers
+ // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
+ // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
+ IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
+ IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
+ IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL);
+ IMGUI_API void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
+ IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
+ IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
+ IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
+ IMGUI_API void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
+ IMGUI_API void RenderBullet(ImVec2 pos);
+ IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
+ IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
+ IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
+ IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
+
+ // Render helpers (those functions don't access any ImGui state!)
+ IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor = ImGuiMouseCursor_Arrow);
+ IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
+ IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
+ IMGUI_API void RenderPixelEllipsis(ImDrawList* draw_list, ImVec2 pos, int count, ImU32 col);
+
+ // Widgets
+ IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
+ IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius);
+ IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos);
+ IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags);
+ IMGUI_API void Scrollbar(ImGuiLayoutType direction);
+ IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout.
+
+ // Widgets low-level behaviors
+ IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
+ IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags);
+ IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
+ IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
+ IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
+ IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
+ IMGUI_API void TreePushRawID(ImGuiID id);
+
+ // Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
+ // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
+ // e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
+ template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, const T v_min, const T v_max, const char* format, float power, ImGuiDragFlags flags);
+ template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, const T v_min, const T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
+ template<typename T, typename FLOAT_T> IMGUI_API float SliderCalcRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, float power, float linear_zero_pos);
+ template<typename T, typename SIGNED_T> IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
+
+ // InputText
+ IMGUI_API bool InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+ IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format);
+
+ // Color
+ IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
+ IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
+ IMGUI_API void ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);
+
+ // Plot
+ IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
+
+ // Shade functions (write over already created vertices)
+ IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
+ IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
+
+} // namespace ImGui
+
+// ImFontAtlas internals
+IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
+IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
+IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
+IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
+IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
+IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
+IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
+
+// Test engine hooks (imgui-test)
+//#define IMGUI_ENABLE_TEST_ENGINE
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
+extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
+extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
+extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, int flags);
+#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register status flags
+#else
+#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) do { } while (0)
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (pop)
+#endif
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imgui_widgets.cpp b/Client/ThirdParty/Box2D/extern/imgui/imgui_widgets.cpp
new file mode 100644
index 0000000..d65a420
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imgui_widgets.cpp
@@ -0,0 +1,6557 @@
+// dear imgui, v1.67 WIP
+// (widgets code)
+
+/*
+
+Index of this file:
+
+// [SECTION] Forward Declarations
+// [SECTION] Widgets: Text, etc.
+// [SECTION] Widgets: Main (Button, Image, Checkbox, RadioButton, ProgressBar, Bullet, etc.)
+// [SECTION] Widgets: Low-level Layout helpers (Spacing, Dummy, NewLine, Separator, etc.)
+// [SECTION] Widgets: ComboBox
+// [SECTION] Data Type and Data Formatting Helpers
+// [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc.
+// [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc.
+// [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc.
+// [SECTION] Widgets: InputText, InputTextMultiline
+// [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc.
+// [SECTION] Widgets: TreeNode, CollapsingHeader, etc.
+// [SECTION] Widgets: Selectable
+// [SECTION] Widgets: ListBox
+// [SECTION] Widgets: PlotLines, PlotHistogram
+// [SECTION] Widgets: Value helpers
+// [SECTION] Widgets: MenuItem, BeginMenu, EndMenu, etc.
+// [SECTION] Widgets: BeginTabBar, EndTabBar, etc.
+// [SECTION] Widgets: BeginTabItem, EndTabItem, etc.
+
+*/
+
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include "imgui.h"
+#ifndef IMGUI_DEFINE_MATH_OPERATORS
+#define IMGUI_DEFINE_MATH_OPERATORS
+#endif
+#include "imgui_internal.h"
+
+#include <ctype.h> // toupper, isprint
+#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
+#include <stddef.h> // intptr_t
+#else
+#include <stdint.h> // intptr_t
+#endif
+
+// Visual Studio warnings
+#ifdef _MSC_VER
+#pragma warning (disable: 4127) // condition expression is constant
+#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
+#endif
+
+// Clang/GCC warnings with -Weverything
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
+#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
+#if __GNUC__ >= 8
+#pragma GCC diagnostic ignored "-Wclass-memaccess" // warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
+#endif
+#endif
+
+//-------------------------------------------------------------------------
+// Data
+//-------------------------------------------------------------------------
+
+// Those MIN/MAX values are not define because we need to point to them
+static const ImS32 IM_S32_MIN = INT_MIN; // (-2147483647 - 1), (0x80000000);
+static const ImS32 IM_S32_MAX = INT_MAX; // (2147483647), (0x7FFFFFFF)
+static const ImU32 IM_U32_MIN = 0;
+static const ImU32 IM_U32_MAX = UINT_MAX; // (0xFFFFFFFF)
+#ifdef LLONG_MIN
+static const ImS64 IM_S64_MIN = LLONG_MIN; // (-9223372036854775807ll - 1ll);
+static const ImS64 IM_S64_MAX = LLONG_MAX; // (9223372036854775807ll);
+#else
+static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1;
+static const ImS64 IM_S64_MAX = 9223372036854775807LL;
+#endif
+static const ImU64 IM_U64_MIN = 0;
+#ifdef ULLONG_MAX
+static const ImU64 IM_U64_MAX = ULLONG_MAX; // (0xFFFFFFFFFFFFFFFFull);
+#else
+static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1);
+#endif
+
+//-------------------------------------------------------------------------
+// [SECTION] Forward Declarations
+//-------------------------------------------------------------------------
+
+// Data Type helpers
+static inline int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format);
+static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2);
+static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* format);
+
+// For InputTextEx()
+static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data);
+static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end);
+static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false);
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: Text, etc.
+//-------------------------------------------------------------------------
+// - TextUnformatted()
+// - Text()
+// - TextV()
+// - TextColored()
+// - TextColoredV()
+// - TextDisabled()
+// - TextDisabledV()
+// - TextWrapped()
+// - TextWrappedV()
+// - LabelText()
+// - LabelTextV()
+// - BulletText()
+// - BulletTextV()
+//-------------------------------------------------------------------------
+
+void ImGui::TextUnformatted(const char* text, const char* text_end)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(text != NULL);
+ const char* text_begin = text;
+ if (text_end == NULL)
+ text_end = text + strlen(text); // FIXME-OPT
+
+ const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrentLineTextBaseOffset);
+ const float wrap_pos_x = window->DC.TextWrapPos;
+ const bool wrap_enabled = wrap_pos_x >= 0.0f;
+ if (text_end - text > 2000 && !wrap_enabled)
+ {
+ // Long text!
+ // Perform manual coarse clipping to optimize for long multi-line text
+ // - From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled.
+ // - We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line.
+ // - We use memchr(), pay attention that well optimized versions of those str/mem functions are much faster than a casually written loop.
+ const char* line = text;
+ const float line_height = GetTextLineHeight();
+ const ImRect clip_rect = window->ClipRect;
+ ImVec2 text_size(0,0);
+
+ if (text_pos.y <= clip_rect.Max.y)
+ {
+ ImVec2 pos = text_pos;
+
+ // Lines to skip (can't skip when logging text)
+ if (!g.LogEnabled)
+ {
+ int lines_skippable = (int)((clip_rect.Min.y - text_pos.y) / line_height);
+ if (lines_skippable > 0)
+ {
+ int lines_skipped = 0;
+ while (line < text_end && lines_skipped < lines_skippable)
+ {
+ const char* line_end = (const char*)memchr(line, '\n', text_end - line);
+ if (!line_end)
+ line_end = text_end;
+ line = line_end + 1;
+ lines_skipped++;
+ }
+ pos.y += lines_skipped * line_height;
+ }
+ }
+
+ // Lines to render
+ if (line < text_end)
+ {
+ ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height));
+ while (line < text_end)
+ {
+ if (IsClippedEx(line_rect, 0, false))
+ break;
+
+ const char* line_end = (const char*)memchr(line, '\n', text_end - line);
+ if (!line_end)
+ line_end = text_end;
+ const ImVec2 line_size = CalcTextSize(line, line_end, false);
+ text_size.x = ImMax(text_size.x, line_size.x);
+ RenderText(pos, line, line_end, false);
+ line = line_end + 1;
+ line_rect.Min.y += line_height;
+ line_rect.Max.y += line_height;
+ pos.y += line_height;
+ }
+
+ // Count remaining lines
+ int lines_skipped = 0;
+ while (line < text_end)
+ {
+ const char* line_end = (const char*)memchr(line, '\n', text_end - line);
+ if (!line_end)
+ line_end = text_end;
+ line = line_end + 1;
+ lines_skipped++;
+ }
+ pos.y += lines_skipped * line_height;
+ }
+
+ text_size.y += (pos - text_pos).y;
+ }
+
+ ImRect bb(text_pos, text_pos + text_size);
+ ItemSize(text_size);
+ ItemAdd(bb, 0);
+ }
+ else
+ {
+ const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f;
+ const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
+
+ // Account of baseline offset
+ ImRect bb(text_pos, text_pos + text_size);
+ ItemSize(text_size);
+ if (!ItemAdd(bb, 0))
+ return;
+
+ // Render (we don't hide text after ## in this end-user function)
+ RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width);
+ }
+}
+
+void ImGui::Text(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ TextV(fmt, args);
+ va_end(args);
+}
+
+void ImGui::TextV(const char* fmt, va_list args)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const char* text_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
+ TextUnformatted(g.TempBuffer, text_end);
+}
+
+void ImGui::TextColored(const ImVec4& col, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ TextColoredV(col, fmt, args);
+ va_end(args);
+}
+
+void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args)
+{
+ PushStyleColor(ImGuiCol_Text, col);
+ TextV(fmt, args);
+ PopStyleColor();
+}
+
+void ImGui::TextDisabled(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ TextDisabledV(fmt, args);
+ va_end(args);
+}
+
+void ImGui::TextDisabledV(const char* fmt, va_list args)
+{
+ PushStyleColor(ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled]);
+ TextV(fmt, args);
+ PopStyleColor();
+}
+
+void ImGui::TextWrapped(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ TextWrappedV(fmt, args);
+ va_end(args);
+}
+
+void ImGui::TextWrappedV(const char* fmt, va_list args)
+{
+ bool need_backup = (GImGui->CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set
+ if (need_backup)
+ PushTextWrapPos(0.0f);
+ TextV(fmt, args);
+ if (need_backup)
+ PopTextWrapPos();
+}
+
+void ImGui::LabelText(const char* label, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ LabelTextV(label, fmt, args);
+ va_end(args);
+}
+
+// Add a label+text combo aligned to other label+value widgets
+void ImGui::LabelTextV(const char* label, const char* fmt, va_list args)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const float w = CalcItemWidth();
+
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2));
+ const ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), style.FramePadding.y*2) + label_size);
+ ItemSize(total_bb, style.FramePadding.y);
+ if (!ItemAdd(total_bb, 0))
+ return;
+
+ // Render
+ const char* value_text_begin = &g.TempBuffer[0];
+ const char* value_text_end = value_text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
+ RenderTextClipped(value_bb.Min, value_bb.Max, value_text_begin, value_text_end, NULL, ImVec2(0.0f,0.5f));
+ if (label_size.x > 0.0f)
+ RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label);
+}
+
+void ImGui::BulletText(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ BulletTextV(fmt, args);
+ va_end(args);
+}
+
+// Text with a little bullet aligned to the typical tree node.
+void ImGui::BulletTextV(const char* fmt, va_list args)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ const char* text_begin = g.TempBuffer;
+ const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
+ const ImVec2 label_size = CalcTextSize(text_begin, text_end, false);
+ const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
+ const float line_height = ImMax(ImMin(window->DC.CurrentLineSize.y, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
+ ItemSize(bb);
+ if (!ItemAdd(bb, 0))
+ return;
+
+ // Render
+ RenderBullet(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f));
+ RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end, false);
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: Main
+//-------------------------------------------------------------------------
+// - ButtonBehavior() [Internal]
+// - Button()
+// - SmallButton()
+// - InvisibleButton()
+// - ArrowButton()
+// - CloseButton() [Internal]
+// - CollapseButton() [Internal]
+// - Scrollbar() [Internal]
+// - Image()
+// - ImageButton()
+// - Checkbox()
+// - CheckboxFlags()
+// - RadioButton()
+// - ProgressBar()
+// - Bullet()
+//-------------------------------------------------------------------------
+
+bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+
+ if (flags & ImGuiButtonFlags_Disabled)
+ {
+ if (out_hovered) *out_hovered = false;
+ if (out_held) *out_held = false;
+ if (g.ActiveId == id) ClearActiveID();
+ return false;
+ }
+
+ // Default behavior requires click+release on same spot
+ if ((flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick)) == 0)
+ flags |= ImGuiButtonFlags_PressedOnClickRelease;
+
+ ImGuiWindow* backup_hovered_window = g.HoveredWindow;
+ if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window)
+ g.HoveredWindow = window;
+
+#ifdef IMGUI_ENABLE_TEST_ENGINE
+ if (id != 0 && window->DC.LastItemId != id)
+ ImGuiTestEngineHook_ItemAdd(&g, bb, id);
+#endif
+
+ bool pressed = false;
+ bool hovered = ItemHoverable(bb, id);
+
+ // Drag source doesn't report as hovered
+ if (hovered && g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover))
+ hovered = false;
+
+ // Special mode for Drag and Drop where holding button pressed for a long time while dragging another item triggers the button
+ if (g.DragDropActive && (flags & ImGuiButtonFlags_PressedOnDragDropHold) && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers))
+ if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
+ {
+ hovered = true;
+ SetHoveredID(id);
+ if (CalcTypematicPressedRepeatAmount(g.HoveredIdTimer + 0.0001f, g.HoveredIdTimer + 0.0001f - g.IO.DeltaTime, 0.01f, 0.70f)) // FIXME: Our formula for CalcTypematicPressedRepeatAmount() is fishy
+ {
+ pressed = true;
+ FocusWindow(window);
+ }
+ }
+
+ if ((flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window)
+ g.HoveredWindow = backup_hovered_window;
+
+ // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
+ if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0))
+ hovered = false;
+
+ // Mouse
+ if (hovered)
+ {
+ if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
+ {
+ // | CLICKING | HOLDING with ImGuiButtonFlags_Repeat
+ // PressedOnClickRelease | <on release>* | <on repeat> <on repeat> .. (NOT on release) <-- MOST COMMON! (*) only if both click/release were over bounds
+ // PressedOnClick | <on click> | <on click> <on repeat> <on repeat> ..
+ // PressedOnRelease | <on release> | <on repeat> <on repeat> .. (NOT on release)
+ // PressedOnDoubleClick | <on dclick> | <on dclick> <on repeat> <on repeat> ..
+ // FIXME-NAV: We don't honor those different behaviors.
+ if ((flags & ImGuiButtonFlags_PressedOnClickRelease) && g.IO.MouseClicked[0])
+ {
+ SetActiveID(id, window);
+ if (!(flags & ImGuiButtonFlags_NoNavFocus))
+ SetFocusID(id, window);
+ FocusWindow(window);
+ }
+ if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0]))
+ {
+ pressed = true;
+ if (flags & ImGuiButtonFlags_NoHoldingActiveID)
+ ClearActiveID();
+ else
+ SetActiveID(id, window); // Hold on ID
+ FocusWindow(window);
+ }
+ if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0])
+ {
+ if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
+ pressed = true;
+ ClearActiveID();
+ }
+
+ // 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
+ // Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings.
+ if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && g.IO.MouseDownDuration[0] > 0.0f && IsMouseClicked(0, true))
+ pressed = true;
+ }
+
+ if (pressed)
+ g.NavDisableHighlight = true;
+ }
+
+ // Gamepad/Keyboard navigation
+ // We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse.
+ if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId))
+ hovered = true;
+
+ if (g.NavActivateDownId == id)
+ {
+ bool nav_activated_by_code = (g.NavActivateId == id);
+ bool nav_activated_by_inputs = IsNavInputPressed(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed);
+ if (nav_activated_by_code || nav_activated_by_inputs)
+ pressed = true;
+ if (nav_activated_by_code || nav_activated_by_inputs || g.ActiveId == id)
+ {
+ // Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button.
+ g.NavActivateId = id; // This is so SetActiveId assign a Nav source
+ SetActiveID(id, window);
+ if ((nav_activated_by_code || nav_activated_by_inputs) && !(flags & ImGuiButtonFlags_NoNavFocus))
+ SetFocusID(id, window);
+ g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right) | (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
+ }
+ }
+
+ bool held = false;
+ if (g.ActiveId == id)
+ {
+ if (g.ActiveIdSource == ImGuiInputSource_Mouse)
+ {
+ if (g.ActiveIdIsJustActivated)
+ g.ActiveIdClickOffset = g.IO.MousePos - bb.Min;
+ if (g.IO.MouseDown[0])
+ {
+ held = true;
+ }
+ else
+ {
+ if (hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease))
+ if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
+ if (!g.DragDropActive)
+ pressed = true;
+ ClearActiveID();
+ }
+ if (!(flags & ImGuiButtonFlags_NoNavFocus))
+ g.NavDisableHighlight = true;
+ }
+ else if (g.ActiveIdSource == ImGuiInputSource_Nav)
+ {
+ if (g.NavActivateDownId != id)
+ ClearActiveID();
+ }
+ }
+
+ if (out_hovered) *out_hovered = hovered;
+ if (out_held) *out_held = held;
+
+ return pressed;
+}
+
+bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+
+ ImVec2 pos = window->DC.CursorPos;
+ if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrentLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag)
+ pos.y += window->DC.CurrentLineTextBaseOffset - style.FramePadding.y;
+ ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);
+
+ const ImRect bb(pos, pos + size);
+ ItemSize(size, style.FramePadding.y);
+ if (!ItemAdd(bb, id))
+ return false;
+
+ if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
+ flags |= ImGuiButtonFlags_Repeat;
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
+ if (pressed)
+ MarkItemEdited(id);
+
+ // Render
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
+ RenderNavHighlight(bb, id);
+ RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
+ RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);
+
+ // Automatically close popups
+ //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup))
+ // CloseCurrentPopup();
+
+ return pressed;
+}
+
+bool ImGui::Button(const char* label, const ImVec2& size_arg)
+{
+ return ButtonEx(label, size_arg, 0);
+}
+
+// Small buttons fits within text without additional vertical spacing.
+bool ImGui::SmallButton(const char* label)
+{
+ ImGuiContext& g = *GImGui;
+ float backup_padding_y = g.Style.FramePadding.y;
+ g.Style.FramePadding.y = 0.0f;
+ bool pressed = ButtonEx(label, ImVec2(0, 0), ImGuiButtonFlags_AlignTextBaseLine);
+ g.Style.FramePadding.y = backup_padding_y;
+ return pressed;
+}
+
+// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack.
+// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
+bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ // Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size.
+ IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f);
+
+ const ImGuiID id = window->GetID(str_id);
+ ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f);
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ ItemSize(size);
+ if (!ItemAdd(bb, id))
+ return false;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
+
+ return pressed;
+}
+
+bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiID id = window->GetID(str_id);
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ const float default_size = GetFrameHeight();
+ ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
+ if (!ItemAdd(bb, id))
+ return false;
+
+ if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
+ flags |= ImGuiButtonFlags_Repeat;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
+
+ // Render
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
+ RenderNavHighlight(bb, id);
+ RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
+ RenderArrow(bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), dir);
+
+ return pressed;
+}
+
+bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
+{
+ float sz = GetFrameHeight();
+ return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), 0);
+}
+
+// Button to close a window
+bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos, float radius)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ // We intentionally allow interaction when clipped so that a mechanical Alt,Right,Validate sequence close a window.
+ // (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible).
+ const ImRect bb(pos - ImVec2(radius,radius), pos + ImVec2(radius,radius));
+ bool is_clipped = !ItemAdd(bb, id);
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
+ if (is_clipped)
+ return pressed;
+
+ // Render
+ ImVec2 center = bb.GetCenter();
+ if (hovered)
+ window->DrawList->AddCircleFilled(center, ImMax(2.0f, radius), GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered), 9);
+
+ float cross_extent = (radius * 0.7071f) - 1.0f;
+ ImU32 cross_col = GetColorU32(ImGuiCol_Text);
+ center -= ImVec2(0.5f, 0.5f);
+ window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), cross_col, 1.0f);
+ window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), cross_col, 1.0f);
+
+ return pressed;
+}
+
+bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
+ ItemAdd(bb, id);
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None);
+
+ ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
+ if (hovered || held)
+ window->DrawList->AddCircleFilled(bb.GetCenter() + ImVec2(0.0f, -0.5f), g.FontSize * 0.5f + 1.0f, col, 9);
+ RenderArrow(bb.Min + g.Style.FramePadding, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
+
+ // Switch to moving the window after mouse is moved beyond the initial drag threshold
+ if (IsItemActive() && IsMouseDragging())
+ StartMouseMovingWindow(window);
+
+ return pressed;
+}
+
+// Vertical/Horizontal scrollbar
+// The entire piece of code below is rather confusing because:
+// - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab)
+// - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar
+// - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal.
+void ImGui::Scrollbar(ImGuiLayoutType direction)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ const bool horizontal = (direction == ImGuiLayoutType_Horizontal);
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(horizontal ? "#SCROLLX" : "#SCROLLY");
+
+ // Render background
+ bool other_scrollbar = (horizontal ? window->ScrollbarY : window->ScrollbarX);
+ float other_scrollbar_size_w = other_scrollbar ? style.ScrollbarSize : 0.0f;
+ const ImRect window_rect = window->Rect();
+ const float border_size = window->WindowBorderSize;
+ ImRect bb = horizontal
+ ? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size)
+ : ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
+ if (!horizontal)
+ bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
+ if (bb.GetWidth() <= 0.0f || bb.GetHeight() <= 0.0f)
+ return;
+
+ int window_rounding_corners;
+ if (horizontal)
+ window_rounding_corners = ImDrawCornerFlags_BotLeft | (other_scrollbar ? 0 : ImDrawCornerFlags_BotRight);
+ else
+ window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? ImDrawCornerFlags_TopRight : 0) | (other_scrollbar ? 0 : ImDrawCornerFlags_BotRight);
+ window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_ScrollbarBg), window->WindowRounding, window_rounding_corners);
+ bb.Expand(ImVec2(-ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
+
+ // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar)
+ float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
+ float scroll_v = horizontal ? window->Scroll.x : window->Scroll.y;
+ float win_size_avail_v = (horizontal ? window->SizeFull.x : window->SizeFull.y) - other_scrollbar_size_w;
+ float win_size_contents_v = horizontal ? window->SizeContents.x : window->SizeContents.y;
+
+ // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount)
+ // But we maintain a minimum size in pixel to allow for the user to still aim inside.
+ IM_ASSERT(ImMax(win_size_contents_v, win_size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers.
+ const float win_size_v = ImMax(ImMax(win_size_contents_v, win_size_avail_v), 1.0f);
+ const float grab_h_pixels = ImClamp(scrollbar_size_v * (win_size_avail_v / win_size_v), style.GrabMinSize, scrollbar_size_v);
+ const float grab_h_norm = grab_h_pixels / scrollbar_size_v;
+
+ // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar().
+ bool held = false;
+ bool hovered = false;
+ const bool previously_held = (g.ActiveId == id);
+ ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_NoNavFocus);
+
+ float scroll_max = ImMax(1.0f, win_size_contents_v - win_size_avail_v);
+ float scroll_ratio = ImSaturate(scroll_v / scroll_max);
+ float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;
+ if (held && grab_h_norm < 1.0f)
+ {
+ float scrollbar_pos_v = horizontal ? bb.Min.x : bb.Min.y;
+ float mouse_pos_v = horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
+ float* click_delta_to_grab_center_v = horizontal ? &g.ScrollbarClickDeltaToGrabCenter.x : &g.ScrollbarClickDeltaToGrabCenter.y;
+
+ // Click position in scrollbar normalized space (0.0f->1.0f)
+ const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
+ SetHoveredID(id);
+
+ bool seek_absolute = false;
+ if (!previously_held)
+ {
+ // On initial click calculate the distance between mouse and the center of the grab
+ if (clicked_v_norm >= grab_v_norm && clicked_v_norm <= grab_v_norm + grab_h_norm)
+ {
+ *click_delta_to_grab_center_v = clicked_v_norm - grab_v_norm - grab_h_norm*0.5f;
+ }
+ else
+ {
+ seek_absolute = true;
+ *click_delta_to_grab_center_v = 0.0f;
+ }
+ }
+
+ // Apply scroll
+ // It is ok to modify Scroll here because we are being called in Begin() after the calculation of SizeContents and before setting up our starting position
+ const float scroll_v_norm = ImSaturate((clicked_v_norm - *click_delta_to_grab_center_v - grab_h_norm*0.5f) / (1.0f - grab_h_norm));
+ scroll_v = (float)(int)(0.5f + scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v));
+ if (horizontal)
+ window->Scroll.x = scroll_v;
+ else
+ window->Scroll.y = scroll_v;
+
+ // Update values for rendering
+ scroll_ratio = ImSaturate(scroll_v / scroll_max);
+ grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;
+
+ // Update distance to grab now that we have seeked and saturated
+ if (seek_absolute)
+ *click_delta_to_grab_center_v = clicked_v_norm - grab_v_norm - grab_h_norm*0.5f;
+ }
+
+ // Render
+ const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab);
+ ImRect grab_rect;
+ if (horizontal)
+ grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImMin(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, window_rect.Max.x), bb.Max.y);
+ else
+ grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImMin(ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels, window_rect.Max.y));
+ window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding);
+}
+
+void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ if (border_col.w > 0.0f)
+ bb.Max += ImVec2(2, 2);
+ ItemSize(bb);
+ if (!ItemAdd(bb, 0))
+ return;
+
+ if (border_col.w > 0.0f)
+ {
+ window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f);
+ window->DrawList->AddImage(user_texture_id, bb.Min + ImVec2(1, 1), bb.Max - ImVec2(1, 1), uv0, uv1, GetColorU32(tint_col));
+ }
+ else
+ {
+ window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col));
+ }
+}
+
+// frame_padding < 0: uses FramePadding from style (default)
+// frame_padding = 0: no framing
+// frame_padding > 0: set framing size
+// The color used are the button colors.
+bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ // Default to using texture ID as ID. User can still push string/integer prefixes.
+ // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV.
+ PushID((void*)(intptr_t)user_texture_id);
+ const ImGuiID id = window->GetID("#image");
+ PopID();
+
+ const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : style.FramePadding;
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2);
+ const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size);
+ ItemSize(bb);
+ if (!ItemAdd(bb, id))
+ return false;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
+
+ // Render
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
+ RenderNavHighlight(bb, id);
+ RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding));
+ if (bg_col.w > 0.0f)
+ window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col));
+ window->DrawList->AddImage(user_texture_id, image_bb.Min, image_bb.Max, uv0, uv1, GetColorU32(tint_col));
+
+ return pressed;
+}
+
+bool ImGui::Checkbox(const char* label, bool* v)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+
+ const ImRect check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(label_size.y + style.FramePadding.y*2, label_size.y + style.FramePadding.y*2)); // We want a square shape to we use Y twice
+ ItemSize(check_bb, style.FramePadding.y);
+
+ ImRect total_bb = check_bb;
+ if (label_size.x > 0)
+ SameLine(0, style.ItemInnerSpacing.x);
+ const ImRect text_bb(window->DC.CursorPos + ImVec2(0,style.FramePadding.y), window->DC.CursorPos + ImVec2(0,style.FramePadding.y) + label_size);
+ if (label_size.x > 0)
+ {
+ ItemSize(ImVec2(text_bb.GetWidth(), check_bb.GetHeight()), style.FramePadding.y);
+ total_bb = ImRect(ImMin(check_bb.Min, text_bb.Min), ImMax(check_bb.Max, text_bb.Max));
+ }
+
+ if (!ItemAdd(total_bb, id))
+ return false;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
+ if (pressed)
+ {
+ *v = !(*v);
+ MarkItemEdited(id);
+ }
+
+ RenderNavHighlight(total_bb, id);
+ RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
+ if (*v)
+ {
+ const float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight());
+ const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
+ RenderCheckMark(check_bb.Min + ImVec2(pad,pad), GetColorU32(ImGuiCol_CheckMark), check_bb.GetWidth() - pad*2.0f);
+ }
+
+ if (g.LogEnabled)
+ LogRenderedText(&text_bb.Min, *v ? "[x]" : "[ ]");
+ if (label_size.x > 0.0f)
+ RenderText(text_bb.Min, label);
+
+ IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
+ return pressed;
+}
+
+bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
+{
+ bool v = ((*flags & flags_value) == flags_value);
+ bool pressed = Checkbox(label, &v);
+ if (pressed)
+ {
+ if (v)
+ *flags |= flags_value;
+ else
+ *flags &= ~flags_value;
+ }
+
+ return pressed;
+}
+
+bool ImGui::RadioButton(const char* label, bool active)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+
+ const ImRect check_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(label_size.y + style.FramePadding.y*2-1, label_size.y + style.FramePadding.y*2-1));
+ ItemSize(check_bb, style.FramePadding.y);
+
+ ImRect total_bb = check_bb;
+ if (label_size.x > 0)
+ SameLine(0, style.ItemInnerSpacing.x);
+ const ImRect text_bb(window->DC.CursorPos + ImVec2(0, style.FramePadding.y), window->DC.CursorPos + ImVec2(0, style.FramePadding.y) + label_size);
+ if (label_size.x > 0)
+ {
+ ItemSize(ImVec2(text_bb.GetWidth(), check_bb.GetHeight()), style.FramePadding.y);
+ total_bb.Add(text_bb);
+ }
+
+ if (!ItemAdd(total_bb, id))
+ return false;
+
+ ImVec2 center = check_bb.GetCenter();
+ center.x = (float)(int)center.x + 0.5f;
+ center.y = (float)(int)center.y + 0.5f;
+ const float radius = check_bb.GetHeight() * 0.5f;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
+ if (pressed)
+ MarkItemEdited(id);
+
+ RenderNavHighlight(total_bb, id);
+ window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16);
+ if (active)
+ {
+ const float check_sz = ImMin(check_bb.GetWidth(), check_bb.GetHeight());
+ const float pad = ImMax(1.0f, (float)(int)(check_sz / 6.0f));
+ window->DrawList->AddCircleFilled(center, radius-pad, GetColorU32(ImGuiCol_CheckMark), 16);
+ }
+
+ if (style.FrameBorderSize > 0.0f)
+ {
+ window->DrawList->AddCircle(center+ImVec2(1,1), radius, GetColorU32(ImGuiCol_BorderShadow), 16, style.FrameBorderSize);
+ window->DrawList->AddCircle(center, radius, GetColorU32(ImGuiCol_Border), 16, style.FrameBorderSize);
+ }
+
+ if (g.LogEnabled)
+ LogRenderedText(&text_bb.Min, active ? "(x)" : "( )");
+ if (label_size.x > 0.0f)
+ RenderText(text_bb.Min, label);
+
+ return pressed;
+}
+
+bool ImGui::RadioButton(const char* label, int* v, int v_button)
+{
+ const bool pressed = RadioButton(label, *v == v_button);
+ if (pressed)
+ *v = v_button;
+ return pressed;
+}
+
+// size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size
+void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* overlay)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ ImVec2 pos = window->DC.CursorPos;
+ ImRect bb(pos, pos + CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f));
+ ItemSize(bb, style.FramePadding.y);
+ if (!ItemAdd(bb, 0))
+ return;
+
+ // Render
+ fraction = ImSaturate(fraction);
+ RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
+ bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
+ const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
+ RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
+
+ // Default displaying the fraction as percentage string, but user can override it
+ char overlay_buf[32];
+ if (!overlay)
+ {
+ ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction*100+0.01f);
+ overlay = overlay_buf;
+ }
+
+ ImVec2 overlay_size = CalcTextSize(overlay, NULL);
+ if (overlay_size.x > 0.0f)
+ RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f,0.5f), &bb);
+}
+
+void ImGui::Bullet()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const float line_height = ImMax(ImMin(window->DC.CurrentLineSize.y, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
+ ItemSize(bb);
+ if (!ItemAdd(bb, 0))
+ {
+ SameLine(0, style.FramePadding.x*2);
+ return;
+ }
+
+ // Render and stay on same line
+ RenderBullet(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f));
+ SameLine(0, style.FramePadding.x*2);
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: Low-level Layout helpers
+//-------------------------------------------------------------------------
+// - Spacing()
+// - Dummy()
+// - NewLine()
+// - AlignTextToFramePadding()
+// - Separator()
+// - VerticalSeparator() [Internal]
+// - SplitterBehavior() [Internal]
+//-------------------------------------------------------------------------
+
+void ImGui::Spacing()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+ ItemSize(ImVec2(0,0));
+}
+
+void ImGui::Dummy(const ImVec2& size)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ ItemSize(bb);
+ ItemAdd(bb, 0);
+}
+
+void ImGui::NewLine()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiLayoutType backup_layout_type = window->DC.LayoutType;
+ window->DC.LayoutType = ImGuiLayoutType_Vertical;
+ if (window->DC.CurrentLineSize.y > 0.0f) // In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height.
+ ItemSize(ImVec2(0,0));
+ else
+ ItemSize(ImVec2(0.0f, g.FontSize));
+ window->DC.LayoutType = backup_layout_type;
+}
+
+void ImGui::AlignTextToFramePadding()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ window->DC.CurrentLineSize.y = ImMax(window->DC.CurrentLineSize.y, g.FontSize + g.Style.FramePadding.y * 2);
+ window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
+}
+
+// Horizontal/vertical separating line
+void ImGui::Separator()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+ ImGuiContext& g = *GImGui;
+
+ // Those flags should eventually be overridable by the user
+ ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
+ IM_ASSERT(ImIsPowerOfTwo((int)(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)))); // Check that only 1 option is selected
+ if (flags & ImGuiSeparatorFlags_Vertical)
+ {
+ VerticalSeparator();
+ return;
+ }
+
+ // Horizontal Separator
+ if (window->DC.ColumnsSet)
+ PopClipRect();
+
+ float x1 = window->Pos.x;
+ float x2 = window->Pos.x + window->Size.x;
+ if (!window->DC.GroupStack.empty())
+ x1 += window->DC.Indent.x;
+
+ const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y+1.0f));
+ ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout.
+ if (!ItemAdd(bb, 0))
+ {
+ if (window->DC.ColumnsSet)
+ PushColumnClipRect();
+ return;
+ }
+
+ window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x,bb.Min.y), GetColorU32(ImGuiCol_Separator));
+
+ if (g.LogEnabled)
+ LogRenderedText(&bb.Min, "--------------------------------");
+
+ if (window->DC.ColumnsSet)
+ {
+ PushColumnClipRect();
+ window->DC.ColumnsSet->LineMinY = window->DC.CursorPos.y;
+ }
+}
+
+void ImGui::VerticalSeparator()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+ ImGuiContext& g = *GImGui;
+
+ float y1 = window->DC.CursorPos.y;
+ float y2 = window->DC.CursorPos.y + window->DC.CurrentLineSize.y;
+ const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + 1.0f, y2));
+ ItemSize(ImVec2(bb.GetWidth(), 0.0f));
+ if (!ItemAdd(bb, 0))
+ return;
+
+ window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator));
+ if (g.LogEnabled)
+ LogText(" |");
+}
+
+// Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise.
+bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend, float hover_visibility_delay)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags;
+ window->DC.ItemFlags |= ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus;
+ bool item_add = ItemAdd(bb, id);
+ window->DC.ItemFlags = item_flags_backup;
+ if (!item_add)
+ return false;
+
+ bool hovered, held;
+ ImRect bb_interact = bb;
+ bb_interact.Expand(axis == ImGuiAxis_Y ? ImVec2(0.0f, hover_extend) : ImVec2(hover_extend, 0.0f));
+ ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap);
+ if (g.ActiveId != id)
+ SetItemAllowOverlap();
+
+ if (held || (g.HoveredId == id && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay))
+ SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW);
+
+ ImRect bb_render = bb;
+ if (held)
+ {
+ ImVec2 mouse_delta_2d = g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min;
+ float mouse_delta = (axis == ImGuiAxis_Y) ? mouse_delta_2d.y : mouse_delta_2d.x;
+
+ // Minimum pane size
+ float size_1_maximum_delta = ImMax(0.0f, *size1 - min_size1);
+ float size_2_maximum_delta = ImMax(0.0f, *size2 - min_size2);
+ if (mouse_delta < -size_1_maximum_delta)
+ mouse_delta = -size_1_maximum_delta;
+ if (mouse_delta > size_2_maximum_delta)
+ mouse_delta = size_2_maximum_delta;
+
+ // Apply resize
+ if (mouse_delta != 0.0f)
+ {
+ if (mouse_delta < 0.0f)
+ IM_ASSERT(*size1 + mouse_delta >= min_size1);
+ if (mouse_delta > 0.0f)
+ IM_ASSERT(*size2 - mouse_delta >= min_size2);
+ *size1 += mouse_delta;
+ *size2 -= mouse_delta;
+ bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta));
+ MarkItemEdited(id);
+ }
+ }
+
+ // Render
+ const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : (hovered && g.HoveredIdTimer >= hover_visibility_delay) ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
+ window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, g.Style.FrameRounding);
+
+ return held;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: ComboBox
+//-------------------------------------------------------------------------
+// - BeginCombo()
+// - EndCombo()
+// - Combo()
+//-------------------------------------------------------------------------
+
+static float CalcMaxPopupHeightFromItemCount(int items_count)
+{
+ ImGuiContext& g = *GImGui;
+ if (items_count <= 0)
+ return FLT_MAX;
+ return (g.FontSize + g.Style.ItemSpacing.y) * items_count - g.Style.ItemSpacing.y + (g.Style.WindowPadding.y * 2);
+}
+
+bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags)
+{
+ // Always consume the SetNextWindowSizeConstraint() call in our early return paths
+ ImGuiContext& g = *GImGui;
+ ImGuiCond backup_next_window_size_constraint = g.NextWindowData.SizeConstraintCond;
+ g.NextWindowData.SizeConstraintCond = 0;
+
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together
+
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+
+ const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight();
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : CalcItemWidth();
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
+ const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
+ ItemSize(total_bb, style.FramePadding.y);
+ if (!ItemAdd(total_bb, id, &frame_bb))
+ return false;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(frame_bb, id, &hovered, &held);
+ bool popup_open = IsPopupOpen(id);
+
+ const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
+ const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
+ RenderNavHighlight(frame_bb, id);
+ if (!(flags & ImGuiComboFlags_NoPreview))
+ window->DrawList->AddRectFilled(frame_bb.Min, ImVec2(frame_bb.Max.x - arrow_size, frame_bb.Max.y), frame_col, style.FrameRounding, ImDrawCornerFlags_Left);
+ if (!(flags & ImGuiComboFlags_NoArrowButton))
+ {
+ window->DrawList->AddRectFilled(ImVec2(frame_bb.Max.x - arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button), style.FrameRounding, (w <= arrow_size) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Right);
+ RenderArrow(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), ImGuiDir_Down);
+ }
+ RenderFrameBorder(frame_bb.Min, frame_bb.Max, style.FrameRounding);
+ if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview))
+ RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, preview_value, NULL, NULL, ImVec2(0.0f,0.0f));
+ if (label_size.x > 0)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
+
+ if ((pressed || g.NavActivateId == id) && !popup_open)
+ {
+ if (window->DC.NavLayerCurrent == 0)
+ window->NavLastIds[0] = id;
+ OpenPopupEx(id);
+ popup_open = true;
+ }
+
+ if (!popup_open)
+ return false;
+
+ if (backup_next_window_size_constraint)
+ {
+ g.NextWindowData.SizeConstraintCond = backup_next_window_size_constraint;
+ g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w);
+ }
+ else
+ {
+ if ((flags & ImGuiComboFlags_HeightMask_) == 0)
+ flags |= ImGuiComboFlags_HeightRegular;
+ IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiComboFlags_HeightMask_)); // Only one
+ int popup_max_height_in_items = -1;
+ if (flags & ImGuiComboFlags_HeightRegular) popup_max_height_in_items = 8;
+ else if (flags & ImGuiComboFlags_HeightSmall) popup_max_height_in_items = 4;
+ else if (flags & ImGuiComboFlags_HeightLarge) popup_max_height_in_items = 20;
+ SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items)));
+ }
+
+ char name[16];
+ ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
+
+ // Peak into expected window size so we can position it
+ if (ImGuiWindow* popup_window = FindWindowByName(name))
+ if (popup_window->WasActive)
+ {
+ ImVec2 size_expected = CalcWindowExpectedSize(popup_window);
+ if (flags & ImGuiComboFlags_PopupAlignLeft)
+ popup_window->AutoPosLastDirection = ImGuiDir_Left;
+ ImRect r_outer = GetWindowAllowedExtentRect(popup_window);
+ ImVec2 pos = FindBestWindowPosForPopupEx(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, r_outer, frame_bb, ImGuiPopupPositionPolicy_ComboBox);
+ SetNextWindowPos(pos);
+ }
+
+ // Horizontally align ourselves with the framed text
+ ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings;
+ PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(style.FramePadding.x, style.WindowPadding.y));
+ bool ret = Begin(name, NULL, window_flags);
+ PopStyleVar();
+ if (!ret)
+ {
+ EndPopup();
+ IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
+ return false;
+ }
+ return true;
+}
+
+void ImGui::EndCombo()
+{
+ EndPopup();
+}
+
+// Getter for the old Combo() API: const char*[]
+static bool Items_ArrayGetter(void* data, int idx, const char** out_text)
+{
+ const char* const* items = (const char* const*)data;
+ if (out_text)
+ *out_text = items[idx];
+ return true;
+}
+
+// Getter for the old Combo() API: "item1\0item2\0item3\0"
+static bool Items_SingleStringGetter(void* data, int idx, const char** out_text)
+{
+ // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited.
+ const char* items_separated_by_zeros = (const char*)data;
+ int items_count = 0;
+ const char* p = items_separated_by_zeros;
+ while (*p)
+ {
+ if (idx == items_count)
+ break;
+ p += strlen(p) + 1;
+ items_count++;
+ }
+ if (!*p)
+ return false;
+ if (out_text)
+ *out_text = p;
+ return true;
+}
+
+// Old API, prefer using BeginCombo() nowadays if you can.
+bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items)
+{
+ ImGuiContext& g = *GImGui;
+
+ // Call the getter to obtain the preview string which is a parameter to BeginCombo()
+ const char* preview_value = NULL;
+ if (*current_item >= 0 && *current_item < items_count)
+ items_getter(data, *current_item, &preview_value);
+
+ // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here.
+ if (popup_max_height_in_items != -1 && !g.NextWindowData.SizeConstraintCond)
+ SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items)));
+
+ if (!BeginCombo(label, preview_value, ImGuiComboFlags_None))
+ return false;
+
+ // Display items
+ // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed)
+ bool value_changed = false;
+ for (int i = 0; i < items_count; i++)
+ {
+ PushID((void*)(intptr_t)i);
+ const bool item_selected = (i == *current_item);
+ const char* item_text;
+ if (!items_getter(data, i, &item_text))
+ item_text = "*Unknown item*";
+ if (Selectable(item_text, item_selected))
+ {
+ value_changed = true;
+ *current_item = i;
+ }
+ if (item_selected)
+ SetItemDefaultFocus();
+ PopID();
+ }
+
+ EndCombo();
+ return value_changed;
+}
+
+// Combo box helper allowing to pass an array of strings.
+bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items)
+{
+ const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items);
+ return value_changed;
+}
+
+// Combo box helper allowing to pass all items in a single string literal holding multiple zero-terminated items "item1\0item2\0"
+bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items)
+{
+ int items_count = 0;
+ const char* p = items_separated_by_zeros; // FIXME-OPT: Avoid computing this, or at least only when combo is open
+ while (*p)
+ {
+ p += strlen(p) + 1;
+ items_count++;
+ }
+ bool value_changed = Combo(label, current_item, Items_SingleStringGetter, (void*)items_separated_by_zeros, items_count, height_in_items);
+ return value_changed;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Data Type and Data Formatting Helpers [Internal]
+//-------------------------------------------------------------------------
+// - PatchFormatStringFloatToInt()
+// - DataTypeFormatString()
+// - DataTypeApplyOp()
+// - DataTypeApplyOpFromText()
+// - GetMinimumStepAtDecimalPrecision
+// - RoundScalarWithFormat<>()
+//-------------------------------------------------------------------------
+
+struct ImGuiDataTypeInfo
+{
+ size_t Size;
+ const char* PrintFmt; // Unused
+ const char* ScanFmt;
+};
+
+static const ImGuiDataTypeInfo GDataTypeInfo[] =
+{
+ { sizeof(int), "%d", "%d" },
+ { sizeof(unsigned int), "%u", "%u" },
+#ifdef _MSC_VER
+ { sizeof(ImS64), "%I64d","%I64d" },
+ { sizeof(ImU64), "%I64u","%I64u" },
+#else
+ { sizeof(ImS64), "%lld", "%lld" },
+ { sizeof(ImU64), "%llu", "%llu" },
+#endif
+ { sizeof(float), "%f", "%f" }, // float are promoted to double in va_arg
+ { sizeof(double), "%f", "%lf" },
+};
+IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
+
+// FIXME-LEGACY: Prior to 1.61 our DragInt() function internally used floats and because of this the compile-time default value for format was "%.0f".
+// Even though we changed the compile-time default, we expect users to have carried %f around, which would break the display of DragInt() calls.
+// To honor backward compatibility we are rewriting the format string, unless IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. What could possibly go wrong?!
+static const char* PatchFormatStringFloatToInt(const char* fmt)
+{
+ if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0) // Fast legacy path for "%.0f" which is expected to be the most common case.
+ return "%d";
+ const char* fmt_start = ImParseFormatFindStart(fmt); // Find % (if any, and ignore %%)
+ const char* fmt_end = ImParseFormatFindEnd(fmt_start); // Find end of format specifier, which itself is an exercise of confidence/recklessness (because snprintf is dependent on libc or user).
+ if (fmt_end > fmt_start && fmt_end[-1] == 'f')
+ {
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ if (fmt_start == fmt && fmt_end[0] == 0)
+ return "%d";
+ ImGuiContext& g = *GImGui;
+ ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%.*s%%d%s", (int)(fmt_start - fmt), fmt, fmt_end); // Honor leading and trailing decorations, but lose alignment/precision.
+ return g.TempBuffer;
+#else
+ IM_ASSERT(0 && "DragInt(): Invalid format string!"); // Old versions used a default parameter of "%.0f", please replace with e.g. "%d"
+#endif
+ }
+ return fmt;
+}
+
+static inline int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format)
+{
+ if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32) // Signedness doesn't matter when pushing the argument
+ return ImFormatString(buf, buf_size, format, *(const ImU32*)data_ptr);
+ if (data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) // Signedness doesn't matter when pushing the argument
+ return ImFormatString(buf, buf_size, format, *(const ImU64*)data_ptr);
+ if (data_type == ImGuiDataType_Float)
+ return ImFormatString(buf, buf_size, format, *(const float*)data_ptr);
+ if (data_type == ImGuiDataType_Double)
+ return ImFormatString(buf, buf_size, format, *(const double*)data_ptr);
+ IM_ASSERT(0);
+ return 0;
+}
+
+// FIXME: Adding support for clamping on boundaries of the data type would be nice.
+static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg1, const void* arg2)
+{
+ IM_ASSERT(op == '+' || op == '-');
+ switch (data_type)
+ {
+ case ImGuiDataType_S32:
+ if (op == '+') *(int*)output = *(const int*)arg1 + *(const int*)arg2;
+ else if (op == '-') *(int*)output = *(const int*)arg1 - *(const int*)arg2;
+ return;
+ case ImGuiDataType_U32:
+ if (op == '+') *(unsigned int*)output = *(const unsigned int*)arg1 + *(const ImU32*)arg2;
+ else if (op == '-') *(unsigned int*)output = *(const unsigned int*)arg1 - *(const ImU32*)arg2;
+ return;
+ case ImGuiDataType_S64:
+ if (op == '+') *(ImS64*)output = *(const ImS64*)arg1 + *(const ImS64*)arg2;
+ else if (op == '-') *(ImS64*)output = *(const ImS64*)arg1 - *(const ImS64*)arg2;
+ return;
+ case ImGuiDataType_U64:
+ if (op == '+') *(ImU64*)output = *(const ImU64*)arg1 + *(const ImU64*)arg2;
+ else if (op == '-') *(ImU64*)output = *(const ImU64*)arg1 - *(const ImU64*)arg2;
+ return;
+ case ImGuiDataType_Float:
+ if (op == '+') *(float*)output = *(const float*)arg1 + *(const float*)arg2;
+ else if (op == '-') *(float*)output = *(const float*)arg1 - *(const float*)arg2;
+ return;
+ case ImGuiDataType_Double:
+ if (op == '+') *(double*)output = *(const double*)arg1 + *(const double*)arg2;
+ else if (op == '-') *(double*)output = *(const double*)arg1 - *(const double*)arg2;
+ return;
+ case ImGuiDataType_COUNT: break;
+ }
+ IM_ASSERT(0);
+}
+
+// User can input math operators (e.g. +100) to edit a numerical values.
+// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess..
+static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* format)
+{
+ while (ImCharIsBlankA(*buf))
+ buf++;
+
+ // We don't support '-' op because it would conflict with inputing negative value.
+ // Instead you can use +-100 to subtract from an existing value
+ char op = buf[0];
+ if (op == '+' || op == '*' || op == '/')
+ {
+ buf++;
+ while (ImCharIsBlankA(*buf))
+ buf++;
+ }
+ else
+ {
+ op = 0;
+ }
+ if (!buf[0])
+ return false;
+
+ // Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
+ IM_ASSERT(data_type < ImGuiDataType_COUNT);
+ int data_backup[2];
+ IM_ASSERT(GDataTypeInfo[data_type].Size <= sizeof(data_backup));
+ memcpy(data_backup, data_ptr, GDataTypeInfo[data_type].Size);
+
+ if (format == NULL)
+ format = GDataTypeInfo[data_type].ScanFmt;
+
+ int arg1i = 0;
+ if (data_type == ImGuiDataType_S32)
+ {
+ int* v = (int*)data_ptr;
+ int arg0i = *v;
+ float arg1f = 0.0f;
+ if (op && sscanf(initial_value_buf, format, &arg0i) < 1)
+ return false;
+ // Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
+ if (op == '+') { if (sscanf(buf, "%d", &arg1i)) *v = (int)(arg0i + arg1i); } // Add (use "+-" to subtract)
+ else if (op == '*') { if (sscanf(buf, "%f", &arg1f)) *v = (int)(arg0i * arg1f); } // Multiply
+ else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); } // Divide
+ else { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; } // Assign constant
+ }
+ else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64)
+ {
+ // Assign constant
+ // FIXME: We don't bother handling support for legacy operators since they are a little too crappy. Instead we may implement a proper expression evaluator in the future.
+ sscanf(buf, format, data_ptr);
+ }
+ else if (data_type == ImGuiDataType_Float)
+ {
+ // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
+ format = "%f";
+ float* v = (float*)data_ptr;
+ float arg0f = *v, arg1f = 0.0f;
+ if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
+ return false;
+ if (sscanf(buf, format, &arg1f) < 1)
+ return false;
+ if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract)
+ else if (op == '*') { *v = arg0f * arg1f; } // Multiply
+ else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
+ else { *v = arg1f; } // Assign constant
+ }
+ else if (data_type == ImGuiDataType_Double)
+ {
+ format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis
+ double* v = (double*)data_ptr;
+ double arg0f = *v, arg1f = 0.0;
+ if (op && sscanf(initial_value_buf, format, &arg0f) < 1)
+ return false;
+ if (sscanf(buf, format, &arg1f) < 1)
+ return false;
+ if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract)
+ else if (op == '*') { *v = arg0f * arg1f; } // Multiply
+ else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide
+ else { *v = arg1f; } // Assign constant
+ }
+ return memcmp(data_backup, data_ptr, GDataTypeInfo[data_type].Size) != 0;
+}
+
+static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
+{
+ static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f };
+ if (decimal_precision < 0)
+ return FLT_MIN;
+ return (decimal_precision >= 0 && decimal_precision < 10) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision);
+}
+
+template<typename TYPE>
+static const char* ImAtoi(const char* src, TYPE* output)
+{
+ int negative = 0;
+ if (*src == '-') { negative = 1; src++; }
+ if (*src == '+') { src++; }
+ TYPE v = 0;
+ while (*src >= '0' && *src <= '9')
+ v = (v * 10) + (*src++ - '0');
+ *output = negative ? -v : v;
+ return src;
+}
+
+template<typename TYPE, typename SIGNEDTYPE>
+TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v)
+{
+ const char* fmt_start = ImParseFormatFindStart(format);
+ if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string
+ return v;
+ char v_str[64];
+ ImFormatString(v_str, IM_ARRAYSIZE(v_str), fmt_start, v);
+ const char* p = v_str;
+ while (*p == ' ')
+ p++;
+ if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
+ v = (TYPE)ImAtof(p);
+ else
+ ImAtoi(p, (SIGNEDTYPE*)&v);
+ return v;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc.
+//-------------------------------------------------------------------------
+// - DragBehaviorT<>() [Internal]
+// - DragBehavior() [Internal]
+// - DragScalar()
+// - DragScalarN()
+// - DragFloat()
+// - DragFloat2()
+// - DragFloat3()
+// - DragFloat4()
+// - DragFloatRange2()
+// - DragInt()
+// - DragInt2()
+// - DragInt3()
+// - DragInt4()
+// - DragIntRange2()
+//-------------------------------------------------------------------------
+
+// This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls)
+template<typename TYPE, typename SIGNEDTYPE, typename FLOATTYPE>
+bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiDragFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ const ImGuiAxis axis = (flags & ImGuiDragFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X;
+ const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
+ const bool has_min_max = (v_min != v_max);
+
+ // Default tweak speed
+ if (v_speed == 0.0f && has_min_max && (v_max - v_min < FLT_MAX))
+ v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio);
+
+ // Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings
+ float adjust_delta = 0.0f;
+ if (g.ActiveIdSource == ImGuiInputSource_Mouse && IsMousePosValid() && g.IO.MouseDragMaxDistanceSqr[0] > 1.0f*1.0f)
+ {
+ adjust_delta = g.IO.MouseDelta[axis];
+ if (g.IO.KeyAlt)
+ adjust_delta *= 1.0f / 100.0f;
+ if (g.IO.KeyShift)
+ adjust_delta *= 10.0f;
+ }
+ else if (g.ActiveIdSource == ImGuiInputSource_Nav)
+ {
+ int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0;
+ adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f)[axis];
+ v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision));
+ }
+ adjust_delta *= v_speed;
+
+ // For vertical drag we currently assume that Up=higher value (like we do with vertical sliders). This may become a parameter.
+ if (axis == ImGuiAxis_Y)
+ adjust_delta = -adjust_delta;
+
+ // Clear current value on activation
+ // Avoid altering values and clamping when we are _already_ past the limits and heading in the same direction, so e.g. if range is 0..255, current value is 300 and we are pushing to the right side, keep the 300.
+ bool is_just_activated = g.ActiveIdIsJustActivated;
+ bool is_already_past_limits_and_pushing_outward = has_min_max && ((*v >= v_max && adjust_delta > 0.0f) || (*v <= v_min && adjust_delta < 0.0f));
+ if (is_just_activated || is_already_past_limits_and_pushing_outward)
+ {
+ g.DragCurrentAccum = 0.0f;
+ g.DragCurrentAccumDirty = false;
+ }
+ else if (adjust_delta != 0.0f)
+ {
+ g.DragCurrentAccum += adjust_delta;
+ g.DragCurrentAccumDirty = true;
+ }
+
+ if (!g.DragCurrentAccumDirty)
+ return false;
+
+ TYPE v_cur = *v;
+ FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f;
+
+ const bool is_power = (power != 1.0f && is_decimal && has_min_max && (v_max - v_min < FLT_MAX));
+ if (is_power)
+ {
+ // Offset + round to user desired precision, with a curve on the v_min..v_max range to get more precision on one side of the range
+ FLOATTYPE v_old_norm_curved = ImPow((FLOATTYPE)(v_cur - v_min) / (FLOATTYPE)(v_max - v_min), (FLOATTYPE)1.0f / power);
+ FLOATTYPE v_new_norm_curved = v_old_norm_curved + (g.DragCurrentAccum / (v_max - v_min));
+ v_cur = v_min + (TYPE)ImPow(ImSaturate((float)v_new_norm_curved), power) * (v_max - v_min);
+ v_old_ref_for_accum_remainder = v_old_norm_curved;
+ }
+ else
+ {
+ v_cur += (TYPE)g.DragCurrentAccum;
+ }
+
+ // Round to user desired precision based on format string
+ v_cur = RoundScalarWithFormatT<TYPE, SIGNEDTYPE>(format, data_type, v_cur);
+
+ // Preserve remainder after rounding has been applied. This also allow slow tweaking of values.
+ g.DragCurrentAccumDirty = false;
+ if (is_power)
+ {
+ FLOATTYPE v_cur_norm_curved = ImPow((FLOATTYPE)(v_cur - v_min) / (FLOATTYPE)(v_max - v_min), (FLOATTYPE)1.0f / power);
+ g.DragCurrentAccum -= (float)(v_cur_norm_curved - v_old_ref_for_accum_remainder);
+ }
+ else
+ {
+ g.DragCurrentAccum -= (float)((SIGNEDTYPE)v_cur - (SIGNEDTYPE)*v);
+ }
+
+ // Lose zero sign for float/double
+ if (v_cur == (TYPE)-0)
+ v_cur = (TYPE)0;
+
+ // Clamp values (+ handle overflow/wrap-around for integer types)
+ if (*v != v_cur && has_min_max)
+ {
+ if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_decimal))
+ v_cur = v_min;
+ if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_decimal))
+ v_cur = v_max;
+ }
+
+ // Apply result
+ if (*v == v_cur)
+ return false;
+ *v = v_cur;
+ return true;
+}
+
+bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.ActiveId == id)
+ {
+ if (g.ActiveIdSource == ImGuiInputSource_Mouse && !g.IO.MouseDown[0])
+ ClearActiveID();
+ else if (g.ActiveIdSource == ImGuiInputSource_Nav && g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated)
+ ClearActiveID();
+ }
+ if (g.ActiveId != id)
+ return false;
+
+ switch (data_type)
+ {
+ case ImGuiDataType_S32: return DragBehaviorT<ImS32, ImS32, float >(data_type, (ImS32*)v, v_speed, v_min ? *(const ImS32* )v_min : IM_S32_MIN, v_max ? *(const ImS32* )v_max : IM_S32_MAX, format, power, flags);
+ case ImGuiDataType_U32: return DragBehaviorT<ImU32, ImS32, float >(data_type, (ImU32*)v, v_speed, v_min ? *(const ImU32* )v_min : IM_U32_MIN, v_max ? *(const ImU32* )v_max : IM_U32_MAX, format, power, flags);
+ case ImGuiDataType_S64: return DragBehaviorT<ImS64, ImS64, double>(data_type, (ImS64*)v, v_speed, v_min ? *(const ImS64* )v_min : IM_S64_MIN, v_max ? *(const ImS64* )v_max : IM_S64_MAX, format, power, flags);
+ case ImGuiDataType_U64: return DragBehaviorT<ImU64, ImS64, double>(data_type, (ImU64*)v, v_speed, v_min ? *(const ImU64* )v_min : IM_U64_MIN, v_max ? *(const ImU64* )v_max : IM_U64_MAX, format, power, flags);
+ case ImGuiDataType_Float: return DragBehaviorT<float, float, float >(data_type, (float*)v, v_speed, v_min ? *(const float* )v_min : -FLT_MAX, v_max ? *(const float* )v_max : FLT_MAX, format, power, flags);
+ case ImGuiDataType_Double: return DragBehaviorT<double,double,double>(data_type, (double*)v, v_speed, v_min ? *(const double*)v_min : -DBL_MAX, v_max ? *(const double*)v_max : DBL_MAX, format, power, flags);
+ case ImGuiDataType_COUNT: break;
+ }
+ IM_ASSERT(0);
+ return false;
+}
+
+bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ if (power != 1.0f)
+ IM_ASSERT(v_min != NULL && v_max != NULL); // When using a power curve the drag needs to have known bounds
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+ const float w = CalcItemWidth();
+
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
+ const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
+ const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
+
+ // NB- we don't call ItemSize() yet because we may turn into a text edit box below
+ if (!ItemAdd(total_bb, id, &frame_bb))
+ {
+ ItemSize(total_bb, style.FramePadding.y);
+ return false;
+ }
+ const bool hovered = ItemHoverable(frame_bb, id);
+
+ // Default format string when passing NULL
+ // Patch old "%.0f" format string to use "%d", read function comments for more details.
+ IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
+ if (format == NULL)
+ format = GDataTypeInfo[data_type].PrintFmt;
+ else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0)
+ format = PatchFormatStringFloatToInt(format);
+
+ // Tabbing or CTRL-clicking on Drag turns it into an input box
+ bool start_text_input = false;
+ const bool tab_focus_requested = FocusableItemRegister(window, id);
+ if (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0])) || g.NavActivateId == id || (g.NavInputId == id && g.ScalarAsInputTextId != id))
+ {
+ SetActiveID(id, window);
+ SetFocusID(id, window);
+ FocusWindow(window);
+ g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
+ if (tab_focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0] || g.NavInputId == id)
+ {
+ start_text_input = true;
+ g.ScalarAsInputTextId = 0;
+ }
+ }
+ if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id))
+ {
+ FocusableItemUnregister(window);
+ return InputScalarAsWidgetReplacement(frame_bb, id, label, data_type, v, format);
+ }
+
+ // Actual drag behavior
+ ItemSize(total_bb, style.FramePadding.y);
+ const bool value_changed = DragBehavior(id, data_type, v, v_speed, v_min, v_max, format, power, ImGuiDragFlags_None);
+ if (value_changed)
+ MarkItemEdited(id);
+
+ // Draw frame
+ const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
+ RenderNavHighlight(frame_bb, id);
+ RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding);
+
+ // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
+ char value_buf[64];
+ const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, v, format);
+ RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f));
+
+ if (label_size.x > 0.0f)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label);
+
+ return value_changed;
+}
+
+bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* v, int components, float v_speed, const void* v_min, const void* v_max, const char* format, float power)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ bool value_changed = false;
+ BeginGroup();
+ PushID(label);
+ PushMultiItemsWidths(components);
+ size_t type_size = GDataTypeInfo[data_type].Size;
+ for (int i = 0; i < components; i++)
+ {
+ PushID(i);
+ value_changed |= DragScalar("##v", data_type, v, v_speed, v_min, v_max, format, power);
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+ PopID();
+ PopItemWidth();
+ v = (void*)((char*)v + type_size);
+ }
+ PopID();
+
+ TextUnformatted(label, FindRenderedTextEnd(label));
+ EndGroup();
+ return value_changed;
+}
+
+bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power)
+{
+ return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power);
+}
+
+bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power)
+{
+ return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power);
+}
+
+bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power)
+{
+ return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power);
+}
+
+bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power)
+{
+ return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power);
+}
+
+bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, float power)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ PushID(label);
+ BeginGroup();
+ PushMultiItemsWidths(2);
+
+ bool value_changed = DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format, power);
+ PopItemWidth();
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+ value_changed |= DragFloat("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? FLT_MAX : v_max, format_max ? format_max : format, power);
+ PopItemWidth();
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+
+ TextUnformatted(label, FindRenderedTextEnd(label));
+ EndGroup();
+ PopID();
+ return value_changed;
+}
+
+// NB: v_speed is float to allow adjusting the drag speed with more precision
+bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* format)
+{
+ return DragScalar(label, ImGuiDataType_S32, v, v_speed, &v_min, &v_max, format);
+}
+
+bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* format)
+{
+ return DragScalarN(label, ImGuiDataType_S32, v, 2, v_speed, &v_min, &v_max, format);
+}
+
+bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* format)
+{
+ return DragScalarN(label, ImGuiDataType_S32, v, 3, v_speed, &v_min, &v_max, format);
+}
+
+bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* format)
+{
+ return DragScalarN(label, ImGuiDataType_S32, v, 4, v_speed, &v_min, &v_max, format);
+}
+
+bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ PushID(label);
+ BeginGroup();
+ PushMultiItemsWidths(2);
+
+ bool value_changed = DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format);
+ PopItemWidth();
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+ value_changed |= DragInt("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? INT_MAX : v_max, format_max ? format_max : format);
+ PopItemWidth();
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+
+ TextUnformatted(label, FindRenderedTextEnd(label));
+ EndGroup();
+ PopID();
+
+ return value_changed;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc.
+//-------------------------------------------------------------------------
+// - SliderBehaviorT<>() [Internal]
+// - SliderBehavior() [Internal]
+// - SliderScalar()
+// - SliderScalarN()
+// - SliderFloat()
+// - SliderFloat2()
+// - SliderFloat3()
+// - SliderFloat4()
+// - SliderAngle()
+// - SliderInt()
+// - SliderInt2()
+// - SliderInt3()
+// - SliderInt4()
+// - VSliderScalar()
+// - VSliderFloat()
+// - VSliderInt()
+//-------------------------------------------------------------------------
+
+template<typename TYPE, typename FLOATTYPE>
+float ImGui::SliderCalcRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, float power, float linear_zero_pos)
+{
+ if (v_min == v_max)
+ return 0.0f;
+
+ const bool is_power = (power != 1.0f) && (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double);
+ const TYPE v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min);
+ if (is_power)
+ {
+ if (v_clamped < 0.0f)
+ {
+ const float f = 1.0f - (float)((v_clamped - v_min) / (ImMin((TYPE)0, v_max) - v_min));
+ return (1.0f - ImPow(f, 1.0f/power)) * linear_zero_pos;
+ }
+ else
+ {
+ const float f = (float)((v_clamped - ImMax((TYPE)0, v_min)) / (v_max - ImMax((TYPE)0, v_min)));
+ return linear_zero_pos + ImPow(f, 1.0f/power) * (1.0f - linear_zero_pos);
+ }
+ }
+
+ // Linear slider
+ return (float)((FLOATTYPE)(v_clamped - v_min) / (FLOATTYPE)(v_max - v_min));
+}
+
+// FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
+template<typename TYPE, typename SIGNEDTYPE, typename FLOATTYPE>
+bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb)
+{
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X;
+ const bool is_decimal = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
+ const bool is_power = (power != 1.0f) && is_decimal;
+
+ const float grab_padding = 2.0f;
+ const float slider_sz = (bb.Max[axis] - bb.Min[axis]) - grab_padding * 2.0f;
+ float grab_sz = style.GrabMinSize;
+ SIGNEDTYPE v_range = (v_min < v_max ? v_max - v_min : v_min - v_max);
+ if (!is_decimal && v_range >= 0) // v_range < 0 may happen on integer overflows
+ grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize); // For integer sliders: if possible have the grab size represent 1 unit
+ grab_sz = ImMin(grab_sz, slider_sz);
+ const float slider_usable_sz = slider_sz - grab_sz;
+ const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz*0.5f;
+ const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz*0.5f;
+
+ // For power curve sliders that cross over sign boundary we want the curve to be symmetric around 0.0f
+ float linear_zero_pos; // 0.0->1.0f
+ if (is_power && v_min * v_max < 0.0f)
+ {
+ // Different sign
+ const FLOATTYPE linear_dist_min_to_0 = ImPow(v_min >= 0 ? (FLOATTYPE)v_min : -(FLOATTYPE)v_min, (FLOATTYPE)1.0f/power);
+ const FLOATTYPE linear_dist_max_to_0 = ImPow(v_max >= 0 ? (FLOATTYPE)v_max : -(FLOATTYPE)v_max, (FLOATTYPE)1.0f/power);
+ linear_zero_pos = (float)(linear_dist_min_to_0 / (linear_dist_min_to_0 + linear_dist_max_to_0));
+ }
+ else
+ {
+ // Same sign
+ linear_zero_pos = v_min < 0.0f ? 1.0f : 0.0f;
+ }
+
+ // Process interacting with the slider
+ bool value_changed = false;
+ if (g.ActiveId == id)
+ {
+ bool set_new_value = false;
+ float clicked_t = 0.0f;
+ if (g.ActiveIdSource == ImGuiInputSource_Mouse)
+ {
+ if (!g.IO.MouseDown[0])
+ {
+ ClearActiveID();
+ }
+ else
+ {
+ const float mouse_abs_pos = g.IO.MousePos[axis];
+ clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f;
+ if (axis == ImGuiAxis_Y)
+ clicked_t = 1.0f - clicked_t;
+ set_new_value = true;
+ }
+ }
+ else if (g.ActiveIdSource == ImGuiInputSource_Nav)
+ {
+ const ImVec2 delta2 = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 0.0f, 0.0f);
+ float delta = (axis == ImGuiAxis_X) ? delta2.x : -delta2.y;
+ if (g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated)
+ {
+ ClearActiveID();
+ }
+ else if (delta != 0.0f)
+ {
+ clicked_t = SliderCalcRatioFromValueT<TYPE,FLOATTYPE>(data_type, *v, v_min, v_max, power, linear_zero_pos);
+ const int decimal_precision = is_decimal ? ImParseFormatPrecision(format, 3) : 0;
+ if ((decimal_precision > 0) || is_power)
+ {
+ delta /= 100.0f; // Gamepad/keyboard tweak speeds in % of slider bounds
+ if (IsNavInputDown(ImGuiNavInput_TweakSlow))
+ delta /= 10.0f;
+ }
+ else
+ {
+ if ((v_range >= -100.0f && v_range <= 100.0f) || IsNavInputDown(ImGuiNavInput_TweakSlow))
+ delta = ((delta < 0.0f) ? -1.0f : +1.0f) / (float)v_range; // Gamepad/keyboard tweak speeds in integer steps
+ else
+ delta /= 100.0f;
+ }
+ if (IsNavInputDown(ImGuiNavInput_TweakFast))
+ delta *= 10.0f;
+ set_new_value = true;
+ if ((clicked_t >= 1.0f && delta > 0.0f) || (clicked_t <= 0.0f && delta < 0.0f)) // This is to avoid applying the saturation when already past the limits
+ set_new_value = false;
+ else
+ clicked_t = ImSaturate(clicked_t + delta);
+ }
+ }
+
+ if (set_new_value)
+ {
+ TYPE v_new;
+ if (is_power)
+ {
+ // Account for power curve scale on both sides of the zero
+ if (clicked_t < linear_zero_pos)
+ {
+ // Negative: rescale to the negative range before powering
+ float a = 1.0f - (clicked_t / linear_zero_pos);
+ a = ImPow(a, power);
+ v_new = ImLerp(ImMin(v_max, (TYPE)0), v_min, a);
+ }
+ else
+ {
+ // Positive: rescale to the positive range before powering
+ float a;
+ if (ImFabs(linear_zero_pos - 1.0f) > 1.e-6f)
+ a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos);
+ else
+ a = clicked_t;
+ a = ImPow(a, power);
+ v_new = ImLerp(ImMax(v_min, (TYPE)0), v_max, a);
+ }
+ }
+ else
+ {
+ // Linear slider
+ if (is_decimal)
+ {
+ v_new = ImLerp(v_min, v_max, clicked_t);
+ }
+ else
+ {
+ // For integer values we want the clicking position to match the grab box so we round above
+ // This code is carefully tuned to work with large values (e.g. high ranges of U64) while preserving this property..
+ FLOATTYPE v_new_off_f = (v_max - v_min) * clicked_t;
+ TYPE v_new_off_floor = (TYPE)(v_new_off_f);
+ TYPE v_new_off_round = (TYPE)(v_new_off_f + (FLOATTYPE)0.5);
+ if (!is_decimal && v_new_off_floor < v_new_off_round)
+ v_new = v_min + v_new_off_round;
+ else
+ v_new = v_min + v_new_off_floor;
+ }
+ }
+
+ // Round to user desired precision based on format string
+ v_new = RoundScalarWithFormatT<TYPE,SIGNEDTYPE>(format, data_type, v_new);
+
+ // Apply result
+ if (*v != v_new)
+ {
+ *v = v_new;
+ value_changed = true;
+ }
+ }
+ }
+
+ // Output grab position so it can be displayed by the caller
+ float grab_t = SliderCalcRatioFromValueT<TYPE,FLOATTYPE>(data_type, *v, v_min, v_max, power, linear_zero_pos);
+ if (axis == ImGuiAxis_Y)
+ grab_t = 1.0f - grab_t;
+ const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
+ if (axis == ImGuiAxis_X)
+ *out_grab_bb = ImRect(grab_pos - grab_sz*0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz*0.5f, bb.Max.y - grab_padding);
+ else
+ *out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz*0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz*0.5f);
+
+ return value_changed;
+}
+
+// For 32-bits and larger types, slider bounds are limited to half the natural type range.
+// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok.
+// It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders.
+bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb)
+{
+ switch (data_type)
+ {
+ case ImGuiDataType_S32:
+ IM_ASSERT(*(const ImS32*)v_min >= IM_S32_MIN/2 && *(const ImS32*)v_max <= IM_S32_MAX/2);
+ return SliderBehaviorT<ImS32, ImS32, float >(bb, id, data_type, (ImS32*)v, *(const ImS32*)v_min, *(const ImS32*)v_max, format, power, flags, out_grab_bb);
+ case ImGuiDataType_U32:
+ IM_ASSERT(*(const ImU32*)v_min <= IM_U32_MAX/2);
+ return SliderBehaviorT<ImU32, ImS32, float >(bb, id, data_type, (ImU32*)v, *(const ImU32*)v_min, *(const ImU32*)v_max, format, power, flags, out_grab_bb);
+ case ImGuiDataType_S64:
+ IM_ASSERT(*(const ImS64*)v_min >= IM_S64_MIN/2 && *(const ImS64*)v_max <= IM_S64_MAX/2);
+ return SliderBehaviorT<ImS64, ImS64, double>(bb, id, data_type, (ImS64*)v, *(const ImS64*)v_min, *(const ImS64*)v_max, format, power, flags, out_grab_bb);
+ case ImGuiDataType_U64:
+ IM_ASSERT(*(const ImU64*)v_min <= IM_U64_MAX/2);
+ return SliderBehaviorT<ImU64, ImS64, double>(bb, id, data_type, (ImU64*)v, *(const ImU64*)v_min, *(const ImU64*)v_max, format, power, flags, out_grab_bb);
+ case ImGuiDataType_Float:
+ IM_ASSERT(*(const float*)v_min >= -FLT_MAX/2.0f && *(const float*)v_max <= FLT_MAX/2.0f);
+ return SliderBehaviorT<float, float, float >(bb, id, data_type, (float*)v, *(const float*)v_min, *(const float*)v_max, format, power, flags, out_grab_bb);
+ case ImGuiDataType_Double:
+ IM_ASSERT(*(const double*)v_min >= -DBL_MAX/2.0f && *(const double*)v_max <= DBL_MAX/2.0f);
+ return SliderBehaviorT<double,double,double>(bb, id, data_type, (double*)v, *(const double*)v_min, *(const double*)v_max, format, power, flags, out_grab_bb);
+ case ImGuiDataType_COUNT: break;
+ }
+ IM_ASSERT(0);
+ return false;
+}
+
+bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+ const float w = CalcItemWidth();
+
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
+ const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
+
+ // NB- we don't call ItemSize() yet because we may turn into a text edit box below
+ if (!ItemAdd(total_bb, id, &frame_bb))
+ {
+ ItemSize(total_bb, style.FramePadding.y);
+ return false;
+ }
+
+ // Default format string when passing NULL
+ // Patch old "%.0f" format string to use "%d", read function comments for more details.
+ IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
+ if (format == NULL)
+ format = GDataTypeInfo[data_type].PrintFmt;
+ else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0)
+ format = PatchFormatStringFloatToInt(format);
+
+ // Tabbing or CTRL-clicking on Slider turns it into an input box
+ bool start_text_input = false;
+ const bool tab_focus_requested = FocusableItemRegister(window, id);
+ const bool hovered = ItemHoverable(frame_bb, id);
+ if (tab_focus_requested || (hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || (g.NavInputId == id && g.ScalarAsInputTextId != id))
+ {
+ SetActiveID(id, window);
+ SetFocusID(id, window);
+ FocusWindow(window);
+ g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
+ if (tab_focus_requested || g.IO.KeyCtrl || g.NavInputId == id)
+ {
+ start_text_input = true;
+ g.ScalarAsInputTextId = 0;
+ }
+ }
+ if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id))
+ {
+ FocusableItemUnregister(window);
+ return InputScalarAsWidgetReplacement(frame_bb, id, label, data_type, v, format);
+ }
+
+ ItemSize(total_bb, style.FramePadding.y);
+
+ // Draw frame
+ const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
+ RenderNavHighlight(frame_bb, id);
+ RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
+
+ // Slider behavior
+ ImRect grab_bb;
+ const bool value_changed = SliderBehavior(frame_bb, id, data_type, v, v_min, v_max, format, power, ImGuiSliderFlags_None, &grab_bb);
+ if (value_changed)
+ MarkItemEdited(id);
+
+ // Render grab
+ window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
+
+ // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
+ char value_buf[64];
+ const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, v, format);
+ RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.5f));
+
+ if (label_size.x > 0.0f)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
+
+ return value_changed;
+}
+
+// Add multiple sliders on 1 line for compact edition of multiple components
+bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, float power)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ bool value_changed = false;
+ BeginGroup();
+ PushID(label);
+ PushMultiItemsWidths(components);
+ size_t type_size = GDataTypeInfo[data_type].Size;
+ for (int i = 0; i < components; i++)
+ {
+ PushID(i);
+ value_changed |= SliderScalar("##v", data_type, v, v_min, v_max, format, power);
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+ PopID();
+ PopItemWidth();
+ v = (void*)((char*)v + type_size);
+ }
+ PopID();
+
+ TextUnformatted(label, FindRenderedTextEnd(label));
+ EndGroup();
+ return value_changed;
+}
+
+bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power)
+{
+ return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power);
+}
+
+bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power)
+{
+ return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power);
+}
+
+bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power)
+{
+ return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power);
+}
+
+bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power)
+{
+ return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power);
+}
+
+bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format)
+{
+ if (format == NULL)
+ format = "%.0f deg";
+ float v_deg = (*v_rad) * 360.0f / (2*IM_PI);
+ bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, format, 1.0f);
+ *v_rad = v_deg * (2*IM_PI) / 360.0f;
+ return value_changed;
+}
+
+bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format)
+{
+ return SliderScalar(label, ImGuiDataType_S32, v, &v_min, &v_max, format);
+}
+
+bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format)
+{
+ return SliderScalarN(label, ImGuiDataType_S32, v, 2, &v_min, &v_max, format);
+}
+
+bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format)
+{
+ return SliderScalarN(label, ImGuiDataType_S32, v, 3, &v_min, &v_max, format);
+}
+
+bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format)
+{
+ return SliderScalarN(label, ImGuiDataType_S32, v, 4, &v_min, &v_max, format);
+}
+
+bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
+
+ ItemSize(bb, style.FramePadding.y);
+ if (!ItemAdd(frame_bb, id))
+ return false;
+
+ // Default format string when passing NULL
+ // Patch old "%.0f" format string to use "%d", read function comments for more details.
+ IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
+ if (format == NULL)
+ format = GDataTypeInfo[data_type].PrintFmt;
+ else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0)
+ format = PatchFormatStringFloatToInt(format);
+
+ const bool hovered = ItemHoverable(frame_bb, id);
+ if ((hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || g.NavInputId == id)
+ {
+ SetActiveID(id, window);
+ SetFocusID(id, window);
+ FocusWindow(window);
+ g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
+ }
+
+ // Draw frame
+ const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
+ RenderNavHighlight(frame_bb, id);
+ RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding);
+
+ // Slider behavior
+ ImRect grab_bb;
+ const bool value_changed = SliderBehavior(frame_bb, id, data_type, v, v_min, v_max, format, power, ImGuiSliderFlags_Vertical, &grab_bb);
+ if (value_changed)
+ MarkItemEdited(id);
+
+ // Render grab
+ window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
+
+ // Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
+ // For the vertical slider we allow centered text to overlap the frame padding
+ char value_buf[64];
+ const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, v, format);
+ RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.0f));
+ if (label_size.x > 0.0f)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
+
+ return value_changed;
+}
+
+bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format, float power)
+{
+ return VSliderScalar(label, size, ImGuiDataType_Float, v, &v_min, &v_max, format, power);
+}
+
+bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format)
+{
+ return VSliderScalar(label, size, ImGuiDataType_S32, v, &v_min, &v_max, format);
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc.
+//-------------------------------------------------------------------------
+// - ImParseFormatFindStart() [Internal]
+// - ImParseFormatFindEnd() [Internal]
+// - ImParseFormatTrimDecorations() [Internal]
+// - ImParseFormatPrecision() [Internal]
+// - InputScalarAsWidgetReplacement() [Internal]
+// - InputScalar()
+// - InputScalarN()
+// - InputFloat()
+// - InputFloat2()
+// - InputFloat3()
+// - InputFloat4()
+// - InputInt()
+// - InputInt2()
+// - InputInt3()
+// - InputInt4()
+// - InputDouble()
+//-------------------------------------------------------------------------
+
+// We don't use strchr() because our strings are usually very short and often start with '%'
+const char* ImParseFormatFindStart(const char* fmt)
+{
+ while (char c = fmt[0])
+ {
+ if (c == '%' && fmt[1] != '%')
+ return fmt;
+ else if (c == '%')
+ fmt++;
+ fmt++;
+ }
+ return fmt;
+}
+
+const char* ImParseFormatFindEnd(const char* fmt)
+{
+ // Printf/scanf types modifiers: I/L/h/j/l/t/w/z. Other uppercase letters qualify as types aka end of the format.
+ if (fmt[0] != '%')
+ return fmt;
+ const unsigned int ignored_uppercase_mask = (1 << ('I'-'A')) | (1 << ('L'-'A'));
+ const unsigned int ignored_lowercase_mask = (1 << ('h'-'a')) | (1 << ('j'-'a')) | (1 << ('l'-'a')) | (1 << ('t'-'a')) | (1 << ('w'-'a')) | (1 << ('z'-'a'));
+ for (char c; (c = *fmt) != 0; fmt++)
+ {
+ if (c >= 'A' && c <= 'Z' && ((1 << (c - 'A')) & ignored_uppercase_mask) == 0)
+ return fmt + 1;
+ if (c >= 'a' && c <= 'z' && ((1 << (c - 'a')) & ignored_lowercase_mask) == 0)
+ return fmt + 1;
+ }
+ return fmt;
+}
+
+// Extract the format out of a format string with leading or trailing decorations
+// fmt = "blah blah" -> return fmt
+// fmt = "%.3f" -> return fmt
+// fmt = "hello %.3f" -> return fmt + 6
+// fmt = "%.3f hello" -> return buf written with "%.3f"
+const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, int buf_size)
+{
+ const char* fmt_start = ImParseFormatFindStart(fmt);
+ if (fmt_start[0] != '%')
+ return fmt;
+ const char* fmt_end = ImParseFormatFindEnd(fmt_start);
+ if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data.
+ return fmt_start;
+ ImStrncpy(buf, fmt_start, ImMin((int)(fmt_end + 1 - fmt_start), buf_size));
+ return buf;
+}
+
+// Parse display precision back from the display format string
+// FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed.
+int ImParseFormatPrecision(const char* fmt, int default_precision)
+{
+ fmt = ImParseFormatFindStart(fmt);
+ if (fmt[0] != '%')
+ return default_precision;
+ fmt++;
+ while (*fmt >= '0' && *fmt <= '9')
+ fmt++;
+ int precision = INT_MAX;
+ if (*fmt == '.')
+ {
+ fmt = ImAtoi<int>(fmt + 1, &precision);
+ if (precision < 0 || precision > 99)
+ precision = default_precision;
+ }
+ if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation
+ precision = -1;
+ if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX)
+ precision = -1;
+ return (precision == INT_MAX) ? default_precision : precision;
+}
+
+// Create text input in place of an active drag/slider (used when doing a CTRL+Click on drag/slider widgets)
+// FIXME: Logic is awkward and confusing. This should be reworked to facilitate using in other situations.
+bool ImGui::InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+
+ // Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen)
+ // On the first frame, g.ScalarAsInputTextId == 0, then on subsequent frames it becomes == id
+ SetActiveID(g.ScalarAsInputTextId, window);
+ SetHoveredID(0);
+ g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
+
+ char fmt_buf[32];
+ char data_buf[32];
+ format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
+ DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, data_ptr, format);
+ ImStrTrimBlanks(data_buf);
+ ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal);
+ bool value_changed = InputTextEx(label, data_buf, IM_ARRAYSIZE(data_buf), bb.GetSize(), flags);
+ if (g.ScalarAsInputTextId == 0) // First frame we started displaying the InputText widget
+ {
+ IM_ASSERT(g.ActiveId == id); // InputText ID expected to match the Slider ID
+ g.ScalarAsInputTextId = g.ActiveId;
+ SetHoveredID(id);
+ }
+ if (value_changed)
+ return DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialText.Data, data_type, data_ptr, NULL);
+ return false;
+}
+
+bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_ptr, const void* step, const void* step_fast, const char* format, ImGuiInputTextFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
+ if (format == NULL)
+ format = GDataTypeInfo[data_type].PrintFmt;
+
+ char buf[64];
+ DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, data_ptr, format);
+
+ bool value_changed = false;
+ if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
+ flags |= ImGuiInputTextFlags_CharsDecimal;
+ flags |= ImGuiInputTextFlags_AutoSelectAll;
+
+ if (step != NULL)
+ {
+ const float button_size = GetFrameHeight();
+
+ BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
+ PushID(label);
+ PushItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
+ if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
+ value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialText.Data, data_type, data_ptr, format);
+ PopItemWidth();
+
+ // Step buttons
+ ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups;
+ if (flags & ImGuiInputTextFlags_ReadOnly)
+ button_flags |= ImGuiButtonFlags_Disabled;
+ SameLine(0, style.ItemInnerSpacing.x);
+ if (ButtonEx("-", ImVec2(button_size, button_size), button_flags))
+ {
+ DataTypeApplyOp(data_type, '-', data_ptr, data_ptr, g.IO.KeyCtrl && step_fast ? step_fast : step);
+ value_changed = true;
+ }
+ SameLine(0, style.ItemInnerSpacing.x);
+ if (ButtonEx("+", ImVec2(button_size, button_size), button_flags))
+ {
+ DataTypeApplyOp(data_type, '+', data_ptr, data_ptr, g.IO.KeyCtrl && step_fast ? step_fast : step);
+ value_changed = true;
+ }
+ SameLine(0, style.ItemInnerSpacing.x);
+ TextUnformatted(label, FindRenderedTextEnd(label));
+
+ PopID();
+ EndGroup();
+ }
+ else
+ {
+ if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
+ value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialText.Data, data_type, data_ptr, format);
+ }
+
+ return value_changed;
+}
+
+bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* step, const void* step_fast, const char* format, ImGuiInputTextFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ bool value_changed = false;
+ BeginGroup();
+ PushID(label);
+ PushMultiItemsWidths(components);
+ size_t type_size = GDataTypeInfo[data_type].Size;
+ for (int i = 0; i < components; i++)
+ {
+ PushID(i);
+ value_changed |= InputScalar("##v", data_type, v, step, step_fast, format, flags);
+ SameLine(0, g.Style.ItemInnerSpacing.x);
+ PopID();
+ PopItemWidth();
+ v = (void*)((char*)v + type_size);
+ }
+ PopID();
+
+ TextUnformatted(label, FindRenderedTextEnd(label));
+ EndGroup();
+ return value_changed;
+}
+
+bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags)
+{
+ flags |= ImGuiInputTextFlags_CharsScientific;
+ return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), format, flags);
+}
+
+bool ImGui::InputFloat2(const char* label, float v[2], const char* format, ImGuiInputTextFlags flags)
+{
+ return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags);
+}
+
+bool ImGui::InputFloat3(const char* label, float v[3], const char* format, ImGuiInputTextFlags flags)
+{
+ return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags);
+}
+
+bool ImGui::InputFloat4(const char* label, float v[4], const char* format, ImGuiInputTextFlags flags)
+{
+ return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags);
+}
+
+// Prefer using "const char* format" directly, which is more flexible and consistent with other API.
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags)
+{
+ char format[16] = "%f";
+ if (decimal_precision >= 0)
+ ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision);
+ return InputFloat(label, v, step, step_fast, format, flags);
+}
+
+bool ImGui::InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags)
+{
+ char format[16] = "%f";
+ if (decimal_precision >= 0)
+ ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision);
+ return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags);
+}
+
+bool ImGui::InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags)
+{
+ char format[16] = "%f";
+ if (decimal_precision >= 0)
+ ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision);
+ return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags);
+}
+
+bool ImGui::InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags)
+{
+ char format[16] = "%f";
+ if (decimal_precision >= 0)
+ ImFormatString(format, IM_ARRAYSIZE(format), "%%.%df", decimal_precision);
+ return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags);
+}
+#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+
+bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags flags)
+{
+ // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes.
+ const char* format = (flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d";
+ return InputScalar(label, ImGuiDataType_S32, (void*)v, (void*)(step>0 ? &step : NULL), (void*)(step_fast>0 ? &step_fast : NULL), format, flags);
+}
+
+bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags)
+{
+ return InputScalarN(label, ImGuiDataType_S32, v, 2, NULL, NULL, "%d", flags);
+}
+
+bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags)
+{
+ return InputScalarN(label, ImGuiDataType_S32, v, 3, NULL, NULL, "%d", flags);
+}
+
+bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags)
+{
+ return InputScalarN(label, ImGuiDataType_S32, v, 4, NULL, NULL, "%d", flags);
+}
+
+bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags)
+{
+ flags |= ImGuiInputTextFlags_CharsScientific;
+ return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step>0.0 ? &step : NULL), (void*)(step_fast>0.0 ? &step_fast : NULL), format, flags);
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: InputText, InputTextMultiline
+//-------------------------------------------------------------------------
+// - InputText()
+// - InputTextMultiline()
+// - InputTextEx() [Internal]
+//-------------------------------------------------------------------------
+
+bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+{
+ IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline()
+ return InputTextEx(label, buf, (int)buf_size, ImVec2(0,0), flags, callback, user_data);
+}
+
+bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+{
+ return InputTextEx(label, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data);
+}
+
+static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end)
+{
+ int line_count = 0;
+ const char* s = text_begin;
+ while (char c = *s++) // We are only matching for \n so we can ignore UTF-8 decoding
+ if (c == '\n')
+ line_count++;
+ s--;
+ if (s[0] != '\n' && s[0] != '\r')
+ line_count++;
+ *out_text_end = s;
+ return line_count;
+}
+
+static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line)
+{
+ ImFont* font = GImGui->Font;
+ const float line_height = GImGui->FontSize;
+ const float scale = line_height / font->FontSize;
+
+ ImVec2 text_size = ImVec2(0,0);
+ float line_width = 0.0f;
+
+ const ImWchar* s = text_begin;
+ while (s < text_end)
+ {
+ unsigned int c = (unsigned int)(*s++);
+ if (c == '\n')
+ {
+ text_size.x = ImMax(text_size.x, line_width);
+ text_size.y += line_height;
+ line_width = 0.0f;
+ if (stop_on_new_line)
+ break;
+ continue;
+ }
+ if (c == '\r')
+ continue;
+
+ const float char_width = font->GetCharAdvance((ImWchar)c) * scale;
+ line_width += char_width;
+ }
+
+ if (text_size.x < line_width)
+ text_size.x = line_width;
+
+ if (out_offset)
+ *out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n
+
+ if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n
+ text_size.y += line_height;
+
+ if (remaining)
+ *remaining = s;
+
+ return text_size;
+}
+
+// Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar)
+namespace ImGuiStb
+{
+
+static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; }
+static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; }
+static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx+char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; return GImGui->Font->GetCharAdvance(c) * (GImGui->FontSize / GImGui->Font->FontSize); }
+static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x10000 ? 0 : key; }
+static ImWchar STB_TEXTEDIT_NEWLINE = '\n';
+static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx)
+{
+ const ImWchar* text = obj->TextW.Data;
+ const ImWchar* text_remaining = NULL;
+ const ImVec2 size = InputTextCalcTextSizeW(text + line_start_idx, text + obj->CurLenW, &text_remaining, NULL, true);
+ r->x0 = 0.0f;
+ r->x1 = size.x;
+ r->baseline_y_delta = size.y;
+ r->ymin = 0.0f;
+ r->ymax = size.y;
+ r->num_chars = (int)(text_remaining - (text + line_start_idx));
+}
+
+static bool is_separator(unsigned int c) { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; }
+static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (is_separator( obj->TextW[idx-1] ) && !is_separator( obj->TextW[idx] ) ) : 1; }
+static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; }
+#ifdef __APPLE__ // FIXME: Move setting to IO structure
+static int is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (!is_separator( obj->TextW[idx-1] ) && is_separator( obj->TextW[idx] ) ) : 1; }
+static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; }
+#else
+static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; }
+#endif
+#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h
+#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL
+
+static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n)
+{
+ ImWchar* dst = obj->TextW.Data + pos;
+
+ // We maintain our buffer length in both UTF-8 and wchar formats
+ obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n);
+ obj->CurLenW -= n;
+
+ // Offset remaining text (FIXME-OPT: Use memmove)
+ const ImWchar* src = obj->TextW.Data + pos + n;
+ while (ImWchar c = *src++)
+ *dst++ = c;
+ *dst = '\0';
+}
+
+static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len)
+{
+ const bool is_resizable = (obj->UserFlags & ImGuiInputTextFlags_CallbackResize) != 0;
+ const int text_len = obj->CurLenW;
+ IM_ASSERT(pos <= text_len);
+
+ const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len);
+ if (!is_resizable && (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufCapacityA))
+ return false;
+
+ // Grow internal buffer if needed
+ if (new_text_len + text_len + 1 > obj->TextW.Size)
+ {
+ if (!is_resizable)
+ return false;
+ IM_ASSERT(text_len < obj->TextW.Size);
+ obj->TextW.resize(text_len + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1);
+ }
+
+ ImWchar* text = obj->TextW.Data;
+ if (pos != text_len)
+ memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar));
+ memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar));
+
+ obj->CurLenW += new_text_len;
+ obj->CurLenA += new_text_len_utf8;
+ obj->TextW[obj->CurLenW] = '\0';
+
+ return true;
+}
+
+// We don't use an enum so we can build even with conflicting symbols (if another user of stb_textedit.h leak their STB_TEXTEDIT_K_* symbols)
+#define STB_TEXTEDIT_K_LEFT 0x10000 // keyboard input to move cursor left
+#define STB_TEXTEDIT_K_RIGHT 0x10001 // keyboard input to move cursor right
+#define STB_TEXTEDIT_K_UP 0x10002 // keyboard input to move cursor up
+#define STB_TEXTEDIT_K_DOWN 0x10003 // keyboard input to move cursor down
+#define STB_TEXTEDIT_K_LINESTART 0x10004 // keyboard input to move cursor to start of line
+#define STB_TEXTEDIT_K_LINEEND 0x10005 // keyboard input to move cursor to end of line
+#define STB_TEXTEDIT_K_TEXTSTART 0x10006 // keyboard input to move cursor to start of text
+#define STB_TEXTEDIT_K_TEXTEND 0x10007 // keyboard input to move cursor to end of text
+#define STB_TEXTEDIT_K_DELETE 0x10008 // keyboard input to delete selection or character under cursor
+#define STB_TEXTEDIT_K_BACKSPACE 0x10009 // keyboard input to delete selection or character left of cursor
+#define STB_TEXTEDIT_K_UNDO 0x1000A // keyboard input to perform undo
+#define STB_TEXTEDIT_K_REDO 0x1000B // keyboard input to perform redo
+#define STB_TEXTEDIT_K_WORDLEFT 0x1000C // keyboard input to move cursor left one word
+#define STB_TEXTEDIT_K_WORDRIGHT 0x1000D // keyboard input to move cursor right one word
+#define STB_TEXTEDIT_K_SHIFT 0x20000
+
+#define STB_TEXTEDIT_IMPLEMENTATION
+#include "imstb_textedit.h"
+
+}
+
+void ImGuiInputTextState::OnKeyPressed(int key)
+{
+ stb_textedit_key(this, &StbState, key);
+ CursorFollow = true;
+ CursorAnimReset();
+}
+
+ImGuiInputTextCallbackData::ImGuiInputTextCallbackData()
+{
+ memset(this, 0, sizeof(*this));
+}
+
+// Public API to manipulate UTF-8 text
+// We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar)
+// FIXME: The existence of this rarely exercised code path is a bit of a nuisance.
+void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count)
+{
+ IM_ASSERT(pos + bytes_count <= BufTextLen);
+ char* dst = Buf + pos;
+ const char* src = Buf + pos + bytes_count;
+ while (char c = *src++)
+ *dst++ = c;
+ *dst = '\0';
+
+ if (CursorPos + bytes_count >= pos)
+ CursorPos -= bytes_count;
+ else if (CursorPos >= pos)
+ CursorPos = pos;
+ SelectionStart = SelectionEnd = CursorPos;
+ BufDirty = true;
+ BufTextLen -= bytes_count;
+}
+
+void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end)
+{
+ const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0;
+ const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text);
+ if (new_text_len + BufTextLen >= BufSize)
+ {
+ if (!is_resizable)
+ return;
+
+ // Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the midly similar code (until we remove the U16 buffer alltogether!)
+ ImGuiContext& g = *GImGui;
+ ImGuiInputTextState* edit_state = &g.InputTextState;
+ IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID);
+ IM_ASSERT(Buf == edit_state->TempBuffer.Data);
+ int new_buf_size = BufTextLen + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1;
+ edit_state->TempBuffer.reserve(new_buf_size + 1);
+ Buf = edit_state->TempBuffer.Data;
+ BufSize = edit_state->BufCapacityA = new_buf_size;
+ }
+
+ if (BufTextLen != pos)
+ memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos));
+ memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char));
+ Buf[BufTextLen + new_text_len] = '\0';
+
+ if (CursorPos >= pos)
+ CursorPos += new_text_len;
+ SelectionStart = SelectionEnd = CursorPos;
+ BufDirty = true;
+ BufTextLen += new_text_len;
+}
+
+// Return false to discard a character.
+static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+{
+ unsigned int c = *p_char;
+
+ if (c < 128 && c != ' ' && !isprint((int)(c & 0xFF)))
+ {
+ bool pass = false;
+ pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline));
+ pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput));
+ if (!pass)
+ return false;
+ }
+
+ if (c >= 0xE000 && c <= 0xF8FF) // Filter private Unicode range. I don't imagine anybody would want to input them. GLFW on OSX seems to send private characters for special keys like arrow keys.
+ return false;
+
+ if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))
+ {
+ if (flags & ImGuiInputTextFlags_CharsDecimal)
+ if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/'))
+ return false;
+
+ if (flags & ImGuiInputTextFlags_CharsScientific)
+ if (!(c >= '0' && c <= '9') && (c != '.') && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E'))
+ return false;
+
+ if (flags & ImGuiInputTextFlags_CharsHexadecimal)
+ if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F'))
+ return false;
+
+ if (flags & ImGuiInputTextFlags_CharsUppercase)
+ if (c >= 'a' && c <= 'z')
+ *p_char = (c += (unsigned int)('A'-'a'));
+
+ if (flags & ImGuiInputTextFlags_CharsNoBlank)
+ if (ImCharIsBlankW(c))
+ return false;
+ }
+
+ if (flags & ImGuiInputTextFlags_CallbackCharFilter)
+ {
+ ImGuiInputTextCallbackData callback_data;
+ memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData));
+ callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
+ callback_data.EventChar = (ImWchar)c;
+ callback_data.Flags = flags;
+ callback_data.UserData = user_data;
+ if (callback(&callback_data) != 0)
+ return false;
+ *p_char = callback_data.EventChar;
+ if (!callback_data.EventChar)
+ return false;
+ }
+
+ return true;
+}
+
+// Edit a string of text
+// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!".
+// This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match
+// Note that in std::string world, capacity() would omit 1 byte used by the zero-terminator.
+// - When active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while the InputText is active has no effect.
+// - If you want to use ImGui::InputText() with std::string, see misc/cpp/imgui_stdlib.h
+// (FIXME: Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls. Ideally we should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188)
+bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* callback_user_data)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
+ IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
+
+ ImGuiContext& g = *GImGui;
+ ImGuiIO& io = g.IO;
+ const ImGuiStyle& style = g.Style;
+
+ const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0;
+ const bool is_editable = (flags & ImGuiInputTextFlags_ReadOnly) == 0;
+ const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0;
+ const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0;
+ const bool is_resizable = (flags & ImGuiInputTextFlags_CallbackResize) != 0;
+ if (is_resizable)
+ IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag!
+
+ if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope,
+ BeginGroup();
+ const ImGuiID id = window->GetID(label);
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? GetTextLineHeight() * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f));
+
+ ImGuiWindow* draw_window = window;
+ if (is_multiline)
+ {
+ ItemAdd(total_bb, id, &frame_bb);
+ if (!BeginChildFrame(id, frame_bb.GetSize()))
+ {
+ EndChildFrame();
+ EndGroup();
+ return false;
+ }
+ draw_window = GetCurrentWindow();
+ draw_window->DC.NavLayerActiveMaskNext |= draw_window->DC.NavLayerCurrentMask; // This is to ensure that EndChild() will display a navigation highlight
+ size.x -= draw_window->ScrollbarSizes.x;
+ }
+ else
+ {
+ ItemSize(total_bb, style.FramePadding.y);
+ if (!ItemAdd(total_bb, id, &frame_bb))
+ return false;
+ }
+ const bool hovered = ItemHoverable(frame_bb, id);
+ if (hovered)
+ g.MouseCursor = ImGuiMouseCursor_TextInput;
+
+ // Password pushes a temporary font with only a fallback glyph
+ if (is_password)
+ {
+ const ImFontGlyph* glyph = g.Font->FindGlyph('*');
+ ImFont* password_font = &g.InputTextPasswordFont;
+ password_font->FontSize = g.Font->FontSize;
+ password_font->Scale = g.Font->Scale;
+ password_font->DisplayOffset = g.Font->DisplayOffset;
+ password_font->Ascent = g.Font->Ascent;
+ password_font->Descent = g.Font->Descent;
+ password_font->ContainerAtlas = g.Font->ContainerAtlas;
+ password_font->FallbackGlyph = glyph;
+ password_font->FallbackAdvanceX = glyph->AdvanceX;
+ IM_ASSERT(password_font->Glyphs.empty() && password_font->IndexAdvanceX.empty() && password_font->IndexLookup.empty());
+ PushFont(password_font);
+ }
+
+ // NB: we are only allowed to access 'edit_state' if we are the active widget.
+ ImGuiInputTextState& edit_state = g.InputTextState;
+
+ const bool focus_requested = FocusableItemRegister(window, id, (flags & (ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_AllowTabInput)) == 0); // Using completion callback disable keyboard tabbing
+ const bool focus_requested_by_code = focus_requested && (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent);
+ const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code;
+
+ const bool user_clicked = hovered && io.MouseClicked[0];
+ const bool user_scrolled = is_multiline && g.ActiveId == 0 && edit_state.ID == id && g.ActiveIdPreviousFrame == draw_window->GetIDNoKeepAlive("#SCROLLY");
+ const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_NavKeyboard));
+
+ bool clear_active_id = false;
+
+ bool select_all = (g.ActiveId != id) && ((flags & ImGuiInputTextFlags_AutoSelectAll) != 0 || user_nav_input_start) && (!is_multiline);
+ if (focus_requested || user_clicked || user_scrolled || user_nav_input_start)
+ {
+ if (g.ActiveId != id)
+ {
+ // Start edition
+ // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
+ // From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode)
+ const int prev_len_w = edit_state.CurLenW;
+ const int init_buf_len = (int)strlen(buf);
+ edit_state.TextW.resize(buf_size+1); // wchar count <= UTF-8 count. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
+ edit_state.InitialText.resize(init_buf_len + 1); // UTF-8. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
+ memcpy(edit_state.InitialText.Data, buf, init_buf_len + 1);
+ const char* buf_end = NULL;
+ edit_state.CurLenW = ImTextStrFromUtf8(edit_state.TextW.Data, buf_size, buf, NULL, &buf_end);
+ edit_state.CurLenA = (int)(buf_end - buf); // We can't get the result from ImStrncpy() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8.
+ edit_state.CursorAnimReset();
+
+ // Preserve cursor position and undo/redo stack if we come back to same widget
+ // FIXME: We should probably compare the whole buffer to be on the safety side. Comparing buf (utf8) and edit_state.Text (wchar).
+ const bool recycle_state = (edit_state.ID == id) && (prev_len_w == edit_state.CurLenW);
+ if (recycle_state)
+ {
+ // Recycle existing cursor/selection/undo stack but clamp position
+ // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler.
+ edit_state.CursorClamp();
+ }
+ else
+ {
+ edit_state.ID = id;
+ edit_state.ScrollX = 0.0f;
+ stb_textedit_initialize_state(&edit_state.StbState, !is_multiline);
+ if (!is_multiline && focus_requested_by_code)
+ select_all = true;
+ }
+ if (flags & ImGuiInputTextFlags_AlwaysInsertMode)
+ edit_state.StbState.insert_mode = true;
+ if (!is_multiline && (focus_requested_by_tab || (user_clicked && io.KeyCtrl)))
+ select_all = true;
+ }
+ SetActiveID(id, window);
+ SetFocusID(id, window);
+ FocusWindow(window);
+ if (!is_multiline && !(flags & ImGuiInputTextFlags_CallbackHistory))
+ g.ActiveIdAllowNavDirFlags |= ((1 << ImGuiDir_Up) | (1 << ImGuiDir_Down));
+ }
+ else if (io.MouseClicked[0])
+ {
+ // Release focus when we click outside
+ clear_active_id = true;
+ }
+
+ bool value_changed = false;
+ bool enter_pressed = false;
+ int backup_current_text_length = 0;
+
+ if (g.ActiveId == id)
+ {
+ if (!is_editable && !g.ActiveIdIsJustActivated)
+ {
+ // When read-only we always use the live data passed to the function
+ edit_state.TextW.resize(buf_size+1);
+ const char* buf_end = NULL;
+ edit_state.CurLenW = ImTextStrFromUtf8(edit_state.TextW.Data, edit_state.TextW.Size, buf, NULL, &buf_end);
+ edit_state.CurLenA = (int)(buf_end - buf);
+ edit_state.CursorClamp();
+ }
+
+ backup_current_text_length = edit_state.CurLenA;
+ edit_state.BufCapacityA = buf_size;
+ edit_state.UserFlags = flags;
+ edit_state.UserCallback = callback;
+ edit_state.UserCallbackData = callback_user_data;
+
+ // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
+ // Down the line we should have a cleaner library-wide concept of Selected vs Active.
+ g.ActiveIdAllowOverlap = !io.MouseDown[0];
+ g.WantTextInputNextFrame = 1;
+
+ // Edit in progress
+ const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
+ const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f));
+
+ const bool is_osx = io.ConfigMacOSXBehaviors;
+ if (select_all || (hovered && !is_osx && io.MouseDoubleClicked[0]))
+ {
+ edit_state.SelectAll();
+ edit_state.SelectedAllMouseLock = true;
+ }
+ else if (hovered && is_osx && io.MouseDoubleClicked[0])
+ {
+ // Double-click select a word only, OS X style (by simulating keystrokes)
+ edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT);
+ edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT);
+ }
+ else if (io.MouseClicked[0] && !edit_state.SelectedAllMouseLock)
+ {
+ if (hovered)
+ {
+ stb_textedit_click(&edit_state, &edit_state.StbState, mouse_x, mouse_y);
+ edit_state.CursorAnimReset();
+ }
+ }
+ else if (io.MouseDown[0] && !edit_state.SelectedAllMouseLock && (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f))
+ {
+ stb_textedit_drag(&edit_state, &edit_state.StbState, mouse_x, mouse_y);
+ edit_state.CursorAnimReset();
+ edit_state.CursorFollow = true;
+ }
+ if (edit_state.SelectedAllMouseLock && !io.MouseDown[0])
+ edit_state.SelectedAllMouseLock = false;
+
+ if (io.InputQueueCharacters.Size > 0)
+ {
+ // Process text input (before we check for Return because using some IME will effectively send a Return?)
+ // We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
+ bool ignore_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
+ if (!ignore_inputs && is_editable && !user_nav_input_start)
+ for (int n = 0; n < io.InputQueueCharacters.Size; n++)
+ {
+ // Insert character if they pass filtering
+ unsigned int c = (unsigned int)io.InputQueueCharacters[n];
+ if (InputTextFilterCharacter(&c, flags, callback, callback_user_data))
+ edit_state.OnKeyPressed((int)c);
+ }
+
+ // Consume characters
+ io.InputQueueCharacters.resize(0);
+ }
+ }
+
+ bool cancel_edit = false;
+ if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id)
+ {
+ // Handle key-presses
+ const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
+ const bool is_osx = io.ConfigMacOSXBehaviors;
+ const bool is_shortcut_key = (is_osx ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
+ const bool is_osx_shift_shortcut = is_osx && io.KeySuper && io.KeyShift && !io.KeyCtrl && !io.KeyAlt;
+ const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
+ const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
+ const bool is_ctrl_key_only = io.KeyCtrl && !io.KeyShift && !io.KeyAlt && !io.KeySuper;
+ const bool is_shift_key_only = io.KeyShift && !io.KeyCtrl && !io.KeyAlt && !io.KeySuper;
+
+ const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && is_editable && !is_password && (!is_multiline || edit_state.HasSelection());
+ const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || edit_state.HasSelection());
+ const bool is_paste = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && is_editable;
+ const bool is_undo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Z)) && is_editable && is_undoable);
+ const bool is_redo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressedMap(ImGuiKey_Z))) && is_editable && is_undoable;
+
+ if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetWindowScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetWindowScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_Home)) { edit_state.OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_End)) { edit_state.OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_Delete) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); }
+ else if (IsKeyPressedMap(ImGuiKey_Backspace) && is_editable)
+ {
+ if (!edit_state.HasSelection())
+ {
+ if (is_wordmove_key_down) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT);
+ else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) edit_state.OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT);
+ }
+ edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
+ }
+ else if (IsKeyPressedMap(ImGuiKey_Enter))
+ {
+ bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
+ if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl))
+ {
+ enter_pressed = clear_active_id = true;
+ }
+ else if (is_editable)
+ {
+ unsigned int c = '\n'; // Insert new line
+ if (InputTextFilterCharacter(&c, flags, callback, callback_user_data))
+ edit_state.OnKeyPressed((int)c);
+ }
+ }
+ else if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !io.KeyCtrl && !io.KeyShift && !io.KeyAlt && is_editable)
+ {
+ unsigned int c = '\t'; // Insert TAB
+ if (InputTextFilterCharacter(&c, flags, callback, callback_user_data))
+ edit_state.OnKeyPressed((int)c);
+ }
+ else if (IsKeyPressedMap(ImGuiKey_Escape))
+ {
+ clear_active_id = cancel_edit = true;
+ }
+ else if (is_undo || is_redo)
+ {
+ edit_state.OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO);
+ edit_state.ClearSelection();
+ }
+ else if (is_shortcut_key && IsKeyPressedMap(ImGuiKey_A))
+ {
+ edit_state.SelectAll();
+ edit_state.CursorFollow = true;
+ }
+ else if (is_cut || is_copy)
+ {
+ // Cut, Copy
+ if (io.SetClipboardTextFn)
+ {
+ const int ib = edit_state.HasSelection() ? ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end) : 0;
+ const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : edit_state.CurLenW;
+ edit_state.TempBuffer.resize((ie-ib) * 4 + 1);
+ ImTextStrToUtf8(edit_state.TempBuffer.Data, edit_state.TempBuffer.Size, edit_state.TextW.Data+ib, edit_state.TextW.Data+ie);
+ SetClipboardText(edit_state.TempBuffer.Data);
+ }
+ if (is_cut)
+ {
+ if (!edit_state.HasSelection())
+ edit_state.SelectAll();
+ edit_state.CursorFollow = true;
+ stb_textedit_cut(&edit_state, &edit_state.StbState);
+ }
+ }
+ else if (is_paste)
+ {
+ if (const char* clipboard = GetClipboardText())
+ {
+ // Filter pasted buffer
+ const int clipboard_len = (int)strlen(clipboard);
+ ImWchar* clipboard_filtered = (ImWchar*)MemAlloc((clipboard_len+1) * sizeof(ImWchar));
+ int clipboard_filtered_len = 0;
+ for (const char* s = clipboard; *s; )
+ {
+ unsigned int c;
+ s += ImTextCharFromUtf8(&c, s, NULL);
+ if (c == 0)
+ break;
+ if (c >= 0x10000 || !InputTextFilterCharacter(&c, flags, callback, callback_user_data))
+ continue;
+ clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c;
+ }
+ clipboard_filtered[clipboard_filtered_len] = 0;
+ if (clipboard_filtered_len > 0) // If everything was filtered, ignore the pasting operation
+ {
+ stb_textedit_paste(&edit_state, &edit_state.StbState, clipboard_filtered, clipboard_filtered_len);
+ edit_state.CursorFollow = true;
+ }
+ MemFree(clipboard_filtered);
+ }
+ }
+ }
+
+ if (g.ActiveId == id)
+ {
+ const char* apply_new_text = NULL;
+ int apply_new_text_length = 0;
+ if (cancel_edit)
+ {
+ // Restore initial value. Only return true if restoring to the initial value changes the current buffer contents.
+ if (is_editable && strcmp(buf, edit_state.InitialText.Data) != 0)
+ {
+ apply_new_text = edit_state.InitialText.Data;
+ apply_new_text_length = edit_state.InitialText.Size - 1;
+ }
+ }
+
+ // When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame.
+ // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail. Also this allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage.
+ bool apply_edit_back_to_user_buffer = !cancel_edit || (enter_pressed && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0);
+ if (apply_edit_back_to_user_buffer)
+ {
+ // Apply new value immediately - copy modified buffer back
+ // Note that as soon as the input box is active, the in-widget value gets priority over any underlying modification of the input buffer
+ // FIXME: We actually always render 'buf' when calling DrawList->AddText, making the comment above incorrect.
+ // FIXME-OPT: CPU waste to do this every time the widget is active, should mark dirty state from the stb_textedit callbacks.
+ if (is_editable)
+ {
+ edit_state.TempBuffer.resize(edit_state.TextW.Size * 4 + 1);
+ ImTextStrToUtf8(edit_state.TempBuffer.Data, edit_state.TempBuffer.Size, edit_state.TextW.Data, NULL);
+ }
+
+ // User callback
+ if ((flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackAlways)) != 0)
+ {
+ IM_ASSERT(callback != NULL);
+
+ // The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
+ ImGuiInputTextFlags event_flag = 0;
+ ImGuiKey event_key = ImGuiKey_COUNT;
+ if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab))
+ {
+ event_flag = ImGuiInputTextFlags_CallbackCompletion;
+ event_key = ImGuiKey_Tab;
+ }
+ else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow))
+ {
+ event_flag = ImGuiInputTextFlags_CallbackHistory;
+ event_key = ImGuiKey_UpArrow;
+ }
+ else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow))
+ {
+ event_flag = ImGuiInputTextFlags_CallbackHistory;
+ event_key = ImGuiKey_DownArrow;
+ }
+ else if (flags & ImGuiInputTextFlags_CallbackAlways)
+ event_flag = ImGuiInputTextFlags_CallbackAlways;
+
+ if (event_flag)
+ {
+ ImGuiInputTextCallbackData callback_data;
+ memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData));
+ callback_data.EventFlag = event_flag;
+ callback_data.Flags = flags;
+ callback_data.UserData = callback_user_data;
+
+ callback_data.EventKey = event_key;
+ callback_data.Buf = edit_state.TempBuffer.Data;
+ callback_data.BufTextLen = edit_state.CurLenA;
+ callback_data.BufSize = edit_state.BufCapacityA;
+ callback_data.BufDirty = false;
+
+ // We have to convert from wchar-positions to UTF-8-positions, which can be pretty slow (an incentive to ditch the ImWchar buffer, see https://github.com/nothings/stb/issues/188)
+ ImWchar* text = edit_state.TextW.Data;
+ const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.cursor);
+ const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.select_start);
+ const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.select_end);
+
+ // Call user code
+ callback(&callback_data);
+
+ // Read back what user may have modified
+ IM_ASSERT(callback_data.Buf == edit_state.TempBuffer.Data); // Invalid to modify those fields
+ IM_ASSERT(callback_data.BufSize == edit_state.BufCapacityA);
+ IM_ASSERT(callback_data.Flags == flags);
+ if (callback_data.CursorPos != utf8_cursor_pos) { edit_state.StbState.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); edit_state.CursorFollow = true; }
+ if (callback_data.SelectionStart != utf8_selection_start) { edit_state.StbState.select_start = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); }
+ if (callback_data.SelectionEnd != utf8_selection_end) { edit_state.StbState.select_end = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); }
+ if (callback_data.BufDirty)
+ {
+ IM_ASSERT(callback_data.BufTextLen == (int)strlen(callback_data.Buf)); // You need to maintain BufTextLen if you change the text!
+ if (callback_data.BufTextLen > backup_current_text_length && is_resizable)
+ edit_state.TextW.resize(edit_state.TextW.Size + (callback_data.BufTextLen - backup_current_text_length));
+ edit_state.CurLenW = ImTextStrFromUtf8(edit_state.TextW.Data, edit_state.TextW.Size, callback_data.Buf, NULL);
+ edit_state.CurLenA = callback_data.BufTextLen; // Assume correct length and valid UTF-8 from user, saves us an extra strlen()
+ edit_state.CursorAnimReset();
+ }
+ }
+ }
+
+ // Will copy result string if modified
+ if (is_editable && strcmp(edit_state.TempBuffer.Data, buf) != 0)
+ {
+ apply_new_text = edit_state.TempBuffer.Data;
+ apply_new_text_length = edit_state.CurLenA;
+ }
+ }
+
+ // Copy result to user buffer
+ if (apply_new_text)
+ {
+ IM_ASSERT(apply_new_text_length >= 0);
+ if (backup_current_text_length != apply_new_text_length && is_resizable)
+ {
+ ImGuiInputTextCallbackData callback_data;
+ callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize;
+ callback_data.Flags = flags;
+ callback_data.Buf = buf;
+ callback_data.BufTextLen = apply_new_text_length;
+ callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1);
+ callback_data.UserData = callback_user_data;
+ callback(&callback_data);
+ buf = callback_data.Buf;
+ buf_size = callback_data.BufSize;
+ apply_new_text_length = ImMin(callback_data.BufTextLen, buf_size - 1);
+ IM_ASSERT(apply_new_text_length <= buf_size);
+ }
+
+ // If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size.
+ ImStrncpy(buf, edit_state.TempBuffer.Data, ImMin(apply_new_text_length + 1, buf_size));
+ value_changed = true;
+ }
+
+ // Clear temporary user storage
+ edit_state.UserFlags = 0;
+ edit_state.UserCallback = NULL;
+ edit_state.UserCallbackData = NULL;
+ }
+
+ // Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value)
+ if (clear_active_id && g.ActiveId == id)
+ ClearActiveID();
+
+ // Render
+ // Select which buffer we are going to display. When ImGuiInputTextFlags_NoLiveEdit is set 'buf' might still be the old value. We set buf to NULL to prevent accidental usage from now on.
+ const char* buf_display = (g.ActiveId == id && is_editable) ? edit_state.TempBuffer.Data : buf; buf = NULL;
+
+ // Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line
+ // without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether.
+ // Note that we only use this limit on single-line InputText(), so a pathologically large line on a InputTextMultiline() would still crash.
+ const int buf_display_max_length = 2 * 1024 * 1024;
+
+ if (!is_multiline)
+ {
+ RenderNavHighlight(frame_bb, id);
+ RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
+ }
+
+ const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + size.x, frame_bb.Min.y + size.y); // Not using frame_bb.Max because we have adjusted size
+ ImVec2 render_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding;
+ ImVec2 text_size(0.f, 0.f);
+ const bool is_currently_scrolling = (edit_state.ID == id && is_multiline && g.ActiveId == draw_window->GetIDNoKeepAlive("#SCROLLY"));
+ if (g.ActiveId == id || is_currently_scrolling)
+ {
+ edit_state.CursorAnim += io.DeltaTime;
+
+ // This is going to be messy. We need to:
+ // - Display the text (this alone can be more easily clipped)
+ // - Handle scrolling, highlight selection, display cursor (those all requires some form of 1d->2d cursor position calculation)
+ // - Measure text height (for scrollbar)
+ // We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort)
+ // FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8.
+ const ImWchar* text_begin = edit_state.TextW.Data;
+ ImVec2 cursor_offset, select_start_offset;
+
+ {
+ // Count lines + find lines numbers straddling 'cursor' and 'select_start' position.
+ const ImWchar* searches_input_ptr[2];
+ searches_input_ptr[0] = text_begin + edit_state.StbState.cursor;
+ searches_input_ptr[1] = NULL;
+ int searches_remaining = 1;
+ int searches_result_line_number[2] = { -1, -999 };
+ if (edit_state.StbState.select_start != edit_state.StbState.select_end)
+ {
+ searches_input_ptr[1] = text_begin + ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end);
+ searches_result_line_number[1] = -1;
+ searches_remaining++;
+ }
+
+ // Iterate all lines to find our line numbers
+ // In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter.
+ searches_remaining += is_multiline ? 1 : 0;
+ int line_count = 0;
+ //for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bits
+ for (const ImWchar* s = text_begin; *s != 0; s++)
+ if (*s == '\n')
+ {
+ line_count++;
+ if (searches_result_line_number[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_number[0] = line_count; if (--searches_remaining <= 0) break; }
+ if (searches_result_line_number[1] == -1 && s >= searches_input_ptr[1]) { searches_result_line_number[1] = line_count; if (--searches_remaining <= 0) break; }
+ }
+ line_count++;
+ if (searches_result_line_number[0] == -1) searches_result_line_number[0] = line_count;
+ if (searches_result_line_number[1] == -1) searches_result_line_number[1] = line_count;
+
+ // Calculate 2d position by finding the beginning of the line and measuring distance
+ cursor_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[0], text_begin), searches_input_ptr[0]).x;
+ cursor_offset.y = searches_result_line_number[0] * g.FontSize;
+ if (searches_result_line_number[1] >= 0)
+ {
+ select_start_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[1], text_begin), searches_input_ptr[1]).x;
+ select_start_offset.y = searches_result_line_number[1] * g.FontSize;
+ }
+
+ // Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224)
+ if (is_multiline)
+ text_size = ImVec2(size.x, line_count * g.FontSize);
+ }
+
+ // Scroll
+ if (edit_state.CursorFollow)
+ {
+ // Horizontal scroll in chunks of quarter width
+ if (!(flags & ImGuiInputTextFlags_NoHorizontalScroll))
+ {
+ const float scroll_increment_x = size.x * 0.25f;
+ if (cursor_offset.x < edit_state.ScrollX)
+ edit_state.ScrollX = (float)(int)ImMax(0.0f, cursor_offset.x - scroll_increment_x);
+ else if (cursor_offset.x - size.x >= edit_state.ScrollX)
+ edit_state.ScrollX = (float)(int)(cursor_offset.x - size.x + scroll_increment_x);
+ }
+ else
+ {
+ edit_state.ScrollX = 0.0f;
+ }
+
+ // Vertical scroll
+ if (is_multiline)
+ {
+ float scroll_y = draw_window->Scroll.y;
+ if (cursor_offset.y - g.FontSize < scroll_y)
+ scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize);
+ else if (cursor_offset.y - size.y >= scroll_y)
+ scroll_y = cursor_offset.y - size.y;
+ draw_window->DC.CursorPos.y += (draw_window->Scroll.y - scroll_y); // To avoid a frame of lag
+ draw_window->Scroll.y = scroll_y;
+ render_pos.y = draw_window->DC.CursorPos.y;
+ }
+ }
+ edit_state.CursorFollow = false;
+ const ImVec2 render_scroll = ImVec2(edit_state.ScrollX, 0.0f);
+
+ // Draw selection
+ if (edit_state.StbState.select_start != edit_state.StbState.select_end)
+ {
+ const ImWchar* text_selected_begin = text_begin + ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end);
+ const ImWchar* text_selected_end = text_begin + ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end);
+
+ float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection.
+ float bg_offy_dn = is_multiline ? 0.0f : 2.0f;
+ ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg);
+ ImVec2 rect_pos = render_pos + select_start_offset - render_scroll;
+ for (const ImWchar* p = text_selected_begin; p < text_selected_end; )
+ {
+ if (rect_pos.y > clip_rect.w + g.FontSize)
+ break;
+ if (rect_pos.y < clip_rect.y)
+ {
+ //p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bits
+ //p = p ? p + 1 : text_selected_end;
+ while (p < text_selected_end)
+ if (*p++ == '\n')
+ break;
+ }
+ else
+ {
+ ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true);
+ if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines
+ ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos +ImVec2(rect_size.x, bg_offy_dn));
+ rect.ClipWith(clip_rect);
+ if (rect.Overlaps(clip_rect))
+ draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color);
+ }
+ rect_pos.x = render_pos.x - render_scroll.x;
+ rect_pos.y += g.FontSize;
+ }
+ }
+
+ const int buf_display_len = edit_state.CurLenA;
+ if (is_multiline || buf_display_len < buf_display_max_length)
+ draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, GetColorU32(ImGuiCol_Text), buf_display, buf_display + buf_display_len, 0.0f, is_multiline ? NULL : &clip_rect);
+
+ // Draw blinking cursor
+ bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (g.InputTextState.CursorAnim <= 0.0f) || ImFmod(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
+ ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll;
+ ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y-g.FontSize+0.5f, cursor_screen_pos.x+1.0f, cursor_screen_pos.y-1.5f);
+ if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
+ draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_Text));
+
+ // Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
+ if (is_editable)
+ g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
+ }
+ else
+ {
+ // Render text only
+ const char* buf_end = NULL;
+ if (is_multiline)
+ text_size = ImVec2(size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_end) * g.FontSize); // We don't need width
+ else
+ buf_end = buf_display + strlen(buf_display);
+ if (is_multiline || (buf_end - buf_display) < buf_display_max_length)
+ draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos, GetColorU32(ImGuiCol_Text), buf_display, buf_end, 0.0f, is_multiline ? NULL : &clip_rect);
+ }
+
+ if (is_multiline)
+ {
+ Dummy(text_size + ImVec2(0.0f, g.FontSize)); // Always add room to scroll an extra line
+ EndChildFrame();
+ EndGroup();
+ }
+
+ if (is_password)
+ PopFont();
+
+ // Log as text
+ if (g.LogEnabled && !is_password)
+ LogRenderedText(&render_pos, buf_display, NULL);
+
+ if (label_size.x > 0)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
+
+ if (value_changed)
+ MarkItemEdited(id);
+
+ if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
+ return enter_pressed;
+ else
+ return value_changed;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc.
+//-------------------------------------------------------------------------
+// - ColorEdit3()
+// - ColorEdit4()
+// - ColorPicker3()
+// - RenderColorRectWithAlphaCheckerboard() [Internal]
+// - ColorPicker4()
+// - ColorButton()
+// - SetColorEditOptions()
+// - ColorTooltip() [Internal]
+// - ColorEditOptionsPopup() [Internal]
+// - ColorPickerOptionsPopup() [Internal]
+//-------------------------------------------------------------------------
+
+bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags)
+{
+ return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha);
+}
+
+// Edit colors components (each component in 0.0f..1.0f range).
+// See enum ImGuiColorEditFlags_ for available options. e.g. Only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set.
+// With typical options: Left-click on colored square to open color picker. Right-click to open option menu. CTRL-Click over input fields to edit them and TAB to go to next item.
+bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const float square_sz = GetFrameHeight();
+ const float w_extra = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x);
+ const float w_items_all = CalcItemWidth() - w_extra;
+ const char* label_display_end = FindRenderedTextEnd(label);
+
+ BeginGroup();
+ PushID(label);
+
+ // If we're not showing any slider there's no point in doing any HSV conversions
+ const ImGuiColorEditFlags flags_untouched = flags;
+ if (flags & ImGuiColorEditFlags_NoInputs)
+ flags = (flags & (~ImGuiColorEditFlags__InputsMask)) | ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_NoOptions;
+
+ // Context menu: display and modify options (before defaults are applied)
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ ColorEditOptionsPopup(col, flags);
+
+ // Read stored options
+ if (!(flags & ImGuiColorEditFlags__InputsMask))
+ flags |= (g.ColorEditOptions & ImGuiColorEditFlags__InputsMask);
+ if (!(flags & ImGuiColorEditFlags__DataTypeMask))
+ flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DataTypeMask);
+ if (!(flags & ImGuiColorEditFlags__PickerMask))
+ flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask);
+ flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
+
+ const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0;
+ const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
+ const int components = alpha ? 4 : 3;
+
+ // Convert to the formats we need
+ float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };
+ if (flags & ImGuiColorEditFlags_HSV)
+ ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
+ int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) };
+
+ bool value_changed = false;
+ bool value_changed_as_float = false;
+
+ if ((flags & (ImGuiColorEditFlags_RGB | ImGuiColorEditFlags_HSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
+ {
+ // RGB/HSV 0..255 Sliders
+ const float w_item_one = ImMax(1.0f, (float)(int)((w_items_all - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
+ const float w_item_last = ImMax(1.0f, (float)(int)(w_items_all - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
+
+ const bool hide_prefix = (w_item_one <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x);
+ const char* ids[4] = { "##X", "##Y", "##Z", "##W" };
+ const char* fmt_table_int[3][4] =
+ {
+ { "%3d", "%3d", "%3d", "%3d" }, // Short display
+ { "R:%3d", "G:%3d", "B:%3d", "A:%3d" }, // Long display for RGBA
+ { "H:%3d", "S:%3d", "V:%3d", "A:%3d" } // Long display for HSVA
+ };
+ const char* fmt_table_float[3][4] =
+ {
+ { "%0.3f", "%0.3f", "%0.3f", "%0.3f" }, // Short display
+ { "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA
+ { "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA
+ };
+ const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_HSV) ? 2 : 1;
+
+ PushItemWidth(w_item_one);
+ for (int n = 0; n < components; n++)
+ {
+ if (n > 0)
+ SameLine(0, style.ItemInnerSpacing.x);
+ if (n + 1 == components)
+ PushItemWidth(w_item_last);
+ if (flags & ImGuiColorEditFlags_Float)
+ value_changed = value_changed_as_float = value_changed | DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
+ else
+ value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ OpenPopupOnItemClick("context");
+ }
+ PopItemWidth();
+ PopItemWidth();
+ }
+ else if ((flags & ImGuiColorEditFlags_HEX) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
+ {
+ // RGB Hexadecimal Input
+ char buf[64];
+ if (alpha)
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255), ImClamp(i[3],0,255));
+ else
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0],0,255), ImClamp(i[1],0,255), ImClamp(i[2],0,255));
+ PushItemWidth(w_items_all);
+ if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase))
+ {
+ value_changed = true;
+ char* p = buf;
+ while (*p == '#' || ImCharIsBlankA(*p))
+ p++;
+ i[0] = i[1] = i[2] = i[3] = 0;
+ if (alpha)
+ sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2], (unsigned int*)&i[3]); // Treat at unsigned (%X is unsigned)
+ else
+ sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]);
+ }
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ OpenPopupOnItemClick("context");
+ PopItemWidth();
+ }
+
+ ImGuiWindow* picker_active_window = NULL;
+ if (!(flags & ImGuiColorEditFlags_NoSmallPreview))
+ {
+ if (!(flags & ImGuiColorEditFlags_NoInputs))
+ SameLine(0, style.ItemInnerSpacing.x);
+
+ const ImVec4 col_v4(col[0], col[1], col[2], alpha ? col[3] : 1.0f);
+ if (ColorButton("##ColorButton", col_v4, flags))
+ {
+ if (!(flags & ImGuiColorEditFlags_NoPicker))
+ {
+ // Store current color and open a picker
+ g.ColorPickerRef = col_v4;
+ OpenPopup("picker");
+ SetNextWindowPos(window->DC.LastItemRect.GetBL() + ImVec2(-1,style.ItemSpacing.y));
+ }
+ }
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ OpenPopupOnItemClick("context");
+
+ if (BeginPopup("picker"))
+ {
+ picker_active_window = g.CurrentWindow;
+ if (label != label_display_end)
+ {
+ TextUnformatted(label, label_display_end);
+ Spacing();
+ }
+ ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
+ ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__InputsMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
+ PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
+ value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x);
+ PopItemWidth();
+ EndPopup();
+ }
+ }
+
+ if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel))
+ {
+ SameLine(0, style.ItemInnerSpacing.x);
+ TextUnformatted(label, label_display_end);
+ }
+
+ // Convert back
+ if (picker_active_window == NULL)
+ {
+ if (!value_changed_as_float)
+ for (int n = 0; n < 4; n++)
+ f[n] = i[n] / 255.0f;
+ if (flags & ImGuiColorEditFlags_HSV)
+ ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);
+ if (value_changed)
+ {
+ col[0] = f[0];
+ col[1] = f[1];
+ col[2] = f[2];
+ if (alpha)
+ col[3] = f[3];
+ }
+ }
+
+ PopID();
+ EndGroup();
+
+ // Drag and Drop Target
+ // NB: The flag test is merely an optional micro-optimization, BeginDragDropTarget() does the same test.
+ if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropTarget())
+ {
+ if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
+ {
+ memcpy((float*)col, payload->Data, sizeof(float) * 3);
+ value_changed = true;
+ }
+ if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
+ {
+ memcpy((float*)col, payload->Data, sizeof(float) * components);
+ value_changed = true;
+ }
+ EndDragDropTarget();
+ }
+
+ // When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4().
+ if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window)
+ window->DC.LastItemId = g.ActiveId;
+
+ if (value_changed)
+ MarkItemEdited(window->DC.LastItemId);
+
+ return value_changed;
+}
+
+bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags)
+{
+ float col4[4] = { col[0], col[1], col[2], 1.0f };
+ if (!ColorPicker4(label, col4, flags | ImGuiColorEditFlags_NoAlpha))
+ return false;
+ col[0] = col4[0]; col[1] = col4[1]; col[2] = col4[2];
+ return true;
+}
+
+static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b)
+{
+ float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f;
+ int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t);
+ int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t);
+ int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t);
+ return IM_COL32(r, g, b, 0xFF);
+}
+
+// Helper for ColorPicker4()
+// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
+// I spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether.
+void ImGui::RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF)
+ {
+ ImU32 col_bg1 = GetColorU32(ImAlphaBlendColor(IM_COL32(204,204,204,255), col));
+ ImU32 col_bg2 = GetColorU32(ImAlphaBlendColor(IM_COL32(128,128,128,255), col));
+ window->DrawList->AddRectFilled(p_min, p_max, col_bg1, rounding, rounding_corners_flags);
+
+ int yi = 0;
+ for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++)
+ {
+ float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y);
+ if (y2 <= y1)
+ continue;
+ for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f)
+ {
+ float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x);
+ if (x2 <= x1)
+ continue;
+ int rounding_corners_flags_cell = 0;
+ if (y1 <= p_min.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_TopRight; }
+ if (y2 >= p_max.y) { if (x1 <= p_min.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotLeft; if (x2 >= p_max.x) rounding_corners_flags_cell |= ImDrawCornerFlags_BotRight; }
+ rounding_corners_flags_cell &= rounding_corners_flags;
+ window->DrawList->AddRectFilled(ImVec2(x1,y1), ImVec2(x2,y2), col_bg2, rounding_corners_flags_cell ? rounding : 0.0f, rounding_corners_flags_cell);
+ }
+ }
+ }
+ else
+ {
+ window->DrawList->AddRectFilled(p_min, p_max, col, rounding, rounding_corners_flags);
+ }
+}
+
+// Helper for ColorPicker4()
+static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w)
+{
+ ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32_BLACK);
+ ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32_WHITE);
+ ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32_BLACK);
+ ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32_WHITE);
+}
+
+// Note: ColorPicker4() only accesses 3 floats if ImGuiColorEditFlags_NoAlpha flag is set.
+// FIXME: we adjust the big color square height based on item width, which may cause a flickering feedback loop (if automatic height makes a vertical scrollbar appears, affecting automatic width..)
+bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags, const float* ref_col)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = GetCurrentWindow();
+ ImDrawList* draw_list = window->DrawList;
+
+ ImGuiStyle& style = g.Style;
+ ImGuiIO& io = g.IO;
+
+ PushID(label);
+ BeginGroup();
+
+ if (!(flags & ImGuiColorEditFlags_NoSidePreview))
+ flags |= ImGuiColorEditFlags_NoSmallPreview;
+
+ // Context menu: display and store options.
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ ColorPickerOptionsPopup(col, flags);
+
+ // Read stored options
+ if (!(flags & ImGuiColorEditFlags__PickerMask))
+ flags |= ((g.ColorEditOptions & ImGuiColorEditFlags__PickerMask) ? g.ColorEditOptions : ImGuiColorEditFlags__OptionsDefault) & ImGuiColorEditFlags__PickerMask;
+ IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check that only 1 is selected
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar);
+
+ // Setup
+ int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4;
+ bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
+ ImVec2 picker_pos = window->DC.CursorPos;
+ float square_sz = GetFrameHeight();
+ float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars
+ float sv_picker_size = ImMax(bars_width * 1, CalcItemWidth() - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box
+ float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x;
+ float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
+ float bars_triangles_half_sz = (float)(int)(bars_width * 0.20f);
+
+ float backup_initial_col[4];
+ memcpy(backup_initial_col, col, components * sizeof(float));
+
+ float wheel_thickness = sv_picker_size * 0.08f;
+ float wheel_r_outer = sv_picker_size * 0.50f;
+ float wheel_r_inner = wheel_r_outer - wheel_thickness;
+ ImVec2 wheel_center(picker_pos.x + (sv_picker_size + bars_width)*0.5f, picker_pos.y + sv_picker_size*0.5f);
+
+ // Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic.
+ float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f);
+ ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point.
+ ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point.
+ ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point.
+
+ float H,S,V;
+ ColorConvertRGBtoHSV(col[0], col[1], col[2], H, S, V);
+
+ bool value_changed = false, value_changed_h = false, value_changed_sv = false;
+
+ PushItemFlag(ImGuiItemFlags_NoNav, true);
+ if (flags & ImGuiColorEditFlags_PickerHueWheel)
+ {
+ // Hue wheel + SV triangle logic
+ InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size));
+ if (IsItemActive())
+ {
+ ImVec2 initial_off = g.IO.MouseClickedPos[0] - wheel_center;
+ ImVec2 current_off = g.IO.MousePos - wheel_center;
+ float initial_dist2 = ImLengthSqr(initial_off);
+ if (initial_dist2 >= (wheel_r_inner-1)*(wheel_r_inner-1) && initial_dist2 <= (wheel_r_outer+1)*(wheel_r_outer+1))
+ {
+ // Interactive with Hue wheel
+ H = ImAtan2(current_off.y, current_off.x) / IM_PI*0.5f;
+ if (H < 0.0f)
+ H += 1.0f;
+ value_changed = value_changed_h = true;
+ }
+ float cos_hue_angle = ImCos(-H * 2.0f * IM_PI);
+ float sin_hue_angle = ImSin(-H * 2.0f * IM_PI);
+ if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle)))
+ {
+ // Interacting with SV triangle
+ ImVec2 current_off_unrotated = ImRotate(current_off, cos_hue_angle, sin_hue_angle);
+ if (!ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated))
+ current_off_unrotated = ImTriangleClosestPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated);
+ float uu, vv, ww;
+ ImTriangleBarycentricCoords(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated, uu, vv, ww);
+ V = ImClamp(1.0f - vv, 0.0001f, 1.0f);
+ S = ImClamp(uu / V, 0.0001f, 1.0f);
+ value_changed = value_changed_sv = true;
+ }
+ }
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ OpenPopupOnItemClick("context");
+ }
+ else if (flags & ImGuiColorEditFlags_PickerHueBar)
+ {
+ // SV rectangle logic
+ InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size));
+ if (IsItemActive())
+ {
+ S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size-1));
+ V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1));
+ value_changed = value_changed_sv = true;
+ }
+ if (!(flags & ImGuiColorEditFlags_NoOptions))
+ OpenPopupOnItemClick("context");
+
+ // Hue bar logic
+ SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
+ InvisibleButton("hue", ImVec2(bars_width, sv_picker_size));
+ if (IsItemActive())
+ {
+ H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1));
+ value_changed = value_changed_h = true;
+ }
+ }
+
+ // Alpha bar logic
+ if (alpha_bar)
+ {
+ SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y));
+ InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size));
+ if (IsItemActive())
+ {
+ col[3] = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size-1));
+ value_changed = true;
+ }
+ }
+ PopItemFlag(); // ImGuiItemFlags_NoNav
+
+ if (!(flags & ImGuiColorEditFlags_NoSidePreview))
+ {
+ SameLine(0, style.ItemInnerSpacing.x);
+ BeginGroup();
+ }
+
+ if (!(flags & ImGuiColorEditFlags_NoLabel))
+ {
+ const char* label_display_end = FindRenderedTextEnd(label);
+ if (label != label_display_end)
+ {
+ if ((flags & ImGuiColorEditFlags_NoSidePreview))
+ SameLine(0, style.ItemInnerSpacing.x);
+ TextUnformatted(label, label_display_end);
+ }
+ }
+
+ if (!(flags & ImGuiColorEditFlags_NoSidePreview))
+ {
+ PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true);
+ ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
+ if ((flags & ImGuiColorEditFlags_NoLabel))
+ Text("Current");
+ ColorButton("##current", col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2));
+ if (ref_col != NULL)
+ {
+ Text("Original");
+ ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]);
+ if (ColorButton("##original", ref_col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2)))
+ {
+ memcpy(col, ref_col, components * sizeof(float));
+ value_changed = true;
+ }
+ }
+ PopItemFlag();
+ EndGroup();
+ }
+
+ // Convert back color to RGB
+ if (value_changed_h || value_changed_sv)
+ ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]);
+
+ // R,G,B and H,S,V slider color editor
+ bool value_changed_fix_hue_wrap = false;
+ if ((flags & ImGuiColorEditFlags_NoInputs) == 0)
+ {
+ PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x);
+ ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf;
+ ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker;
+ if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0)
+ if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB))
+ {
+ // FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
+ // For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050)
+ value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap);
+ value_changed = true;
+ }
+ if (flags & ImGuiColorEditFlags_HSV || (flags & ImGuiColorEditFlags__InputsMask) == 0)
+ value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_HSV);
+ if (flags & ImGuiColorEditFlags_HEX || (flags & ImGuiColorEditFlags__InputsMask) == 0)
+ value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_HEX);
+ PopItemWidth();
+ }
+
+ // Try to cancel hue wrap (after ColorEdit4 call), if any
+ if (value_changed_fix_hue_wrap)
+ {
+ float new_H, new_S, new_V;
+ ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V);
+ if (new_H <= 0 && H > 0)
+ {
+ if (new_V <= 0 && V != new_V)
+ ColorConvertHSVtoRGB(H, S, new_V <= 0 ? V * 0.5f : new_V, col[0], col[1], col[2]);
+ else if (new_S <= 0)
+ ColorConvertHSVtoRGB(H, new_S <= 0 ? S * 0.5f : new_S, new_V, col[0], col[1], col[2]);
+ }
+ }
+
+ ImVec4 hue_color_f(1, 1, 1, 1); ColorConvertHSVtoRGB(H, 1, 1, hue_color_f.x, hue_color_f.y, hue_color_f.z);
+ ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f);
+ ImU32 col32_no_alpha = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 1.0f));
+
+ const ImU32 hue_colors[6+1] = { IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255), IM_COL32(0,255,255,255), IM_COL32(0,0,255,255), IM_COL32(255,0,255,255), IM_COL32(255,0,0,255) };
+ ImVec2 sv_cursor_pos;
+
+ if (flags & ImGuiColorEditFlags_PickerHueWheel)
+ {
+ // Render Hue Wheel
+ const float aeps = 1.5f / wheel_r_outer; // Half a pixel arc length in radians (2pi cancels out).
+ const int segment_per_arc = ImMax(4, (int)wheel_r_outer / 12);
+ for (int n = 0; n < 6; n++)
+ {
+ const float a0 = (n) /6.0f * 2.0f * IM_PI - aeps;
+ const float a1 = (n+1.0f)/6.0f * 2.0f * IM_PI + aeps;
+ const int vert_start_idx = draw_list->VtxBuffer.Size;
+ draw_list->PathArcTo(wheel_center, (wheel_r_inner + wheel_r_outer)*0.5f, a0, a1, segment_per_arc);
+ draw_list->PathStroke(IM_COL32_WHITE, false, wheel_thickness);
+ const int vert_end_idx = draw_list->VtxBuffer.Size;
+
+ // Paint colors over existing vertices
+ ImVec2 gradient_p0(wheel_center.x + ImCos(a0) * wheel_r_inner, wheel_center.y + ImSin(a0) * wheel_r_inner);
+ ImVec2 gradient_p1(wheel_center.x + ImCos(a1) * wheel_r_inner, wheel_center.y + ImSin(a1) * wheel_r_inner);
+ ShadeVertsLinearColorGradientKeepAlpha(draw_list, vert_start_idx, vert_end_idx, gradient_p0, gradient_p1, hue_colors[n], hue_colors[n+1]);
+ }
+
+ // Render Cursor + preview on Hue Wheel
+ float cos_hue_angle = ImCos(H * 2.0f * IM_PI);
+ float sin_hue_angle = ImSin(H * 2.0f * IM_PI);
+ ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner+wheel_r_outer)*0.5f);
+ float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f;
+ int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32);
+ draw_list->AddCircleFilled(hue_cursor_pos, hue_cursor_rad, hue_color32, hue_cursor_segments);
+ draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad+1, IM_COL32(128,128,128,255), hue_cursor_segments);
+ draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad, IM_COL32_WHITE, hue_cursor_segments);
+
+ // Render SV triangle (rotated according to hue)
+ ImVec2 tra = wheel_center + ImRotate(triangle_pa, cos_hue_angle, sin_hue_angle);
+ ImVec2 trb = wheel_center + ImRotate(triangle_pb, cos_hue_angle, sin_hue_angle);
+ ImVec2 trc = wheel_center + ImRotate(triangle_pc, cos_hue_angle, sin_hue_angle);
+ ImVec2 uv_white = GetFontTexUvWhitePixel();
+ draw_list->PrimReserve(6, 6);
+ draw_list->PrimVtx(tra, uv_white, hue_color32);
+ draw_list->PrimVtx(trb, uv_white, hue_color32);
+ draw_list->PrimVtx(trc, uv_white, IM_COL32_WHITE);
+ draw_list->PrimVtx(tra, uv_white, IM_COL32_BLACK_TRANS);
+ draw_list->PrimVtx(trb, uv_white, IM_COL32_BLACK);
+ draw_list->PrimVtx(trc, uv_white, IM_COL32_BLACK_TRANS);
+ draw_list->AddTriangle(tra, trb, trc, IM_COL32(128,128,128,255), 1.5f);
+ sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V));
+ }
+ else if (flags & ImGuiColorEditFlags_PickerHueBar)
+ {
+ // Render SV Square
+ draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_WHITE, hue_color32, hue_color32, IM_COL32_WHITE);
+ draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_BLACK_TRANS, IM_COL32_BLACK_TRANS, IM_COL32_BLACK, IM_COL32_BLACK);
+ RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), 0.0f);
+ sv_cursor_pos.x = ImClamp((float)(int)(picker_pos.x + ImSaturate(S) * sv_picker_size + 0.5f), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much
+ sv_cursor_pos.y = ImClamp((float)(int)(picker_pos.y + ImSaturate(1 - V) * sv_picker_size + 0.5f), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2);
+
+ // Render Hue Bar
+ for (int i = 0; i < 6; ++i)
+ draw_list->AddRectFilledMultiColor(ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size / 6)), ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size / 6)), hue_colors[i], hue_colors[i], hue_colors[i + 1], hue_colors[i + 1]);
+ float bar0_line_y = (float)(int)(picker_pos.y + H * sv_picker_size + 0.5f);
+ RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f);
+ RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f);
+ }
+
+ // Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range)
+ float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f;
+ draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, col32_no_alpha, 12);
+ draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad+1, IM_COL32(128,128,128,255), 12);
+ draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad, IM_COL32_WHITE, 12);
+
+ // Render alpha bar
+ if (alpha_bar)
+ {
+ float alpha = ImSaturate(col[3]);
+ ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size);
+ RenderColorRectWithAlphaCheckerboard(bar1_bb.Min, bar1_bb.Max, IM_COL32(0,0,0,0), bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f));
+ draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, col32_no_alpha, col32_no_alpha, col32_no_alpha & ~IM_COL32_A_MASK, col32_no_alpha & ~IM_COL32_A_MASK);
+ float bar1_line_y = (float)(int)(picker_pos.y + (1.0f - alpha) * sv_picker_size + 0.5f);
+ RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f);
+ RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f);
+ }
+
+ EndGroup();
+
+ if (value_changed && memcmp(backup_initial_col, col, components * sizeof(float)) == 0)
+ value_changed = false;
+ if (value_changed)
+ MarkItemEdited(window->DC.LastItemId);
+
+ PopID();
+
+ return value_changed;
+}
+
+// A little colored square. Return true when clicked.
+// FIXME: May want to display/ignore the alpha component in the color display? Yet show it in the tooltip.
+// 'desc_id' is not called 'label' because we don't display it next to the button, but only in the tooltip.
+bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags, ImVec2 size)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiID id = window->GetID(desc_id);
+ float default_size = GetFrameHeight();
+ if (size.x == 0.0f)
+ size.x = default_size;
+ if (size.y == 0.0f)
+ size.y = default_size;
+ const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
+ ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
+ if (!ItemAdd(bb, id))
+ return false;
+
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held);
+
+ if (flags & ImGuiColorEditFlags_NoAlpha)
+ flags &= ~(ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf);
+
+ ImVec4 col_without_alpha(col.x, col.y, col.z, 1.0f);
+ float grid_step = ImMin(size.x, size.y) / 2.99f;
+ float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
+ ImRect bb_inner = bb;
+ float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
+ bb_inner.Expand(off);
+ if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col.w < 1.0f)
+ {
+ float mid_x = (float)(int)((bb_inner.Min.x + bb_inner.Max.x) * 0.5f + 0.5f);
+ RenderColorRectWithAlphaCheckerboard(ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawCornerFlags_TopRight| ImDrawCornerFlags_BotRight);
+ window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_without_alpha), rounding, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotLeft);
+ }
+ else
+ {
+ // Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha
+ ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col : col_without_alpha;
+ if (col_source.w < 1.0f)
+ RenderColorRectWithAlphaCheckerboard(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding);
+ else
+ window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All);
+ }
+ RenderNavHighlight(bb, id);
+ if (g.Style.FrameBorderSize > 0.0f)
+ RenderFrameBorder(bb.Min, bb.Max, rounding);
+ else
+ window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
+
+ // Drag and Drop Source
+ // NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test.
+ if (g.ActiveId == id && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropSource())
+ {
+ if (flags & ImGuiColorEditFlags_NoAlpha)
+ SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, &col, sizeof(float) * 3, ImGuiCond_Once);
+ else
+ SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, &col, sizeof(float) * 4, ImGuiCond_Once);
+ ColorButton(desc_id, col, flags);
+ SameLine();
+ TextUnformatted("Color");
+ EndDragDropSource();
+ }
+
+ // Tooltip
+ if (!(flags & ImGuiColorEditFlags_NoTooltip) && hovered)
+ ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf));
+
+ if (pressed)
+ MarkItemEdited(id);
+
+ return pressed;
+}
+
+void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ if ((flags & ImGuiColorEditFlags__InputsMask) == 0)
+ flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__InputsMask;
+ if ((flags & ImGuiColorEditFlags__DataTypeMask) == 0)
+ flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask;
+ if ((flags & ImGuiColorEditFlags__PickerMask) == 0)
+ flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask;
+ IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__InputsMask))); // Check only 1 option is selected
+ IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__DataTypeMask))); // Check only 1 option is selected
+ IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check only 1 option is selected
+ g.ColorEditOptions = flags;
+}
+
+// Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set.
+void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+
+ int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
+ BeginTooltipEx(0, true);
+
+ const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text;
+ if (text_end > text)
+ {
+ TextUnformatted(text, text_end);
+ Separator();
+ }
+
+ ImVec2 sz(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2);
+ ColorButton("##preview", ImVec4(col[0], col[1], col[2], col[3]), (flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz);
+ SameLine();
+ if (flags & ImGuiColorEditFlags_NoAlpha)
+ Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col[0], col[1], col[2]);
+ else
+ Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col[0], col[1], col[2], col[3]);
+ EndTooltip();
+}
+
+void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
+{
+ bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__InputsMask);
+ bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask);
+ if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context"))
+ return;
+ ImGuiContext& g = *GImGui;
+ ImGuiColorEditFlags opts = g.ColorEditOptions;
+ if (allow_opt_inputs)
+ {
+ if (RadioButton("RGB", (opts & ImGuiColorEditFlags_RGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_RGB;
+ if (RadioButton("HSV", (opts & ImGuiColorEditFlags_HSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HSV;
+ if (RadioButton("HEX", (opts & ImGuiColorEditFlags_HEX) != 0)) opts = (opts & ~ImGuiColorEditFlags__InputsMask) | ImGuiColorEditFlags_HEX;
+ }
+ if (allow_opt_datatype)
+ {
+ if (allow_opt_inputs) Separator();
+ if (RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) != 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8;
+ if (RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) != 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float;
+ }
+
+ if (allow_opt_inputs || allow_opt_datatype)
+ Separator();
+ if (Button("Copy as..", ImVec2(-1,0)))
+ OpenPopup("Copy");
+ if (BeginPopup("Copy"))
+ {
+ int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
+ char buf[64];
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
+ if (Selectable(buf))
+ SetClipboardText(buf);
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca);
+ if (Selectable(buf))
+ SetClipboardText(buf);
+ if (flags & ImGuiColorEditFlags_NoAlpha)
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "0x%02X%02X%02X", cr, cg, cb);
+ else
+ ImFormatString(buf, IM_ARRAYSIZE(buf), "0x%02X%02X%02X%02X", cr, cg, cb, ca);
+ if (Selectable(buf))
+ SetClipboardText(buf);
+ EndPopup();
+ }
+
+ g.ColorEditOptions = opts;
+ EndPopup();
+}
+
+void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags)
+{
+ bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask);
+ bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar);
+ if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context"))
+ return;
+ ImGuiContext& g = *GImGui;
+ if (allow_opt_picker)
+ {
+ ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function
+ PushItemWidth(picker_size.x);
+ for (int picker_type = 0; picker_type < 2; picker_type++)
+ {
+ // Draw small/thumbnail version of each picker type (over an invisible button for selection)
+ if (picker_type > 0) Separator();
+ PushID(picker_type);
+ ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoOptions|ImGuiColorEditFlags_NoLabel|ImGuiColorEditFlags_NoSidePreview|(flags & ImGuiColorEditFlags_NoAlpha);
+ if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar;
+ if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel;
+ ImVec2 backup_pos = GetCursorScreenPos();
+ if (Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup
+ g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags__PickerMask) | (picker_flags & ImGuiColorEditFlags__PickerMask);
+ SetCursorScreenPos(backup_pos);
+ ImVec4 dummy_ref_col;
+ memcpy(&dummy_ref_col.x, ref_col, sizeof(float) * (picker_flags & ImGuiColorEditFlags_NoAlpha ? 3 : 4));
+ ColorPicker4("##dummypicker", &dummy_ref_col.x, picker_flags);
+ PopID();
+ }
+ PopItemWidth();
+ }
+ if (allow_opt_alpha_bar)
+ {
+ if (allow_opt_picker) Separator();
+ CheckboxFlags("Alpha Bar", (unsigned int*)&g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar);
+ }
+ EndPopup();
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: TreeNode, CollapsingHeader, etc.
+//-------------------------------------------------------------------------
+// - TreeNode()
+// - TreeNodeV()
+// - TreeNodeEx()
+// - TreeNodeExV()
+// - TreeNodeBehavior() [Internal]
+// - TreePush()
+// - TreePop()
+// - TreeAdvanceToLabelPos()
+// - GetTreeNodeToLabelSpacing()
+// - SetNextTreeNodeOpen()
+// - CollapsingHeader()
+//-------------------------------------------------------------------------
+
+bool ImGui::TreeNode(const char* str_id, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ bool is_open = TreeNodeExV(str_id, 0, fmt, args);
+ va_end(args);
+ return is_open;
+}
+
+bool ImGui::TreeNode(const void* ptr_id, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ bool is_open = TreeNodeExV(ptr_id, 0, fmt, args);
+ va_end(args);
+ return is_open;
+}
+
+bool ImGui::TreeNode(const char* label)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+ return TreeNodeBehavior(window->GetID(label), 0, label, NULL);
+}
+
+bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args)
+{
+ return TreeNodeExV(str_id, 0, fmt, args);
+}
+
+bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, va_list args)
+{
+ return TreeNodeExV(ptr_id, 0, fmt, args);
+}
+
+bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ return TreeNodeBehavior(window->GetID(label), flags, label, NULL);
+}
+
+bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ bool is_open = TreeNodeExV(str_id, flags, fmt, args);
+ va_end(args);
+ return is_open;
+}
+
+bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ bool is_open = TreeNodeExV(ptr_id, flags, fmt, args);
+ va_end(args);
+ return is_open;
+}
+
+bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
+ return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end);
+}
+
+bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
+ return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end);
+}
+
+bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
+{
+ if (flags & ImGuiTreeNodeFlags_Leaf)
+ return true;
+
+ // We only write to the tree storage if the user clicks (or explicitly use SetNextTreeNode*** functions)
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ ImGuiStorage* storage = window->DC.StateStorage;
+
+ bool is_open;
+ if (g.NextTreeNodeOpenCond != 0)
+ {
+ if (g.NextTreeNodeOpenCond & ImGuiCond_Always)
+ {
+ is_open = g.NextTreeNodeOpenVal;
+ storage->SetInt(id, is_open);
+ }
+ else
+ {
+ // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
+ const int stored_value = storage->GetInt(id, -1);
+ if (stored_value == -1)
+ {
+ is_open = g.NextTreeNodeOpenVal;
+ storage->SetInt(id, is_open);
+ }
+ else
+ {
+ is_open = stored_value != 0;
+ }
+ }
+ g.NextTreeNodeOpenCond = 0;
+ }
+ else
+ {
+ is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
+ }
+
+ // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
+ // NB- If we are above max depth we still allow manually opened nodes to be logged.
+ if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && window->DC.TreeDepth < g.LogAutoExpandMaxDepth)
+ is_open = true;
+
+ return is_open;
+}
+
+bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
+ const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f);
+
+ if (!label_end)
+ label_end = FindRenderedTextEnd(label);
+ const ImVec2 label_size = CalcTextSize(label, label_end, false);
+
+ // We vertically grow up to current line height up the typical widget height.
+ const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
+ const float frame_height = ImMax(ImMin(window->DC.CurrentLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2);
+ ImRect frame_bb = ImRect(window->DC.CursorPos, ImVec2(window->Pos.x + GetContentRegionMax().x, window->DC.CursorPos.y + frame_height));
+ if (display_frame)
+ {
+ // Framed header expand a little outside the default padding
+ frame_bb.Min.x -= (float)(int)(window->WindowPadding.x*0.5f) - 1;
+ frame_bb.Max.x += (float)(int)(window->WindowPadding.x*0.5f) - 1;
+ }
+
+ const float text_offset_x = (g.FontSize + (display_frame ? padding.x*3 : padding.x*2)); // Collapser arrow width + Spacing
+ const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser
+ ItemSize(ImVec2(text_width, frame_height), text_base_offset_y);
+
+ // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
+ // (Ideally we'd want to add a flag for the user to specify if we want the hit test to be done up to the right side of the content or not)
+ const ImRect interact_bb = display_frame ? frame_bb : ImRect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + text_width + style.ItemSpacing.x*2, frame_bb.Max.y);
+ bool is_open = TreeNodeBehaviorIsOpen(id, flags);
+ bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;
+
+ // Store a flag for the current depth to tell if we will allow closing this node when navigating one of its child.
+ // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop().
+ // This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero.
+ if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
+ window->DC.TreeDepthMayJumpToParentOnPop |= (1 << window->DC.TreeDepth);
+
+ bool item_add = ItemAdd(interact_bb, id);
+ window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDisplayRect;
+ window->DC.LastItemDisplayRect = frame_bb;
+
+ if (!item_add)
+ {
+ if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
+ TreePushRawID(id);
+ IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0));
+ return is_open;
+ }
+
+ // Flags that affects opening behavior:
+ // - 0(default) ..................... single-click anywhere to open
+ // - OpenOnDoubleClick .............. double-click anywhere to open
+ // - OpenOnArrow .................... single-click on arrow to open
+ // - OpenOnDoubleClick|OpenOnArrow .. single-click on arrow or double-click anywhere to open
+ ImGuiButtonFlags button_flags = ImGuiButtonFlags_NoKeyModifiers | ((flags & ImGuiTreeNodeFlags_AllowItemOverlap) ? ImGuiButtonFlags_AllowItemOverlap : 0);
+ if (!is_leaf)
+ button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
+ if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
+ button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0);
+
+ bool hovered, held, pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags);
+ if (!is_leaf)
+ {
+ bool toggled = false;
+ if (pressed)
+ {
+ toggled = !(flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) || (g.NavActivateId == id);
+ if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
+ toggled |= IsMouseHoveringRect(interact_bb.Min, ImVec2(interact_bb.Min.x + text_offset_x, interact_bb.Max.y)) && (!g.NavDisableMouseHover);
+ if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
+ toggled |= g.IO.MouseDoubleClicked[0];
+ if (g.DragDropActive && is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again.
+ toggled = false;
+ }
+
+ if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Left && is_open)
+ {
+ toggled = true;
+ NavMoveRequestCancel();
+ }
+ if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority?
+ {
+ toggled = true;
+ NavMoveRequestCancel();
+ }
+
+ if (toggled)
+ {
+ is_open = !is_open;
+ window->DC.StateStorage->SetInt(id, is_open);
+ }
+ }
+ if (flags & ImGuiTreeNodeFlags_AllowItemOverlap)
+ SetItemAllowOverlap();
+
+ // Render
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
+ const ImVec2 text_pos = frame_bb.Min + ImVec2(text_offset_x, text_base_offset_y);
+ if (display_frame)
+ {
+ // Framed type
+ RenderFrame(frame_bb.Min, frame_bb.Max, col, true, style.FrameRounding);
+ RenderNavHighlight(frame_bb, id, ImGuiNavHighlightFlags_TypeThin);
+ RenderArrow(frame_bb.Min + ImVec2(padding.x, text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
+ if (g.LogEnabled)
+ {
+ // NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here.
+ const char log_prefix[] = "\n##";
+ const char log_suffix[] = "##";
+ LogRenderedText(&text_pos, log_prefix, log_prefix+3);
+ RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size);
+ LogRenderedText(&text_pos, log_suffix+1, log_suffix+3);
+ }
+ else
+ {
+ RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size);
+ }
+ }
+ else
+ {
+ // Unframed typed for tree nodes
+ if (hovered || (flags & ImGuiTreeNodeFlags_Selected))
+ {
+ RenderFrame(frame_bb.Min, frame_bb.Max, col, false);
+ RenderNavHighlight(frame_bb, id, ImGuiNavHighlightFlags_TypeThin);
+ }
+
+ if (flags & ImGuiTreeNodeFlags_Bullet)
+ RenderBullet(frame_bb.Min + ImVec2(text_offset_x * 0.5f, g.FontSize*0.50f + text_base_offset_y));
+ else if (!is_leaf)
+ RenderArrow(frame_bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f);
+ if (g.LogEnabled)
+ LogRenderedText(&text_pos, ">");
+ RenderText(text_pos, label, label_end, false);
+ }
+
+ if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
+ TreePushRawID(id);
+ IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0));
+ return is_open;
+}
+
+void ImGui::TreePush(const char* str_id)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ Indent();
+ window->DC.TreeDepth++;
+ PushID(str_id ? str_id : "#TreePush");
+}
+
+void ImGui::TreePush(const void* ptr_id)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ Indent();
+ window->DC.TreeDepth++;
+ PushID(ptr_id ? ptr_id : (const void*)"#TreePush");
+}
+
+void ImGui::TreePushRawID(ImGuiID id)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ Indent();
+ window->DC.TreeDepth++;
+ window->IDStack.push_back(id);
+}
+
+void ImGui::TreePop()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ Unindent();
+
+ window->DC.TreeDepth--;
+ if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
+ if (g.NavIdIsAlive && (window->DC.TreeDepthMayJumpToParentOnPop & (1 << window->DC.TreeDepth)))
+ {
+ SetNavID(window->IDStack.back(), g.NavLayer);
+ NavMoveRequestCancel();
+ }
+ window->DC.TreeDepthMayJumpToParentOnPop &= (1 << window->DC.TreeDepth) - 1;
+
+ IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much.
+ PopID();
+}
+
+void ImGui::TreeAdvanceToLabelPos()
+{
+ ImGuiContext& g = *GImGui;
+ g.CurrentWindow->DC.CursorPos.x += GetTreeNodeToLabelSpacing();
+}
+
+// Horizontal distance preceding label when using TreeNode() or Bullet()
+float ImGui::GetTreeNodeToLabelSpacing()
+{
+ ImGuiContext& g = *GImGui;
+ return g.FontSize + (g.Style.FramePadding.x * 2.0f);
+}
+
+void ImGui::SetNextTreeNodeOpen(bool is_open, ImGuiCond cond)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.CurrentWindow->SkipItems)
+ return;
+ g.NextTreeNodeOpenVal = is_open;
+ g.NextTreeNodeOpenCond = cond ? cond : ImGuiCond_Always;
+}
+
+// CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag).
+// This is basically the same as calling TreeNodeEx(label, ImGuiTreeNodeFlags_CollapsingHeader). You can remove the _NoTreePushOnOpen flag if you want behavior closer to normal TreeNode().
+bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label);
+}
+
+bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ if (p_open && !*p_open)
+ return false;
+
+ ImGuiID id = window->GetID(label);
+ bool is_open = TreeNodeBehavior(id, flags | ImGuiTreeNodeFlags_CollapsingHeader | (p_open ? ImGuiTreeNodeFlags_AllowItemOverlap : 0), label);
+ if (p_open)
+ {
+ // Create a small overlapping close button // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc.
+ ImGuiContext& g = *GImGui;
+ ImGuiItemHoveredDataBackup last_item_backup;
+ float button_radius = g.FontSize * 0.5f;
+ ImVec2 button_center = ImVec2(ImMin(window->DC.LastItemRect.Max.x, window->ClipRect.Max.x) - g.Style.FramePadding.x - button_radius, window->DC.LastItemRect.GetCenter().y);
+ if (CloseButton(window->GetID((void*)(intptr_t)(id+1)), button_center, button_radius))
+ *p_open = false;
+ last_item_backup.Restore();
+ }
+
+ return is_open;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: Selectable
+//-------------------------------------------------------------------------
+// - Selectable()
+//-------------------------------------------------------------------------
+
+// Tip: pass a non-visible label (e.g. "##dummy") then you can use the space to draw other text or image.
+// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id.
+bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet) // FIXME-OPT: Avoid if vertically clipped.
+ PopClipRect();
+
+ ImGuiID id = window->GetID(label);
+ ImVec2 label_size = CalcTextSize(label, NULL, true);
+ ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y);
+ ImVec2 pos = window->DC.CursorPos;
+ pos.y += window->DC.CurrentLineTextBaseOffset;
+ ImRect bb_inner(pos, pos + size);
+ ItemSize(bb_inner);
+
+ // Fill horizontal space.
+ ImVec2 window_padding = window->WindowPadding;
+ float max_x = (flags & ImGuiSelectableFlags_SpanAllColumns) ? GetWindowContentRegionMax().x : GetContentRegionMax().x;
+ float w_draw = ImMax(label_size.x, window->Pos.x + max_x - window_padding.x - window->DC.CursorPos.x);
+ ImVec2 size_draw((size_arg.x != 0 && !(flags & ImGuiSelectableFlags_DrawFillAvailWidth)) ? size_arg.x : w_draw, size_arg.y != 0.0f ? size_arg.y : size.y);
+ ImRect bb(pos, pos + size_draw);
+ if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_DrawFillAvailWidth))
+ bb.Max.x += window_padding.x;
+
+ // Selectables are tightly packed together, we extend the box to cover spacing between selectable.
+ float spacing_L = (float)(int)(style.ItemSpacing.x * 0.5f);
+ float spacing_U = (float)(int)(style.ItemSpacing.y * 0.5f);
+ float spacing_R = style.ItemSpacing.x - spacing_L;
+ float spacing_D = style.ItemSpacing.y - spacing_U;
+ bb.Min.x -= spacing_L;
+ bb.Min.y -= spacing_U;
+ bb.Max.x += spacing_R;
+ bb.Max.y += spacing_D;
+ if (!ItemAdd(bb, id))
+ {
+ if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet)
+ PushColumnClipRect();
+ return false;
+ }
+
+ // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries
+ ImGuiButtonFlags button_flags = 0;
+ if (flags & ImGuiSelectableFlags_NoHoldingActiveID) button_flags |= ImGuiButtonFlags_NoHoldingActiveID;
+ if (flags & ImGuiSelectableFlags_PressedOnClick) button_flags |= ImGuiButtonFlags_PressedOnClick;
+ if (flags & ImGuiSelectableFlags_PressedOnRelease) button_flags |= ImGuiButtonFlags_PressedOnRelease;
+ if (flags & ImGuiSelectableFlags_Disabled) button_flags |= ImGuiButtonFlags_Disabled;
+ if (flags & ImGuiSelectableFlags_AllowDoubleClick) button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick;
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
+ if (flags & ImGuiSelectableFlags_Disabled)
+ selected = false;
+
+ // Hovering selectable with mouse updates NavId accordingly so navigation can be resumed with gamepad/keyboard (this doesn't happen on most widgets)
+ if (pressed || hovered)
+ if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent)
+ {
+ g.NavDisableHighlight = true;
+ SetNavID(id, window->DC.NavLayerCurrent);
+ }
+ if (pressed)
+ MarkItemEdited(id);
+
+ // Render
+ if (hovered || selected)
+ {
+ const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
+ RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
+ RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
+ }
+
+ if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet)
+ {
+ PushColumnClipRect();
+ bb.Max.x -= (GetContentRegionMax().x - max_x);
+ }
+
+ if (flags & ImGuiSelectableFlags_Disabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
+ RenderTextClipped(bb_inner.Min, bb.Max, label, NULL, &label_size, ImVec2(0.0f,0.0f));
+ if (flags & ImGuiSelectableFlags_Disabled) PopStyleColor();
+
+ // Automatically close popups
+ if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(window->DC.ItemFlags & ImGuiItemFlags_SelectableDontClosePopup))
+ CloseCurrentPopup();
+ return pressed;
+}
+
+bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg)
+{
+ if (Selectable(label, *p_selected, flags, size_arg))
+ {
+ *p_selected = !*p_selected;
+ return true;
+ }
+ return false;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: ListBox
+//-------------------------------------------------------------------------
+// - ListBox()
+// - ListBoxHeader()
+// - ListBoxFooter()
+//-------------------------------------------------------------------------
+
+// FIXME: In principle this function should be called BeginListBox(). We should rename it after re-evaluating if we want to keep the same signature.
+// Helper to calculate the size of a listbox and display a label on the right.
+// Tip: To have a list filling the entire window width, PushItemWidth(-1) and pass an non-visible label e.g. "##empty"
+bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ const ImGuiStyle& style = GetStyle();
+ const ImGuiID id = GetID(label);
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+
+ // Size default to hold ~7 items. Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar.
+ ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.4f + style.ItemSpacing.y);
+ ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y));
+ ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size);
+ ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
+ window->DC.LastItemRect = bb; // Forward storage for ListBoxFooter.. dodgy.
+
+ BeginGroup();
+ if (label_size.x > 0)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
+
+ BeginChildFrame(id, frame_bb.GetSize());
+ return true;
+}
+
+// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature.
+bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items)
+{
+ // Size default to hold ~7.25 items.
+ // We add +25% worth of item height to allow the user to see at a glance if there are more items up/down, without looking at the scrollbar.
+ // We don't add this extra bit if items_count <= height_in_items. It is slightly dodgy, because it means a dynamic list of items will make the widget resize occasionally when it crosses that size.
+ // I am expecting that someone will come and complain about this behavior in a remote future, then we can advise on a better solution.
+ if (height_in_items < 0)
+ height_in_items = ImMin(items_count, 7);
+ const ImGuiStyle& style = GetStyle();
+ float height_in_items_f = (height_in_items < items_count) ? (height_in_items + 0.25f) : (height_in_items + 0.00f);
+
+ // We include ItemSpacing.y so that a list sized for the exact number of items doesn't make a scrollbar appears. We could also enforce that by passing a flag to BeginChild().
+ ImVec2 size;
+ size.x = 0.0f;
+ size.y = GetTextLineHeightWithSpacing() * height_in_items_f + style.FramePadding.y * 2.0f;
+ return ListBoxHeader(label, size);
+}
+
+// FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature.
+void ImGui::ListBoxFooter()
+{
+ ImGuiWindow* parent_window = GetCurrentWindow()->ParentWindow;
+ const ImRect bb = parent_window->DC.LastItemRect;
+ const ImGuiStyle& style = GetStyle();
+
+ EndChildFrame();
+
+ // Redeclare item size so that it includes the label (we have stored the full size in LastItemRect)
+ // We call SameLine() to restore DC.CurrentLine* data
+ SameLine();
+ parent_window->DC.CursorPos = bb.Min;
+ ItemSize(bb, style.FramePadding.y);
+ EndGroup();
+}
+
+bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_items)
+{
+ const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items);
+ return value_changed;
+}
+
+bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items)
+{
+ if (!ListBoxHeader(label, items_count, height_in_items))
+ return false;
+
+ // Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper.
+ ImGuiContext& g = *GImGui;
+ bool value_changed = false;
+ ImGuiListClipper clipper(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to.
+ while (clipper.Step())
+ for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
+ {
+ const bool item_selected = (i == *current_item);
+ const char* item_text;
+ if (!items_getter(data, i, &item_text))
+ item_text = "*Unknown item*";
+
+ PushID(i);
+ if (Selectable(item_text, item_selected))
+ {
+ *current_item = i;
+ value_changed = true;
+ }
+ if (item_selected)
+ SetItemDefaultFocus();
+ PopID();
+ }
+ ListBoxFooter();
+ if (value_changed)
+ MarkItemEdited(g.CurrentWindow->DC.LastItemId);
+
+ return value_changed;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: PlotLines, PlotHistogram
+//-------------------------------------------------------------------------
+// - PlotEx() [Internal]
+// - PlotLines()
+// - PlotHistogram()
+//-------------------------------------------------------------------------
+
+void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+
+ const ImVec2 label_size = CalcTextSize(label, NULL, true);
+ if (graph_size.x == 0.0f)
+ graph_size.x = CalcItemWidth();
+ if (graph_size.y == 0.0f)
+ graph_size.y = label_size.y + (style.FramePadding.y * 2);
+
+ const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(graph_size.x, graph_size.y));
+ const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
+ const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
+ ItemSize(total_bb, style.FramePadding.y);
+ if (!ItemAdd(total_bb, 0, &frame_bb))
+ return;
+ const bool hovered = ItemHoverable(inner_bb, 0);
+
+ // Determine scale from values if not specified
+ if (scale_min == FLT_MAX || scale_max == FLT_MAX)
+ {
+ float v_min = FLT_MAX;
+ float v_max = -FLT_MAX;
+ for (int i = 0; i < values_count; i++)
+ {
+ const float v = values_getter(data, i);
+ v_min = ImMin(v_min, v);
+ v_max = ImMax(v_max, v);
+ }
+ if (scale_min == FLT_MAX)
+ scale_min = v_min;
+ if (scale_max == FLT_MAX)
+ scale_max = v_max;
+ }
+
+ RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
+
+ if (values_count > 0)
+ {
+ int res_w = ImMin((int)graph_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
+ int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
+
+ // Tooltip on hover
+ int v_hovered = -1;
+ if (hovered)
+ {
+ const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f);
+ const int v_idx = (int)(t * item_count);
+ IM_ASSERT(v_idx >= 0 && v_idx < values_count);
+
+ const float v0 = values_getter(data, (v_idx + values_offset) % values_count);
+ const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count);
+ if (plot_type == ImGuiPlotType_Lines)
+ SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx+1, v1);
+ else if (plot_type == ImGuiPlotType_Histogram)
+ SetTooltip("%d: %8.4g", v_idx, v0);
+ v_hovered = v_idx;
+ }
+
+ const float t_step = 1.0f / (float)res_w;
+ const float inv_scale = (scale_min == scale_max) ? 0.0f : (1.0f / (scale_max - scale_min));
+
+ float v0 = values_getter(data, (0 + values_offset) % values_count);
+ float t0 = 0.0f;
+ ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle
+ float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (-scale_min * inv_scale) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands
+
+ const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram);
+ const ImU32 col_hovered = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLinesHovered : ImGuiCol_PlotHistogramHovered);
+
+ for (int n = 0; n < res_w; n++)
+ {
+ const float t1 = t0 + t_step;
+ const int v1_idx = (int)(t0 * item_count + 0.5f);
+ IM_ASSERT(v1_idx >= 0 && v1_idx < values_count);
+ const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count);
+ const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) );
+
+ // NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU.
+ ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0);
+ ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, histogram_zero_line_t));
+ if (plot_type == ImGuiPlotType_Lines)
+ {
+ window->DrawList->AddLine(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base);
+ }
+ else if (plot_type == ImGuiPlotType_Histogram)
+ {
+ if (pos1.x >= pos0.x + 2.0f)
+ pos1.x -= 1.0f;
+ window->DrawList->AddRectFilled(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base);
+ }
+
+ t0 = t1;
+ tp0 = tp1;
+ }
+ }
+
+ // Text overlay
+ if (overlay_text)
+ RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, NULL, NULL, ImVec2(0.5f,0.0f));
+
+ if (label_size.x > 0.0f)
+ RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label);
+}
+
+struct ImGuiPlotArrayGetterData
+{
+ const float* Values;
+ int Stride;
+
+ ImGuiPlotArrayGetterData(const float* values, int stride) { Values = values; Stride = stride; }
+};
+
+static float Plot_ArrayGetter(void* data, int idx)
+{
+ ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data;
+ const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride);
+ return v;
+}
+
+void ImGui::PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride)
+{
+ ImGuiPlotArrayGetterData data(values, stride);
+ PlotEx(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
+}
+
+void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
+{
+ PlotEx(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
+}
+
+void ImGui::PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride)
+{
+ ImGuiPlotArrayGetterData data(values, stride);
+ PlotEx(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
+}
+
+void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
+{
+ PlotEx(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: Value helpers
+// Those is not very useful, legacy API.
+//-------------------------------------------------------------------------
+// - Value()
+//-------------------------------------------------------------------------
+
+void ImGui::Value(const char* prefix, bool b)
+{
+ Text("%s: %s", prefix, (b ? "true" : "false"));
+}
+
+void ImGui::Value(const char* prefix, int v)
+{
+ Text("%s: %d", prefix, v);
+}
+
+void ImGui::Value(const char* prefix, unsigned int v)
+{
+ Text("%s: %d", prefix, v);
+}
+
+void ImGui::Value(const char* prefix, float v, const char* float_format)
+{
+ if (float_format)
+ {
+ char fmt[64];
+ ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format);
+ Text(fmt, prefix, v);
+ }
+ else
+ {
+ Text("%s: %.3f", prefix, v);
+ }
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] MenuItem, BeginMenu, EndMenu, etc.
+//-------------------------------------------------------------------------
+// - ImGuiMenuColumns [Internal]
+// - BeginMainMenuBar()
+// - EndMainMenuBar()
+// - BeginMenuBar()
+// - EndMenuBar()
+// - BeginMenu()
+// - EndMenu()
+// - MenuItem()
+//-------------------------------------------------------------------------
+
+// Helpers for internal use
+ImGuiMenuColumns::ImGuiMenuColumns()
+{
+ Count = 0;
+ Spacing = Width = NextWidth = 0.0f;
+ memset(Pos, 0, sizeof(Pos));
+ memset(NextWidths, 0, sizeof(NextWidths));
+}
+
+void ImGuiMenuColumns::Update(int count, float spacing, bool clear)
+{
+ IM_ASSERT(Count <= IM_ARRAYSIZE(Pos));
+ Count = count;
+ Width = NextWidth = 0.0f;
+ Spacing = spacing;
+ if (clear) memset(NextWidths, 0, sizeof(NextWidths));
+ for (int i = 0; i < Count; i++)
+ {
+ if (i > 0 && NextWidths[i] > 0.0f)
+ Width += Spacing;
+ Pos[i] = (float)(int)Width;
+ Width += NextWidths[i];
+ NextWidths[i] = 0.0f;
+ }
+}
+
+float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double
+{
+ NextWidth = 0.0f;
+ NextWidths[0] = ImMax(NextWidths[0], w0);
+ NextWidths[1] = ImMax(NextWidths[1], w1);
+ NextWidths[2] = ImMax(NextWidths[2], w2);
+ for (int i = 0; i < 3; i++)
+ NextWidth += NextWidths[i] + ((i > 0 && NextWidths[i] > 0.0f) ? Spacing : 0.0f);
+ return ImMax(Width, NextWidth);
+}
+
+float ImGuiMenuColumns::CalcExtraSpace(float avail_w)
+{
+ return ImMax(0.0f, avail_w - Width);
+}
+
+// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
+bool ImGui::BeginMainMenuBar()
+{
+ ImGuiContext& g = *GImGui;
+ g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
+ SetNextWindowPos(ImVec2(0.0f, 0.0f));
+ SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
+ PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
+ PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
+ ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
+ bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
+ PopStyleVar(2);
+ g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
+ if (!is_open)
+ {
+ End();
+ return false;
+ }
+ return true;
+}
+
+void ImGui::EndMainMenuBar()
+{
+ EndMenuBar();
+
+ // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
+ ImGuiContext& g = *GImGui;
+ if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0)
+ FocusPreviousWindowIgnoringOne(g.NavWindow);
+
+ End();
+}
+
+bool ImGui::BeginMenuBar()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+ if (!(window->Flags & ImGuiWindowFlags_MenuBar))
+ return false;
+
+ IM_ASSERT(!window->DC.MenuBarAppending);
+ BeginGroup(); // Backup position on layer 0
+ PushID("##menubar");
+
+ // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
+ // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
+ ImRect bar_rect = window->MenuBarRect();
+ ImRect clip_rect(ImFloor(bar_rect.Min.x + 0.5f), ImFloor(bar_rect.Min.y + window->WindowBorderSize + 0.5f), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - window->WindowRounding) + 0.5f), ImFloor(bar_rect.Max.y + 0.5f));
+ clip_rect.ClipWith(window->OuterRectClipped);
+ PushClipRect(clip_rect.Min, clip_rect.Max, false);
+
+ window->DC.CursorPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y);
+ window->DC.LayoutType = ImGuiLayoutType_Horizontal;
+ window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
+ window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
+ window->DC.MenuBarAppending = true;
+ AlignTextToFramePadding();
+ return true;
+}
+
+void ImGui::EndMenuBar()
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return;
+ ImGuiContext& g = *GImGui;
+
+ // Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings.
+ if (NavMoveRequestButNoResultYet() && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
+ {
+ ImGuiWindow* nav_earliest_child = g.NavWindow;
+ while (nav_earliest_child->ParentWindow && (nav_earliest_child->ParentWindow->Flags & ImGuiWindowFlags_ChildMenu))
+ nav_earliest_child = nav_earliest_child->ParentWindow;
+ if (nav_earliest_child->ParentWindow == window && nav_earliest_child->DC.ParentLayoutType == ImGuiLayoutType_Horizontal && g.NavMoveRequestForward == ImGuiNavForward_None)
+ {
+ // To do so we claim focus back, restore NavId and then process the movement request for yet another frame.
+ // This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost)
+ IM_ASSERT(window->DC.NavLayerActiveMaskNext & 0x02); // Sanity check
+ FocusWindow(window);
+ SetNavIDWithRectRel(window->NavLastIds[1], 1, window->NavRectRel[1]);
+ g.NavLayer = ImGuiNavLayer_Menu;
+ g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection.
+ g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
+ NavMoveRequestCancel();
+ }
+ }
+
+ IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar);
+ IM_ASSERT(window->DC.MenuBarAppending);
+ PopClipRect();
+ PopID();
+ window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
+ window->DC.GroupStack.back().AdvanceCursor = false;
+ EndGroup(); // Restore position on layer 0
+ window->DC.LayoutType = ImGuiLayoutType_Vertical;
+ window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
+ window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
+ window->DC.MenuBarAppending = false;
+}
+
+bool ImGui::BeginMenu(const char* label, bool enabled)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = window->GetID(label);
+
+ ImVec2 label_size = CalcTextSize(label, NULL, true);
+
+ bool pressed;
+ bool menu_is_open = IsPopupOpen(id);
+ bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].OpenParentId == window->IDStack.back());
+ ImGuiWindow* backed_nav_window = g.NavWindow;
+ if (menuset_is_open)
+ g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent)
+
+ // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu (using FindBestWindowPosForPopup).
+ ImVec2 popup_pos, pos = window->DC.CursorPos;
+ if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
+ {
+ // Menu inside an horizontal menu bar
+ // Selectable extend their highlight by half ItemSpacing in each direction.
+ // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin()
+ popup_pos = ImVec2(pos.x - 1.0f - (float)(int)(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight());
+ window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
+ PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
+ float w = label_size.x;
+ pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
+ PopStyleVar();
+ window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
+ }
+ else
+ {
+ // Menu inside a menu
+ popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y);
+ float w = window->MenuColumns.DeclColumns(label_size.x, 0.0f, (float)(int)(g.FontSize * 1.20f)); // Feedback to next frame
+ float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
+ pressed = Selectable(label, menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | (!enabled ? ImGuiSelectableFlags_Disabled : 0), ImVec2(w, 0.0f));
+ if (!enabled) PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
+ RenderArrow(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.30f, 0.0f), ImGuiDir_Right);
+ if (!enabled) PopStyleColor();
+ }
+
+ const bool hovered = enabled && ItemHoverable(window->DC.LastItemRect, id);
+ if (menuset_is_open)
+ g.NavWindow = backed_nav_window;
+
+ bool want_open = false, want_close = false;
+ if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
+ {
+ // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive.
+ bool moving_within_opened_triangle = false;
+ if (g.HoveredWindow == window && g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].ParentWindow == window && !(window->Flags & ImGuiWindowFlags_MenuBar))
+ {
+ if (ImGuiWindow* next_window = g.OpenPopupStack[g.BeginPopupStack.Size].Window)
+ {
+ ImRect next_window_rect = next_window->Rect();
+ ImVec2 ta = g.IO.MousePos - g.IO.MouseDelta;
+ ImVec2 tb = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR();
+ ImVec2 tc = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR();
+ float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack.
+ ta.x += (window->Pos.x < next_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues
+ tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale?
+ tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f);
+ moving_within_opened_triangle = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos);
+ //window->DrawList->PushClipRectFullScreen(); window->DrawList->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); window->DrawList->PopClipRect(); // Debug
+ }
+ }
+
+ want_close = (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
+ want_open = (!menu_is_open && hovered && !moving_within_opened_triangle) || (!menu_is_open && hovered && pressed);
+
+ if (g.NavActivateId == id)
+ {
+ want_close = menu_is_open;
+ want_open = !menu_is_open;
+ }
+ if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open
+ {
+ want_open = true;
+ NavMoveRequestCancel();
+ }
+ }
+ else
+ {
+ // Menu bar
+ if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it
+ {
+ want_close = true;
+ want_open = menu_is_open = false;
+ }
+ else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others
+ {
+ want_open = true;
+ }
+ else if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiDir_Down) // Nav-Down to open
+ {
+ want_open = true;
+ NavMoveRequestCancel();
+ }
+ }
+
+ if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
+ want_close = true;
+ if (want_close && IsPopupOpen(id))
+ ClosePopupToLevel(g.BeginPopupStack.Size, true);
+
+ IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0));
+
+ if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size)
+ {
+ // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame.
+ OpenPopup(label);
+ return false;
+ }
+
+ menu_is_open |= want_open;
+ if (want_open)
+ OpenPopup(label);
+
+ if (menu_is_open)
+ {
+ // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
+ SetNextWindowPos(popup_pos, ImGuiCond_Always);
+ ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
+ if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
+ flags |= ImGuiWindowFlags_ChildWindow;
+ menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
+ }
+
+ return menu_is_open;
+}
+
+void ImGui::EndMenu()
+{
+ // Nav: When a left move request _within our child menu_ failed, close ourselves (the _parent_ menu).
+ // A menu doesn't close itself because EndMenuBar() wants the catch the last Left<>Right inputs.
+ // However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction.
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (g.NavWindow && g.NavWindow->ParentWindow == window && g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet() && window->DC.LayoutType == ImGuiLayoutType_Vertical)
+ {
+ ClosePopupToLevel(g.BeginPopupStack.Size, true);
+ NavMoveRequestCancel();
+ }
+
+ EndPopup();
+}
+
+bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled)
+{
+ ImGuiWindow* window = GetCurrentWindow();
+ if (window->SkipItems)
+ return false;
+
+ ImGuiContext& g = *GImGui;
+ ImGuiStyle& style = g.Style;
+ ImVec2 pos = window->DC.CursorPos;
+ ImVec2 label_size = CalcTextSize(label, NULL, true);
+
+ ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
+ bool pressed;
+ if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
+ {
+ // Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful
+ // Note that in this situation we render neither the shortcut neither the selected tick mark
+ float w = label_size.x;
+ window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
+ PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
+ pressed = Selectable(label, false, flags, ImVec2(w, 0.0f));
+ PopStyleVar();
+ window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
+ }
+ else
+ {
+ ImVec2 shortcut_size = shortcut ? CalcTextSize(shortcut, NULL) : ImVec2(0.0f, 0.0f);
+ float w = window->MenuColumns.DeclColumns(label_size.x, shortcut_size.x, (float)(int)(g.FontSize * 1.20f)); // Feedback for next frame
+ float extra_w = ImMax(0.0f, GetContentRegionAvail().x - w);
+ pressed = Selectable(label, false, flags | ImGuiSelectableFlags_DrawFillAvailWidth, ImVec2(w, 0.0f));
+ if (shortcut_size.x > 0.0f)
+ {
+ PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
+ RenderText(pos + ImVec2(window->MenuColumns.Pos[1] + extra_w, 0.0f), shortcut, NULL, false);
+ PopStyleColor();
+ }
+ if (selected)
+ RenderCheckMark(pos + ImVec2(window->MenuColumns.Pos[2] + extra_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled), g.FontSize * 0.866f);
+ }
+
+ IMGUI_TEST_ENGINE_ITEM_INFO(window->DC.LastItemId, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0));
+ return pressed;
+}
+
+bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled)
+{
+ if (MenuItem(label, shortcut, p_selected ? *p_selected : false, enabled))
+ {
+ if (p_selected)
+ *p_selected = !*p_selected;
+ return true;
+ }
+ return false;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: BeginTabBar, EndTabBar, etc.
+//-------------------------------------------------------------------------
+// [BETA API] API may evolve! This code has been extracted out of the Docking branch,
+// and some of the construct which are not used in Master may be left here to facilitate merging.
+//-------------------------------------------------------------------------
+// - BeginTabBar()
+// - BeginTabBarEx() [Internal]
+// - EndTabBar()
+// - TabBarLayout() [Internal]
+// - TabBarCalcTabID() [Internal]
+// - TabBarCalcMaxTabWidth() [Internal]
+// - TabBarFindTabById() [Internal]
+// - TabBarRemoveTab() [Internal]
+// - TabBarCloseTab() [Internal]
+// - TabBarScrollClamp()v
+// - TabBarScrollToTab() [Internal]
+// - TabBarQueueChangeTabOrder() [Internal]
+// - TabBarScrollingButtons() [Internal]
+//-------------------------------------------------------------------------
+
+namespace ImGui
+{
+ static void TabBarLayout(ImGuiTabBar* tab_bar);
+ static ImU32 TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label);
+ static float TabBarCalcMaxTabWidth();
+ static float TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling);
+ static void TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
+ static ImGuiTabItem* TabBarScrollingButtons(ImGuiTabBar* tab_bar);
+}
+
+ImGuiTabBar::ImGuiTabBar()
+{
+ ID = 0;
+ SelectedTabId = NextSelectedTabId = VisibleTabId = 0;
+ CurrFrameVisible = PrevFrameVisible = -1;
+ OffsetMax = OffsetNextTab = 0.0f;
+ ScrollingAnim = ScrollingTarget = 0.0f;
+ Flags = ImGuiTabBarFlags_None;
+ ReorderRequestTabId = 0;
+ ReorderRequestDir = 0;
+ WantLayout = VisibleTabWasSubmitted = false;
+ LastTabItemIdx = -1;
+}
+
+static int IMGUI_CDECL TabItemComparerByVisibleOffset(const void* lhs, const void* rhs)
+{
+ const ImGuiTabItem* a = (const ImGuiTabItem*)lhs;
+ const ImGuiTabItem* b = (const ImGuiTabItem*)rhs;
+ return (int)(a->Offset - b->Offset);
+}
+
+static int IMGUI_CDECL TabBarSortItemComparer(const void* lhs, const void* rhs)
+{
+ const ImGuiTabBarSortItem* a = (const ImGuiTabBarSortItem*)lhs;
+ const ImGuiTabBarSortItem* b = (const ImGuiTabBarSortItem*)rhs;
+ if (int d = (int)(b->Width - a->Width))
+ return d;
+ return (b->Index - a->Index);
+}
+
+bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->SkipItems)
+ return false;
+
+ ImGuiID id = window->GetID(str_id);
+ ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
+ ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->InnerClipRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
+ tab_bar->ID = id;
+ return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused);
+}
+
+bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->SkipItems)
+ return false;
+
+ if ((flags & ImGuiTabBarFlags_DockNode) == 0)
+ window->IDStack.push_back(tab_bar->ID);
+
+ g.CurrentTabBar.push_back(tab_bar);
+ if (tab_bar->CurrFrameVisible == g.FrameCount)
+ {
+ //IMGUI_DEBUG_LOG("BeginTabBarEx already called this frame\n", g.FrameCount);
+ IM_ASSERT(0);
+ return true;
+ }
+
+ // When toggling back from ordered to manually-reorderable, shuffle tabs to enforce the last visible order.
+ // Otherwise, the most recently inserted tabs would move at the end of visible list which can be a little too confusing or magic for the user.
+ if ((flags & ImGuiTabBarFlags_Reorderable) && !(tab_bar->Flags & ImGuiTabBarFlags_Reorderable) && tab_bar->Tabs.Size > 1 && tab_bar->PrevFrameVisible != -1)
+ ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByVisibleOffset);
+
+ // Flags
+ if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
+ flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
+
+ tab_bar->Flags = flags;
+ tab_bar->BarRect = tab_bar_bb;
+ tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab()
+ tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible;
+ tab_bar->CurrFrameVisible = g.FrameCount;
+
+ // Layout
+ ItemSize(ImVec2(tab_bar->OffsetMax, tab_bar->BarRect.GetHeight()));
+ window->DC.CursorPos.x = tab_bar->BarRect.Min.x;
+
+ // Draw separator
+ const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_Tab);
+ const float y = tab_bar->BarRect.Max.y - 1.0f;
+ {
+ const float separator_min_x = tab_bar->BarRect.Min.x - ((flags & ImGuiTabBarFlags_DockNodeIsDockSpace) ? 0.0f : window->WindowPadding.x);
+ const float separator_max_x = tab_bar->BarRect.Max.x + ((flags & ImGuiTabBarFlags_DockNodeIsDockSpace) ? 0.0f : window->WindowPadding.x);
+ window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f);
+ }
+ return true;
+}
+
+void ImGui::EndTabBar()
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->SkipItems)
+ return;
+
+ IM_ASSERT(!g.CurrentTabBar.empty()); // Mismatched BeginTabBar/EndTabBar
+ ImGuiTabBar* tab_bar = g.CurrentTabBar.back();
+ if (tab_bar->WantLayout)
+ TabBarLayout(tab_bar);
+
+ // Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed().
+ const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
+ if (tab_bar->VisibleTabWasSubmitted || tab_bar->VisibleTabId == 0 || tab_bar_appearing)
+ tab_bar->ContentsHeight = ImMax(window->DC.CursorPos.y - tab_bar->BarRect.Max.y, 0.0f);
+ else
+ window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->ContentsHeight;
+
+ if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0)
+ PopID();
+ g.CurrentTabBar.pop_back();
+}
+
+// This is called only once a frame before by the first call to ItemTab()
+// The reason we're not calling it in BeginTabBar() is to leave a chance to the user to call the SetTabItemClosed() functions.
+static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
+{
+ ImGuiContext& g = *GImGui;
+ tab_bar->WantLayout = false;
+
+ // Garbage collect
+ int tab_dst_n = 0;
+ for (int tab_src_n = 0; tab_src_n < tab_bar->Tabs.Size; tab_src_n++)
+ {
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_src_n];
+ if (tab->LastFrameVisible < tab_bar->PrevFrameVisible)
+ {
+ if (tab->ID == tab_bar->SelectedTabId)
+ tab_bar->SelectedTabId = 0;
+ continue;
+ }
+ if (tab_dst_n != tab_src_n)
+ tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n];
+ tab_dst_n++;
+ }
+ if (tab_bar->Tabs.Size != tab_dst_n)
+ tab_bar->Tabs.resize(tab_dst_n);
+
+ // Setup next selected tab
+ ImGuiID scroll_track_selected_tab_id = 0;
+ if (tab_bar->NextSelectedTabId)
+ {
+ tab_bar->SelectedTabId = tab_bar->NextSelectedTabId;
+ tab_bar->NextSelectedTabId = 0;
+ scroll_track_selected_tab_id = tab_bar->SelectedTabId;
+ }
+
+ // Process order change request (we could probably process it when requested but it's just saner to do it in a single spot).
+ if (tab_bar->ReorderRequestTabId != 0)
+ {
+ if (ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId))
+ {
+ //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools
+ int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestDir;
+ if (tab2_order >= 0 && tab2_order < tab_bar->Tabs.Size)
+ {
+ ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order];
+ ImGuiTabItem item_tmp = *tab1;
+ *tab1 = *tab2;
+ *tab2 = item_tmp;
+ if (tab2->ID == tab_bar->SelectedTabId)
+ scroll_track_selected_tab_id = tab2->ID;
+ tab1 = tab2 = NULL;
+ }
+ if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings)
+ MarkIniSettingsDirty();
+ }
+ tab_bar->ReorderRequestTabId = 0;
+ }
+
+ ImVector<ImGuiTabBarSortItem>& width_sort_buffer = g.TabSortByWidthBuffer;
+ width_sort_buffer.resize(tab_bar->Tabs.Size);
+
+ // Compute ideal widths
+ float width_total_contents = 0.0f;
+ ImGuiTabItem* most_recently_selected_tab = NULL;
+ bool found_selected_tab_id = false;
+ for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
+ {
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
+ IM_ASSERT(tab->LastFrameVisible >= tab_bar->PrevFrameVisible);
+
+ if (most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected)
+ most_recently_selected_tab = tab;
+ if (tab->ID == tab_bar->SelectedTabId)
+ found_selected_tab_id = true;
+
+ // Refresh tab width immediately if we can (for manual tab bar, WidthContent will lag by one frame which is mostly noticeable when changing style.FramePadding.x)
+ // Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet,
+ // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
+ width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->WidthContents;
+
+ // Store data so we can build an array sorted by width if we need to shrink tabs down
+ width_sort_buffer[tab_n].Index = tab_n;
+ width_sort_buffer[tab_n].Width = tab->WidthContents;
+ }
+
+ // Compute width
+ const float width_avail = tab_bar->BarRect.GetWidth();
+ float width_excess = (width_avail < width_total_contents) ? (width_total_contents - width_avail) : 0.0f;
+ if (width_excess > 0.0f && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown))
+ {
+ // If we don't have enough room, resize down the largest tabs first
+ if (tab_bar->Tabs.Size > 1)
+ ImQsort(width_sort_buffer.Data, (size_t)width_sort_buffer.Size, sizeof(ImGuiTabBarSortItem), TabBarSortItemComparer);
+ int tab_count_same_width = 1;
+ while (width_excess > 0.0f && tab_count_same_width < tab_bar->Tabs.Size)
+ {
+ while (tab_count_same_width < tab_bar->Tabs.Size && width_sort_buffer[0].Width == width_sort_buffer[tab_count_same_width].Width)
+ tab_count_same_width++;
+ float width_to_remove_per_tab_max = (tab_count_same_width < tab_bar->Tabs.Size) ? (width_sort_buffer[0].Width - width_sort_buffer[tab_count_same_width].Width) : (width_sort_buffer[0].Width - 1.0f);
+ float width_to_remove_per_tab = ImMin(width_excess / tab_count_same_width, width_to_remove_per_tab_max);
+ for (int tab_n = 0; tab_n < tab_count_same_width; tab_n++)
+ width_sort_buffer[tab_n].Width -= width_to_remove_per_tab;
+ width_excess -= width_to_remove_per_tab * tab_count_same_width;
+ }
+ for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
+ tab_bar->Tabs[width_sort_buffer[tab_n].Index].Width = (float)(int)width_sort_buffer[tab_n].Width;
+ }
+ else
+ {
+ const float tab_max_width = TabBarCalcMaxTabWidth();
+ for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
+ {
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
+ tab->Width = ImMin(tab->WidthContents, tab_max_width);
+ }
+ }
+
+ // Layout all active tabs
+ float offset_x = 0.0f;
+ for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
+ {
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
+ tab->Offset = offset_x;
+ if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID)
+ scroll_track_selected_tab_id = tab->ID;
+ offset_x += tab->Width + g.Style.ItemInnerSpacing.x;
+ }
+ tab_bar->OffsetMax = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f);
+ tab_bar->OffsetNextTab = 0.0f;
+
+ // Horizontal scrolling buttons
+ const bool scrolling_buttons = (tab_bar->OffsetMax > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll);
+ if (scrolling_buttons)
+ if (ImGuiTabItem* tab_to_select = TabBarScrollingButtons(tab_bar)) // NB: Will alter BarRect.Max.x!
+ scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID;
+
+ // If we have lost the selected tab, select the next most recently active one
+ if (found_selected_tab_id == false)
+ tab_bar->SelectedTabId = 0;
+ if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL)
+ scroll_track_selected_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;
+
+ // Lock in visible tab
+ tab_bar->VisibleTabId = tab_bar->SelectedTabId;
+ tab_bar->VisibleTabWasSubmitted = false;
+
+ // Update scrolling
+ if (scroll_track_selected_tab_id)
+ if (ImGuiTabItem* scroll_track_selected_tab = TabBarFindTabByID(tab_bar, scroll_track_selected_tab_id))
+ TabBarScrollToTab(tab_bar, scroll_track_selected_tab);
+ tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim);
+ tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget);
+ const float scrolling_speed = (tab_bar->PrevFrameVisible + 1 < g.FrameCount) ? FLT_MAX : (g.IO.DeltaTime * g.FontSize * 70.0f);
+ if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget)
+ tab_bar->ScrollingAnim = ImLinearSweep(tab_bar->ScrollingAnim, tab_bar->ScrollingTarget, scrolling_speed);
+}
+
+// Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack.
+static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label)
+{
+ if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
+ {
+ ImGuiID id = ImHash(label, 0);
+ KeepAliveID(id);
+ return id;
+ }
+ else
+ {
+ ImGuiWindow* window = GImGui->CurrentWindow;
+ return window->GetID(label);
+ }
+}
+
+static float ImGui::TabBarCalcMaxTabWidth()
+{
+ ImGuiContext& g = *GImGui;
+ return g.FontSize * 20.0f;
+}
+
+ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id)
+{
+ if (tab_id != 0)
+ for (int n = 0; n < tab_bar->Tabs.Size; n++)
+ if (tab_bar->Tabs[n].ID == tab_id)
+ return &tab_bar->Tabs[n];
+ return NULL;
+}
+
+// The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless.
+void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id)
+{
+ if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id))
+ tab_bar->Tabs.erase(tab);
+ if (tab_bar->VisibleTabId == tab_id) { tab_bar->VisibleTabId = 0; }
+ if (tab_bar->SelectedTabId == tab_id) { tab_bar->SelectedTabId = 0; }
+ if (tab_bar->NextSelectedTabId == tab_id) { tab_bar->NextSelectedTabId = 0; }
+}
+
+// Called on manual closure attempt
+void ImGui::TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
+{
+ if ((tab_bar->VisibleTabId == tab->ID) && !(tab->Flags & ImGuiTabItemFlags_UnsavedDocument))
+ {
+ // This will remove a frame of lag for selecting another tab on closure.
+ // However we don't run it in the case where the 'Unsaved' flag is set, so user gets a chance to fully undo the closure
+ tab->LastFrameVisible = -1;
+ tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = 0;
+ }
+ else if ((tab_bar->VisibleTabId != tab->ID) && (tab->Flags & ImGuiTabItemFlags_UnsavedDocument))
+ {
+ // Actually select before expecting closure
+ tab_bar->NextSelectedTabId = tab->ID;
+ }
+}
+
+static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling)
+{
+ scrolling = ImMin(scrolling, tab_bar->OffsetMax - tab_bar->BarRect.GetWidth());
+ return ImMax(scrolling, 0.0f);
+}
+
+static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
+{
+ ImGuiContext& g = *GImGui;
+ float margin = g.FontSize * 1.0f; // When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar)
+ int order = tab_bar->GetTabOrder(tab);
+ float tab_x1 = tab->Offset + (order > 0 ? -margin : 0.0f);
+ float tab_x2 = tab->Offset + tab->Width + (order + 1 < tab_bar->Tabs.Size ? margin : 1.0f);
+ if (tab_bar->ScrollingTarget > tab_x1)
+ tab_bar->ScrollingTarget = tab_x1;
+ if (tab_bar->ScrollingTarget + tab_bar->BarRect.GetWidth() < tab_x2)
+ tab_bar->ScrollingTarget = tab_x2 - tab_bar->BarRect.GetWidth();
+}
+
+void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir)
+{
+ IM_ASSERT(dir == -1 || dir == +1);
+ IM_ASSERT(tab_bar->ReorderRequestTabId == 0);
+ tab_bar->ReorderRequestTabId = tab->ID;
+ tab_bar->ReorderRequestDir = dir;
+}
+
+static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+
+ const ImVec2 arrow_button_size(g.FontSize - 2.0f, g.FontSize + g.Style.FramePadding.y * 2.0f);
+ const float scrolling_buttons_width = arrow_button_size.x * 2.0f;
+
+ const ImVec2 backup_cursor_pos = window->DC.CursorPos;
+ //window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255));
+
+ const ImRect avail_bar_rect = tab_bar->BarRect;
+ bool want_clip_rect = !avail_bar_rect.Contains(ImRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(scrolling_buttons_width, 0.0f)));
+ if (want_clip_rect)
+ PushClipRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max + ImVec2(g.Style.ItemInnerSpacing.x, 0.0f), true);
+
+ ImGuiTabItem* tab_to_select = NULL;
+
+ int select_dir = 0;
+ ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text];
+ arrow_col.w *= 0.5f;
+
+ PushStyleColor(ImGuiCol_Text, arrow_col);
+ PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
+ const float backup_repeat_delay = g.IO.KeyRepeatDelay;
+ const float backup_repeat_rate = g.IO.KeyRepeatRate;
+ g.IO.KeyRepeatDelay = 0.250f;
+ g.IO.KeyRepeatRate = 0.200f;
+ window->DC.CursorPos = ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y);
+ if (ArrowButtonEx("##<", ImGuiDir_Left, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat))
+ select_dir = -1;
+ window->DC.CursorPos = ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width + arrow_button_size.x, tab_bar->BarRect.Min.y);
+ if (ArrowButtonEx("##>", ImGuiDir_Right, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat))
+ select_dir = +1;
+ PopStyleColor(2);
+ g.IO.KeyRepeatRate = backup_repeat_rate;
+ g.IO.KeyRepeatDelay = backup_repeat_delay;
+
+ if (want_clip_rect)
+ PopClipRect();
+
+ if (select_dir != 0)
+ if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId))
+ {
+ int selected_order = tab_bar->GetTabOrder(tab_item);
+ int target_order = selected_order + select_dir;
+ tab_to_select = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order]; // If we are at the end of the list, still scroll to make our tab visible
+ }
+ window->DC.CursorPos = backup_cursor_pos;
+ tab_bar->BarRect.Max.x -= scrolling_buttons_width + 1.0f;
+
+ return tab_to_select;
+}
+
+//-------------------------------------------------------------------------
+// [SECTION] Widgets: BeginTabItem, EndTabItem, etc.
+//-------------------------------------------------------------------------
+// [BETA API] API may evolve! This code has been extracted out of the Docking branch,
+// and some of the construct which are not used in Master may be left here to facilitate merging.
+//-------------------------------------------------------------------------
+// - BeginTabItem()
+// - EndTabItem()
+// - TabItemEx() [Internal]
+// - SetTabItemClosed()
+// - TabItemCalcSize() [Internal]
+// - TabItemRenderBackground() [Internal]
+// - TabItemLabelAndCloseButton() [Internal]
+//-------------------------------------------------------------------------
+
+bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags flags)
+{
+ ImGuiContext& g = *GImGui;
+ if (g.CurrentWindow->SkipItems)
+ return false;
+
+ IM_ASSERT(g.CurrentTabBar.Size > 0 && "Needs to be called between BeginTabBar() and EndTabBar()!");
+ ImGuiTabBar* tab_bar = g.CurrentTabBar.back();
+ bool ret = TabItemEx(tab_bar, label, p_open, flags);
+ if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
+ {
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx];
+ g.CurrentWindow->IDStack.push_back(tab->ID); // We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label)
+ }
+ return ret;
+}
+
+void ImGui::EndTabItem()
+{
+ ImGuiContext& g = *GImGui;
+ if (g.CurrentWindow->SkipItems)
+ return;
+
+ IM_ASSERT(g.CurrentTabBar.Size > 0 && "Needs to be called between BeginTabBar() and EndTabBar()!");
+ ImGuiTabBar* tab_bar = g.CurrentTabBar.back();
+ IM_ASSERT(tab_bar->LastTabItemIdx >= 0 && "Needs to be called between BeginTabItem() and EndTabItem()");
+ ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx];
+ if (!(tab->Flags & ImGuiTabItemFlags_NoPushId))
+ g.CurrentWindow->IDStack.pop_back();
+}
+
+bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags)
+{
+ // Layout whole tab bar if not already done
+ if (tab_bar->WantLayout)
+ TabBarLayout(tab_bar);
+
+ ImGuiContext& g = *GImGui;
+ ImGuiWindow* window = g.CurrentWindow;
+ if (window->SkipItems)
+ return false;
+
+ const ImGuiStyle& style = g.Style;
+ const ImGuiID id = TabBarCalcTabID(tab_bar, label);
+
+ // If the user called us with *p_open == false, we early out and don't render. We make a dummy call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID.
+ if (p_open && !*p_open)
+ {
+ PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true);
+ ItemAdd(ImRect(), id);
+ PopItemFlag();
+ return false;
+ }
+
+ // Calculate tab contents size
+ ImVec2 size = TabItemCalcSize(label, p_open != NULL);
+
+ // Acquire tab data
+ ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id);
+ bool tab_is_new = false;
+ if (tab == NULL)
+ {
+ tab_bar->Tabs.push_back(ImGuiTabItem());
+ tab = &tab_bar->Tabs.back();
+ tab->ID = id;
+ tab->Width = size.x;
+ tab_is_new = true;
+ }
+ tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab);
+ tab->WidthContents = size.x;
+
+ const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
+ const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0;
+ const bool tab_appearing = (tab->LastFrameVisible + 1 < g.FrameCount);
+ tab->LastFrameVisible = g.FrameCount;
+ tab->Flags = flags;
+
+ // If we are not reorderable, always reset offset based on submission order.
+ // (We already handled layout and sizing using the previous known order, but sizing is not affected by order!)
+ if (!tab_appearing && !(tab_bar->Flags & ImGuiTabBarFlags_Reorderable))
+ {
+ tab->Offset = tab_bar->OffsetNextTab;
+ tab_bar->OffsetNextTab += tab->Width + g.Style.ItemInnerSpacing.x;
+ }
+
+ // Update selected tab
+ if (tab_appearing && (tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs) && tab_bar->NextSelectedTabId == 0)
+ if (!tab_bar_appearing || tab_bar->SelectedTabId == 0)
+ tab_bar->NextSelectedTabId = id; // New tabs gets activated
+
+ // Lock visibility
+ bool tab_contents_visible = (tab_bar->VisibleTabId == id);
+ if (tab_contents_visible)
+ tab_bar->VisibleTabWasSubmitted = true;
+
+ // On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
+ if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing)
+ if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
+ tab_contents_visible = true;
+
+ if (tab_appearing && !(tab_bar_appearing && !tab_is_new))
+ {
+ PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true);
+ ItemAdd(ImRect(), id);
+ PopItemFlag();
+ return tab_contents_visible;
+ }
+
+ if (tab_bar->SelectedTabId == id)
+ tab->LastFrameSelected = g.FrameCount;
+
+ // Backup current layout position
+ const ImVec2 backup_main_cursor_pos = window->DC.CursorPos;
+
+ // Layout
+ size.x = tab->Width;
+ window->DC.CursorPos = tab_bar->BarRect.Min + ImVec2((float)(int)tab->Offset - tab_bar->ScrollingAnim, 0.0f);
+ ImVec2 pos = window->DC.CursorPos;
+ ImRect bb(pos, pos + size);
+
+ // We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation)
+ bool want_clip_rect = (bb.Min.x < tab_bar->BarRect.Min.x) || (bb.Max.x >= tab_bar->BarRect.Max.x);
+ if (want_clip_rect)
+ PushClipRect(ImVec2(ImMax(bb.Min.x, tab_bar->BarRect.Min.x), bb.Min.y - 1), ImVec2(tab_bar->BarRect.Max.x, bb.Max.y), true);
+
+ ItemSize(bb, style.FramePadding.y);
+ if (!ItemAdd(bb, id))
+ {
+ if (want_clip_rect)
+ PopClipRect();
+ window->DC.CursorPos = backup_main_cursor_pos;
+ return tab_contents_visible;
+ }
+
+ // Click to Select a tab
+ ImGuiButtonFlags button_flags = (ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_AllowItemOverlap);
+ if (g.DragDropActive)
+ button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
+ bool hovered, held;
+ bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
+ hovered |= (g.HoveredId == id);
+ if (pressed || ((flags & ImGuiTabItemFlags_SetSelected) && !tab_contents_visible)) // SetSelected can only be passed on explicit tab bar
+ tab_bar->NextSelectedTabId = id;
+
+ // Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered)
+ if (!held)
+ SetItemAllowOverlap();
+
+ // Drag and drop: re-order tabs
+ if (held && !tab_appearing && IsMouseDragging(0))
+ {
+ if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable))
+ {
+ // While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
+ if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
+ {
+ if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
+ TabBarQueueChangeTabOrder(tab_bar, tab, -1);
+ }
+ else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
+ {
+ if (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)
+ TabBarQueueChangeTabOrder(tab_bar, tab, +1);
+ }
+ }
+ }
+
+#if 0
+ if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->WidthContents)
+ {
+ // Enlarge tab display when hovering
+ bb.Max.x = bb.Min.x + (float)(int)ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f));
+ display_draw_list = GetOverlayDrawList(window);
+ TabItemRenderBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
+ }
+#endif
+
+ // Render tab shape
+ ImDrawList* display_draw_list = window->DrawList;
+ const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabUnfocused));
+ TabItemBackground(display_draw_list, bb, flags, tab_col);
+ RenderNavHighlight(bb, id);
+
+ // Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget.
+ const bool hovered_unblocked = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup);
+ if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1)))
+ tab_bar->NextSelectedTabId = id;
+
+ if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)
+ flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
+
+ // Render tab label, process close button
+ const ImGuiID close_button_id = p_open ? window->GetID((void*)(intptr_t)(id + 1)) : 0;
+ bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, label, id, close_button_id);
+ if (just_closed)
+ {
+ *p_open = false;
+ TabBarCloseTab(tab_bar, tab);
+ }
+
+ // Restore main window position so user can draw there
+ if (want_clip_rect)
+ PopClipRect();
+ window->DC.CursorPos = backup_main_cursor_pos;
+
+ // Tooltip (FIXME: Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer)
+ if (g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > 0.50f)
+ if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip))
+ SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label);
+
+ return tab_contents_visible;
+}
+
+// [Public] This is call is 100% optional but it allows to remove some one-frame glitches when a tab has been unexpectedly removed.
+// To use it to need to call the function SetTabItemClosed() after BeginTabBar() and before any call to BeginTabItem()
+void ImGui::SetTabItemClosed(const char* label)
+{
+ ImGuiContext& g = *GImGui;
+ bool is_within_manual_tab_bar = (g.CurrentTabBar.Size > 0) && !(g.CurrentTabBar.back()->Flags & ImGuiTabBarFlags_DockNode);
+ if (is_within_manual_tab_bar)
+ {
+ ImGuiTabBar* tab_bar = g.CurrentTabBar.back();
+ IM_ASSERT(tab_bar->WantLayout); // Needs to be called AFTER BeginTabBar() and BEFORE the first call to BeginTabItem()
+ ImGuiID tab_id = TabBarCalcTabID(tab_bar, label);
+ TabBarRemoveTab(tab_bar, tab_id);
+ }
+}
+
+ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button)
+{
+ ImGuiContext& g = *GImGui;
+ ImVec2 label_size = CalcTextSize(label, NULL, true);
+ ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f);
+ if (has_close_button)
+ size.x += g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize); // We use Y intentionally to fit the close button circle.
+ else
+ size.x += g.Style.FramePadding.x + 1.0f;
+ return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y);
+}
+
+void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col)
+{
+ // While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it.
+ (void)flags;
+ ImGuiContext& g = *GImGui;
+ const float width = bb.GetWidth();
+ IM_ASSERT(width > 0.0f);
+ const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
+ float y1 = bb.Min.y + 1.0f;
+ float y2 = bb.Max.y - 1.0f;
+ draw_list->PathLineTo(ImVec2(bb.Min.x, y2));
+ draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9);
+ draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12);
+ draw_list->PathLineTo(ImVec2(bb.Max.x, y2));
+ draw_list->AddConvexPolyFilled(draw_list->_Path.Data, draw_list->_Path.Size, col);
+ if (g.Style.TabBorderSize > 0.0f)
+ draw_list->AddPolyline(draw_list->_Path.Data, draw_list->_Path.Size, GetColorU32(ImGuiCol_Border), false, g.Style.TabBorderSize);
+ draw_list->PathClear();
+}
+
+// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
+bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, const char* label, ImGuiID tab_id, ImGuiID close_button_id)
+{
+ ImGuiContext& g = *GImGui;
+ ImGuiStyle& style = g.Style;
+ ImVec2 label_size = CalcTextSize(label, NULL, true);
+ if (bb.GetWidth() <= 1.0f)
+ return false;
+
+ // Render text label (with clipping + alpha gradient) + unsaved marker
+ const char* TAB_UNSAVED_MARKER = "*";
+ ImRect text_pixel_clip_bb(bb.Min.x + style.FramePadding.x, bb.Min.y + style.FramePadding.y, bb.Max.x - style.FramePadding.x, bb.Max.y);
+ if (flags & ImGuiTabItemFlags_UnsavedDocument)
+ {
+ text_pixel_clip_bb.Max.x -= CalcTextSize(TAB_UNSAVED_MARKER, NULL, false).x;
+ ImVec2 unsaved_marker_pos(ImMin(bb.Min.x + style.FramePadding.x + label_size.x + 2, text_pixel_clip_bb.Max.x), bb.Min.y + style.FramePadding.y + (float)(int)(-g.FontSize * 0.25f));
+ RenderTextClippedEx(draw_list, unsaved_marker_pos, bb.Max - style.FramePadding, TAB_UNSAVED_MARKER, NULL, NULL);
+ }
+ ImRect text_ellipsis_clip_bb = text_pixel_clip_bb;
+
+ // Close Button
+ // We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap()
+ // 'hovered' will be true when hovering the Tab but NOT when hovering the close button
+ // 'g.HoveredId==id' will be true when hovering the Tab including when hovering the close button
+ // 'g.ActiveId==close_button_id' will be true when we are holding on the close button, in which case both hovered booleans are false
+ bool close_button_pressed = false;
+ bool close_button_visible = false;
+ if (close_button_id != 0)
+ if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id)
+ close_button_visible = true;
+ if (close_button_visible)
+ {
+ ImGuiItemHoveredDataBackup last_item_backup;
+ const float close_button_sz = g.FontSize * 0.5f;
+ if (CloseButton(close_button_id, ImVec2(bb.Max.x - style.FramePadding.x - close_button_sz, bb.Min.y + style.FramePadding.y + close_button_sz), close_button_sz))
+ close_button_pressed = true;
+ last_item_backup.Restore();
+
+ // Close with middle mouse button
+ if (!(flags & ImGuiTabItemFlags_NoCloseWithMiddleMouseButton) && IsMouseClicked(2))
+ close_button_pressed = true;
+
+ text_pixel_clip_bb.Max.x -= close_button_sz * 2.0f;
+ }
+
+ // Label with ellipsis
+ // FIXME: This should be extracted into a helper but the use of text_pixel_clip_bb and !close_button_visible makes it tricky to abstract at the moment
+ const char* label_display_end = FindRenderedTextEnd(label);
+ if (label_size.x > text_ellipsis_clip_bb.GetWidth())
+ {
+ const int ellipsis_dot_count = 3;
+ const float ellipsis_width = (1.0f + 1.0f) * ellipsis_dot_count - 1.0f;
+ const char* label_end = NULL;
+ float label_size_clipped_x = g.Font->CalcTextSizeA(g.FontSize, text_ellipsis_clip_bb.GetWidth() - ellipsis_width + 1.0f, 0.0f, label, label_display_end, &label_end).x;
+ if (label_end == label && label_end < label_display_end) // Always display at least 1 character if there's no room for character + ellipsis
+ {
+ label_end = label + ImTextCountUtf8BytesFromChar(label, label_display_end);
+ label_size_clipped_x = g.Font->CalcTextSizeA(g.FontSize, FLT_MAX, 0.0f, label, label_end).x;
+ }
+ while (label_end > label && ImCharIsBlankA(label_end[-1])) // Trim trailing space
+ {
+ label_end--;
+ label_size_clipped_x -= g.Font->CalcTextSizeA(g.FontSize, FLT_MAX, 0.0f, label_end, label_end + 1).x; // Ascii blanks are always 1 byte
+ }
+ RenderTextClippedEx(draw_list, text_pixel_clip_bb.Min, text_pixel_clip_bb.Max, label, label_end, &label_size, ImVec2(0.0f, 0.0f));
+
+ const float ellipsis_x = text_pixel_clip_bb.Min.x + label_size_clipped_x + 1.0f;
+ if (!close_button_visible && ellipsis_x + ellipsis_width <= bb.Max.x)
+ RenderPixelEllipsis(draw_list, ImVec2(ellipsis_x, text_pixel_clip_bb.Min.y), ellipsis_dot_count, GetColorU32(ImGuiCol_Text));
+ }
+ else
+ {
+ RenderTextClippedEx(draw_list, text_pixel_clip_bb.Min, text_pixel_clip_bb.Max, label, label_display_end, &label_size, ImVec2(0.0f, 0.0f));
+ }
+
+ return close_button_pressed;
+}
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imstb_rectpack.h b/Client/ThirdParty/Box2D/extern/imgui/imstb_rectpack.h
new file mode 100644
index 0000000..2b07dcc
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imstb_rectpack.h
@@ -0,0 +1,623 @@
+// stb_rect_pack.h - v0.11 - public domain - rectangle packing
+// Sean Barrett 2014
+//
+// Useful for e.g. packing rectangular textures into an atlas.
+// Does not do rotation.
+//
+// Not necessarily the awesomest packing method, but better than
+// the totally naive one in stb_truetype (which is primarily what
+// this is meant to replace).
+//
+// Has only had a few tests run, may have issues.
+//
+// More docs to come.
+//
+// No memory allocations; uses qsort() and assert() from stdlib.
+// Can override those by defining STBRP_SORT and STBRP_ASSERT.
+//
+// This library currently uses the Skyline Bottom-Left algorithm.
+//
+// Please note: better rectangle packers are welcome! Please
+// implement them to the same API, but with a different init
+// function.
+//
+// Credits
+//
+// Library
+// Sean Barrett
+// Minor features
+// Martins Mozeiko
+// github:IntellectualKitty
+//
+// Bugfixes / warning fixes
+// Jeremy Jaussaud
+//
+// Version history:
+//
+// 0.11 (2017-03-03) return packing success/fail result
+// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
+// 0.09 (2016-08-27) fix compiler warnings
+// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
+// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
+// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
+// 0.05: added STBRP_ASSERT to allow replacing assert
+// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
+// 0.01: initial release
+//
+// LICENSE
+//
+// See end of file for license information.
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// INCLUDE SECTION
+//
+
+#ifndef STB_INCLUDE_STB_RECT_PACK_H
+#define STB_INCLUDE_STB_RECT_PACK_H
+
+#define STB_RECT_PACK_VERSION 1
+
+#ifdef STBRP_STATIC
+#define STBRP_DEF static
+#else
+#define STBRP_DEF extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct stbrp_context stbrp_context;
+typedef struct stbrp_node stbrp_node;
+typedef struct stbrp_rect stbrp_rect;
+
+#ifdef STBRP_LARGE_RECTS
+typedef int stbrp_coord;
+#else
+typedef unsigned short stbrp_coord;
+#endif
+
+STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
+// Assign packed locations to rectangles. The rectangles are of type
+// 'stbrp_rect' defined below, stored in the array 'rects', and there
+// are 'num_rects' many of them.
+//
+// Rectangles which are successfully packed have the 'was_packed' flag
+// set to a non-zero value and 'x' and 'y' store the minimum location
+// on each axis (i.e. bottom-left in cartesian coordinates, top-left
+// if you imagine y increasing downwards). Rectangles which do not fit
+// have the 'was_packed' flag set to 0.
+//
+// You should not try to access the 'rects' array from another thread
+// while this function is running, as the function temporarily reorders
+// the array while it executes.
+//
+// To pack into another rectangle, you need to call stbrp_init_target
+// again. To continue packing into the same rectangle, you can call
+// this function again. Calling this multiple times with multiple rect
+// arrays will probably produce worse packing results than calling it
+// a single time with the full rectangle array, but the option is
+// available.
+//
+// The function returns 1 if all of the rectangles were successfully
+// packed and 0 otherwise.
+
+struct stbrp_rect
+{
+ // reserved for your use:
+ int id;
+
+ // input:
+ stbrp_coord w, h;
+
+ // output:
+ stbrp_coord x, y;
+ int was_packed; // non-zero if valid packing
+
+}; // 16 bytes, nominally
+
+
+STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
+// Initialize a rectangle packer to:
+// pack a rectangle that is 'width' by 'height' in dimensions
+// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
+//
+// You must call this function every time you start packing into a new target.
+//
+// There is no "shutdown" function. The 'nodes' memory must stay valid for
+// the following stbrp_pack_rects() call (or calls), but can be freed after
+// the call (or calls) finish.
+//
+// Note: to guarantee best results, either:
+// 1. make sure 'num_nodes' >= 'width'
+// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
+//
+// If you don't do either of the above things, widths will be quantized to multiples
+// of small integers to guarantee the algorithm doesn't run out of temporary storage.
+//
+// If you do #2, then the non-quantized algorithm will be used, but the algorithm
+// may run out of temporary storage and be unable to pack some rectangles.
+
+STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
+// Optionally call this function after init but before doing any packing to
+// change the handling of the out-of-temp-memory scenario, described above.
+// If you call init again, this will be reset to the default (false).
+
+
+STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
+// Optionally select which packing heuristic the library should use. Different
+// heuristics will produce better/worse results for different data sets.
+// If you call init again, this will be reset to the default.
+
+enum
+{
+ STBRP_HEURISTIC_Skyline_default=0,
+ STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
+ STBRP_HEURISTIC_Skyline_BF_sortHeight
+};
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// the details of the following structures don't matter to you, but they must
+// be visible so you can handle the memory allocations for them
+
+struct stbrp_node
+{
+ stbrp_coord x,y;
+ stbrp_node *next;
+};
+
+struct stbrp_context
+{
+ int width;
+ int height;
+ int align;
+ int init_mode;
+ int heuristic;
+ int num_nodes;
+ stbrp_node *active_head;
+ stbrp_node *free_head;
+ stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// IMPLEMENTATION SECTION
+//
+
+#ifdef STB_RECT_PACK_IMPLEMENTATION
+#ifndef STBRP_SORT
+#include <stdlib.h>
+#define STBRP_SORT qsort
+#endif
+
+#ifndef STBRP_ASSERT
+#include <assert.h>
+#define STBRP_ASSERT assert
+#endif
+
+#ifdef _MSC_VER
+#define STBRP__NOTUSED(v) (void)(v)
+#define STBRP__CDECL __cdecl
+#else
+#define STBRP__NOTUSED(v) (void)sizeof(v)
+#define STBRP__CDECL
+#endif
+
+enum
+{
+ STBRP__INIT_skyline = 1
+};
+
+STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
+{
+ switch (context->init_mode) {
+ case STBRP__INIT_skyline:
+ STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
+ context->heuristic = heuristic;
+ break;
+ default:
+ STBRP_ASSERT(0);
+ }
+}
+
+STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
+{
+ if (allow_out_of_mem)
+ // if it's ok to run out of memory, then don't bother aligning them;
+ // this gives better packing, but may fail due to OOM (even though
+ // the rectangles easily fit). @TODO a smarter approach would be to only
+ // quantize once we've hit OOM, then we could get rid of this parameter.
+ context->align = 1;
+ else {
+ // if it's not ok to run out of memory, then quantize the widths
+ // so that num_nodes is always enough nodes.
+ //
+ // I.e. num_nodes * align >= width
+ // align >= width / num_nodes
+ // align = ceil(width/num_nodes)
+
+ context->align = (context->width + context->num_nodes-1) / context->num_nodes;
+ }
+}
+
+STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
+{
+ int i;
+#ifndef STBRP_LARGE_RECTS
+ STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
+#endif
+
+ for (i=0; i < num_nodes-1; ++i)
+ nodes[i].next = &nodes[i+1];
+ nodes[i].next = NULL;
+ context->init_mode = STBRP__INIT_skyline;
+ context->heuristic = STBRP_HEURISTIC_Skyline_default;
+ context->free_head = &nodes[0];
+ context->active_head = &context->extra[0];
+ context->width = width;
+ context->height = height;
+ context->num_nodes = num_nodes;
+ stbrp_setup_allow_out_of_mem(context, 0);
+
+ // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
+ context->extra[0].x = 0;
+ context->extra[0].y = 0;
+ context->extra[0].next = &context->extra[1];
+ context->extra[1].x = (stbrp_coord) width;
+#ifdef STBRP_LARGE_RECTS
+ context->extra[1].y = (1<<30);
+#else
+ context->extra[1].y = 65535;
+#endif
+ context->extra[1].next = NULL;
+}
+
+// find minimum y position if it starts at x1
+static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
+{
+ stbrp_node *node = first;
+ int x1 = x0 + width;
+ int min_y, visited_width, waste_area;
+
+ STBRP__NOTUSED(c);
+
+ STBRP_ASSERT(first->x <= x0);
+
+ #if 0
+ // skip in case we're past the node
+ while (node->next->x <= x0)
+ ++node;
+ #else
+ STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
+ #endif
+
+ STBRP_ASSERT(node->x <= x0);
+
+ min_y = 0;
+ waste_area = 0;
+ visited_width = 0;
+ while (node->x < x1) {
+ if (node->y > min_y) {
+ // raise min_y higher.
+ // we've accounted for all waste up to min_y,
+ // but we'll now add more waste for everything we've visted
+ waste_area += visited_width * (node->y - min_y);
+ min_y = node->y;
+ // the first time through, visited_width might be reduced
+ if (node->x < x0)
+ visited_width += node->next->x - x0;
+ else
+ visited_width += node->next->x - node->x;
+ } else {
+ // add waste area
+ int under_width = node->next->x - node->x;
+ if (under_width + visited_width > width)
+ under_width = width - visited_width;
+ waste_area += under_width * (min_y - node->y);
+ visited_width += under_width;
+ }
+ node = node->next;
+ }
+
+ *pwaste = waste_area;
+ return min_y;
+}
+
+typedef struct
+{
+ int x,y;
+ stbrp_node **prev_link;
+} stbrp__findresult;
+
+static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
+{
+ int best_waste = (1<<30), best_x, best_y = (1 << 30);
+ stbrp__findresult fr;
+ stbrp_node **prev, *node, *tail, **best = NULL;
+
+ // align to multiple of c->align
+ width = (width + c->align - 1);
+ width -= width % c->align;
+ STBRP_ASSERT(width % c->align == 0);
+
+ node = c->active_head;
+ prev = &c->active_head;
+ while (node->x + width <= c->width) {
+ int y,waste;
+ y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
+ if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
+ // bottom left
+ if (y < best_y) {
+ best_y = y;
+ best = prev;
+ }
+ } else {
+ // best-fit
+ if (y + height <= c->height) {
+ // can only use it if it first vertically
+ if (y < best_y || (y == best_y && waste < best_waste)) {
+ best_y = y;
+ best_waste = waste;
+ best = prev;
+ }
+ }
+ }
+ prev = &node->next;
+ node = node->next;
+ }
+
+ best_x = (best == NULL) ? 0 : (*best)->x;
+
+ // if doing best-fit (BF), we also have to try aligning right edge to each node position
+ //
+ // e.g, if fitting
+ //
+ // ____________________
+ // |____________________|
+ //
+ // into
+ //
+ // | |
+ // | ____________|
+ // |____________|
+ //
+ // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
+ //
+ // This makes BF take about 2x the time
+
+ if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
+ tail = c->active_head;
+ node = c->active_head;
+ prev = &c->active_head;
+ // find first node that's admissible
+ while (tail->x < width)
+ tail = tail->next;
+ while (tail) {
+ int xpos = tail->x - width;
+ int y,waste;
+ STBRP_ASSERT(xpos >= 0);
+ // find the left position that matches this
+ while (node->next->x <= xpos) {
+ prev = &node->next;
+ node = node->next;
+ }
+ STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
+ y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
+ if (y + height < c->height) {
+ if (y <= best_y) {
+ if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
+ best_x = xpos;
+ STBRP_ASSERT(y <= best_y);
+ best_y = y;
+ best_waste = waste;
+ best = prev;
+ }
+ }
+ }
+ tail = tail->next;
+ }
+ }
+
+ fr.prev_link = best;
+ fr.x = best_x;
+ fr.y = best_y;
+ return fr;
+}
+
+static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
+{
+ // find best position according to heuristic
+ stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
+ stbrp_node *node, *cur;
+
+ // bail if:
+ // 1. it failed
+ // 2. the best node doesn't fit (we don't always check this)
+ // 3. we're out of memory
+ if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
+ res.prev_link = NULL;
+ return res;
+ }
+
+ // on success, create new node
+ node = context->free_head;
+ node->x = (stbrp_coord) res.x;
+ node->y = (stbrp_coord) (res.y + height);
+
+ context->free_head = node->next;
+
+ // insert the new node into the right starting point, and
+ // let 'cur' point to the remaining nodes needing to be
+ // stiched back in
+
+ cur = *res.prev_link;
+ if (cur->x < res.x) {
+ // preserve the existing one, so start testing with the next one
+ stbrp_node *next = cur->next;
+ cur->next = node;
+ cur = next;
+ } else {
+ *res.prev_link = node;
+ }
+
+ // from here, traverse cur and free the nodes, until we get to one
+ // that shouldn't be freed
+ while (cur->next && cur->next->x <= res.x + width) {
+ stbrp_node *next = cur->next;
+ // move the current node to the free list
+ cur->next = context->free_head;
+ context->free_head = cur;
+ cur = next;
+ }
+
+ // stitch the list back in
+ node->next = cur;
+
+ if (cur->x < res.x + width)
+ cur->x = (stbrp_coord) (res.x + width);
+
+#ifdef _DEBUG
+ cur = context->active_head;
+ while (cur->x < context->width) {
+ STBRP_ASSERT(cur->x < cur->next->x);
+ cur = cur->next;
+ }
+ STBRP_ASSERT(cur->next == NULL);
+
+ {
+ int count=0;
+ cur = context->active_head;
+ while (cur) {
+ cur = cur->next;
+ ++count;
+ }
+ cur = context->free_head;
+ while (cur) {
+ cur = cur->next;
+ ++count;
+ }
+ STBRP_ASSERT(count == context->num_nodes+2);
+ }
+#endif
+
+ return res;
+}
+
+static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
+{
+ const stbrp_rect *p = (const stbrp_rect *) a;
+ const stbrp_rect *q = (const stbrp_rect *) b;
+ if (p->h > q->h)
+ return -1;
+ if (p->h < q->h)
+ return 1;
+ return (p->w > q->w) ? -1 : (p->w < q->w);
+}
+
+static int STBRP__CDECL rect_original_order(const void *a, const void *b)
+{
+ const stbrp_rect *p = (const stbrp_rect *) a;
+ const stbrp_rect *q = (const stbrp_rect *) b;
+ return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
+}
+
+#ifdef STBRP_LARGE_RECTS
+#define STBRP__MAXVAL 0xffffffff
+#else
+#define STBRP__MAXVAL 0xffff
+#endif
+
+STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
+{
+ int i, all_rects_packed = 1;
+
+ // we use the 'was_packed' field internally to allow sorting/unsorting
+ for (i=0; i < num_rects; ++i) {
+ rects[i].was_packed = i;
+ #ifndef STBRP_LARGE_RECTS
+ STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff);
+ #endif
+ }
+
+ // sort according to heuristic
+ STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
+
+ for (i=0; i < num_rects; ++i) {
+ if (rects[i].w == 0 || rects[i].h == 0) {
+ rects[i].x = rects[i].y = 0; // empty rect needs no space
+ } else {
+ stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
+ if (fr.prev_link) {
+ rects[i].x = (stbrp_coord) fr.x;
+ rects[i].y = (stbrp_coord) fr.y;
+ } else {
+ rects[i].x = rects[i].y = STBRP__MAXVAL;
+ }
+ }
+ }
+
+ // unsort
+ STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
+
+ // set was_packed flags and all_rects_packed status
+ for (i=0; i < num_rects; ++i) {
+ rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
+ if (!rects[i].was_packed)
+ all_rects_packed = 0;
+ }
+
+ // return the all_rects_packed status
+ return all_rects_packed;
+}
+#endif
+
+/*
+------------------------------------------------------------------------------
+This software is available under 2 licenses -- choose whichever you prefer.
+------------------------------------------------------------------------------
+ALTERNATIVE A - MIT License
+Copyright (c) 2017 Sean Barrett
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+------------------------------------------------------------------------------
+ALTERNATIVE B - Public Domain (www.unlicense.org)
+This is free and unencumbered software released into the public domain.
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
+software, either in source code form or as a compiled binary, for any purpose,
+commercial or non-commercial, and by any means.
+In jurisdictions that recognize copyright laws, the author or authors of this
+software dedicate any and all copyright interest in the software to the public
+domain. We make this dedication for the benefit of the public at large and to
+the detriment of our heirs and successors. We intend this dedication to be an
+overt act of relinquishment in perpetuity of all present and future rights to
+this software under copyright law.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+------------------------------------------------------------------------------
+*/
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imstb_textedit.h b/Client/ThirdParty/Box2D/extern/imgui/imstb_textedit.h
new file mode 100644
index 0000000..9e12469
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imstb_textedit.h
@@ -0,0 +1,1409 @@
+// [ImGui] this is a slightly modified version of stb_textedit.h 1.12. Those changes would need to be pushed into nothings/stb
+// [ImGui] - 2018-06: fixed undo/redo after pasting large amount of text (over 32 kb). Redo will still fail when undo buffers are exhausted, but text won't be corrupted (see nothings/stb issue #620)
+// [ImGui] - 2018-06: fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
+// [ImGui] - fixed some minor warnings
+
+// stb_textedit.h - v1.12 - public domain - Sean Barrett
+// Development of this library was sponsored by RAD Game Tools
+//
+// This C header file implements the guts of a multi-line text-editing
+// widget; you implement display, word-wrapping, and low-level string
+// insertion/deletion, and stb_textedit will map user inputs into
+// insertions & deletions, plus updates to the cursor position,
+// selection state, and undo state.
+//
+// It is intended for use in games and other systems that need to build
+// their own custom widgets and which do not have heavy text-editing
+// requirements (this library is not recommended for use for editing large
+// texts, as its performance does not scale and it has limited undo).
+//
+// Non-trivial behaviors are modelled after Windows text controls.
+//
+//
+// LICENSE
+//
+// See end of file for license information.
+//
+//
+// DEPENDENCIES
+//
+// Uses the C runtime function 'memmove', which you can override
+// by defining STB_TEXTEDIT_memmove before the implementation.
+// Uses no other functions. Performs no runtime allocations.
+//
+//
+// VERSION HISTORY
+//
+// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
+// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
+// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual
+// 1.9 (2016-08-27) customizable move-by-word
+// 1.8 (2016-04-02) better keyboard handling when mouse button is down
+// 1.7 (2015-09-13) change y range handling in case baseline is non-0
+// 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove
+// 1.5 (2014-09-10) add support for secondary keys for OS X
+// 1.4 (2014-08-17) fix signed/unsigned warnings
+// 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary
+// 1.2 (2014-05-27) fix some RAD types that had crept into the new code
+// 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE )
+// 1.0 (2012-07-26) improve documentation, initial public release
+// 0.3 (2012-02-24) bugfixes, single-line mode; insert mode
+// 0.2 (2011-11-28) fixes to undo/redo
+// 0.1 (2010-07-08) initial version
+//
+// ADDITIONAL CONTRIBUTORS
+//
+// Ulf Winklemann: move-by-word in 1.1
+// Fabian Giesen: secondary key inputs in 1.5
+// Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6
+//
+// Bugfixes:
+// Scott Graham
+// Daniel Keller
+// Omar Cornut
+// Dan Thompson
+//
+// USAGE
+//
+// This file behaves differently depending on what symbols you define
+// before including it.
+//
+//
+// Header-file mode:
+//
+// If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this,
+// it will operate in "header file" mode. In this mode, it declares a
+// single public symbol, STB_TexteditState, which encapsulates the current
+// state of a text widget (except for the string, which you will store
+// separately).
+//
+// To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a
+// primitive type that defines a single character (e.g. char, wchar_t, etc).
+//
+// To save space or increase undo-ability, you can optionally define the
+// following things that are used by the undo system:
+//
+// STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position
+// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow
+// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer
+//
+// If you don't define these, they are set to permissive types and
+// moderate sizes. The undo system does no memory allocations, so
+// it grows STB_TexteditState by the worst-case storage which is (in bytes):
+//
+// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT
+// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT
+//
+//
+// Implementation mode:
+//
+// If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it
+// will compile the implementation of the text edit widget, depending
+// on a large number of symbols which must be defined before the include.
+//
+// The implementation is defined only as static functions. You will then
+// need to provide your own APIs in the same file which will access the
+// static functions.
+//
+// The basic concept is that you provide a "string" object which
+// behaves like an array of characters. stb_textedit uses indices to
+// refer to positions in the string, implicitly representing positions
+// in the displayed textedit. This is true for both plain text and
+// rich text; even with rich text stb_truetype interacts with your
+// code as if there was an array of all the displayed characters.
+//
+// Symbols that must be the same in header-file and implementation mode:
+//
+// STB_TEXTEDIT_CHARTYPE the character type
+// STB_TEXTEDIT_POSITIONTYPE small type that is a valid cursor position
+// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow
+// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer
+//
+// Symbols you must define for implementation mode:
+//
+// STB_TEXTEDIT_STRING the type of object representing a string being edited,
+// typically this is a wrapper object with other data you need
+//
+// STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1))
+// STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters
+// starting from character #n (see discussion below)
+// STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character
+// to the xpos of the i+1'th char for a line of characters
+// starting at character #n (i.e. accounts for kerning
+// with previous char)
+// STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character
+// (return type is int, -1 means not valid to insert)
+// STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based
+// STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize
+// as manually wordwrapping for end-of-line positioning
+//
+// STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i
+// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*)
+//
+// STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key
+//
+// STB_TEXTEDIT_K_LEFT keyboard input to move cursor left
+// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right
+// STB_TEXTEDIT_K_UP keyboard input to move cursor up
+// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down
+// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME
+// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END
+// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME
+// STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END
+// STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor
+// STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor
+// STB_TEXTEDIT_K_UNDO keyboard input to perform undo
+// STB_TEXTEDIT_K_REDO keyboard input to perform redo
+//
+// Optional:
+// STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode
+// STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'),
+// required for default WORDLEFT/WORDRIGHT handlers
+// STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to
+// STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to
+// STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT
+// STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT
+// STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line
+// STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line
+// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
+// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
+//
+// Todo:
+// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page
+// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page
+//
+// Keyboard input must be encoded as a single integer value; e.g. a character code
+// and some bitflags that represent shift states. to simplify the interface, SHIFT must
+// be a bitflag, so we can test the shifted state of cursor movements to allow selection,
+// i.e. (STB_TEXTED_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow.
+//
+// You can encode other things, such as CONTROL or ALT, in additional bits, and
+// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example,
+// my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN
+// bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit,
+// and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the
+// API below. The control keys will only match WM_KEYDOWN events because of the
+// keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN
+// bit so it only decodes WM_CHAR events.
+//
+// STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed
+// row of characters assuming they start on the i'th character--the width and
+// the height and the number of characters consumed. This allows this library
+// to traverse the entire layout incrementally. You need to compute word-wrapping
+// here.
+//
+// Each textfield keeps its own insert mode state, which is not how normal
+// applications work. To keep an app-wide insert mode, update/copy the
+// "insert_mode" field of STB_TexteditState before/after calling API functions.
+//
+// API
+//
+// void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line)
+//
+// void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
+// void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
+// int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+// int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len)
+// void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXEDIT_KEYTYPE key)
+//
+// Each of these functions potentially updates the string and updates the
+// state.
+//
+// initialize_state:
+// set the textedit state to a known good default state when initially
+// constructing the textedit.
+//
+// click:
+// call this with the mouse x,y on a mouse down; it will update the cursor
+// and reset the selection start/end to the cursor point. the x,y must
+// be relative to the text widget, with (0,0) being the top left.
+//
+// drag:
+// call this with the mouse x,y on a mouse drag/up; it will update the
+// cursor and the selection end point
+//
+// cut:
+// call this to delete the current selection; returns true if there was
+// one. you should FIRST copy the current selection to the system paste buffer.
+// (To copy, just copy the current selection out of the string yourself.)
+//
+// paste:
+// call this to paste text at the current cursor point or over the current
+// selection if there is one.
+//
+// key:
+// call this for keyboard inputs sent to the textfield. you can use it
+// for "key down" events or for "translated" key events. if you need to
+// do both (as in Win32), or distinguish Unicode characters from control
+// inputs, set a high bit to distinguish the two; then you can define the
+// various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit
+// set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is
+// clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to
+// anything other type you wante before including.
+//
+//
+// When rendering, you can read the cursor position and selection state from
+// the STB_TexteditState.
+//
+//
+// Notes:
+//
+// This is designed to be usable in IMGUI, so it allows for the possibility of
+// running in an IMGUI that has NOT cached the multi-line layout. For this
+// reason, it provides an interface that is compatible with computing the
+// layout incrementally--we try to make sure we make as few passes through
+// as possible. (For example, to locate the mouse pointer in the text, we
+// could define functions that return the X and Y positions of characters
+// and binary search Y and then X, but if we're doing dynamic layout this
+// will run the layout algorithm many times, so instead we manually search
+// forward in one pass. Similar logic applies to e.g. up-arrow and
+// down-arrow movement.)
+//
+// If it's run in a widget that *has* cached the layout, then this is less
+// efficient, but it's not horrible on modern computers. But you wouldn't
+// want to edit million-line files with it.
+
+
+////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+////
+//// Header-file mode
+////
+////
+
+#ifndef INCLUDE_STB_TEXTEDIT_H
+#define INCLUDE_STB_TEXTEDIT_H
+
+////////////////////////////////////////////////////////////////////////
+//
+// STB_TexteditState
+//
+// Definition of STB_TexteditState which you should store
+// per-textfield; it includes cursor position, selection state,
+// and undo state.
+//
+
+#ifndef STB_TEXTEDIT_UNDOSTATECOUNT
+#define STB_TEXTEDIT_UNDOSTATECOUNT 99
+#endif
+#ifndef STB_TEXTEDIT_UNDOCHARCOUNT
+#define STB_TEXTEDIT_UNDOCHARCOUNT 999
+#endif
+#ifndef STB_TEXTEDIT_CHARTYPE
+#define STB_TEXTEDIT_CHARTYPE int
+#endif
+#ifndef STB_TEXTEDIT_POSITIONTYPE
+#define STB_TEXTEDIT_POSITIONTYPE int
+#endif
+
+typedef struct
+{
+ // private data
+ STB_TEXTEDIT_POSITIONTYPE where;
+ STB_TEXTEDIT_POSITIONTYPE insert_length;
+ STB_TEXTEDIT_POSITIONTYPE delete_length;
+ int char_storage;
+} StbUndoRecord;
+
+typedef struct
+{
+ // private data
+ StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT];
+ STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT];
+ short undo_point, redo_point;
+ int undo_char_point, redo_char_point;
+} StbUndoState;
+
+typedef struct
+{
+ /////////////////////
+ //
+ // public data
+ //
+
+ int cursor;
+ // position of the text cursor within the string
+
+ int select_start; // selection start point
+ int select_end;
+ // selection start and end point in characters; if equal, no selection.
+ // note that start may be less than or greater than end (e.g. when
+ // dragging the mouse, start is where the initial click was, and you
+ // can drag in either direction)
+
+ unsigned char insert_mode;
+ // each textfield keeps its own insert mode state. to keep an app-wide
+ // insert mode, copy this value in/out of the app state
+
+ /////////////////////
+ //
+ // private data
+ //
+ unsigned char cursor_at_end_of_line; // not implemented yet
+ unsigned char initialized;
+ unsigned char has_preferred_x;
+ unsigned char single_line;
+ unsigned char padding1, padding2, padding3;
+ float preferred_x; // this determines where the cursor up/down tries to seek to along x
+ StbUndoState undostate;
+} STB_TexteditState;
+
+
+////////////////////////////////////////////////////////////////////////
+//
+// StbTexteditRow
+//
+// Result of layout query, used by stb_textedit to determine where
+// the text in each row is.
+
+// result of layout query
+typedef struct
+{
+ float x0,x1; // starting x location, end x location (allows for align=right, etc)
+ float baseline_y_delta; // position of baseline relative to previous row's baseline
+ float ymin,ymax; // height of row above and below baseline
+ int num_chars;
+} StbTexteditRow;
+#endif //INCLUDE_STB_TEXTEDIT_H
+
+
+////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+////
+//// Implementation mode
+////
+////
+
+
+// implementation isn't include-guarded, since it might have indirectly
+// included just the "header" portion
+#ifdef STB_TEXTEDIT_IMPLEMENTATION
+
+#ifndef STB_TEXTEDIT_memmove
+#include <string.h>
+#define STB_TEXTEDIT_memmove memmove
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Mouse input handling
+//
+
+// traverse the layout to locate the nearest character to a display position
+static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y)
+{
+ StbTexteditRow r;
+ int n = STB_TEXTEDIT_STRINGLEN(str);
+ float base_y = 0, prev_x;
+ int i=0, k;
+
+ r.x0 = r.x1 = 0;
+ r.ymin = r.ymax = 0;
+ r.num_chars = 0;
+
+ // search rows to find one that straddles 'y'
+ while (i < n) {
+ STB_TEXTEDIT_LAYOUTROW(&r, str, i);
+ if (r.num_chars <= 0)
+ return n;
+
+ if (i==0 && y < base_y + r.ymin)
+ return 0;
+
+ if (y < base_y + r.ymax)
+ break;
+
+ i += r.num_chars;
+ base_y += r.baseline_y_delta;
+ }
+
+ // below all text, return 'after' last character
+ if (i >= n)
+ return n;
+
+ // check if it's before the beginning of the line
+ if (x < r.x0)
+ return i;
+
+ // check if it's before the end of the line
+ if (x < r.x1) {
+ // search characters in row for one that straddles 'x'
+ prev_x = r.x0;
+ for (k=0; k < r.num_chars; ++k) {
+ float w = STB_TEXTEDIT_GETWIDTH(str, i, k);
+ if (x < prev_x+w) {
+ if (x < prev_x+w/2)
+ return k+i;
+ else
+ return k+i+1;
+ }
+ prev_x += w;
+ }
+ // shouldn't happen, but if it does, fall through to end-of-line case
+ }
+
+ // if the last character is a newline, return that. otherwise return 'after' the last character
+ if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE)
+ return i+r.num_chars-1;
+ else
+ return i+r.num_chars;
+}
+
+// API click: on mouse down, move the cursor to the clicked location, and reset the selection
+static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
+{
+ // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
+ // goes off the top or bottom of the text
+ if( state->single_line )
+ {
+ StbTexteditRow r;
+ STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
+ y = r.ymin;
+ }
+
+ state->cursor = stb_text_locate_coord(str, x, y);
+ state->select_start = state->cursor;
+ state->select_end = state->cursor;
+ state->has_preferred_x = 0;
+}
+
+// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location
+static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)
+{
+ int p = 0;
+
+ // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse
+ // goes off the top or bottom of the text
+ if( state->single_line )
+ {
+ StbTexteditRow r;
+ STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
+ y = r.ymin;
+ }
+
+ if (state->select_start == state->select_end)
+ state->select_start = state->cursor;
+
+ p = stb_text_locate_coord(str, x, y);
+ state->cursor = state->select_end = p;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Keyboard input handling
+//
+
+// forward declarations
+static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state);
+static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state);
+static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length);
+static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length);
+static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length);
+
+typedef struct
+{
+ float x,y; // position of n'th character
+ float height; // height of line
+ int first_char, length; // first char of row, and length
+ int prev_first; // first char of previous row
+} StbFindState;
+
+// find the x/y location of a character, and remember info about the previous row in
+// case we get a move-up event (for page up, we'll have to rescan)
+static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line)
+{
+ StbTexteditRow r;
+ int prev_start = 0;
+ int z = STB_TEXTEDIT_STRINGLEN(str);
+ int i=0, first;
+
+ if (n == z) {
+ // if it's at the end, then find the last line -- simpler than trying to
+ // explicitly handle this case in the regular code
+ if (single_line) {
+ STB_TEXTEDIT_LAYOUTROW(&r, str, 0);
+ find->y = 0;
+ find->first_char = 0;
+ find->length = z;
+ find->height = r.ymax - r.ymin;
+ find->x = r.x1;
+ } else {
+ find->y = 0;
+ find->x = 0;
+ find->height = 1;
+ while (i < z) {
+ STB_TEXTEDIT_LAYOUTROW(&r, str, i);
+ prev_start = i;
+ i += r.num_chars;
+ }
+ find->first_char = i;
+ find->length = 0;
+ find->prev_first = prev_start;
+ }
+ return;
+ }
+
+ // search rows to find the one that straddles character n
+ find->y = 0;
+
+ for(;;) {
+ STB_TEXTEDIT_LAYOUTROW(&r, str, i);
+ if (n < i + r.num_chars)
+ break;
+ prev_start = i;
+ i += r.num_chars;
+ find->y += r.baseline_y_delta;
+ }
+
+ find->first_char = first = i;
+ find->length = r.num_chars;
+ find->height = r.ymax - r.ymin;
+ find->prev_first = prev_start;
+
+ // now scan to find xpos
+ find->x = r.x0;
+ i = 0;
+ for (i=0; first+i < n; ++i)
+ find->x += STB_TEXTEDIT_GETWIDTH(str, first, i);
+}
+
+#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
+
+// make the selection/cursor state valid if client altered the string
+static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+{
+ int n = STB_TEXTEDIT_STRINGLEN(str);
+ if (STB_TEXT_HAS_SELECTION(state)) {
+ if (state->select_start > n) state->select_start = n;
+ if (state->select_end > n) state->select_end = n;
+ // if clamping forced them to be equal, move the cursor to match
+ if (state->select_start == state->select_end)
+ state->cursor = state->select_start;
+ }
+ if (state->cursor > n) state->cursor = n;
+}
+
+// delete characters while updating undo
+static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len)
+{
+ stb_text_makeundo_delete(str, state, where, len);
+ STB_TEXTEDIT_DELETECHARS(str, where, len);
+ state->has_preferred_x = 0;
+}
+
+// delete the section
+static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+{
+ stb_textedit_clamp(str, state);
+ if (STB_TEXT_HAS_SELECTION(state)) {
+ if (state->select_start < state->select_end) {
+ stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start);
+ state->select_end = state->cursor = state->select_start;
+ } else {
+ stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end);
+ state->select_start = state->cursor = state->select_end;
+ }
+ state->has_preferred_x = 0;
+ }
+}
+
+// canoncialize the selection so start <= end
+static void stb_textedit_sortselection(STB_TexteditState *state)
+{
+ if (state->select_end < state->select_start) {
+ int temp = state->select_end;
+ state->select_end = state->select_start;
+ state->select_start = temp;
+ }
+}
+
+// move cursor to first character of selection
+static void stb_textedit_move_to_first(STB_TexteditState *state)
+{
+ if (STB_TEXT_HAS_SELECTION(state)) {
+ stb_textedit_sortselection(state);
+ state->cursor = state->select_start;
+ state->select_end = state->select_start;
+ state->has_preferred_x = 0;
+ }
+}
+
+// move cursor to last character of selection
+static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+{
+ if (STB_TEXT_HAS_SELECTION(state)) {
+ stb_textedit_sortselection(state);
+ stb_textedit_clamp(str, state);
+ state->cursor = state->select_end;
+ state->select_start = state->select_end;
+ state->has_preferred_x = 0;
+ }
+}
+
+#ifdef STB_TEXTEDIT_IS_SPACE
+static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx )
+{
+ return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1;
+}
+
+#ifndef STB_TEXTEDIT_MOVEWORDLEFT
+static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c )
+{
+ --c; // always move at least one character
+ while( c >= 0 && !is_word_boundary( str, c ) )
+ --c;
+
+ if( c < 0 )
+ c = 0;
+
+ return c;
+}
+#define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous
+#endif
+
+#ifndef STB_TEXTEDIT_MOVEWORDRIGHT
+static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c )
+{
+ const int len = STB_TEXTEDIT_STRINGLEN(str);
+ ++c; // always move at least one character
+ while( c < len && !is_word_boundary( str, c ) )
+ ++c;
+
+ if( c > len )
+ c = len;
+
+ return c;
+}
+#define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next
+#endif
+
+#endif
+
+// update selection and cursor to match each other
+static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state)
+{
+ if (!STB_TEXT_HAS_SELECTION(state))
+ state->select_start = state->select_end = state->cursor;
+ else
+ state->cursor = state->select_end;
+}
+
+// API cut: delete selection
+static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+{
+ if (STB_TEXT_HAS_SELECTION(state)) {
+ stb_textedit_delete_selection(str,state); // implicity clamps
+ state->has_preferred_x = 0;
+ return 1;
+ }
+ return 0;
+}
+
+// API paste: replace existing selection with passed-in text
+static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len)
+{
+ // if there's a selection, the paste should delete it
+ stb_textedit_clamp(str, state);
+ stb_textedit_delete_selection(str,state);
+ // try to insert the characters
+ if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) {
+ stb_text_makeundo_insert(state, state->cursor, len);
+ state->cursor += len;
+ state->has_preferred_x = 0;
+ return 1;
+ }
+ // remove the undo since we didn't actually insert the characters
+ if (state->undostate.undo_point)
+ --state->undostate.undo_point;
+ return 0;
+}
+
+#ifndef STB_TEXTEDIT_KEYTYPE
+#define STB_TEXTEDIT_KEYTYPE int
+#endif
+
+// API key: process a keyboard input
+static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key)
+{
+retry:
+ switch (key) {
+ default: {
+ int c = STB_TEXTEDIT_KEYTOTEXT(key);
+ if (c > 0) {
+ STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c;
+
+ // can't add newline in single-line mode
+ if (c == '\n' && state->single_line)
+ break;
+
+ if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) {
+ stb_text_makeundo_replace(str, state, state->cursor, 1, 1);
+ STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1);
+ if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) {
+ ++state->cursor;
+ state->has_preferred_x = 0;
+ }
+ } else {
+ stb_textedit_delete_selection(str,state); // implicity clamps
+ if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) {
+ stb_text_makeundo_insert(state, state->cursor, 1);
+ ++state->cursor;
+ state->has_preferred_x = 0;
+ }
+ }
+ }
+ break;
+ }
+
+#ifdef STB_TEXTEDIT_K_INSERT
+ case STB_TEXTEDIT_K_INSERT:
+ state->insert_mode = !state->insert_mode;
+ break;
+#endif
+
+ case STB_TEXTEDIT_K_UNDO:
+ stb_text_undo(str, state);
+ state->has_preferred_x = 0;
+ break;
+
+ case STB_TEXTEDIT_K_REDO:
+ stb_text_redo(str, state);
+ state->has_preferred_x = 0;
+ break;
+
+ case STB_TEXTEDIT_K_LEFT:
+ // if currently there's a selection, move cursor to start of selection
+ if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_move_to_first(state);
+ else
+ if (state->cursor > 0)
+ --state->cursor;
+ state->has_preferred_x = 0;
+ break;
+
+ case STB_TEXTEDIT_K_RIGHT:
+ // if currently there's a selection, move cursor to end of selection
+ if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_move_to_last(str, state);
+ else
+ ++state->cursor;
+ stb_textedit_clamp(str, state);
+ state->has_preferred_x = 0;
+ break;
+
+ case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT:
+ stb_textedit_clamp(str, state);
+ stb_textedit_prep_selection_at_cursor(state);
+ // move selection left
+ if (state->select_end > 0)
+ --state->select_end;
+ state->cursor = state->select_end;
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_MOVEWORDLEFT
+ case STB_TEXTEDIT_K_WORDLEFT:
+ if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_move_to_first(state);
+ else {
+ state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor);
+ stb_textedit_clamp( str, state );
+ }
+ break;
+
+ case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT:
+ if( !STB_TEXT_HAS_SELECTION( state ) )
+ stb_textedit_prep_selection_at_cursor(state);
+
+ state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor);
+ state->select_end = state->cursor;
+
+ stb_textedit_clamp( str, state );
+ break;
+#endif
+
+#ifdef STB_TEXTEDIT_MOVEWORDRIGHT
+ case STB_TEXTEDIT_K_WORDRIGHT:
+ if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_move_to_last(str, state);
+ else {
+ state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
+ stb_textedit_clamp( str, state );
+ }
+ break;
+
+ case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT:
+ if( !STB_TEXT_HAS_SELECTION( state ) )
+ stb_textedit_prep_selection_at_cursor(state);
+
+ state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor);
+ state->select_end = state->cursor;
+
+ stb_textedit_clamp( str, state );
+ break;
+#endif
+
+ case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT:
+ stb_textedit_prep_selection_at_cursor(state);
+ // move selection right
+ ++state->select_end;
+ stb_textedit_clamp(str, state);
+ state->cursor = state->select_end;
+ state->has_preferred_x = 0;
+ break;
+
+ case STB_TEXTEDIT_K_DOWN:
+ case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: {
+ StbFindState find;
+ StbTexteditRow row;
+ int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
+
+ if (state->single_line) {
+ // on windows, up&down in single-line behave like left&right
+ key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT);
+ goto retry;
+ }
+
+ if (sel)
+ stb_textedit_prep_selection_at_cursor(state);
+ else if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_move_to_last(str,state);
+
+ // compute current position of cursor point
+ stb_textedit_clamp(str, state);
+ stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
+
+ // now find character position down a row
+ if (find.length) {
+ float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
+ float x;
+ int start = find.first_char + find.length;
+ state->cursor = start;
+ STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
+ x = row.x0;
+ for (i=0; i < row.num_chars; ++i) {
+ float dx = STB_TEXTEDIT_GETWIDTH(str, start, i);
+ #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE
+ if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE)
+ break;
+ #endif
+ x += dx;
+ if (x > goal_x)
+ break;
+ ++state->cursor;
+ }
+ stb_textedit_clamp(str, state);
+
+ state->has_preferred_x = 1;
+ state->preferred_x = goal_x;
+
+ if (sel)
+ state->select_end = state->cursor;
+ }
+ break;
+ }
+
+ case STB_TEXTEDIT_K_UP:
+ case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: {
+ StbFindState find;
+ StbTexteditRow row;
+ int i, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0;
+
+ if (state->single_line) {
+ // on windows, up&down become left&right
+ key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT);
+ goto retry;
+ }
+
+ if (sel)
+ stb_textedit_prep_selection_at_cursor(state);
+ else if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_move_to_first(state);
+
+ // compute current position of cursor point
+ stb_textedit_clamp(str, state);
+ stb_textedit_find_charpos(&find, str, state->cursor, state->single_line);
+
+ // can only go up if there's a previous row
+ if (find.prev_first != find.first_char) {
+ // now find character position up a row
+ float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
+ float x;
+ state->cursor = find.prev_first;
+ STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor);
+ x = row.x0;
+ for (i=0; i < row.num_chars; ++i) {
+ float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i);
+ #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE
+ if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE)
+ break;
+ #endif
+ x += dx;
+ if (x > goal_x)
+ break;
+ ++state->cursor;
+ }
+ stb_textedit_clamp(str, state);
+
+ state->has_preferred_x = 1;
+ state->preferred_x = goal_x;
+
+ if (sel)
+ state->select_end = state->cursor;
+ }
+ break;
+ }
+
+ case STB_TEXTEDIT_K_DELETE:
+ case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT:
+ if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_delete_selection(str, state);
+ else {
+ int n = STB_TEXTEDIT_STRINGLEN(str);
+ if (state->cursor < n)
+ stb_textedit_delete(str, state, state->cursor, 1);
+ }
+ state->has_preferred_x = 0;
+ break;
+
+ case STB_TEXTEDIT_K_BACKSPACE:
+ case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT:
+ if (STB_TEXT_HAS_SELECTION(state))
+ stb_textedit_delete_selection(str, state);
+ else {
+ stb_textedit_clamp(str, state);
+ if (state->cursor > 0) {
+ stb_textedit_delete(str, state, state->cursor-1, 1);
+ --state->cursor;
+ }
+ }
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_K_TEXTSTART2
+ case STB_TEXTEDIT_K_TEXTSTART2:
+#endif
+ case STB_TEXTEDIT_K_TEXTSTART:
+ state->cursor = state->select_start = state->select_end = 0;
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_K_TEXTEND2
+ case STB_TEXTEDIT_K_TEXTEND2:
+#endif
+ case STB_TEXTEDIT_K_TEXTEND:
+ state->cursor = STB_TEXTEDIT_STRINGLEN(str);
+ state->select_start = state->select_end = 0;
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_K_TEXTSTART2
+ case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT:
+#endif
+ case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT:
+ stb_textedit_prep_selection_at_cursor(state);
+ state->cursor = state->select_end = 0;
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_K_TEXTEND2
+ case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT:
+#endif
+ case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT:
+ stb_textedit_prep_selection_at_cursor(state);
+ state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str);
+ state->has_preferred_x = 0;
+ break;
+
+
+#ifdef STB_TEXTEDIT_K_LINESTART2
+ case STB_TEXTEDIT_K_LINESTART2:
+#endif
+ case STB_TEXTEDIT_K_LINESTART:
+ stb_textedit_clamp(str, state);
+ stb_textedit_move_to_first(state);
+ if (state->single_line)
+ state->cursor = 0;
+ else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
+ --state->cursor;
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_K_LINEEND2
+ case STB_TEXTEDIT_K_LINEEND2:
+#endif
+ case STB_TEXTEDIT_K_LINEEND: {
+ int n = STB_TEXTEDIT_STRINGLEN(str);
+ stb_textedit_clamp(str, state);
+ stb_textedit_move_to_first(state);
+ if (state->single_line)
+ state->cursor = n;
+ else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
+ ++state->cursor;
+ state->has_preferred_x = 0;
+ break;
+ }
+
+#ifdef STB_TEXTEDIT_K_LINESTART2
+ case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT:
+#endif
+ case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT:
+ stb_textedit_clamp(str, state);
+ stb_textedit_prep_selection_at_cursor(state);
+ if (state->single_line)
+ state->cursor = 0;
+ else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE)
+ --state->cursor;
+ state->select_end = state->cursor;
+ state->has_preferred_x = 0;
+ break;
+
+#ifdef STB_TEXTEDIT_K_LINEEND2
+ case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT:
+#endif
+ case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: {
+ int n = STB_TEXTEDIT_STRINGLEN(str);
+ stb_textedit_clamp(str, state);
+ stb_textedit_prep_selection_at_cursor(state);
+ if (state->single_line)
+ state->cursor = n;
+ else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE)
+ ++state->cursor;
+ state->select_end = state->cursor;
+ state->has_preferred_x = 0;
+ break;
+ }
+
+// @TODO:
+// STB_TEXTEDIT_K_PGUP - move cursor up a page
+// STB_TEXTEDIT_K_PGDOWN - move cursor down a page
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Undo processing
+//
+// @OPTIMIZE: the undo/redo buffer should be circular
+
+static void stb_textedit_flush_redo(StbUndoState *state)
+{
+ state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT;
+ state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT;
+}
+
+// discard the oldest entry in the undo list
+static void stb_textedit_discard_undo(StbUndoState *state)
+{
+ if (state->undo_point > 0) {
+ // if the 0th undo state has characters, clean those up
+ if (state->undo_rec[0].char_storage >= 0) {
+ int n = state->undo_rec[0].insert_length, i;
+ // delete n characters from all other records
+ state->undo_char_point -= n;
+ STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
+ for (i=0; i < state->undo_point; ++i)
+ if (state->undo_rec[i].char_storage >= 0)
+ state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it
+ }
+ --state->undo_point;
+ STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
+ }
+}
+
+// discard the oldest entry in the redo list--it's bad if this
+// ever happens, but because undo & redo have to store the actual
+// characters in different cases, the redo character buffer can
+// fill up even though the undo buffer didn't
+static void stb_textedit_discard_redo(StbUndoState *state)
+{
+ int k = STB_TEXTEDIT_UNDOSTATECOUNT-1;
+
+ if (state->redo_point <= k) {
+ // if the k'th undo state has characters, clean those up
+ if (state->undo_rec[k].char_storage >= 0) {
+ int n = state->undo_rec[k].insert_length, i;
+ // move the remaining redo character data to the end of the buffer
+ state->redo_char_point += n;
+ STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
+ // adjust the position of all the other records to account for above memmove
+ for (i=state->redo_point; i < k; ++i)
+ if (state->undo_rec[i].char_storage >= 0)
+ state->undo_rec[i].char_storage += n;
+ }
+ // now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
+ STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
+ // now move redo_point to point to the new one
+ ++state->redo_point;
+ }
+}
+
+static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars)
+{
+ // any time we create a new undo record, we discard redo
+ stb_textedit_flush_redo(state);
+
+ // if we have no free records, we have to make room, by sliding the
+ // existing records down
+ if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
+ stb_textedit_discard_undo(state);
+
+ // if the characters to store won't possibly fit in the buffer, we can't undo
+ if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) {
+ state->undo_point = 0;
+ state->undo_char_point = 0;
+ return NULL;
+ }
+
+ // if we don't have enough free characters in the buffer, we have to make room
+ while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT)
+ stb_textedit_discard_undo(state);
+
+ return &state->undo_rec[state->undo_point++];
+}
+
+static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len)
+{
+ StbUndoRecord *r = stb_text_create_undo_record(state, insert_len);
+ if (r == NULL)
+ return NULL;
+
+ r->where = pos;
+ r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len;
+ r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len;
+
+ if (insert_len == 0) {
+ r->char_storage = -1;
+ return NULL;
+ } else {
+ r->char_storage = state->undo_char_point;
+ state->undo_char_point += insert_len;
+ return &state->undo_char[r->char_storage];
+ }
+}
+
+static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+{
+ StbUndoState *s = &state->undostate;
+ StbUndoRecord u, *r;
+ if (s->undo_point == 0)
+ return;
+
+ // we need to do two things: apply the undo record, and create a redo record
+ u = s->undo_rec[s->undo_point-1];
+ r = &s->undo_rec[s->redo_point-1];
+ r->char_storage = -1;
+
+ r->insert_length = u.delete_length;
+ r->delete_length = u.insert_length;
+ r->where = u.where;
+
+ if (u.delete_length) {
+ // if the undo record says to delete characters, then the redo record will
+ // need to re-insert the characters that get deleted, so we need to store
+ // them.
+
+ // there are three cases:
+ // there's enough room to store the characters
+ // characters stored for *redoing* don't leave room for redo
+ // characters stored for *undoing* don't leave room for redo
+ // if the last is true, we have to bail
+
+ if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) {
+ // the undo records take up too much character space; there's no space to store the redo characters
+ r->insert_length = 0;
+ } else {
+ int i;
+
+ // there's definitely room to store the characters eventually
+ while (s->undo_char_point + u.delete_length > s->redo_char_point) {
+ // should never happen:
+ if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
+ return;
+ // there's currently not enough room, so discard a redo record
+ stb_textedit_discard_redo(s);
+ }
+ r = &s->undo_rec[s->redo_point-1];
+
+ r->char_storage = s->redo_char_point - u.delete_length;
+ s->redo_char_point = s->redo_char_point - u.delete_length;
+
+ // now save the characters
+ for (i=0; i < u.delete_length; ++i)
+ s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i);
+ }
+
+ // now we can carry out the deletion
+ STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length);
+ }
+
+ // check type of recorded action:
+ if (u.insert_length) {
+ // easy case: was a deletion, so we need to insert n characters
+ STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length);
+ s->undo_char_point -= u.insert_length;
+ }
+
+ state->cursor = u.where + u.insert_length;
+
+ s->undo_point--;
+ s->redo_point--;
+}
+
+static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
+{
+ StbUndoState *s = &state->undostate;
+ StbUndoRecord *u, r;
+ if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT)
+ return;
+
+ // we need to do two things: apply the redo record, and create an undo record
+ u = &s->undo_rec[s->undo_point];
+ r = s->undo_rec[s->redo_point];
+
+ // we KNOW there must be room for the undo record, because the redo record
+ // was derived from an undo record
+
+ u->delete_length = r.insert_length;
+ u->insert_length = r.delete_length;
+ u->where = r.where;
+ u->char_storage = -1;
+
+ if (r.delete_length) {
+ // the redo record requires us to delete characters, so the undo record
+ // needs to store the characters
+
+ if (s->undo_char_point + u->insert_length > s->redo_char_point) {
+ u->insert_length = 0;
+ u->delete_length = 0;
+ } else {
+ int i;
+ u->char_storage = s->undo_char_point;
+ s->undo_char_point = s->undo_char_point + u->insert_length;
+
+ // now save the characters
+ for (i=0; i < u->insert_length; ++i)
+ s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i);
+ }
+
+ STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length);
+ }
+
+ if (r.insert_length) {
+ // easy case: need to insert n characters
+ STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length);
+ s->redo_char_point += r.insert_length;
+ }
+
+ state->cursor = r.where + r.insert_length;
+
+ s->undo_point++;
+ s->redo_point++;
+}
+
+static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length)
+{
+ stb_text_createundo(&state->undostate, where, 0, length);
+}
+
+static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length)
+{
+ int i;
+ STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0);
+ if (p) {
+ for (i=0; i < length; ++i)
+ p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
+ }
+}
+
+static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length)
+{
+ int i;
+ STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length);
+ if (p) {
+ for (i=0; i < old_length; ++i)
+ p[i] = STB_TEXTEDIT_GETCHAR(str, where+i);
+ }
+}
+
+// reset the state to default
+static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line)
+{
+ state->undostate.undo_point = 0;
+ state->undostate.undo_char_point = 0;
+ state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT;
+ state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT;
+ state->select_end = state->select_start = 0;
+ state->cursor = 0;
+ state->has_preferred_x = 0;
+ state->preferred_x = 0;
+ state->cursor_at_end_of_line = 0;
+ state->initialized = 1;
+ state->single_line = (unsigned char) is_single_line;
+ state->insert_mode = 0;
+}
+
+// API initialize
+static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line)
+{
+ stb_textedit_clear_state(state, is_single_line);
+}
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+
+static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len)
+{
+ return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len);
+}
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
+#endif//STB_TEXTEDIT_IMPLEMENTATION
+
+/*
+------------------------------------------------------------------------------
+This software is available under 2 licenses -- choose whichever you prefer.
+------------------------------------------------------------------------------
+ALTERNATIVE A - MIT License
+Copyright (c) 2017 Sean Barrett
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+------------------------------------------------------------------------------
+ALTERNATIVE B - Public Domain (www.unlicense.org)
+This is free and unencumbered software released into the public domain.
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
+software, either in source code form or as a compiled binary, for any purpose,
+commercial or non-commercial, and by any means.
+In jurisdictions that recognize copyright laws, the author or authors of this
+software dedicate any and all copyright interest in the software to the public
+domain. We make this dedication for the benefit of the public at large and to
+the detriment of our heirs and successors. We intend this dedication to be an
+overt act of relinquishment in perpetuity of all present and future rights to
+this software under copyright law.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+------------------------------------------------------------------------------
+*/
diff --git a/Client/ThirdParty/Box2D/extern/imgui/imstb_truetype.h b/Client/ThirdParty/Box2D/extern/imgui/imstb_truetype.h
new file mode 100644
index 0000000..f65deb5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/imgui/imstb_truetype.h
@@ -0,0 +1,4854 @@
+// stb_truetype.h - v1.19 - public domain
+// authored from 2009-2016 by Sean Barrett / RAD Game Tools
+//
+// This library processes TrueType files:
+// parse files
+// extract glyph metrics
+// extract glyph shapes
+// render glyphs to one-channel bitmaps with antialiasing (box filter)
+// render glyphs to one-channel SDF bitmaps (signed-distance field/function)
+//
+// Todo:
+// non-MS cmaps
+// crashproof on bad data
+// hinting? (no longer patented)
+// cleartype-style AA?
+// optimize: use simple memory allocator for intermediates
+// optimize: build edge-list directly from curves
+// optimize: rasterize directly from curves?
+//
+// ADDITIONAL CONTRIBUTORS
+//
+// Mikko Mononen: compound shape support, more cmap formats
+// Tor Andersson: kerning, subpixel rendering
+// Dougall Johnson: OpenType / Type 2 font handling
+// Daniel Ribeiro Maciel: basic GPOS-based kerning
+//
+// Misc other:
+// Ryan Gordon
+// Simon Glass
+// github:IntellectualKitty
+// Imanol Celaya
+// Daniel Ribeiro Maciel
+//
+// Bug/warning reports/fixes:
+// "Zer" on mollyrocket Fabian "ryg" Giesen
+// Cass Everitt Martins Mozeiko
+// stoiko (Haemimont Games) Cap Petschulat
+// Brian Hook Omar Cornut
+// Walter van Niftrik github:aloucks
+// David Gow Peter LaValle
+// David Given Sergey Popov
+// Ivan-Assen Ivanov Giumo X. Clanjor
+// Anthony Pesch Higor Euripedes
+// Johan Duparc Thomas Fields
+// Hou Qiming Derek Vinyard
+// Rob Loach Cort Stratton
+// Kenney Phillis Jr. github:oyvindjam
+// Brian Costabile github:vassvik
+//
+// VERSION HISTORY
+//
+// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod
+// 1.18 (2018-01-29) add missing function
+// 1.17 (2017-07-23) make more arguments const; doc fix
+// 1.16 (2017-07-12) SDF support
+// 1.15 (2017-03-03) make more arguments const
+// 1.14 (2017-01-16) num-fonts-in-TTC function
+// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts
+// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
+// 1.11 (2016-04-02) fix unused-variable warning
+// 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef
+// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly
+// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
+// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
+// variant PackFontRanges to pack and render in separate phases;
+// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?);
+// fixed an assert() bug in the new rasterizer
+// replace assert() with STBTT_assert() in new rasterizer
+//
+// Full history can be found at the end of this file.
+//
+// LICENSE
+//
+// See end of file for license information.
+//
+// USAGE
+//
+// Include this file in whatever places neeed to refer to it. In ONE C/C++
+// file, write:
+// #define STB_TRUETYPE_IMPLEMENTATION
+// before the #include of this file. This expands out the actual
+// implementation into that C/C++ file.
+//
+// To make the implementation private to the file that generates the implementation,
+// #define STBTT_STATIC
+//
+// Simple 3D API (don't ship this, but it's fine for tools and quick start)
+// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture
+// stbtt_GetBakedQuad() -- compute quad to draw for a given char
+//
+// Improved 3D API (more shippable):
+// #include "stb_rect_pack.h" -- optional, but you really want it
+// stbtt_PackBegin()
+// stbtt_PackSetOversampling() -- for improved quality on small fonts
+// stbtt_PackFontRanges() -- pack and renders
+// stbtt_PackEnd()
+// stbtt_GetPackedQuad()
+//
+// "Load" a font file from a memory buffer (you have to keep the buffer loaded)
+// stbtt_InitFont()
+// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections
+// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections
+//
+// Render a unicode codepoint to a bitmap
+// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap
+// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide
+// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be
+//
+// Character advance/positioning
+// stbtt_GetCodepointHMetrics()
+// stbtt_GetFontVMetrics()
+// stbtt_GetFontVMetricsOS2()
+// stbtt_GetCodepointKernAdvance()
+//
+// Starting with version 1.06, the rasterizer was replaced with a new,
+// faster and generally-more-precise rasterizer. The new rasterizer more
+// accurately measures pixel coverage for anti-aliasing, except in the case
+// where multiple shapes overlap, in which case it overestimates the AA pixel
+// coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If
+// this turns out to be a problem, you can re-enable the old rasterizer with
+// #define STBTT_RASTERIZER_VERSION 1
+// which will incur about a 15% speed hit.
+//
+// ADDITIONAL DOCUMENTATION
+//
+// Immediately after this block comment are a series of sample programs.
+//
+// After the sample programs is the "header file" section. This section
+// includes documentation for each API function.
+//
+// Some important concepts to understand to use this library:
+//
+// Codepoint
+// Characters are defined by unicode codepoints, e.g. 65 is
+// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is
+// the hiragana for "ma".
+//
+// Glyph
+// A visual character shape (every codepoint is rendered as
+// some glyph)
+//
+// Glyph index
+// A font-specific integer ID representing a glyph
+//
+// Baseline
+// Glyph shapes are defined relative to a baseline, which is the
+// bottom of uppercase characters. Characters extend both above
+// and below the baseline.
+//
+// Current Point
+// As you draw text to the screen, you keep track of a "current point"
+// which is the origin of each character. The current point's vertical
+// position is the baseline. Even "baked fonts" use this model.
+//
+// Vertical Font Metrics
+// The vertical qualities of the font, used to vertically position
+// and space the characters. See docs for stbtt_GetFontVMetrics.
+//
+// Font Size in Pixels or Points
+// The preferred interface for specifying font sizes in stb_truetype
+// is to specify how tall the font's vertical extent should be in pixels.
+// If that sounds good enough, skip the next paragraph.
+//
+// Most font APIs instead use "points", which are a common typographic
+// measurement for describing font size, defined as 72 points per inch.
+// stb_truetype provides a point API for compatibility. However, true
+// "per inch" conventions don't make much sense on computer displays
+// since different monitors have different number of pixels per
+// inch. For example, Windows traditionally uses a convention that
+// there are 96 pixels per inch, thus making 'inch' measurements have
+// nothing to do with inches, and thus effectively defining a point to
+// be 1.333 pixels. Additionally, the TrueType font data provides
+// an explicit scale factor to scale a given font's glyphs to points,
+// but the author has observed that this scale factor is often wrong
+// for non-commercial fonts, thus making fonts scaled in points
+// according to the TrueType spec incoherently sized in practice.
+//
+// DETAILED USAGE:
+//
+// Scale:
+// Select how high you want the font to be, in points or pixels.
+// Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute
+// a scale factor SF that will be used by all other functions.
+//
+// Baseline:
+// You need to select a y-coordinate that is the baseline of where
+// your text will appear. Call GetFontBoundingBox to get the baseline-relative
+// bounding box for all characters. SF*-y0 will be the distance in pixels
+// that the worst-case character could extend above the baseline, so if
+// you want the top edge of characters to appear at the top of the
+// screen where y=0, then you would set the baseline to SF*-y0.
+//
+// Current point:
+// Set the current point where the first character will appear. The
+// first character could extend left of the current point; this is font
+// dependent. You can either choose a current point that is the leftmost
+// point and hope, or add some padding, or check the bounding box or
+// left-side-bearing of the first character to be displayed and set
+// the current point based on that.
+//
+// Displaying a character:
+// Compute the bounding box of the character. It will contain signed values
+// relative to <current_point, baseline>. I.e. if it returns x0,y0,x1,y1,
+// then the character should be displayed in the rectangle from
+// <current_point+SF*x0, baseline+SF*y0> to <current_point+SF*x1,baseline+SF*y1).
+//
+// Advancing for the next character:
+// Call GlyphHMetrics, and compute 'current_point += SF * advance'.
+//
+//
+// ADVANCED USAGE
+//
+// Quality:
+//
+// - Use the functions with Subpixel at the end to allow your characters
+// to have subpixel positioning. Since the font is anti-aliased, not
+// hinted, this is very import for quality. (This is not possible with
+// baked fonts.)
+//
+// - Kerning is now supported, and if you're supporting subpixel rendering
+// then kerning is worth using to give your text a polished look.
+//
+// Performance:
+//
+// - Convert Unicode codepoints to glyph indexes and operate on the glyphs;
+// if you don't do this, stb_truetype is forced to do the conversion on
+// every call.
+//
+// - There are a lot of memory allocations. We should modify it to take
+// a temp buffer and allocate from the temp buffer (without freeing),
+// should help performance a lot.
+//
+// NOTES
+//
+// The system uses the raw data found in the .ttf file without changing it
+// and without building auxiliary data structures. This is a bit inefficient
+// on little-endian systems (the data is big-endian), but assuming you're
+// caching the bitmaps or glyph shapes this shouldn't be a big deal.
+//
+// It appears to be very hard to programmatically determine what font a
+// given file is in a general way. I provide an API for this, but I don't
+// recommend it.
+//
+//
+// SOURCE STATISTICS (based on v0.6c, 2050 LOC)
+//
+// Documentation & header file 520 LOC \___ 660 LOC documentation
+// Sample code 140 LOC /
+// Truetype parsing 620 LOC ---- 620 LOC TrueType
+// Software rasterization 240 LOC \ .
+// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation
+// Bitmap management 100 LOC /
+// Baked bitmap interface 70 LOC /
+// Font name matching & access 150 LOC ---- 150
+// C runtime library abstraction 60 LOC ---- 60
+//
+//
+// PERFORMANCE MEASUREMENTS FOR 1.06:
+//
+// 32-bit 64-bit
+// Previous release: 8.83 s 7.68 s
+// Pool allocations: 7.72 s 6.34 s
+// Inline sort : 6.54 s 5.65 s
+// New rasterizer : 5.63 s 5.00 s
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+////
+//// SAMPLE PROGRAMS
+////
+//
+// Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless
+//
+#if 0
+#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation
+#include "stb_truetype.h"
+
+unsigned char ttf_buffer[1<<20];
+unsigned char temp_bitmap[512*512];
+
+stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs
+GLuint ftex;
+
+void my_stbtt_initfont(void)
+{
+ fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb"));
+ stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits!
+ // can free ttf_buffer at this point
+ glGenTextures(1, &ftex);
+ glBindTexture(GL_TEXTURE_2D, ftex);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap);
+ // can free temp_bitmap at this point
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+}
+
+void my_stbtt_print(float x, float y, char *text)
+{
+ // assume orthographic projection with units = screen pixels, origin at top left
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, ftex);
+ glBegin(GL_QUADS);
+ while (*text) {
+ if (*text >= 32 && *text < 128) {
+ stbtt_aligned_quad q;
+ stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9
+ glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0);
+ glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0);
+ glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1);
+ glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1);
+ }
+ ++text;
+ }
+ glEnd();
+}
+#endif
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Complete program (this compiles): get a single bitmap, print as ASCII art
+//
+#if 0
+#include <stdio.h>
+#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation
+#include "stb_truetype.h"
+
+char ttf_buffer[1<<25];
+
+int main(int argc, char **argv)
+{
+ stbtt_fontinfo font;
+ unsigned char *bitmap;
+ int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20);
+
+ fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb"));
+
+ stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
+ bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0);
+
+ for (j=0; j < h; ++j) {
+ for (i=0; i < w; ++i)
+ putchar(" .:ioVM@"[bitmap[j*w+i]>>5]);
+ putchar('\n');
+ }
+ return 0;
+}
+#endif
+//
+// Output:
+//
+// .ii.
+// @@@@@@.
+// V@Mio@@o
+// :i. V@V
+// :oM@@M
+// :@@@MM@M
+// @@o o@M
+// :@@. M@M
+// @@@o@@@@
+// :M@@V:@@.
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Complete program: print "Hello World!" banner, with bugs
+//
+#if 0
+char buffer[24<<20];
+unsigned char screen[20][79];
+
+int main(int arg, char **argv)
+{
+ stbtt_fontinfo font;
+ int i,j,ascent,baseline,ch=0;
+ float scale, xpos=2; // leave a little padding in case the character extends left
+ char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness
+
+ fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb"));
+ stbtt_InitFont(&font, buffer, 0);
+
+ scale = stbtt_ScaleForPixelHeight(&font, 15);
+ stbtt_GetFontVMetrics(&font, &ascent,0,0);
+ baseline = (int) (ascent*scale);
+
+ while (text[ch]) {
+ int advance,lsb,x0,y0,x1,y1;
+ float x_shift = xpos - (float) floor(xpos);
+ stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb);
+ stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1);
+ stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]);
+ // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong
+ // because this API is really for baking character bitmaps into textures. if you want to render
+ // a sequence of characters, you really need to render each bitmap to a temp buffer, then
+ // "alpha blend" that into the working buffer
+ xpos += (advance * scale);
+ if (text[ch+1])
+ xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]);
+ ++ch;
+ }
+
+ for (j=0; j < 20; ++j) {
+ for (i=0; i < 78; ++i)
+ putchar(" .:ioVM@"[screen[j][i]>>5]);
+ putchar('\n');
+ }
+
+ return 0;
+}
+#endif
+
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+////
+//// INTEGRATION WITH YOUR CODEBASE
+////
+//// The following sections allow you to supply alternate definitions
+//// of C library functions used by stb_truetype, e.g. if you don't
+//// link with the C runtime library.
+
+#ifdef STB_TRUETYPE_IMPLEMENTATION
+ // #define your own (u)stbtt_int8/16/32 before including to override this
+ #ifndef stbtt_uint8
+ typedef unsigned char stbtt_uint8;
+ typedef signed char stbtt_int8;
+ typedef unsigned short stbtt_uint16;
+ typedef signed short stbtt_int16;
+ typedef unsigned int stbtt_uint32;
+ typedef signed int stbtt_int32;
+ #endif
+
+ typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
+ typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
+
+ // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h
+ #ifndef STBTT_ifloor
+ #include <math.h>
+ #define STBTT_ifloor(x) ((int) floor(x))
+ #define STBTT_iceil(x) ((int) ceil(x))
+ #endif
+
+ #ifndef STBTT_sqrt
+ #include <math.h>
+ #define STBTT_sqrt(x) sqrt(x)
+ #define STBTT_pow(x,y) pow(x,y)
+ #endif
+
+ #ifndef STBTT_fmod
+ #include <math.h>
+ #define STBTT_fmod(x,y) fmod(x,y)
+ #endif
+
+ #ifndef STBTT_cos
+ #include <math.h>
+ #define STBTT_cos(x) cos(x)
+ #define STBTT_acos(x) acos(x)
+ #endif
+
+ #ifndef STBTT_fabs
+ #include <math.h>
+ #define STBTT_fabs(x) fabs(x)
+ #endif
+
+ // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h
+ #ifndef STBTT_malloc
+ #include <stdlib.h>
+ #define STBTT_malloc(x,u) ((void)(u),malloc(x))
+ #define STBTT_free(x,u) ((void)(u),free(x))
+ #endif
+
+ #ifndef STBTT_assert
+ #include <assert.h>
+ #define STBTT_assert(x) assert(x)
+ #endif
+
+ #ifndef STBTT_strlen
+ #include <string.h>
+ #define STBTT_strlen(x) strlen(x)
+ #endif
+
+ #ifndef STBTT_memcpy
+ #include <string.h>
+ #define STBTT_memcpy memcpy
+ #define STBTT_memset memset
+ #endif
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+////
+//// INTERFACE
+////
+////
+
+#ifndef __STB_INCLUDE_STB_TRUETYPE_H__
+#define __STB_INCLUDE_STB_TRUETYPE_H__
+
+#ifdef STBTT_STATIC
+#define STBTT_DEF static
+#else
+#define STBTT_DEF extern
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// private structure
+typedef struct
+{
+ unsigned char *data;
+ int cursor;
+ int size;
+} stbtt__buf;
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// TEXTURE BAKING API
+//
+// If you use this API, you only have to call two functions ever.
+//
+
+typedef struct
+{
+ unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
+ float xoff,yoff,xadvance;
+} stbtt_bakedchar;
+
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
+ float pixel_height, // height of font in pixels
+ unsigned char *pixels, int pw, int ph, // bitmap to be filled in
+ int first_char, int num_chars, // characters to bake
+ stbtt_bakedchar *chardata); // you allocate this, it's num_chars long
+// if return is positive, the first unused row of the bitmap
+// if return is negative, returns the negative of the number of characters that fit
+// if return is 0, no characters fit and no rows were used
+// This uses a very crappy packing.
+
+typedef struct
+{
+ float x0,y0,s0,t0; // top-left
+ float x1,y1,s1,t1; // bottom-right
+} stbtt_aligned_quad;
+
+STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above
+ int char_index, // character to display
+ float *xpos, float *ypos, // pointers to current position in screen pixel space
+ stbtt_aligned_quad *q, // output: quad to draw
+ int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier
+// Call GetBakedQuad with char_index = 'character - first_char', and it
+// creates the quad you need to draw and advances the current position.
+//
+// The coordinate system used assumes y increases downwards.
+//
+// Characters will extend both above and below the current position;
+// see discussion of "BASELINE" above.
+//
+// It's inefficient; you might want to c&p it and optimize it.
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// NEW TEXTURE BAKING API
+//
+// This provides options for packing multiple fonts into one atlas, not
+// perfectly but better than nothing.
+
+typedef struct
+{
+ unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
+ float xoff,yoff,xadvance;
+ float xoff2,yoff2;
+} stbtt_packedchar;
+
+typedef struct stbtt_pack_context stbtt_pack_context;
+typedef struct stbtt_fontinfo stbtt_fontinfo;
+#ifndef STB_RECT_PACK_VERSION
+typedef struct stbrp_rect stbrp_rect;
+#endif
+
+STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
+// Initializes a packing context stored in the passed-in stbtt_pack_context.
+// Future calls using this context will pack characters into the bitmap passed
+// in here: a 1-channel bitmap that is width * height. stride_in_bytes is
+// the distance from one row to the next (or 0 to mean they are packed tightly
+// together). "padding" is the amount of padding to leave between each
+// character (normally you want '1' for bitmaps you'll use as textures with
+// bilinear filtering).
+//
+// Returns 0 on failure, 1 on success.
+
+STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc);
+// Cleans up the packing context and frees all memory.
+
+#define STBTT_POINT_SIZE(x) (-(x))
+
+STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
+ int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
+// Creates character bitmaps from the font_index'th font found in fontdata (use
+// font_index=0 if you don't know what that is). It creates num_chars_in_range
+// bitmaps for characters with unicode values starting at first_unicode_char_in_range
+// and increasing. Data for how to render them is stored in chardata_for_range;
+// pass these to stbtt_GetPackedQuad to get back renderable quads.
+//
+// font_size is the full height of the character from ascender to descender,
+// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed
+// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE()
+// and pass that result as 'font_size':
+// ..., 20 , ... // font max minus min y is 20 pixels tall
+// ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall
+
+typedef struct
+{
+ float font_size;
+ int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint
+ int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints
+ int num_chars;
+ stbtt_packedchar *chardata_for_range; // output
+ unsigned char h_oversample, v_oversample; // don't set these, they're used internally
+} stbtt_pack_range;
+
+STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
+// Creates character bitmaps from multiple ranges of characters stored in
+// ranges. This will usually create a better-packed bitmap than multiple
+// calls to stbtt_PackFontRange. Note that you can call this multiple
+// times within a single PackBegin/PackEnd.
+
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
+// Oversampling a font increases the quality by allowing higher-quality subpixel
+// positioning, and is especially valuable at smaller text sizes.
+//
+// This function sets the amount of oversampling for all following calls to
+// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given
+// pack context. The default (no oversampling) is achieved by h_oversample=1
+// and v_oversample=1. The total number of pixels required is
+// h_oversample*v_oversample larger than the default; for example, 2x2
+// oversampling requires 4x the storage of 1x1. For best results, render
+// oversampled textures with bilinear filtering. Look at the readme in
+// stb/tests/oversample for information about oversampled fonts
+//
+// To use with PackFontRangesGather etc., you must set it before calls
+// call to PackFontRangesGatherRects.
+
+STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
+ int char_index, // character to display
+ float *xpos, float *ypos, // pointers to current position in screen pixel space
+ stbtt_aligned_quad *q, // output: quad to draw
+ int align_to_integer);
+
+STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
+STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects);
+STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
+// Calling these functions in sequence is roughly equivalent to calling
+// stbtt_PackFontRanges(). If you more control over the packing of multiple
+// fonts, or if you want to pack custom data into a font texture, take a look
+// at the source to of stbtt_PackFontRanges() and create a custom version
+// using these functions, e.g. call GatherRects multiple times,
+// building up a single array of rects, then call PackRects once,
+// then call RenderIntoRects repeatedly. This may result in a
+// better packing than calling PackFontRanges multiple times
+// (or it may not).
+
+// this is an opaque structure that you shouldn't mess with which holds
+// all the context needed from PackBegin to PackEnd.
+struct stbtt_pack_context {
+ void *user_allocator_context;
+ void *pack_info;
+ int width;
+ int height;
+ int stride_in_bytes;
+ int padding;
+ unsigned int h_oversample, v_oversample;
+ unsigned char *pixels;
+ void *nodes;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// FONT LOADING
+//
+//
+
+STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data);
+// This function will determine the number of fonts in a font file. TrueType
+// collection (.ttc) files may contain multiple fonts, while TrueType font
+// (.ttf) files only contain one font. The number of fonts can be used for
+// indexing with the previous function where the index is between zero and one
+// less than the total fonts. If an error occurs, -1 is returned.
+
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
+// Each .ttf/.ttc file may have more than one font. Each font has a sequential
+// index number starting from 0. Call this function to get the font offset for
+// a given index; it returns -1 if the index is out of range. A regular .ttf
+// file will only define one font and it always be at offset 0, so it will
+// return '0' for index 0, and -1 for all other indices.
+
+// The following structure is defined publically so you can declare one on
+// the stack or as a global or etc, but you should treat it as opaque.
+struct stbtt_fontinfo
+{
+ void * userdata;
+ unsigned char * data; // pointer to .ttf file
+ int fontstart; // offset of start of font
+
+ int numGlyphs; // number of glyphs, needed for range checking
+
+ int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf
+ int index_map; // a cmap mapping for our chosen character encoding
+ int indexToLocFormat; // format needed to map from glyph index to glyph
+
+ stbtt__buf cff; // cff font data
+ stbtt__buf charstrings; // the charstring index
+ stbtt__buf gsubrs; // global charstring subroutines index
+ stbtt__buf subrs; // private charstring subroutines index
+ stbtt__buf fontdicts; // array of font dicts
+ stbtt__buf fdselect; // map from glyph to fontdict
+};
+
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
+// Given an offset into the file that defines a font, this function builds
+// the necessary cached info for the rest of the system. You must allocate
+// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
+// need to do anything special to free it, because the contents are pure
+// value data with no additional data structures. Returns 0 on failure.
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// CHARACTER TO GLYPH-INDEX CONVERSIOn
+
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
+// If you're going to perform multiple operations on the same character
+// and you want a speed-up, call this function with the character you're
+// going to process, then use glyph-based functions instead of the
+// codepoint-based functions.
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// CHARACTER PROPERTIES
+//
+
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
+// computes a scale factor to produce a font whose "height" is 'pixels' tall.
+// Height is measured as the distance from the highest ascender to the lowest
+// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
+// and computing:
+// scale = pixels / (ascent - descent)
+// so if you prefer to measure height by the ascent only, use a similar calculation.
+
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
+// computes a scale factor to produce a font whose EM size is mapped to
+// 'pixels' tall. This is probably what traditional APIs compute, but
+// I'm not positive.
+
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
+// ascent is the coordinate above the baseline the font extends; descent
+// is the coordinate below the baseline the font extends (i.e. it is typically negative)
+// lineGap is the spacing between one row's descent and the next row's ascent...
+// so you should advance the vertical position by "*ascent - *descent + *lineGap"
+// these are expressed in unscaled coordinates, so you must multiply by
+// the scale factor for a given size
+
+STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap);
+// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2
+// table (specific to MS/Windows TTF files).
+//
+// Returns 1 on success (table present), 0 on failure.
+
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
+// the bounding box around all possible characters
+
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
+// leftSideBearing is the offset from the current horizontal position to the left edge of the character
+// advanceWidth is the offset from the current horizontal position to the next horizontal position
+// these are expressed in unscaled coordinates
+
+STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
+// an additional amount to add to the 'advance' value between ch1 and ch2
+
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
+// Gets the bounding box of the visible part of the glyph, in unscaled coordinates
+
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
+STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
+STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
+// as above, but takes one or more glyph indices for greater efficiency
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// GLYPH SHAPES (you probably don't need these, but they have to go before
+// the bitmaps for C declaration-order reasons)
+//
+
+#ifndef STBTT_vmove // you can predefine these to use different values (but why?)
+ enum {
+ STBTT_vmove=1,
+ STBTT_vline,
+ STBTT_vcurve,
+ STBTT_vcubic
+ };
+#endif
+
+#ifndef stbtt_vertex // you can predefine this to use different values
+ // (we share this with other code at RAD)
+ #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file
+ typedef struct
+ {
+ stbtt_vertex_type x,y,cx,cy,cx1,cy1;
+ unsigned char type,padding;
+ } stbtt_vertex;
+#endif
+
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
+// returns non-zero if nothing is drawn for this glyph
+
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
+// returns # of vertices and fills *vertices with the pointer to them
+// these are expressed in "unscaled" coordinates
+//
+// The shape is a series of countours. Each one starts with
+// a STBTT_moveto, then consists of a series of mixed
+// STBTT_lineto and STBTT_curveto segments. A lineto
+// draws a line from previous endpoint to its x,y; a curveto
+// draws a quadratic bezier from previous endpoint to
+// its x,y, using cx,cy as the bezier control point.
+
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
+// frees the data allocated above
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// BITMAP RENDERING
+//
+
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
+// frees the bitmap allocated below
+
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
+// allocates a large-enough single-channel 8bpp bitmap and renders the
+// specified character/glyph at the specified scale into it, with
+// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
+// *width & *height are filled out with the width & height of the bitmap,
+// which is stored left-to-right, top-to-bottom.
+//
+// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
+
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
+// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
+// shift for the character
+
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
+// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
+// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
+// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
+// width and height and positioning info for it first.
+
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
+// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
+// shift for the character
+
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint);
+// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering
+// is performed (see stbtt_PackSetOversampling)
+
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
+// get the bbox of the bitmap centered around the glyph origin; so the
+// bitmap width is ix1-ix0, height is iy1-iy0, and location to place
+// the bitmap top left is (leftSideBearing*scale,iy0).
+// (Note that the bitmap uses y-increases-down, but the shape uses
+// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
+
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
+// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
+// shift for the character
+
+// the following functions are equivalent to the above functions, but operate
+// on glyph indices instead of Unicode codepoints (for efficiency)
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph);
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
+
+
+// @TODO: don't expose this structure
+typedef struct
+{
+ int w,h,stride;
+ unsigned char *pixels;
+} stbtt__bitmap;
+
+// rasterize a shape with quadratic beziers into a bitmap
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into
+ float flatness_in_pixels, // allowable error of curve in pixels
+ stbtt_vertex *vertices, // array of vertices defining shape
+ int num_verts, // number of vertices in above array
+ float scale_x, float scale_y, // scale applied to input vertices
+ float shift_x, float shift_y, // translation applied to input vertices
+ int x_off, int y_off, // another translation applied to input
+ int invert, // if non-zero, vertically flip shape
+ void *userdata); // context for to STBTT_MALLOC
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Signed Distance Function (or Field) rendering
+
+STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata);
+// frees the SDF bitmap allocated below
+
+STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
+STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
+// These functions compute a discretized SDF field for a single character, suitable for storing
+// in a single-channel texture, sampling with bilinear filtering, and testing against
+// larger than some threshhold to produce scalable fonts.
+// info -- the font
+// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
+// glyph/codepoint -- the character to generate the SDF for
+// padding -- extra "pixels" around the character which are filled with the distance to the character (not 0),
+// which allows effects like bit outlines
+// onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character)
+// pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale)
+// if positive, > onedge_value is inside; if negative, < onedge_value is inside
+// width,height -- output height & width of the SDF bitmap (including padding)
+// xoff,yoff -- output origin of the character
+// return value -- a 2D array of bytes 0..255, width*height in size
+//
+// pixel_dist_scale & onedge_value are a scale & bias that allows you to make
+// optimal use of the limited 0..255 for your application, trading off precision
+// and special effects. SDF values outside the range 0..255 are clamped to 0..255.
+//
+// Example:
+// scale = stbtt_ScaleForPixelHeight(22)
+// padding = 5
+// onedge_value = 180
+// pixel_dist_scale = 180/5.0 = 36.0
+//
+// This will create an SDF bitmap in which the character is about 22 pixels
+// high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled
+// shape, sample the SDF at each pixel and fill the pixel if the SDF value
+// is greater than or equal to 180/255. (You'll actually want to antialias,
+// which is beyond the scope of this example.) Additionally, you can compute
+// offset outlines (e.g. to stroke the character border inside & outside,
+// or only outside). For example, to fill outside the character up to 3 SDF
+// pixels, you would compare against (180-36.0*3)/255 = 72/255. The above
+// choice of variables maps a range from 5 pixels outside the shape to
+// 2 pixels inside the shape to 0..255; this is intended primarily for apply
+// outside effects only (the interior range is needed to allow proper
+// antialiasing of the font at *smaller* sizes)
+//
+// The function computes the SDF analytically at each SDF pixel, not by e.g.
+// building a higher-res bitmap and approximating it. In theory the quality
+// should be as high as possible for an SDF of this size & representation, but
+// unclear if this is true in practice (perhaps building a higher-res bitmap
+// and computing from that can allow drop-out prevention).
+//
+// The algorithm has not been optimized at all, so expect it to be slow
+// if computing lots of characters or very large sizes.
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Finding the right font...
+//
+// You should really just solve this offline, keep your own tables
+// of what font is what, and don't try to get it out of the .ttf file.
+// That's because getting it out of the .ttf file is really hard, because
+// the names in the file can appear in many possible encodings, in many
+// possible languages, and e.g. if you need a case-insensitive comparison,
+// the details of that depend on the encoding & language in a complex way
+// (actually underspecified in truetype, but also gigantic).
+//
+// But you can use the provided functions in two possible ways:
+// stbtt_FindMatchingFont() will use *case-sensitive* comparisons on
+// unicode-encoded names to try to find the font you want;
+// you can run this before calling stbtt_InitFont()
+//
+// stbtt_GetFontNameString() lets you get any of the various strings
+// from the file yourself and do your own comparisons on them.
+// You have to have called stbtt_InitFont() first.
+
+
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
+// returns the offset (not index) of the font that matches, or -1 if none
+// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
+// if you use any other flag, use a font name like "Arial"; this checks
+// the 'macStyle' header field; i don't know if fonts set this consistently
+#define STBTT_MACSTYLE_DONTCARE 0
+#define STBTT_MACSTYLE_BOLD 1
+#define STBTT_MACSTYLE_ITALIC 2
+#define STBTT_MACSTYLE_UNDERSCORE 4
+#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0
+
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
+// returns 1/0 whether the first string interpreted as utf8 is identical to
+// the second string interpreted as big-endian utf16... useful for strings from next func
+
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
+// returns the string (which may be big-endian double byte, e.g. for unicode)
+// and puts the length in bytes in *length.
+//
+// some of the values for the IDs are below; for more see the truetype spec:
+// http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
+// http://www.microsoft.com/typography/otspec/name.htm
+
+enum { // platformID
+ STBTT_PLATFORM_ID_UNICODE =0,
+ STBTT_PLATFORM_ID_MAC =1,
+ STBTT_PLATFORM_ID_ISO =2,
+ STBTT_PLATFORM_ID_MICROSOFT =3
+};
+
+enum { // encodingID for STBTT_PLATFORM_ID_UNICODE
+ STBTT_UNICODE_EID_UNICODE_1_0 =0,
+ STBTT_UNICODE_EID_UNICODE_1_1 =1,
+ STBTT_UNICODE_EID_ISO_10646 =2,
+ STBTT_UNICODE_EID_UNICODE_2_0_BMP=3,
+ STBTT_UNICODE_EID_UNICODE_2_0_FULL=4
+};
+
+enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT
+ STBTT_MS_EID_SYMBOL =0,
+ STBTT_MS_EID_UNICODE_BMP =1,
+ STBTT_MS_EID_SHIFTJIS =2,
+ STBTT_MS_EID_UNICODE_FULL =10
+};
+
+enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes
+ STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4,
+ STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5,
+ STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6,
+ STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7
+};
+
+enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID...
+ // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs
+ STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410,
+ STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411,
+ STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412,
+ STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419,
+ STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409,
+ STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D
+};
+
+enum { // languageID for STBTT_PLATFORM_ID_MAC
+ STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11,
+ STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23,
+ STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32,
+ STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 ,
+ STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 ,
+ STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33,
+ STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __STB_INCLUDE_STB_TRUETYPE_H__
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+////
+//// IMPLEMENTATION
+////
+////
+
+#ifdef STB_TRUETYPE_IMPLEMENTATION
+
+#ifndef STBTT_MAX_OVERSAMPLE
+#define STBTT_MAX_OVERSAMPLE 8
+#endif
+
+#if STBTT_MAX_OVERSAMPLE > 255
+#error "STBTT_MAX_OVERSAMPLE cannot be > 255"
+#endif
+
+typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1];
+
+#ifndef STBTT_RASTERIZER_VERSION
+#define STBTT_RASTERIZER_VERSION 2
+#endif
+
+#ifdef _MSC_VER
+#define STBTT__NOTUSED(v) (void)(v)
+#else
+#define STBTT__NOTUSED(v) (void)sizeof(v)
+#endif
+
+//////////////////////////////////////////////////////////////////////////
+//
+// stbtt__buf helpers to parse data from file
+//
+
+static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b)
+{
+ if (b->cursor >= b->size)
+ return 0;
+ return b->data[b->cursor++];
+}
+
+static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b)
+{
+ if (b->cursor >= b->size)
+ return 0;
+ return b->data[b->cursor];
+}
+
+static void stbtt__buf_seek(stbtt__buf *b, int o)
+{
+ STBTT_assert(!(o > b->size || o < 0));
+ b->cursor = (o > b->size || o < 0) ? b->size : o;
+}
+
+static void stbtt__buf_skip(stbtt__buf *b, int o)
+{
+ stbtt__buf_seek(b, b->cursor + o);
+}
+
+static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n)
+{
+ stbtt_uint32 v = 0;
+ int i;
+ STBTT_assert(n >= 1 && n <= 4);
+ for (i = 0; i < n; i++)
+ v = (v << 8) | stbtt__buf_get8(b);
+ return v;
+}
+
+static stbtt__buf stbtt__new_buf(const void *p, size_t size)
+{
+ stbtt__buf r;
+ STBTT_assert(size < 0x40000000);
+ r.data = (stbtt_uint8*) p;
+ r.size = (int) size;
+ r.cursor = 0;
+ return r;
+}
+
+#define stbtt__buf_get16(b) stbtt__buf_get((b), 2)
+#define stbtt__buf_get32(b) stbtt__buf_get((b), 4)
+
+static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s)
+{
+ stbtt__buf r = stbtt__new_buf(NULL, 0);
+ if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r;
+ r.data = b->data + o;
+ r.size = s;
+ return r;
+}
+
+static stbtt__buf stbtt__cff_get_index(stbtt__buf *b)
+{
+ int count, start, offsize;
+ start = b->cursor;
+ count = stbtt__buf_get16(b);
+ if (count) {
+ offsize = stbtt__buf_get8(b);
+ STBTT_assert(offsize >= 1 && offsize <= 4);
+ stbtt__buf_skip(b, offsize * count);
+ stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1);
+ }
+ return stbtt__buf_range(b, start, b->cursor - start);
+}
+
+static stbtt_uint32 stbtt__cff_int(stbtt__buf *b)
+{
+ int b0 = stbtt__buf_get8(b);
+ if (b0 >= 32 && b0 <= 246) return b0 - 139;
+ else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108;
+ else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108;
+ else if (b0 == 28) return stbtt__buf_get16(b);
+ else if (b0 == 29) return stbtt__buf_get32(b);
+ STBTT_assert(0);
+ return 0;
+}
+
+static void stbtt__cff_skip_operand(stbtt__buf *b) {
+ int v, b0 = stbtt__buf_peek8(b);
+ STBTT_assert(b0 >= 28);
+ if (b0 == 30) {
+ stbtt__buf_skip(b, 1);
+ while (b->cursor < b->size) {
+ v = stbtt__buf_get8(b);
+ if ((v & 0xF) == 0xF || (v >> 4) == 0xF)
+ break;
+ }
+ } else {
+ stbtt__cff_int(b);
+ }
+}
+
+static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key)
+{
+ stbtt__buf_seek(b, 0);
+ while (b->cursor < b->size) {
+ int start = b->cursor, end, op;
+ while (stbtt__buf_peek8(b) >= 28)
+ stbtt__cff_skip_operand(b);
+ end = b->cursor;
+ op = stbtt__buf_get8(b);
+ if (op == 12) op = stbtt__buf_get8(b) | 0x100;
+ if (op == key) return stbtt__buf_range(b, start, end-start);
+ }
+ return stbtt__buf_range(b, 0, 0);
+}
+
+static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out)
+{
+ int i;
+ stbtt__buf operands = stbtt__dict_get(b, key);
+ for (i = 0; i < outcount && operands.cursor < operands.size; i++)
+ out[i] = stbtt__cff_int(&operands);
+}
+
+static int stbtt__cff_index_count(stbtt__buf *b)
+{
+ stbtt__buf_seek(b, 0);
+ return stbtt__buf_get16(b);
+}
+
+static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i)
+{
+ int count, offsize, start, end;
+ stbtt__buf_seek(&b, 0);
+ count = stbtt__buf_get16(&b);
+ offsize = stbtt__buf_get8(&b);
+ STBTT_assert(i >= 0 && i < count);
+ STBTT_assert(offsize >= 1 && offsize <= 4);
+ stbtt__buf_skip(&b, i*offsize);
+ start = stbtt__buf_get(&b, offsize);
+ end = stbtt__buf_get(&b, offsize);
+ return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start);
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+// accessors to parse data from file
+//
+
+// on platforms that don't allow misaligned reads, if we want to allow
+// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE
+
+#define ttBYTE(p) (* (stbtt_uint8 *) (p))
+#define ttCHAR(p) (* (stbtt_int8 *) (p))
+#define ttFixed(p) ttLONG(p)
+
+static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; }
+static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; }
+static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
+static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
+
+#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
+#define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3])
+
+static int stbtt__isfont(stbtt_uint8 *font)
+{
+ // check the version number
+ if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1
+ if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this!
+ if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF
+ if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0
+ if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts
+ return 0;
+}
+
+// @OPTIMIZE: binary search
+static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag)
+{
+ stbtt_int32 num_tables = ttUSHORT(data+fontstart+4);
+ stbtt_uint32 tabledir = fontstart + 12;
+ stbtt_int32 i;
+ for (i=0; i < num_tables; ++i) {
+ stbtt_uint32 loc = tabledir + 16*i;
+ if (stbtt_tag(data+loc+0, tag))
+ return ttULONG(data+loc+8);
+ }
+ return 0;
+}
+
+static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index)
+{
+ // if it's just a font, there's only one valid index
+ if (stbtt__isfont(font_collection))
+ return index == 0 ? 0 : -1;
+
+ // check if it's a TTC
+ if (stbtt_tag(font_collection, "ttcf")) {
+ // version 1?
+ if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) {
+ stbtt_int32 n = ttLONG(font_collection+8);
+ if (index >= n)
+ return -1;
+ return ttULONG(font_collection+12+index*4);
+ }
+ }
+ return -1;
+}
+
+static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection)
+{
+ // if it's just a font, there's only one valid font
+ if (stbtt__isfont(font_collection))
+ return 1;
+
+ // check if it's a TTC
+ if (stbtt_tag(font_collection, "ttcf")) {
+ // version 1?
+ if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) {
+ return ttLONG(font_collection+8);
+ }
+ }
+ return 0;
+}
+
+static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict)
+{
+ stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 };
+ stbtt__buf pdict;
+ stbtt__dict_get_ints(&fontdict, 18, 2, private_loc);
+ if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0);
+ pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]);
+ stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff);
+ if (!subrsoff) return stbtt__new_buf(NULL, 0);
+ stbtt__buf_seek(&cff, private_loc[1]+subrsoff);
+ return stbtt__cff_get_index(&cff);
+}
+
+static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart)
+{
+ stbtt_uint32 cmap, t;
+ stbtt_int32 i,numTables;
+
+ info->data = data;
+ info->fontstart = fontstart;
+ info->cff = stbtt__new_buf(NULL, 0);
+
+ cmap = stbtt__find_table(data, fontstart, "cmap"); // required
+ info->loca = stbtt__find_table(data, fontstart, "loca"); // required
+ info->head = stbtt__find_table(data, fontstart, "head"); // required
+ info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required
+ info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required
+ info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required
+ info->kern = stbtt__find_table(data, fontstart, "kern"); // not required
+ info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required
+
+ if (!cmap || !info->head || !info->hhea || !info->hmtx)
+ return 0;
+ if (info->glyf) {
+ // required for truetype
+ if (!info->loca) return 0;
+ } else {
+ // initialization for CFF / Type2 fonts (OTF)
+ stbtt__buf b, topdict, topdictidx;
+ stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0;
+ stbtt_uint32 cff;
+
+ cff = stbtt__find_table(data, fontstart, "CFF ");
+ if (!cff) return 0;
+
+ info->fontdicts = stbtt__new_buf(NULL, 0);
+ info->fdselect = stbtt__new_buf(NULL, 0);
+
+ // @TODO this should use size from table (not 512MB)
+ info->cff = stbtt__new_buf(data+cff, 512*1024*1024);
+ b = info->cff;
+
+ // read the header
+ stbtt__buf_skip(&b, 2);
+ stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize
+
+ // @TODO the name INDEX could list multiple fonts,
+ // but we just use the first one.
+ stbtt__cff_get_index(&b); // name INDEX
+ topdictidx = stbtt__cff_get_index(&b);
+ topdict = stbtt__cff_index_get(topdictidx, 0);
+ stbtt__cff_get_index(&b); // string INDEX
+ info->gsubrs = stbtt__cff_get_index(&b);
+
+ stbtt__dict_get_ints(&topdict, 17, 1, &charstrings);
+ stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype);
+ stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff);
+ stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff);
+ info->subrs = stbtt__get_subrs(b, topdict);
+
+ // we only support Type 2 charstrings
+ if (cstype != 2) return 0;
+ if (charstrings == 0) return 0;
+
+ if (fdarrayoff) {
+ // looks like a CID font
+ if (!fdselectoff) return 0;
+ stbtt__buf_seek(&b, fdarrayoff);
+ info->fontdicts = stbtt__cff_get_index(&b);
+ info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff);
+ }
+
+ stbtt__buf_seek(&b, charstrings);
+ info->charstrings = stbtt__cff_get_index(&b);
+ }
+
+ t = stbtt__find_table(data, fontstart, "maxp");
+ if (t)
+ info->numGlyphs = ttUSHORT(data+t+4);
+ else
+ info->numGlyphs = 0xffff;
+
+ // find a cmap encoding table we understand *now* to avoid searching
+ // later. (todo: could make this installable)
+ // the same regardless of glyph.
+ numTables = ttUSHORT(data + cmap + 2);
+ info->index_map = 0;
+ for (i=0; i < numTables; ++i) {
+ stbtt_uint32 encoding_record = cmap + 4 + 8 * i;
+ // find an encoding we understand:
+ switch(ttUSHORT(data+encoding_record)) {
+ case STBTT_PLATFORM_ID_MICROSOFT:
+ switch (ttUSHORT(data+encoding_record+2)) {
+ case STBTT_MS_EID_UNICODE_BMP:
+ case STBTT_MS_EID_UNICODE_FULL:
+ // MS/Unicode
+ info->index_map = cmap + ttULONG(data+encoding_record+4);
+ break;
+ }
+ break;
+ case STBTT_PLATFORM_ID_UNICODE:
+ // Mac/iOS has these
+ // all the encodingIDs are unicode, so we don't bother to check it
+ info->index_map = cmap + ttULONG(data+encoding_record+4);
+ break;
+ }
+ }
+ if (info->index_map == 0)
+ return 0;
+
+ info->indexToLocFormat = ttUSHORT(data+info->head + 50);
+ return 1;
+}
+
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
+{
+ stbtt_uint8 *data = info->data;
+ stbtt_uint32 index_map = info->index_map;
+
+ stbtt_uint16 format = ttUSHORT(data + index_map + 0);
+ if (format == 0) { // apple byte encoding
+ stbtt_int32 bytes = ttUSHORT(data + index_map + 2);
+ if (unicode_codepoint < bytes-6)
+ return ttBYTE(data + index_map + 6 + unicode_codepoint);
+ return 0;
+ } else if (format == 6) {
+ stbtt_uint32 first = ttUSHORT(data + index_map + 6);
+ stbtt_uint32 count = ttUSHORT(data + index_map + 8);
+ if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count)
+ return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2);
+ return 0;
+ } else if (format == 2) {
+ STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean
+ return 0;
+ } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges
+ stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1;
+ stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1;
+ stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10);
+ stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1;
+
+ // do a binary search of the segments
+ stbtt_uint32 endCount = index_map + 14;
+ stbtt_uint32 search = endCount;
+
+ if (unicode_codepoint > 0xffff)
+ return 0;
+
+ // they lie from endCount .. endCount + segCount
+ // but searchRange is the nearest power of two, so...
+ if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2))
+ search += rangeShift*2;
+
+ // now decrement to bias correctly to find smallest
+ search -= 2;
+ while (entrySelector) {
+ stbtt_uint16 end;
+ searchRange >>= 1;
+ end = ttUSHORT(data + search + searchRange*2);
+ if (unicode_codepoint > end)
+ search += searchRange*2;
+ --entrySelector;
+ }
+ search += 2;
+
+ {
+ stbtt_uint16 offset, start;
+ stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1);
+
+ STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item));
+ start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
+ if (unicode_codepoint < start)
+ return 0;
+
+ offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
+ if (offset == 0)
+ return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
+
+ return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
+ }
+ } else if (format == 12 || format == 13) {
+ stbtt_uint32 ngroups = ttULONG(data+index_map+12);
+ stbtt_int32 low,high;
+ low = 0; high = (stbtt_int32)ngroups;
+ // Binary search the right group.
+ while (low < high) {
+ stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high
+ stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12);
+ stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4);
+ if ((stbtt_uint32) unicode_codepoint < start_char)
+ high = mid;
+ else if ((stbtt_uint32) unicode_codepoint > end_char)
+ low = mid+1;
+ else {
+ stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8);
+ if (format == 12)
+ return start_glyph + unicode_codepoint-start_char;
+ else // format == 13
+ return start_glyph;
+ }
+ }
+ return 0; // not found
+ }
+ // @TODO
+ STBTT_assert(0);
+ return 0;
+}
+
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
+{
+ return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
+}
+
+static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy)
+{
+ v->type = type;
+ v->x = (stbtt_int16) x;
+ v->y = (stbtt_int16) y;
+ v->cx = (stbtt_int16) cx;
+ v->cy = (stbtt_int16) cy;
+}
+
+static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
+{
+ int g1,g2;
+
+ STBTT_assert(!info->cff.size);
+
+ if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range
+ if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format
+
+ if (info->indexToLocFormat == 0) {
+ g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
+ g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
+ } else {
+ g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4);
+ g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4);
+ }
+
+ return g1==g2 ? -1 : g1; // if length is 0, return -1
+}
+
+static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
+
+STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
+{
+ if (info->cff.size) {
+ stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1);
+ } else {
+ int g = stbtt__GetGlyfOffset(info, glyph_index);
+ if (g < 0) return 0;
+
+ if (x0) *x0 = ttSHORT(info->data + g + 2);
+ if (y0) *y0 = ttSHORT(info->data + g + 4);
+ if (x1) *x1 = ttSHORT(info->data + g + 6);
+ if (y1) *y1 = ttSHORT(info->data + g + 8);
+ }
+ return 1;
+}
+
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
+{
+ return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
+}
+
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
+{
+ stbtt_int16 numberOfContours;
+ int g;
+ if (info->cff.size)
+ return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0;
+ g = stbtt__GetGlyfOffset(info, glyph_index);
+ if (g < 0) return 1;
+ numberOfContours = ttSHORT(info->data + g);
+ return numberOfContours == 0;
+}
+
+static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off,
+ stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy)
+{
+ if (start_off) {
+ if (was_off)
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy);
+ } else {
+ if (was_off)
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy);
+ else
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0);
+ }
+ return num_vertices;
+}
+
+static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
+{
+ stbtt_int16 numberOfContours;
+ stbtt_uint8 *endPtsOfContours;
+ stbtt_uint8 *data = info->data;
+ stbtt_vertex *vertices=0;
+ int num_vertices=0;
+ int g = stbtt__GetGlyfOffset(info, glyph_index);
+
+ *pvertices = NULL;
+
+ if (g < 0) return 0;
+
+ numberOfContours = ttSHORT(data + g);
+
+ if (numberOfContours > 0) {
+ stbtt_uint8 flags=0,flagcount;
+ stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0;
+ stbtt_int32 x,y,cx,cy,sx,sy, scx,scy;
+ stbtt_uint8 *points;
+ endPtsOfContours = (data + g + 10);
+ ins = ttUSHORT(data + g + 10 + numberOfContours * 2);
+ points = data + g + 10 + numberOfContours * 2 + 2 + ins;
+
+ n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2);
+
+ m = n + 2*numberOfContours; // a loose bound on how many vertices we might need
+ vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata);
+ if (vertices == 0)
+ return 0;
+
+ next_move = 0;
+ flagcount=0;
+
+ // in first pass, we load uninterpreted data into the allocated array
+ // above, shifted to the end of the array so we won't overwrite it when
+ // we create our final data starting from the front
+
+ off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated
+
+ // first load flags
+
+ for (i=0; i < n; ++i) {
+ if (flagcount == 0) {
+ flags = *points++;
+ if (flags & 8)
+ flagcount = *points++;
+ } else
+ --flagcount;
+ vertices[off+i].type = flags;
+ }
+
+ // now load x coordinates
+ x=0;
+ for (i=0; i < n; ++i) {
+ flags = vertices[off+i].type;
+ if (flags & 2) {
+ stbtt_int16 dx = *points++;
+ x += (flags & 16) ? dx : -dx; // ???
+ } else {
+ if (!(flags & 16)) {
+ x = x + (stbtt_int16) (points[0]*256 + points[1]);
+ points += 2;
+ }
+ }
+ vertices[off+i].x = (stbtt_int16) x;
+ }
+
+ // now load y coordinates
+ y=0;
+ for (i=0; i < n; ++i) {
+ flags = vertices[off+i].type;
+ if (flags & 4) {
+ stbtt_int16 dy = *points++;
+ y += (flags & 32) ? dy : -dy; // ???
+ } else {
+ if (!(flags & 32)) {
+ y = y + (stbtt_int16) (points[0]*256 + points[1]);
+ points += 2;
+ }
+ }
+ vertices[off+i].y = (stbtt_int16) y;
+ }
+
+ // now convert them to our format
+ num_vertices=0;
+ sx = sy = cx = cy = scx = scy = 0;
+ for (i=0; i < n; ++i) {
+ flags = vertices[off+i].type;
+ x = (stbtt_int16) vertices[off+i].x;
+ y = (stbtt_int16) vertices[off+i].y;
+
+ if (next_move == i) {
+ if (i != 0)
+ num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
+
+ // now start the new one
+ start_off = !(flags & 1);
+ if (start_off) {
+ // if we start off with an off-curve point, then when we need to find a point on the curve
+ // where we can start, and we need to save some state for when we wraparound.
+ scx = x;
+ scy = y;
+ if (!(vertices[off+i+1].type & 1)) {
+ // next point is also a curve point, so interpolate an on-point curve
+ sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1;
+ sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1;
+ } else {
+ // otherwise just use the next point as our start point
+ sx = (stbtt_int32) vertices[off+i+1].x;
+ sy = (stbtt_int32) vertices[off+i+1].y;
+ ++i; // we're using point i+1 as the starting point, so skip it
+ }
+ } else {
+ sx = x;
+ sy = y;
+ }
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0);
+ was_off = 0;
+ next_move = 1 + ttUSHORT(endPtsOfContours+j*2);
+ ++j;
+ } else {
+ if (!(flags & 1)) { // if it's a curve
+ if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
+ cx = x;
+ cy = y;
+ was_off = 1;
+ } else {
+ if (was_off)
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy);
+ else
+ stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0);
+ was_off = 0;
+ }
+ }
+ }
+ num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
+ } else if (numberOfContours == -1) {
+ // Compound shapes.
+ int more = 1;
+ stbtt_uint8 *comp = data + g + 10;
+ num_vertices = 0;
+ vertices = 0;
+ while (more) {
+ stbtt_uint16 flags, gidx;
+ int comp_num_verts = 0, i;
+ stbtt_vertex *comp_verts = 0, *tmp = 0;
+ float mtx[6] = {1,0,0,1,0,0}, m, n;
+
+ flags = ttSHORT(comp); comp+=2;
+ gidx = ttSHORT(comp); comp+=2;
+
+ if (flags & 2) { // XY values
+ if (flags & 1) { // shorts
+ mtx[4] = ttSHORT(comp); comp+=2;
+ mtx[5] = ttSHORT(comp); comp+=2;
+ } else {
+ mtx[4] = ttCHAR(comp); comp+=1;
+ mtx[5] = ttCHAR(comp); comp+=1;
+ }
+ }
+ else {
+ // @TODO handle matching point
+ STBTT_assert(0);
+ }
+ if (flags & (1<<3)) { // WE_HAVE_A_SCALE
+ mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
+ mtx[1] = mtx[2] = 0;
+ } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE
+ mtx[0] = ttSHORT(comp)/16384.0f; comp+=2;
+ mtx[1] = mtx[2] = 0;
+ mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
+ } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO
+ mtx[0] = ttSHORT(comp)/16384.0f; comp+=2;
+ mtx[1] = ttSHORT(comp)/16384.0f; comp+=2;
+ mtx[2] = ttSHORT(comp)/16384.0f; comp+=2;
+ mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
+ }
+
+ // Find transformation scales.
+ m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
+ n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
+
+ // Get indexed glyph.
+ comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts);
+ if (comp_num_verts > 0) {
+ // Transform vertices.
+ for (i = 0; i < comp_num_verts; ++i) {
+ stbtt_vertex* v = &comp_verts[i];
+ stbtt_vertex_type x,y;
+ x=v->x; y=v->y;
+ v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
+ v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
+ x=v->cx; y=v->cy;
+ v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
+ v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
+ }
+ // Append vertices.
+ tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata);
+ if (!tmp) {
+ if (vertices) STBTT_free(vertices, info->userdata);
+ if (comp_verts) STBTT_free(comp_verts, info->userdata);
+ return 0;
+ }
+ if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex));
+ STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex));
+ if (vertices) STBTT_free(vertices, info->userdata);
+ vertices = tmp;
+ STBTT_free(comp_verts, info->userdata);
+ num_vertices += comp_num_verts;
+ }
+ // More components ?
+ more = flags & (1<<5);
+ }
+ } else if (numberOfContours < 0) {
+ // @TODO other compound variations?
+ STBTT_assert(0);
+ } else {
+ // numberOfCounters == 0, do nothing
+ }
+
+ *pvertices = vertices;
+ return num_vertices;
+}
+
+typedef struct
+{
+ int bounds;
+ int started;
+ float first_x, first_y;
+ float x, y;
+ stbtt_int32 min_x, max_x, min_y, max_y;
+
+ stbtt_vertex *pvertices;
+ int num_vertices;
+} stbtt__csctx;
+
+#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0}
+
+static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y)
+{
+ if (x > c->max_x || !c->started) c->max_x = x;
+ if (y > c->max_y || !c->started) c->max_y = y;
+ if (x < c->min_x || !c->started) c->min_x = x;
+ if (y < c->min_y || !c->started) c->min_y = y;
+ c->started = 1;
+}
+
+static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1)
+{
+ if (c->bounds) {
+ stbtt__track_vertex(c, x, y);
+ if (type == STBTT_vcubic) {
+ stbtt__track_vertex(c, cx, cy);
+ stbtt__track_vertex(c, cx1, cy1);
+ }
+ } else {
+ stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy);
+ c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1;
+ c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1;
+ }
+ c->num_vertices++;
+}
+
+static void stbtt__csctx_close_shape(stbtt__csctx *ctx)
+{
+ if (ctx->first_x != ctx->x || ctx->first_y != ctx->y)
+ stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0);
+}
+
+static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy)
+{
+ stbtt__csctx_close_shape(ctx);
+ ctx->first_x = ctx->x = ctx->x + dx;
+ ctx->first_y = ctx->y = ctx->y + dy;
+ stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
+}
+
+static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy)
+{
+ ctx->x += dx;
+ ctx->y += dy;
+ stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
+}
+
+static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
+{
+ float cx1 = ctx->x + dx1;
+ float cy1 = ctx->y + dy1;
+ float cx2 = cx1 + dx2;
+ float cy2 = cy1 + dy2;
+ ctx->x = cx2 + dx3;
+ ctx->y = cy2 + dy3;
+ stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2);
+}
+
+static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n)
+{
+ int count = stbtt__cff_index_count(&idx);
+ int bias = 107;
+ if (count >= 33900)
+ bias = 32768;
+ else if (count >= 1240)
+ bias = 1131;
+ n += bias;
+ if (n < 0 || n >= count)
+ return stbtt__new_buf(NULL, 0);
+ return stbtt__cff_index_get(idx, n);
+}
+
+static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index)
+{
+ stbtt__buf fdselect = info->fdselect;
+ int nranges, start, end, v, fmt, fdselector = -1, i;
+
+ stbtt__buf_seek(&fdselect, 0);
+ fmt = stbtt__buf_get8(&fdselect);
+ if (fmt == 0) {
+ // untested
+ stbtt__buf_skip(&fdselect, glyph_index);
+ fdselector = stbtt__buf_get8(&fdselect);
+ } else if (fmt == 3) {
+ nranges = stbtt__buf_get16(&fdselect);
+ start = stbtt__buf_get16(&fdselect);
+ for (i = 0; i < nranges; i++) {
+ v = stbtt__buf_get8(&fdselect);
+ end = stbtt__buf_get16(&fdselect);
+ if (glyph_index >= start && glyph_index < end) {
+ fdselector = v;
+ break;
+ }
+ start = end;
+ }
+ }
+ if (fdselector == -1) stbtt__new_buf(NULL, 0);
+ return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector));
+}
+
+static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c)
+{
+ int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0;
+ int has_subrs = 0, clear_stack;
+ float s[48];
+ stbtt__buf subr_stack[10], subrs = info->subrs, b;
+ float f;
+
+#define STBTT__CSERR(s) (0)
+
+ // this currently ignores the initial width value, which isn't needed if we have hmtx
+ b = stbtt__cff_index_get(info->charstrings, glyph_index);
+ while (b.cursor < b.size) {
+ i = 0;
+ clear_stack = 1;
+ b0 = stbtt__buf_get8(&b);
+ switch (b0) {
+ // @TODO implement hinting
+ case 0x13: // hintmask
+ case 0x14: // cntrmask
+ if (in_header)
+ maskbits += (sp / 2); // implicit "vstem"
+ in_header = 0;
+ stbtt__buf_skip(&b, (maskbits + 7) / 8);
+ break;
+
+ case 0x01: // hstem
+ case 0x03: // vstem
+ case 0x12: // hstemhm
+ case 0x17: // vstemhm
+ maskbits += (sp / 2);
+ break;
+
+ case 0x15: // rmoveto
+ in_header = 0;
+ if (sp < 2) return STBTT__CSERR("rmoveto stack");
+ stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]);
+ break;
+ case 0x04: // vmoveto
+ in_header = 0;
+ if (sp < 1) return STBTT__CSERR("vmoveto stack");
+ stbtt__csctx_rmove_to(c, 0, s[sp-1]);
+ break;
+ case 0x16: // hmoveto
+ in_header = 0;
+ if (sp < 1) return STBTT__CSERR("hmoveto stack");
+ stbtt__csctx_rmove_to(c, s[sp-1], 0);
+ break;
+
+ case 0x05: // rlineto
+ if (sp < 2) return STBTT__CSERR("rlineto stack");
+ for (; i + 1 < sp; i += 2)
+ stbtt__csctx_rline_to(c, s[i], s[i+1]);
+ break;
+
+ // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical
+ // starting from a different place.
+
+ case 0x07: // vlineto
+ if (sp < 1) return STBTT__CSERR("vlineto stack");
+ goto vlineto;
+ case 0x06: // hlineto
+ if (sp < 1) return STBTT__CSERR("hlineto stack");
+ for (;;) {
+ if (i >= sp) break;
+ stbtt__csctx_rline_to(c, s[i], 0);
+ i++;
+ vlineto:
+ if (i >= sp) break;
+ stbtt__csctx_rline_to(c, 0, s[i]);
+ i++;
+ }
+ break;
+
+ case 0x1F: // hvcurveto
+ if (sp < 4) return STBTT__CSERR("hvcurveto stack");
+ goto hvcurveto;
+ case 0x1E: // vhcurveto
+ if (sp < 4) return STBTT__CSERR("vhcurveto stack");
+ for (;;) {
+ if (i + 3 >= sp) break;
+ stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f);
+ i += 4;
+ hvcurveto:
+ if (i + 3 >= sp) break;
+ stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]);
+ i += 4;
+ }
+ break;
+
+ case 0x08: // rrcurveto
+ if (sp < 6) return STBTT__CSERR("rcurveline stack");
+ for (; i + 5 < sp; i += 6)
+ stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
+ break;
+
+ case 0x18: // rcurveline
+ if (sp < 8) return STBTT__CSERR("rcurveline stack");
+ for (; i + 5 < sp - 2; i += 6)
+ stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
+ if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack");
+ stbtt__csctx_rline_to(c, s[i], s[i+1]);
+ break;
+
+ case 0x19: // rlinecurve
+ if (sp < 8) return STBTT__CSERR("rlinecurve stack");
+ for (; i + 1 < sp - 6; i += 2)
+ stbtt__csctx_rline_to(c, s[i], s[i+1]);
+ if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack");
+ stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
+ break;
+
+ case 0x1A: // vvcurveto
+ case 0x1B: // hhcurveto
+ if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack");
+ f = 0.0;
+ if (sp & 1) { f = s[i]; i++; }
+ for (; i + 3 < sp; i += 4) {
+ if (b0 == 0x1B)
+ stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0);
+ else
+ stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]);
+ f = 0.0;
+ }
+ break;
+
+ case 0x0A: // callsubr
+ if (!has_subrs) {
+ if (info->fdselect.size)
+ subrs = stbtt__cid_get_glyph_subrs(info, glyph_index);
+ has_subrs = 1;
+ }
+ // fallthrough
+ case 0x1D: // callgsubr
+ if (sp < 1) return STBTT__CSERR("call(g|)subr stack");
+ v = (int) s[--sp];
+ if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit");
+ subr_stack[subr_stack_height++] = b;
+ b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v);
+ if (b.size == 0) return STBTT__CSERR("subr not found");
+ b.cursor = 0;
+ clear_stack = 0;
+ break;
+
+ case 0x0B: // return
+ if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr");
+ b = subr_stack[--subr_stack_height];
+ clear_stack = 0;
+ break;
+
+ case 0x0E: // endchar
+ stbtt__csctx_close_shape(c);
+ return 1;
+
+ case 0x0C: { // two-byte escape
+ float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6;
+ float dx, dy;
+ int b1 = stbtt__buf_get8(&b);
+ switch (b1) {
+ // @TODO These "flex" implementations ignore the flex-depth and resolution,
+ // and always draw beziers.
+ case 0x22: // hflex
+ if (sp < 7) return STBTT__CSERR("hflex stack");
+ dx1 = s[0];
+ dx2 = s[1];
+ dy2 = s[2];
+ dx3 = s[3];
+ dx4 = s[4];
+ dx5 = s[5];
+ dx6 = s[6];
+ stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0);
+ stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0);
+ break;
+
+ case 0x23: // flex
+ if (sp < 13) return STBTT__CSERR("flex stack");
+ dx1 = s[0];
+ dy1 = s[1];
+ dx2 = s[2];
+ dy2 = s[3];
+ dx3 = s[4];
+ dy3 = s[5];
+ dx4 = s[6];
+ dy4 = s[7];
+ dx5 = s[8];
+ dy5 = s[9];
+ dx6 = s[10];
+ dy6 = s[11];
+ //fd is s[12]
+ stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3);
+ stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6);
+ break;
+
+ case 0x24: // hflex1
+ if (sp < 9) return STBTT__CSERR("hflex1 stack");
+ dx1 = s[0];
+ dy1 = s[1];
+ dx2 = s[2];
+ dy2 = s[3];
+ dx3 = s[4];
+ dx4 = s[5];
+ dx5 = s[6];
+ dy5 = s[7];
+ dx6 = s[8];
+ stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0);
+ stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5));
+ break;
+
+ case 0x25: // flex1
+ if (sp < 11) return STBTT__CSERR("flex1 stack");
+ dx1 = s[0];
+ dy1 = s[1];
+ dx2 = s[2];
+ dy2 = s[3];
+ dx3 = s[4];
+ dy3 = s[5];
+ dx4 = s[6];
+ dy4 = s[7];
+ dx5 = s[8];
+ dy5 = s[9];
+ dx6 = dy6 = s[10];
+ dx = dx1+dx2+dx3+dx4+dx5;
+ dy = dy1+dy2+dy3+dy4+dy5;
+ if (STBTT_fabs(dx) > STBTT_fabs(dy))
+ dy6 = -dy;
+ else
+ dx6 = -dx;
+ stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3);
+ stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6);
+ break;
+
+ default:
+ return STBTT__CSERR("unimplemented");
+ }
+ } break;
+
+ default:
+ if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254))
+ return STBTT__CSERR("reserved operator");
+
+ // push immediate
+ if (b0 == 255) {
+ f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000;
+ } else {
+ stbtt__buf_skip(&b, -1);
+ f = (float)(stbtt_int16)stbtt__cff_int(&b);
+ }
+ if (sp >= 48) return STBTT__CSERR("push stack overflow");
+ s[sp++] = f;
+ clear_stack = 0;
+ break;
+ }
+ if (clear_stack) sp = 0;
+ }
+ return STBTT__CSERR("no endchar");
+
+#undef STBTT__CSERR
+}
+
+static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
+{
+ // runs the charstring twice, once to count and once to output (to avoid realloc)
+ stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1);
+ stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0);
+ if (stbtt__run_charstring(info, glyph_index, &count_ctx)) {
+ *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata);
+ output_ctx.pvertices = *pvertices;
+ if (stbtt__run_charstring(info, glyph_index, &output_ctx)) {
+ STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices);
+ return output_ctx.num_vertices;
+ }
+ }
+ *pvertices = NULL;
+ return 0;
+}
+
+static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
+{
+ stbtt__csctx c = STBTT__CSCTX_INIT(1);
+ int r = stbtt__run_charstring(info, glyph_index, &c);
+ if (x0) *x0 = r ? c.min_x : 0;
+ if (y0) *y0 = r ? c.min_y : 0;
+ if (x1) *x1 = r ? c.max_x : 0;
+ if (y1) *y1 = r ? c.max_y : 0;
+ return r ? c.num_vertices : 0;
+}
+
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
+{
+ if (!info->cff.size)
+ return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices);
+ else
+ return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices);
+}
+
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
+{
+ stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
+ if (glyph_index < numOfLongHorMetrics) {
+ if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index);
+ if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
+ } else {
+ if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
+ if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
+ }
+}
+
+static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
+{
+ stbtt_uint8 *data = info->data + info->kern;
+ stbtt_uint32 needle, straw;
+ int l, r, m;
+
+ // we only look at the first table. it must be 'horizontal' and format 0.
+ if (!info->kern)
+ return 0;
+ if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
+ return 0;
+ if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
+ return 0;
+
+ l = 0;
+ r = ttUSHORT(data+10) - 1;
+ needle = glyph1 << 16 | glyph2;
+ while (l <= r) {
+ m = (l + r) >> 1;
+ straw = ttULONG(data+18+(m*6)); // note: unaligned read
+ if (needle < straw)
+ r = m - 1;
+ else if (needle > straw)
+ l = m + 1;
+ else
+ return ttSHORT(data+22+(m*6));
+ }
+ return 0;
+}
+
+static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
+{
+ stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
+ switch(coverageFormat) {
+ case 1: {
+ stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2);
+
+ // Binary search.
+ stbtt_int32 l=0, r=glyphCount-1, m;
+ int straw, needle=glyph;
+ while (l <= r) {
+ stbtt_uint8 *glyphArray = coverageTable + 4;
+ stbtt_uint16 glyphID;
+ m = (l + r) >> 1;
+ glyphID = ttUSHORT(glyphArray + 2 * m);
+ straw = glyphID;
+ if (needle < straw)
+ r = m - 1;
+ else if (needle > straw)
+ l = m + 1;
+ else {
+ return m;
+ }
+ }
+ } break;
+
+ case 2: {
+ stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2);
+ stbtt_uint8 *rangeArray = coverageTable + 4;
+
+ // Binary search.
+ stbtt_int32 l=0, r=rangeCount-1, m;
+ int strawStart, strawEnd, needle=glyph;
+ while (l <= r) {
+ stbtt_uint8 *rangeRecord;
+ m = (l + r) >> 1;
+ rangeRecord = rangeArray + 6 * m;
+ strawStart = ttUSHORT(rangeRecord);
+ strawEnd = ttUSHORT(rangeRecord + 2);
+ if (needle < strawStart)
+ r = m - 1;
+ else if (needle > strawEnd)
+ l = m + 1;
+ else {
+ stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4);
+ return startCoverageIndex + glyph - strawStart;
+ }
+ }
+ } break;
+
+ default: {
+ // There are no other cases.
+ STBTT_assert(0);
+ } break;
+ }
+
+ return -1;
+}
+
+static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
+{
+ stbtt_uint16 classDefFormat = ttUSHORT(classDefTable);
+ switch(classDefFormat)
+ {
+ case 1: {
+ stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2);
+ stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4);
+ stbtt_uint8 *classDef1ValueArray = classDefTable + 6;
+
+ if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
+ return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
+
+ classDefTable = classDef1ValueArray + 2 * glyphCount;
+ } break;
+
+ case 2: {
+ stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2);
+ stbtt_uint8 *classRangeRecords = classDefTable + 4;
+
+ // Binary search.
+ stbtt_int32 l=0, r=classRangeCount-1, m;
+ int strawStart, strawEnd, needle=glyph;
+ while (l <= r) {
+ stbtt_uint8 *classRangeRecord;
+ m = (l + r) >> 1;
+ classRangeRecord = classRangeRecords + 6 * m;
+ strawStart = ttUSHORT(classRangeRecord);
+ strawEnd = ttUSHORT(classRangeRecord + 2);
+ if (needle < strawStart)
+ r = m - 1;
+ else if (needle > strawEnd)
+ l = m + 1;
+ else
+ return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
+ }
+
+ classDefTable = classRangeRecords + 6 * classRangeCount;
+ } break;
+
+ default: {
+ // There are no other cases.
+ STBTT_assert(0);
+ } break;
+ }
+
+ return -1;
+}
+
+// Define to STBTT_assert(x) if you want to break on unimplemented formats.
+#define STBTT_GPOS_TODO_assert(x)
+
+static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
+{
+ stbtt_uint16 lookupListOffset;
+ stbtt_uint8 *lookupList;
+ stbtt_uint16 lookupCount;
+ stbtt_uint8 *data;
+ stbtt_int32 i;
+
+ if (!info->gpos) return 0;
+
+ data = info->data + info->gpos;
+
+ if (ttUSHORT(data+0) != 1) return 0; // Major version 1
+ if (ttUSHORT(data+2) != 0) return 0; // Minor version 0
+
+ lookupListOffset = ttUSHORT(data+8);
+ lookupList = data + lookupListOffset;
+ lookupCount = ttUSHORT(lookupList);
+
+ for (i=0; i<lookupCount; ++i) {
+ stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i);
+ stbtt_uint8 *lookupTable = lookupList + lookupOffset;
+
+ stbtt_uint16 lookupType = ttUSHORT(lookupTable);
+ stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
+ stbtt_uint8 *subTableOffsets = lookupTable + 6;
+ switch(lookupType) {
+ case 2: { // Pair Adjustment Positioning Subtable
+ stbtt_int32 sti;
+ for (sti=0; sti<subTableCount; sti++) {
+ stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
+ stbtt_uint8 *table = lookupTable + subtableOffset;
+ stbtt_uint16 posFormat = ttUSHORT(table);
+ stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
+ stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
+ if (coverageIndex == -1) continue;
+
+ switch (posFormat) {
+ case 1: {
+ stbtt_int32 l, r, m;
+ int straw, needle;
+ stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
+ stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
+ stbtt_int32 valueRecordPairSizeInBytes = 2;
+ stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
+ stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
+ stbtt_uint8 *pairValueTable = table + pairPosOffset;
+ stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable);
+ stbtt_uint8 *pairValueArray = pairValueTable + 2;
+ // TODO: Support more formats.
+ STBTT_GPOS_TODO_assert(valueFormat1 == 4);
+ if (valueFormat1 != 4) return 0;
+ STBTT_GPOS_TODO_assert(valueFormat2 == 0);
+ if (valueFormat2 != 0) return 0;
+
+ STBTT_assert(coverageIndex < pairSetCount);
+ STBTT__NOTUSED(pairSetCount);
+
+ needle=glyph2;
+ r=pairValueCount-1;
+ l=0;
+
+ // Binary search.
+ while (l <= r) {
+ stbtt_uint16 secondGlyph;
+ stbtt_uint8 *pairValue;
+ m = (l + r) >> 1;
+ pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m;
+ secondGlyph = ttUSHORT(pairValue);
+ straw = secondGlyph;
+ if (needle < straw)
+ r = m - 1;
+ else if (needle > straw)
+ l = m + 1;
+ else {
+ stbtt_int16 xAdvance = ttSHORT(pairValue + 2);
+ return xAdvance;
+ }
+ }
+ } break;
+
+ case 2: {
+ stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
+ stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
+
+ stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
+ stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
+ int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
+ int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2);
+
+ stbtt_uint16 class1Count = ttUSHORT(table + 12);
+ stbtt_uint16 class2Count = ttUSHORT(table + 14);
+ STBTT_assert(glyph1class < class1Count);
+ STBTT_assert(glyph2class < class2Count);
+
+ // TODO: Support more formats.
+ STBTT_GPOS_TODO_assert(valueFormat1 == 4);
+ if (valueFormat1 != 4) return 0;
+ STBTT_GPOS_TODO_assert(valueFormat2 == 0);
+ if (valueFormat2 != 0) return 0;
+
+ if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) {
+ stbtt_uint8 *class1Records = table + 16;
+ stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count);
+ stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class);
+ return xAdvance;
+ }
+ } break;
+
+ default: {
+ // There are no other cases.
+ STBTT_assert(0);
+ break;
+ };
+ }
+ }
+ break;
+ };
+
+ default:
+ // TODO: Implement other stuff.
+ break;
+ }
+ }
+
+ return 0;
+}
+
+STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2)
+{
+ int xAdvance = 0;
+
+ if (info->gpos)
+ xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
+
+ if (info->kern)
+ xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
+
+ return xAdvance;
+}
+
+STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
+{
+ if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs
+ return 0;
+ return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
+}
+
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
+{
+ stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
+}
+
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
+{
+ if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4);
+ if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
+ if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
+}
+
+STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap)
+{
+ int tab = stbtt__find_table(info->data, info->fontstart, "OS/2");
+ if (!tab)
+ return 0;
+ if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68);
+ if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70);
+ if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72);
+ return 1;
+}
+
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
+{
+ *x0 = ttSHORT(info->data + info->head + 36);
+ *y0 = ttSHORT(info->data + info->head + 38);
+ *x1 = ttSHORT(info->data + info->head + 40);
+ *y1 = ttSHORT(info->data + info->head + 42);
+}
+
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
+{
+ int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
+ return (float) height / fheight;
+}
+
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
+{
+ int unitsPerEm = ttUSHORT(info->data + info->head + 18);
+ return pixels / unitsPerEm;
+}
+
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
+{
+ STBTT_free(v, info->userdata);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// antialiasing software rasterizer
+//
+
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
+{
+ int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning
+ if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
+ // e.g. space character
+ if (ix0) *ix0 = 0;
+ if (iy0) *iy0 = 0;
+ if (ix1) *ix1 = 0;
+ if (iy1) *iy1 = 0;
+ } else {
+ // move to integral bboxes (treating pixels as little squares, what pixels get touched)?
+ if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x);
+ if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y);
+ if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x);
+ if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y);
+ }
+}
+
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
+{
+ stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
+}
+
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
+{
+ stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
+}
+
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
+{
+ stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Rasterizer
+
+typedef struct stbtt__hheap_chunk
+{
+ struct stbtt__hheap_chunk *next;
+} stbtt__hheap_chunk;
+
+typedef struct stbtt__hheap
+{
+ struct stbtt__hheap_chunk *head;
+ void *first_free;
+ int num_remaining_in_head_chunk;
+} stbtt__hheap;
+
+static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata)
+{
+ if (hh->first_free) {
+ void *p = hh->first_free;
+ hh->first_free = * (void **) p;
+ return p;
+ } else {
+ if (hh->num_remaining_in_head_chunk == 0) {
+ int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
+ stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata);
+ if (c == NULL)
+ return NULL;
+ c->next = hh->head;
+ hh->head = c;
+ hh->num_remaining_in_head_chunk = count;
+ }
+ --hh->num_remaining_in_head_chunk;
+ return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk;
+ }
+}
+
+static void stbtt__hheap_free(stbtt__hheap *hh, void *p)
+{
+ *(void **) p = hh->first_free;
+ hh->first_free = p;
+}
+
+static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata)
+{
+ stbtt__hheap_chunk *c = hh->head;
+ while (c) {
+ stbtt__hheap_chunk *n = c->next;
+ STBTT_free(c, userdata);
+ c = n;
+ }
+}
+
+typedef struct stbtt__edge {
+ float x0,y0, x1,y1;
+ int invert;
+} stbtt__edge;
+
+
+typedef struct stbtt__active_edge
+{
+ struct stbtt__active_edge *next;
+ #if STBTT_RASTERIZER_VERSION==1
+ int x,dx;
+ float ey;
+ int direction;
+ #elif STBTT_RASTERIZER_VERSION==2
+ float fx,fdx,fdy;
+ float direction;
+ float sy;
+ float ey;
+ #else
+ #error "Unrecognized value of STBTT_RASTERIZER_VERSION"
+ #endif
+} stbtt__active_edge;
+
+#if STBTT_RASTERIZER_VERSION == 1
+#define STBTT_FIXSHIFT 10
+#define STBTT_FIX (1 << STBTT_FIXSHIFT)
+#define STBTT_FIXMASK (STBTT_FIX-1)
+
+static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
+{
+ stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
+ float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
+ STBTT_assert(z != NULL);
+ if (!z) return z;
+
+ // round dx down to avoid overshooting
+ if (dxdy < 0)
+ z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy);
+ else
+ z->dx = STBTT_ifloor(STBTT_FIX * dxdy);
+
+ z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount
+ z->x -= off_x * STBTT_FIX;
+
+ z->ey = e->y1;
+ z->next = 0;
+ z->direction = e->invert ? 1 : -1;
+ return z;
+}
+#elif STBTT_RASTERIZER_VERSION == 2
+static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
+{
+ stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
+ float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
+ STBTT_assert(z != NULL);
+ //STBTT_assert(e->y0 <= start_point);
+ if (!z) return z;
+ z->fdx = dxdy;
+ z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f;
+ z->fx = e->x0 + dxdy * (start_point - e->y0);
+ z->fx -= off_x;
+ z->direction = e->invert ? 1.0f : -1.0f;
+ z->sy = e->y0;
+ z->ey = e->y1;
+ z->next = 0;
+ return z;
+}
+#else
+#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
+#endif
+
+#if STBTT_RASTERIZER_VERSION == 1
+// note: this routine clips fills that extend off the edges... ideally this
+// wouldn't happen, but it could happen if the truetype glyph bounding boxes
+// are wrong, or if the user supplies a too-small bitmap
+static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight)
+{
+ // non-zero winding fill
+ int x0=0, w=0;
+
+ while (e) {
+ if (w == 0) {
+ // if we're currently at zero, we need to record the edge start point
+ x0 = e->x; w += e->direction;
+ } else {
+ int x1 = e->x; w += e->direction;
+ // if we went to zero, we need to draw
+ if (w == 0) {
+ int i = x0 >> STBTT_FIXSHIFT;
+ int j = x1 >> STBTT_FIXSHIFT;
+
+ if (i < len && j >= 0) {
+ if (i == j) {
+ // x0,x1 are the same pixel, so compute combined coverage
+ scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT);
+ } else {
+ if (i >= 0) // add antialiasing for x0
+ scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT);
+ else
+ i = -1; // clip
+
+ if (j < len) // add antialiasing for x1
+ scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT);
+ else
+ j = len; // clip
+
+ for (++i; i < j; ++i) // fill pixels between x0 and x1
+ scanline[i] = scanline[i] + (stbtt_uint8) max_weight;
+ }
+ }
+ }
+ }
+
+ e = e->next;
+ }
+}
+
+static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
+{
+ stbtt__hheap hh = { 0, 0, 0 };
+ stbtt__active_edge *active = NULL;
+ int y,j=0;
+ int max_weight = (255 / vsubsample); // weight per vertical scanline
+ int s; // vertical subsample index
+ unsigned char scanline_data[512], *scanline;
+
+ if (result->w > 512)
+ scanline = (unsigned char *) STBTT_malloc(result->w, userdata);
+ else
+ scanline = scanline_data;
+
+ y = off_y * vsubsample;
+ e[n].y0 = (off_y + result->h) * (float) vsubsample + 1;
+
+ while (j < result->h) {
+ STBTT_memset(scanline, 0, result->w);
+ for (s=0; s < vsubsample; ++s) {
+ // find center of pixel for this scanline
+ float scan_y = y + 0.5f;
+ stbtt__active_edge **step = &active;
+
+ // update all active edges;
+ // remove all active edges that terminate before the center of this scanline
+ while (*step) {
+ stbtt__active_edge * z = *step;
+ if (z->ey <= scan_y) {
+ *step = z->next; // delete from list
+ STBTT_assert(z->direction);
+ z->direction = 0;
+ stbtt__hheap_free(&hh, z);
+ } else {
+ z->x += z->dx; // advance to position for current scanline
+ step = &((*step)->next); // advance through list
+ }
+ }
+
+ // resort the list if needed
+ for(;;) {
+ int changed=0;
+ step = &active;
+ while (*step && (*step)->next) {
+ if ((*step)->x > (*step)->next->x) {
+ stbtt__active_edge *t = *step;
+ stbtt__active_edge *q = t->next;
+
+ t->next = q->next;
+ q->next = t;
+ *step = q;
+ changed = 1;
+ }
+ step = &(*step)->next;
+ }
+ if (!changed) break;
+ }
+
+ // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
+ while (e->y0 <= scan_y) {
+ if (e->y1 > scan_y) {
+ stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata);
+ if (z != NULL) {
+ // find insertion point
+ if (active == NULL)
+ active = z;
+ else if (z->x < active->x) {
+ // insert at front
+ z->next = active;
+ active = z;
+ } else {
+ // find thing to insert AFTER
+ stbtt__active_edge *p = active;
+ while (p->next && p->next->x < z->x)
+ p = p->next;
+ // at this point, p->next->x is NOT < z->x
+ z->next = p->next;
+ p->next = z;
+ }
+ }
+ }
+ ++e;
+ }
+
+ // now process all active edges in XOR fashion
+ if (active)
+ stbtt__fill_active_edges(scanline, result->w, active, max_weight);
+
+ ++y;
+ }
+ STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w);
+ ++j;
+ }
+
+ stbtt__hheap_cleanup(&hh, userdata);
+
+ if (scanline != scanline_data)
+ STBTT_free(scanline, userdata);
+}
+
+#elif STBTT_RASTERIZER_VERSION == 2
+
+// the edge passed in here does not cross the vertical line at x or the vertical line at x+1
+// (i.e. it has already been clipped to those)
+static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1)
+{
+ if (y0 == y1) return;
+ STBTT_assert(y0 < y1);
+ STBTT_assert(e->sy <= e->ey);
+ if (y0 > e->ey) return;
+ if (y1 < e->sy) return;
+ if (y0 < e->sy) {
+ x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
+ y0 = e->sy;
+ }
+ if (y1 > e->ey) {
+ x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
+ y1 = e->ey;
+ }
+
+ if (x0 == x)
+ STBTT_assert(x1 <= x+1);
+ else if (x0 == x+1)
+ STBTT_assert(x1 >= x);
+ else if (x0 <= x)
+ STBTT_assert(x1 <= x);
+ else if (x0 >= x+1)
+ STBTT_assert(x1 >= x+1);
+ else
+ STBTT_assert(x1 >= x && x1 <= x+1);
+
+ if (x0 <= x && x1 <= x)
+ scanline[x] += e->direction * (y1-y0);
+ else if (x0 >= x+1 && x1 >= x+1)
+ ;
+ else {
+ STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
+ scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position
+ }
+}
+
+static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top)
+{
+ float y_bottom = y_top+1;
+
+ while (e) {
+ // brute force every pixel
+
+ // compute intersection points with top & bottom
+ STBTT_assert(e->ey >= y_top);
+
+ if (e->fdx == 0) {
+ float x0 = e->fx;
+ if (x0 < len) {
+ if (x0 >= 0) {
+ stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom);
+ stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom);
+ } else {
+ stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
+ }
+ }
+ } else {
+ float x0 = e->fx;
+ float dx = e->fdx;
+ float xb = x0 + dx;
+ float x_top, x_bottom;
+ float sy0,sy1;
+ float dy = e->fdy;
+ STBTT_assert(e->sy <= y_bottom && e->ey >= y_top);
+
+ // compute endpoints of line segment clipped to this scanline (if the
+ // line segment starts on this scanline. x0 is the intersection of the
+ // line with y_top, but that may be off the line segment.
+ if (e->sy > y_top) {
+ x_top = x0 + dx * (e->sy - y_top);
+ sy0 = e->sy;
+ } else {
+ x_top = x0;
+ sy0 = y_top;
+ }
+ if (e->ey < y_bottom) {
+ x_bottom = x0 + dx * (e->ey - y_top);
+ sy1 = e->ey;
+ } else {
+ x_bottom = xb;
+ sy1 = y_bottom;
+ }
+
+ if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) {
+ // from here on, we don't have to range check x values
+
+ if ((int) x_top == (int) x_bottom) {
+ float height;
+ // simple case, only spans one pixel
+ int x = (int) x_top;
+ height = sy1 - sy0;
+ STBTT_assert(x >= 0 && x < len);
+ scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height;
+ scanline_fill[x] += e->direction * height; // everything right of this pixel is filled
+ } else {
+ int x,x1,x2;
+ float y_crossing, step, sign, area;
+ // covers 2+ pixels
+ if (x_top > x_bottom) {
+ // flip scanline vertically; signed area is the same
+ float t;
+ sy0 = y_bottom - (sy0 - y_top);
+ sy1 = y_bottom - (sy1 - y_top);
+ t = sy0, sy0 = sy1, sy1 = t;
+ t = x_bottom, x_bottom = x_top, x_top = t;
+ dx = -dx;
+ dy = -dy;
+ t = x0, x0 = xb, xb = t;
+ }
+
+ x1 = (int) x_top;
+ x2 = (int) x_bottom;
+ // compute intersection with y axis at x1+1
+ y_crossing = (x1+1 - x0) * dy + y_top;
+
+ sign = e->direction;
+ // area of the rectangle covered from y0..y_crossing
+ area = sign * (y_crossing-sy0);
+ // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing)
+ scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2);
+
+ step = sign * dy;
+ for (x = x1+1; x < x2; ++x) {
+ scanline[x] += area + step/2;
+ area += step;
+ }
+ y_crossing += dy * (x2 - (x1+1));
+
+ STBTT_assert(STBTT_fabs(area) <= 1.01f);
+
+ scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing);
+
+ scanline_fill[x2] += sign * (sy1-sy0);
+ }
+ } else {
+ // if edge goes outside of box we're drawing, we require
+ // clipping logic. since this does not match the intended use
+ // of this library, we use a different, very slow brute
+ // force implementation
+ int x;
+ for (x=0; x < len; ++x) {
+ // cases:
+ //
+ // there can be up to two intersections with the pixel. any intersection
+ // with left or right edges can be handled by splitting into two (or three)
+ // regions. intersections with top & bottom do not necessitate case-wise logic.
+ //
+ // the old way of doing this found the intersections with the left & right edges,
+ // then used some simple logic to produce up to three segments in sorted order
+ // from top-to-bottom. however, this had a problem: if an x edge was epsilon
+ // across the x border, then the corresponding y position might not be distinct
+ // from the other y segment, and it might ignored as an empty segment. to avoid
+ // that, we need to explicitly produce segments based on x positions.
+
+ // rename variables to clearly-defined pairs
+ float y0 = y_top;
+ float x1 = (float) (x);
+ float x2 = (float) (x+1);
+ float x3 = xb;
+ float y3 = y_bottom;
+
+ // x = e->x + e->dx * (y-y_top)
+ // (y-y_top) = (x - e->x) / e->dx
+ // y = (x - e->x) / e->dx + y_top
+ float y1 = (x - x0) / dx + y_top;
+ float y2 = (x+1 - x0) / dx + y_top;
+
+ if (x0 < x1 && x3 > x2) { // three segments descending down-right
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
+ stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2);
+ stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
+ } else if (x3 < x1 && x0 > x2) { // three segments descending down-left
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
+ stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1);
+ stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
+ } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
+ stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
+ } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
+ stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
+ } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
+ stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
+ } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
+ stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
+ } else { // one segment
+ stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3);
+ }
+ }
+ }
+ }
+ e = e->next;
+ }
+}
+
+// directly AA rasterize edges w/o supersampling
+static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
+{
+ stbtt__hheap hh = { 0, 0, 0 };
+ stbtt__active_edge *active = NULL;
+ int y,j=0, i;
+ float scanline_data[129], *scanline, *scanline2;
+
+ STBTT__NOTUSED(vsubsample);
+
+ if (result->w > 64)
+ scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata);
+ else
+ scanline = scanline_data;
+
+ scanline2 = scanline + result->w;
+
+ y = off_y;
+ e[n].y0 = (float) (off_y + result->h) + 1;
+
+ while (j < result->h) {
+ // find center of pixel for this scanline
+ float scan_y_top = y + 0.0f;
+ float scan_y_bottom = y + 1.0f;
+ stbtt__active_edge **step = &active;
+
+ STBTT_memset(scanline , 0, result->w*sizeof(scanline[0]));
+ STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0]));
+
+ // update all active edges;
+ // remove all active edges that terminate before the top of this scanline
+ while (*step) {
+ stbtt__active_edge * z = *step;
+ if (z->ey <= scan_y_top) {
+ *step = z->next; // delete from list
+ STBTT_assert(z->direction);
+ z->direction = 0;
+ stbtt__hheap_free(&hh, z);
+ } else {
+ step = &((*step)->next); // advance through list
+ }
+ }
+
+ // insert all edges that start before the bottom of this scanline
+ while (e->y0 <= scan_y_bottom) {
+ if (e->y0 != e->y1) {
+ stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
+ if (z != NULL) {
+ STBTT_assert(z->ey >= scan_y_top);
+ // insert at front
+ z->next = active;
+ active = z;
+ }
+ }
+ ++e;
+ }
+
+ // now process all active edges
+ if (active)
+ stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
+
+ {
+ float sum = 0;
+ for (i=0; i < result->w; ++i) {
+ float k;
+ int m;
+ sum += scanline2[i];
+ k = scanline[i] + sum;
+ k = (float) STBTT_fabs(k)*255 + 0.5f;
+ m = (int) k;
+ if (m > 255) m = 255;
+ result->pixels[j*result->stride + i] = (unsigned char) m;
+ }
+ }
+ // advance all the edges
+ step = &active;
+ while (*step) {
+ stbtt__active_edge *z = *step;
+ z->fx += z->fdx; // advance to position for current scanline
+ step = &((*step)->next); // advance through list
+ }
+
+ ++y;
+ ++j;
+ }
+
+ stbtt__hheap_cleanup(&hh, userdata);
+
+ if (scanline != scanline_data)
+ STBTT_free(scanline, userdata);
+}
+#else
+#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
+#endif
+
+#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0)
+
+static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n)
+{
+ int i,j;
+ for (i=1; i < n; ++i) {
+ stbtt__edge t = p[i], *a = &t;
+ j = i;
+ while (j > 0) {
+ stbtt__edge *b = &p[j-1];
+ int c = STBTT__COMPARE(a,b);
+ if (!c) break;
+ p[j] = p[j-1];
+ --j;
+ }
+ if (i != j)
+ p[j] = t;
+ }
+}
+
+static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
+{
+ /* threshhold for transitioning to insertion sort */
+ while (n > 12) {
+ stbtt__edge t;
+ int c01,c12,c,m,i,j;
+
+ /* compute median of three */
+ m = n >> 1;
+ c01 = STBTT__COMPARE(&p[0],&p[m]);
+ c12 = STBTT__COMPARE(&p[m],&p[n-1]);
+ /* if 0 >= mid >= end, or 0 < mid < end, then use mid */
+ if (c01 != c12) {
+ /* otherwise, we'll need to swap something else to middle */
+ int z;
+ c = STBTT__COMPARE(&p[0],&p[n-1]);
+ /* 0>mid && mid<n: 0>n => n; 0<n => 0 */
+ /* 0<mid && mid>n: 0>n => 0; 0<n => n */
+ z = (c == c12) ? 0 : n-1;
+ t = p[z];
+ p[z] = p[m];
+ p[m] = t;
+ }
+ /* now p[m] is the median-of-three */
+ /* swap it to the beginning so it won't move around */
+ t = p[0];
+ p[0] = p[m];
+ p[m] = t;
+
+ /* partition loop */
+ i=1;
+ j=n-1;
+ for(;;) {
+ /* handling of equality is crucial here */
+ /* for sentinels & efficiency with duplicates */
+ for (;;++i) {
+ if (!STBTT__COMPARE(&p[i], &p[0])) break;
+ }
+ for (;;--j) {
+ if (!STBTT__COMPARE(&p[0], &p[j])) break;
+ }
+ /* make sure we haven't crossed */
+ if (i >= j) break;
+ t = p[i];
+ p[i] = p[j];
+ p[j] = t;
+
+ ++i;
+ --j;
+ }
+ /* recurse on smaller side, iterate on larger */
+ if (j < (n-i)) {
+ stbtt__sort_edges_quicksort(p,j);
+ p = p+i;
+ n = n-i;
+ } else {
+ stbtt__sort_edges_quicksort(p+i, n-i);
+ n = j;
+ }
+ }
+}
+
+static void stbtt__sort_edges(stbtt__edge *p, int n)
+{
+ stbtt__sort_edges_quicksort(p, n);
+ stbtt__sort_edges_ins_sort(p, n);
+}
+
+typedef struct
+{
+ float x,y;
+} stbtt__point;
+
+static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata)
+{
+ float y_scale_inv = invert ? -scale_y : scale_y;
+ stbtt__edge *e;
+ int n,i,j,k,m;
+#if STBTT_RASTERIZER_VERSION == 1
+ int vsubsample = result->h < 8 ? 15 : 5;
+#elif STBTT_RASTERIZER_VERSION == 2
+ int vsubsample = 1;
+#else
+ #error "Unrecognized value of STBTT_RASTERIZER_VERSION"
+#endif
+ // vsubsample should divide 255 evenly; otherwise we won't reach full opacity
+
+ // now we have to blow out the windings into explicit edge lists
+ n = 0;
+ for (i=0; i < windings; ++i)
+ n += wcount[i];
+
+ e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel
+ if (e == 0) return;
+ n = 0;
+
+ m=0;
+ for (i=0; i < windings; ++i) {
+ stbtt__point *p = pts + m;
+ m += wcount[i];
+ j = wcount[i]-1;
+ for (k=0; k < wcount[i]; j=k++) {
+ int a=k,b=j;
+ // skip the edge if horizontal
+ if (p[j].y == p[k].y)
+ continue;
+ // add edge from j to k to the list
+ e[n].invert = 0;
+ if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
+ e[n].invert = 1;
+ a=j,b=k;
+ }
+ e[n].x0 = p[a].x * scale_x + shift_x;
+ e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample;
+ e[n].x1 = p[b].x * scale_x + shift_x;
+ e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample;
+ ++n;
+ }
+ }
+
+ // now sort the edges by their highest point (should snap to integer, and then by x)
+ //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare);
+ stbtt__sort_edges(e, n);
+
+ // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule
+ stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata);
+
+ STBTT_free(e, userdata);
+}
+
+static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
+{
+ if (!points) return; // during first pass, it's unallocated
+ points[n].x = x;
+ points[n].y = y;
+}
+
+// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching
+static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
+{
+ // midpoint
+ float mx = (x0 + 2*x1 + x2)/4;
+ float my = (y0 + 2*y1 + y2)/4;
+ // versus directly drawn line
+ float dx = (x0+x2)/2 - mx;
+ float dy = (y0+y2)/2 - my;
+ if (n > 16) // 65536 segments on one curve better be enough!
+ return 1;
+ if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA
+ stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
+ stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
+ } else {
+ stbtt__add_point(points, *num_points,x2,y2);
+ *num_points = *num_points+1;
+ }
+ return 1;
+}
+
+static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n)
+{
+ // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough
+ float dx0 = x1-x0;
+ float dy0 = y1-y0;
+ float dx1 = x2-x1;
+ float dy1 = y2-y1;
+ float dx2 = x3-x2;
+ float dy2 = y3-y2;
+ float dx = x3-x0;
+ float dy = y3-y0;
+ float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2));
+ float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy);
+ float flatness_squared = longlen*longlen-shortlen*shortlen;
+
+ if (n > 16) // 65536 segments on one curve better be enough!
+ return;
+
+ if (flatness_squared > objspace_flatness_squared) {
+ float x01 = (x0+x1)/2;
+ float y01 = (y0+y1)/2;
+ float x12 = (x1+x2)/2;
+ float y12 = (y1+y2)/2;
+ float x23 = (x2+x3)/2;
+ float y23 = (y2+y3)/2;
+
+ float xa = (x01+x12)/2;
+ float ya = (y01+y12)/2;
+ float xb = (x12+x23)/2;
+ float yb = (y12+y23)/2;
+
+ float mx = (xa+xb)/2;
+ float my = (ya+yb)/2;
+
+ stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1);
+ stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1);
+ } else {
+ stbtt__add_point(points, *num_points,x3,y3);
+ *num_points = *num_points+1;
+ }
+}
+
+// returns number of contours
+static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
+{
+ stbtt__point *points=0;
+ int num_points=0;
+
+ float objspace_flatness_squared = objspace_flatness * objspace_flatness;
+ int i,n=0,start=0, pass;
+
+ // count how many "moves" there are to get the contour count
+ for (i=0; i < num_verts; ++i)
+ if (vertices[i].type == STBTT_vmove)
+ ++n;
+
+ *num_contours = n;
+ if (n == 0) return 0;
+
+ *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata);
+
+ if (*contour_lengths == 0) {
+ *num_contours = 0;
+ return 0;
+ }
+
+ // make two passes through the points so we don't need to realloc
+ for (pass=0; pass < 2; ++pass) {
+ float x=0,y=0;
+ if (pass == 1) {
+ points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata);
+ if (points == NULL) goto error;
+ }
+ num_points = 0;
+ n= -1;
+ for (i=0; i < num_verts; ++i) {
+ switch (vertices[i].type) {
+ case STBTT_vmove:
+ // start the next contour
+ if (n >= 0)
+ (*contour_lengths)[n] = num_points - start;
+ ++n;
+ start = num_points;
+
+ x = vertices[i].x, y = vertices[i].y;
+ stbtt__add_point(points, num_points++, x,y);
+ break;
+ case STBTT_vline:
+ x = vertices[i].x, y = vertices[i].y;
+ stbtt__add_point(points, num_points++, x, y);
+ break;
+ case STBTT_vcurve:
+ stbtt__tesselate_curve(points, &num_points, x,y,
+ vertices[i].cx, vertices[i].cy,
+ vertices[i].x, vertices[i].y,
+ objspace_flatness_squared, 0);
+ x = vertices[i].x, y = vertices[i].y;
+ break;
+ case STBTT_vcubic:
+ stbtt__tesselate_cubic(points, &num_points, x,y,
+ vertices[i].cx, vertices[i].cy,
+ vertices[i].cx1, vertices[i].cy1,
+ vertices[i].x, vertices[i].y,
+ objspace_flatness_squared, 0);
+ x = vertices[i].x, y = vertices[i].y;
+ break;
+ }
+ }
+ (*contour_lengths)[n] = num_points - start;
+ }
+
+ return points;
+error:
+ STBTT_free(points, userdata);
+ STBTT_free(*contour_lengths, userdata);
+ *contour_lengths = 0;
+ *num_contours = 0;
+ return NULL;
+}
+
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
+{
+ float scale = scale_x > scale_y ? scale_y : scale_x;
+ int winding_count = 0;
+ int *winding_lengths = NULL;
+ stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata);
+ if (windings) {
+ stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata);
+ STBTT_free(winding_lengths, userdata);
+ STBTT_free(windings, userdata);
+ }
+}
+
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
+{
+ STBTT_free(bitmap, userdata);
+}
+
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
+{
+ int ix0,iy0,ix1,iy1;
+ stbtt__bitmap gbm;
+ stbtt_vertex *vertices;
+ int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
+
+ if (scale_x == 0) scale_x = scale_y;
+ if (scale_y == 0) {
+ if (scale_x == 0) {
+ STBTT_free(vertices, info->userdata);
+ return NULL;
+ }
+ scale_y = scale_x;
+ }
+
+ stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1);
+
+ // now we get the size
+ gbm.w = (ix1 - ix0);
+ gbm.h = (iy1 - iy0);
+ gbm.pixels = NULL; // in case we error
+
+ if (width ) *width = gbm.w;
+ if (height) *height = gbm.h;
+ if (xoff ) *xoff = ix0;
+ if (yoff ) *yoff = iy0;
+
+ if (gbm.w && gbm.h) {
+ gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata);
+ if (gbm.pixels) {
+ gbm.stride = gbm.w;
+
+ stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata);
+ }
+ }
+ STBTT_free(vertices, info->userdata);
+ return gbm.pixels;
+}
+
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
+{
+ return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
+}
+
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
+{
+ int ix0,iy0;
+ stbtt_vertex *vertices;
+ int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
+ stbtt__bitmap gbm;
+
+ stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0);
+ gbm.pixels = output;
+ gbm.w = out_w;
+ gbm.h = out_h;
+ gbm.stride = out_stride;
+
+ if (gbm.w && gbm.h)
+ stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata);
+
+ STBTT_free(vertices, info->userdata);
+}
+
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
+{
+ stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
+}
+
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
+{
+ return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
+}
+
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint)
+{
+ stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint));
+}
+
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
+{
+ stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
+}
+
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
+{
+ return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
+}
+
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
+{
+ stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// bitmap baking
+//
+// This is SUPER-CRAPPY packing to keep source code small
+
+static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
+ float pixel_height, // height of font in pixels
+ unsigned char *pixels, int pw, int ph, // bitmap to be filled in
+ int first_char, int num_chars, // characters to bake
+ stbtt_bakedchar *chardata)
+{
+ float scale;
+ int x,y,bottom_y, i;
+ stbtt_fontinfo f;
+ f.userdata = NULL;
+ if (!stbtt_InitFont(&f, data, offset))
+ return -1;
+ STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
+ x=y=1;
+ bottom_y = 1;
+
+ scale = stbtt_ScaleForPixelHeight(&f, pixel_height);
+
+ for (i=0; i < num_chars; ++i) {
+ int advance, lsb, x0,y0,x1,y1,gw,gh;
+ int g = stbtt_FindGlyphIndex(&f, first_char + i);
+ stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb);
+ stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1);
+ gw = x1-x0;
+ gh = y1-y0;
+ if (x + gw + 1 >= pw)
+ y = bottom_y, x = 1; // advance to next row
+ if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row
+ return -i;
+ STBTT_assert(x+gw < pw);
+ STBTT_assert(y+gh < ph);
+ stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g);
+ chardata[i].x0 = (stbtt_int16) x;
+ chardata[i].y0 = (stbtt_int16) y;
+ chardata[i].x1 = (stbtt_int16) (x + gw);
+ chardata[i].y1 = (stbtt_int16) (y + gh);
+ chardata[i].xadvance = scale * advance;
+ chardata[i].xoff = (float) x0;
+ chardata[i].yoff = (float) y0;
+ x = x + gw + 1;
+ if (y+gh+1 > bottom_y)
+ bottom_y = y+gh+1;
+ }
+ return bottom_y;
+}
+
+STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
+{
+ float d3d_bias = opengl_fillrule ? 0 : -0.5f;
+ float ipw = 1.0f / pw, iph = 1.0f / ph;
+ const stbtt_bakedchar *b = chardata + char_index;
+ int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f);
+ int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f);
+
+ q->x0 = round_x + d3d_bias;
+ q->y0 = round_y + d3d_bias;
+ q->x1 = round_x + b->x1 - b->x0 + d3d_bias;
+ q->y1 = round_y + b->y1 - b->y0 + d3d_bias;
+
+ q->s0 = b->x0 * ipw;
+ q->t0 = b->y0 * iph;
+ q->s1 = b->x1 * ipw;
+ q->t1 = b->y1 * iph;
+
+ *xpos += b->xadvance;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// rectangle packing replacement routines if you don't have stb_rect_pack.h
+//
+
+#ifndef STB_RECT_PACK_VERSION
+
+typedef int stbrp_coord;
+
+////////////////////////////////////////////////////////////////////////////////////
+// //
+// //
+// COMPILER WARNING ?!?!? //
+// //
+// //
+// if you get a compile warning due to these symbols being defined more than //
+// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" //
+// //
+////////////////////////////////////////////////////////////////////////////////////
+
+typedef struct
+{
+ int width,height;
+ int x,y,bottom_y;
+} stbrp_context;
+
+typedef struct
+{
+ unsigned char x;
+} stbrp_node;
+
+struct stbrp_rect
+{
+ stbrp_coord x,y;
+ int id,w,h,was_packed;
+};
+
+static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
+{
+ con->width = pw;
+ con->height = ph;
+ con->x = 0;
+ con->y = 0;
+ con->bottom_y = 0;
+ STBTT__NOTUSED(nodes);
+ STBTT__NOTUSED(num_nodes);
+}
+
+static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects)
+{
+ int i;
+ for (i=0; i < num_rects; ++i) {
+ if (con->x + rects[i].w > con->width) {
+ con->x = 0;
+ con->y = con->bottom_y;
+ }
+ if (con->y + rects[i].h > con->height)
+ break;
+ rects[i].x = con->x;
+ rects[i].y = con->y;
+ rects[i].was_packed = 1;
+ con->x += rects[i].w;
+ if (con->y + rects[i].h > con->bottom_y)
+ con->bottom_y = con->y + rects[i].h;
+ }
+ for ( ; i < num_rects; ++i)
+ rects[i].was_packed = 0;
+}
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// bitmap baking
+//
+// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
+// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
+
+STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
+{
+ stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context);
+ int num_nodes = pw - padding;
+ stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context);
+
+ if (context == NULL || nodes == NULL) {
+ if (context != NULL) STBTT_free(context, alloc_context);
+ if (nodes != NULL) STBTT_free(nodes , alloc_context);
+ return 0;
+ }
+
+ spc->user_allocator_context = alloc_context;
+ spc->width = pw;
+ spc->height = ph;
+ spc->pixels = pixels;
+ spc->pack_info = context;
+ spc->nodes = nodes;
+ spc->padding = padding;
+ spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
+ spc->h_oversample = 1;
+ spc->v_oversample = 1;
+
+ stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
+
+ if (pixels)
+ STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
+
+ return 1;
+}
+
+STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc)
+{
+ STBTT_free(spc->nodes , spc->user_allocator_context);
+ STBTT_free(spc->pack_info, spc->user_allocator_context);
+}
+
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
+{
+ STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
+ STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
+ if (h_oversample <= STBTT_MAX_OVERSAMPLE)
+ spc->h_oversample = h_oversample;
+ if (v_oversample <= STBTT_MAX_OVERSAMPLE)
+ spc->v_oversample = v_oversample;
+}
+
+#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
+
+static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
+{
+ unsigned char buffer[STBTT_MAX_OVERSAMPLE];
+ int safe_w = w - kernel_width;
+ int j;
+ STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
+ for (j=0; j < h; ++j) {
+ int i;
+ unsigned int total;
+ STBTT_memset(buffer, 0, kernel_width);
+
+ total = 0;
+
+ // make kernel_width a constant in common cases so compiler can optimize out the divide
+ switch (kernel_width) {
+ case 2:
+ for (i=0; i <= safe_w; ++i) {
+ total += pixels[i] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
+ pixels[i] = (unsigned char) (total / 2);
+ }
+ break;
+ case 3:
+ for (i=0; i <= safe_w; ++i) {
+ total += pixels[i] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
+ pixels[i] = (unsigned char) (total / 3);
+ }
+ break;
+ case 4:
+ for (i=0; i <= safe_w; ++i) {
+ total += pixels[i] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
+ pixels[i] = (unsigned char) (total / 4);
+ }
+ break;
+ case 5:
+ for (i=0; i <= safe_w; ++i) {
+ total += pixels[i] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
+ pixels[i] = (unsigned char) (total / 5);
+ }
+ break;
+ default:
+ for (i=0; i <= safe_w; ++i) {
+ total += pixels[i] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
+ pixels[i] = (unsigned char) (total / kernel_width);
+ }
+ break;
+ }
+
+ for (; i < w; ++i) {
+ STBTT_assert(pixels[i] == 0);
+ total -= buffer[i & STBTT__OVER_MASK];
+ pixels[i] = (unsigned char) (total / kernel_width);
+ }
+
+ pixels += stride_in_bytes;
+ }
+}
+
+static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
+{
+ unsigned char buffer[STBTT_MAX_OVERSAMPLE];
+ int safe_h = h - kernel_width;
+ int j;
+ STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
+ for (j=0; j < w; ++j) {
+ int i;
+ unsigned int total;
+ STBTT_memset(buffer, 0, kernel_width);
+
+ total = 0;
+
+ // make kernel_width a constant in common cases so compiler can optimize out the divide
+ switch (kernel_width) {
+ case 2:
+ for (i=0; i <= safe_h; ++i) {
+ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
+ pixels[i*stride_in_bytes] = (unsigned char) (total / 2);
+ }
+ break;
+ case 3:
+ for (i=0; i <= safe_h; ++i) {
+ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
+ pixels[i*stride_in_bytes] = (unsigned char) (total / 3);
+ }
+ break;
+ case 4:
+ for (i=0; i <= safe_h; ++i) {
+ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
+ pixels[i*stride_in_bytes] = (unsigned char) (total / 4);
+ }
+ break;
+ case 5:
+ for (i=0; i <= safe_h; ++i) {
+ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
+ pixels[i*stride_in_bytes] = (unsigned char) (total / 5);
+ }
+ break;
+ default:
+ for (i=0; i <= safe_h; ++i) {
+ total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
+ buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
+ pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
+ }
+ break;
+ }
+
+ for (; i < h; ++i) {
+ STBTT_assert(pixels[i*stride_in_bytes] == 0);
+ total -= buffer[i & STBTT__OVER_MASK];
+ pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
+ }
+
+ pixels += 1;
+ }
+}
+
+static float stbtt__oversample_shift(int oversample)
+{
+ if (!oversample)
+ return 0.0f;
+
+ // The prefilter is a box filter of width "oversample",
+ // which shifts phase by (oversample - 1)/2 pixels in
+ // oversampled space. We want to shift in the opposite
+ // direction to counter this.
+ return (float)-(oversample - 1) / (2.0f * (float)oversample);
+}
+
+// rects array must be big enough to accommodate all characters in the given ranges
+STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
+{
+ int i,j,k;
+
+ k=0;
+ for (i=0; i < num_ranges; ++i) {
+ float fh = ranges[i].font_size;
+ float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
+ ranges[i].h_oversample = (unsigned char) spc->h_oversample;
+ ranges[i].v_oversample = (unsigned char) spc->v_oversample;
+ for (j=0; j < ranges[i].num_chars; ++j) {
+ int x0,y0,x1,y1;
+ int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
+ int glyph = stbtt_FindGlyphIndex(info, codepoint);
+ stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
+ scale * spc->h_oversample,
+ scale * spc->v_oversample,
+ 0,0,
+ &x0,&y0,&x1,&y1);
+ rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
+ rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
+ ++k;
+ }
+ }
+
+ return k;
+}
+
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph)
+{
+ stbtt_MakeGlyphBitmapSubpixel(info,
+ output,
+ out_w - (prefilter_x - 1),
+ out_h - (prefilter_y - 1),
+ out_stride,
+ scale_x,
+ scale_y,
+ shift_x,
+ shift_y,
+ glyph);
+
+ if (prefilter_x > 1)
+ stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x);
+
+ if (prefilter_y > 1)
+ stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y);
+
+ *sub_x = stbtt__oversample_shift(prefilter_x);
+ *sub_y = stbtt__oversample_shift(prefilter_y);
+}
+
+// rects array must be big enough to accommodate all characters in the given ranges
+STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
+{
+ int i,j,k, return_value = 1;
+
+ // save current values
+ int old_h_over = spc->h_oversample;
+ int old_v_over = spc->v_oversample;
+
+ k = 0;
+ for (i=0; i < num_ranges; ++i) {
+ float fh = ranges[i].font_size;
+ float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
+ float recip_h,recip_v,sub_x,sub_y;
+ spc->h_oversample = ranges[i].h_oversample;
+ spc->v_oversample = ranges[i].v_oversample;
+ recip_h = 1.0f / spc->h_oversample;
+ recip_v = 1.0f / spc->v_oversample;
+ sub_x = stbtt__oversample_shift(spc->h_oversample);
+ sub_y = stbtt__oversample_shift(spc->v_oversample);
+ for (j=0; j < ranges[i].num_chars; ++j) {
+ stbrp_rect *r = &rects[k];
+ if (r->was_packed) {
+ stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
+ int advance, lsb, x0,y0,x1,y1;
+ int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
+ int glyph = stbtt_FindGlyphIndex(info, codepoint);
+ stbrp_coord pad = (stbrp_coord) spc->padding;
+
+ // pad on left and top
+ r->x += pad;
+ r->y += pad;
+ r->w -= pad;
+ r->h -= pad;
+ stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
+ stbtt_GetGlyphBitmapBox(info, glyph,
+ scale * spc->h_oversample,
+ scale * spc->v_oversample,
+ &x0,&y0,&x1,&y1);
+ stbtt_MakeGlyphBitmapSubpixel(info,
+ spc->pixels + r->x + r->y*spc->stride_in_bytes,
+ r->w - spc->h_oversample+1,
+ r->h - spc->v_oversample+1,
+ spc->stride_in_bytes,
+ scale * spc->h_oversample,
+ scale * spc->v_oversample,
+ 0,0,
+ glyph);
+
+ if (spc->h_oversample > 1)
+ stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
+ r->w, r->h, spc->stride_in_bytes,
+ spc->h_oversample);
+
+ if (spc->v_oversample > 1)
+ stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
+ r->w, r->h, spc->stride_in_bytes,
+ spc->v_oversample);
+
+ bc->x0 = (stbtt_int16) r->x;
+ bc->y0 = (stbtt_int16) r->y;
+ bc->x1 = (stbtt_int16) (r->x + r->w);
+ bc->y1 = (stbtt_int16) (r->y + r->h);
+ bc->xadvance = scale * advance;
+ bc->xoff = (float) x0 * recip_h + sub_x;
+ bc->yoff = (float) y0 * recip_v + sub_y;
+ bc->xoff2 = (x0 + r->w) * recip_h + sub_x;
+ bc->yoff2 = (y0 + r->h) * recip_v + sub_y;
+ } else {
+ return_value = 0; // if any fail, report failure
+ }
+
+ ++k;
+ }
+ }
+
+ // restore original values
+ spc->h_oversample = old_h_over;
+ spc->v_oversample = old_v_over;
+
+ return return_value;
+}
+
+STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects)
+{
+ stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects);
+}
+
+STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
+{
+ stbtt_fontinfo info;
+ int i,j,n, return_value = 1;
+ //stbrp_context *context = (stbrp_context *) spc->pack_info;
+ stbrp_rect *rects;
+
+ // flag all characters as NOT packed
+ for (i=0; i < num_ranges; ++i)
+ for (j=0; j < ranges[i].num_chars; ++j)
+ ranges[i].chardata_for_range[j].x0 =
+ ranges[i].chardata_for_range[j].y0 =
+ ranges[i].chardata_for_range[j].x1 =
+ ranges[i].chardata_for_range[j].y1 = 0;
+
+ n = 0;
+ for (i=0; i < num_ranges; ++i)
+ n += ranges[i].num_chars;
+
+ rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
+ if (rects == NULL)
+ return 0;
+
+ info.userdata = spc->user_allocator_context;
+ stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index));
+
+ n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects);
+
+ stbtt_PackFontRangesPackRects(spc, rects, n);
+
+ return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects);
+
+ STBTT_free(rects, spc->user_allocator_context);
+ return return_value;
+}
+
+STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
+ int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
+{
+ stbtt_pack_range range;
+ range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range;
+ range.array_of_unicode_codepoints = NULL;
+ range.num_chars = num_chars_in_range;
+ range.chardata_for_range = chardata_for_range;
+ range.font_size = font_size;
+ return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
+}
+
+STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
+{
+ float ipw = 1.0f / pw, iph = 1.0f / ph;
+ const stbtt_packedchar *b = chardata + char_index;
+
+ if (align_to_integer) {
+ float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f);
+ float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f);
+ q->x0 = x;
+ q->y0 = y;
+ q->x1 = x + b->xoff2 - b->xoff;
+ q->y1 = y + b->yoff2 - b->yoff;
+ } else {
+ q->x0 = *xpos + b->xoff;
+ q->y0 = *ypos + b->yoff;
+ q->x1 = *xpos + b->xoff2;
+ q->y1 = *ypos + b->yoff2;
+ }
+
+ q->s0 = b->x0 * ipw;
+ q->t0 = b->y0 * iph;
+ q->s1 = b->x1 * ipw;
+ q->t1 = b->y1 * iph;
+
+ *xpos += b->xadvance;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// sdf computation
+//
+
+#define STBTT_min(a,b) ((a) < (b) ? (a) : (b))
+#define STBTT_max(a,b) ((a) < (b) ? (b) : (a))
+
+static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2])
+{
+ float q0perp = q0[1]*ray[0] - q0[0]*ray[1];
+ float q1perp = q1[1]*ray[0] - q1[0]*ray[1];
+ float q2perp = q2[1]*ray[0] - q2[0]*ray[1];
+ float roperp = orig[1]*ray[0] - orig[0]*ray[1];
+
+ float a = q0perp - 2*q1perp + q2perp;
+ float b = q1perp - q0perp;
+ float c = q0perp - roperp;
+
+ float s0 = 0., s1 = 0.;
+ int num_s = 0;
+
+ if (a != 0.0) {
+ float discr = b*b - a*c;
+ if (discr > 0.0) {
+ float rcpna = -1 / a;
+ float d = (float) STBTT_sqrt(discr);
+ s0 = (b+d) * rcpna;
+ s1 = (b-d) * rcpna;
+ if (s0 >= 0.0 && s0 <= 1.0)
+ num_s = 1;
+ if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) {
+ if (num_s == 0) s0 = s1;
+ ++num_s;
+ }
+ }
+ } else {
+ // 2*b*s + c = 0
+ // s = -c / (2*b)
+ s0 = c / (-2 * b);
+ if (s0 >= 0.0 && s0 <= 1.0)
+ num_s = 1;
+ }
+
+ if (num_s == 0)
+ return 0;
+ else {
+ float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]);
+ float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2;
+
+ float q0d = q0[0]*rayn_x + q0[1]*rayn_y;
+ float q1d = q1[0]*rayn_x + q1[1]*rayn_y;
+ float q2d = q2[0]*rayn_x + q2[1]*rayn_y;
+ float rod = orig[0]*rayn_x + orig[1]*rayn_y;
+
+ float q10d = q1d - q0d;
+ float q20d = q2d - q0d;
+ float q0rd = q0d - rod;
+
+ hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d;
+ hits[0][1] = a*s0+b;
+
+ if (num_s > 1) {
+ hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d;
+ hits[1][1] = a*s1+b;
+ return 2;
+ } else {
+ return 1;
+ }
+ }
+}
+
+static int equal(float *a, float *b)
+{
+ return (a[0] == b[0] && a[1] == b[1]);
+}
+
+static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts)
+{
+ int i;
+ float orig[2], ray[2] = { 1, 0 };
+ float y_frac;
+ int winding = 0;
+
+ orig[0] = x;
+ orig[1] = y;
+
+ // make sure y never passes through a vertex of the shape
+ y_frac = (float) STBTT_fmod(y, 1.0f);
+ if (y_frac < 0.01f)
+ y += 0.01f;
+ else if (y_frac > 0.99f)
+ y -= 0.01f;
+ orig[1] = y;
+
+ // test a ray from (-infinity,y) to (x,y)
+ for (i=0; i < nverts; ++i) {
+ if (verts[i].type == STBTT_vline) {
+ int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y;
+ int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y;
+ if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
+ float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
+ if (x_inter < x)
+ winding += (y0 < y1) ? 1 : -1;
+ }
+ }
+ if (verts[i].type == STBTT_vcurve) {
+ int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ;
+ int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy;
+ int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ;
+ int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2));
+ int by = STBTT_max(y0,STBTT_max(y1,y2));
+ if (y > ay && y < by && x > ax) {
+ float q0[2],q1[2],q2[2];
+ float hits[2][2];
+ q0[0] = (float)x0;
+ q0[1] = (float)y0;
+ q1[0] = (float)x1;
+ q1[1] = (float)y1;
+ q2[0] = (float)x2;
+ q2[1] = (float)y2;
+ if (equal(q0,q1) || equal(q1,q2)) {
+ x0 = (int)verts[i-1].x;
+ y0 = (int)verts[i-1].y;
+ x1 = (int)verts[i ].x;
+ y1 = (int)verts[i ].y;
+ if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
+ float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
+ if (x_inter < x)
+ winding += (y0 < y1) ? 1 : -1;
+ }
+ } else {
+ int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits);
+ if (num_hits >= 1)
+ if (hits[0][0] < 0)
+ winding += (hits[0][1] < 0 ? -1 : 1);
+ if (num_hits >= 2)
+ if (hits[1][0] < 0)
+ winding += (hits[1][1] < 0 ? -1 : 1);
+ }
+ }
+ }
+ }
+ return winding;
+}
+
+static float stbtt__cuberoot( float x )
+{
+ if (x<0)
+ return -(float) STBTT_pow(-x,1.0f/3.0f);
+ else
+ return (float) STBTT_pow( x,1.0f/3.0f);
+}
+
+// x^3 + c*x^2 + b*x + a = 0
+static int stbtt__solve_cubic(float a, float b, float c, float* r)
+{
+ float s = -a / 3;
+ float p = b - a*a / 3;
+ float q = a * (2*a*a - 9*b) / 27 + c;
+ float p3 = p*p*p;
+ float d = q*q + 4*p3 / 27;
+ if (d >= 0) {
+ float z = (float) STBTT_sqrt(d);
+ float u = (-q + z) / 2;
+ float v = (-q - z) / 2;
+ u = stbtt__cuberoot(u);
+ v = stbtt__cuberoot(v);
+ r[0] = s + u + v;
+ return 1;
+ } else {
+ float u = (float) STBTT_sqrt(-p/3);
+ float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative
+ float m = (float) STBTT_cos(v);
+ float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f;
+ r[0] = s + u * 2 * m;
+ r[1] = s - u * (m + n);
+ r[2] = s - u * (m - n);
+
+ //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe?
+ //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f);
+ //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f);
+ return 3;
+ }
+}
+
+STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
+{
+ float scale_x = scale, scale_y = scale;
+ int ix0,iy0,ix1,iy1;
+ int w,h;
+ unsigned char *data;
+
+ // if one scale is 0, use same scale for both
+ if (scale_x == 0) scale_x = scale_y;
+ if (scale_y == 0) {
+ if (scale_x == 0) return NULL; // if both scales are 0, return NULL
+ scale_y = scale_x;
+ }
+
+ stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1);
+
+ // if empty, return NULL
+ if (ix0 == ix1 || iy0 == iy1)
+ return NULL;
+
+ ix0 -= padding;
+ iy0 -= padding;
+ ix1 += padding;
+ iy1 += padding;
+
+ w = (ix1 - ix0);
+ h = (iy1 - iy0);
+
+ if (width ) *width = w;
+ if (height) *height = h;
+ if (xoff ) *xoff = ix0;
+ if (yoff ) *yoff = iy0;
+
+ // invert for y-downwards bitmaps
+ scale_y = -scale_y;
+
+ {
+ int x,y,i,j;
+ float *precompute;
+ stbtt_vertex *verts;
+ int num_verts = stbtt_GetGlyphShape(info, glyph, &verts);
+ data = (unsigned char *) STBTT_malloc(w * h, info->userdata);
+ precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata);
+
+ for (i=0,j=num_verts-1; i < num_verts; j=i++) {
+ if (verts[i].type == STBTT_vline) {
+ float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
+ float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y;
+ float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
+ precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist;
+ } else if (verts[i].type == STBTT_vcurve) {
+ float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y;
+ float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y;
+ float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y;
+ float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
+ float len2 = bx*bx + by*by;
+ if (len2 != 0.0f)
+ precompute[i] = 1.0f / (bx*bx + by*by);
+ else
+ precompute[i] = 0.0f;
+ } else
+ precompute[i] = 0.0f;
+ }
+
+ for (y=iy0; y < iy1; ++y) {
+ for (x=ix0; x < ix1; ++x) {
+ float val;
+ float min_dist = 999999.0f;
+ float sx = (float) x + 0.5f;
+ float sy = (float) y + 0.5f;
+ float x_gspace = (sx / scale_x);
+ float y_gspace = (sy / scale_y);
+
+ int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path
+
+ for (i=0; i < num_verts; ++i) {
+ float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
+
+ // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve
+ float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy);
+ if (dist2 < min_dist*min_dist)
+ min_dist = (float) STBTT_sqrt(dist2);
+
+ if (verts[i].type == STBTT_vline) {
+ float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y;
+
+ // coarse culling against bbox
+ //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist &&
+ // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist)
+ float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i];
+ STBTT_assert(i != 0);
+ if (dist < min_dist) {
+ // check position along line
+ // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0)
+ // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy)
+ float dx = x1-x0, dy = y1-y0;
+ float px = x0-sx, py = y0-sy;
+ // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy
+ // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve
+ float t = -(px*dx + py*dy) / (dx*dx + dy*dy);
+ if (t >= 0.0f && t <= 1.0f)
+ min_dist = dist;
+ }
+ } else if (verts[i].type == STBTT_vcurve) {
+ float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y;
+ float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y;
+ float box_x0 = STBTT_min(STBTT_min(x0,x1),x2);
+ float box_y0 = STBTT_min(STBTT_min(y0,y1),y2);
+ float box_x1 = STBTT_max(STBTT_max(x0,x1),x2);
+ float box_y1 = STBTT_max(STBTT_max(y0,y1),y2);
+ // coarse culling against bbox to avoid computing cubic unnecessarily
+ if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) {
+ int num=0;
+ float ax = x1-x0, ay = y1-y0;
+ float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
+ float mx = x0 - sx, my = y0 - sy;
+ float res[3],px,py,t,it;
+ float a_inv = precompute[i];
+ if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula
+ float a = 3*(ax*bx + ay*by);
+ float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by);
+ float c = mx*ax+my*ay;
+ if (a == 0.0) { // if a is 0, it's linear
+ if (b != 0.0) {
+ res[num++] = -c/b;
+ }
+ } else {
+ float discriminant = b*b - 4*a*c;
+ if (discriminant < 0)
+ num = 0;
+ else {
+ float root = (float) STBTT_sqrt(discriminant);
+ res[0] = (-b - root)/(2*a);
+ res[1] = (-b + root)/(2*a);
+ num = 2; // don't bother distinguishing 1-solution case, as code below will still work
+ }
+ }
+ } else {
+ float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point
+ float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv;
+ float d = (mx*ax+my*ay) * a_inv;
+ num = stbtt__solve_cubic(b, c, d, res);
+ }
+ if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) {
+ t = res[0], it = 1.0f - t;
+ px = it*it*x0 + 2*t*it*x1 + t*t*x2;
+ py = it*it*y0 + 2*t*it*y1 + t*t*y2;
+ dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
+ if (dist2 < min_dist * min_dist)
+ min_dist = (float) STBTT_sqrt(dist2);
+ }
+ if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) {
+ t = res[1], it = 1.0f - t;
+ px = it*it*x0 + 2*t*it*x1 + t*t*x2;
+ py = it*it*y0 + 2*t*it*y1 + t*t*y2;
+ dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
+ if (dist2 < min_dist * min_dist)
+ min_dist = (float) STBTT_sqrt(dist2);
+ }
+ if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) {
+ t = res[2], it = 1.0f - t;
+ px = it*it*x0 + 2*t*it*x1 + t*t*x2;
+ py = it*it*y0 + 2*t*it*y1 + t*t*y2;
+ dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
+ if (dist2 < min_dist * min_dist)
+ min_dist = (float) STBTT_sqrt(dist2);
+ }
+ }
+ }
+ }
+ if (winding == 0)
+ min_dist = -min_dist; // if outside the shape, value is negative
+ val = onedge_value + pixel_dist_scale * min_dist;
+ if (val < 0)
+ val = 0;
+ else if (val > 255)
+ val = 255;
+ data[(y-iy0)*w+(x-ix0)] = (unsigned char) val;
+ }
+ }
+ STBTT_free(precompute, info->userdata);
+ STBTT_free(verts, info->userdata);
+ }
+ return data;
+}
+
+STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
+{
+ return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff);
+}
+
+STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata)
+{
+ STBTT_free(bitmap, userdata);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// font name matching -- recommended not to use this
+//
+
+// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string
+static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
+{
+ stbtt_int32 i=0;
+
+ // convert utf16 to utf8 and compare the results while converting
+ while (len2) {
+ stbtt_uint16 ch = s2[0]*256 + s2[1];
+ if (ch < 0x80) {
+ if (i >= len1) return -1;
+ if (s1[i++] != ch) return -1;
+ } else if (ch < 0x800) {
+ if (i+1 >= len1) return -1;
+ if (s1[i++] != 0xc0 + (ch >> 6)) return -1;
+ if (s1[i++] != 0x80 + (ch & 0x3f)) return -1;
+ } else if (ch >= 0xd800 && ch < 0xdc00) {
+ stbtt_uint32 c;
+ stbtt_uint16 ch2 = s2[2]*256 + s2[3];
+ if (i+3 >= len1) return -1;
+ c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000;
+ if (s1[i++] != 0xf0 + (c >> 18)) return -1;
+ if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1;
+ if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1;
+ if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1;
+ s2 += 2; // plus another 2 below
+ len2 -= 2;
+ } else if (ch >= 0xdc00 && ch < 0xe000) {
+ return -1;
+ } else {
+ if (i+2 >= len1) return -1;
+ if (s1[i++] != 0xe0 + (ch >> 12)) return -1;
+ if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1;
+ if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1;
+ }
+ s2 += 2;
+ len2 -= 2;
+ }
+ return i;
+}
+
+static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2)
+{
+ return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2);
+}
+
+// returns results in whatever encoding you request... but note that 2-byte encodings
+// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
+{
+ stbtt_int32 i,count,stringOffset;
+ stbtt_uint8 *fc = font->data;
+ stbtt_uint32 offset = font->fontstart;
+ stbtt_uint32 nm = stbtt__find_table(fc, offset, "name");
+ if (!nm) return NULL;
+
+ count = ttUSHORT(fc+nm+2);
+ stringOffset = nm + ttUSHORT(fc+nm+4);
+ for (i=0; i < count; ++i) {
+ stbtt_uint32 loc = nm + 6 + 12 * i;
+ if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2)
+ && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) {
+ *length = ttUSHORT(fc+loc+8);
+ return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10));
+ }
+ }
+ return NULL;
+}
+
+static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id)
+{
+ stbtt_int32 i;
+ stbtt_int32 count = ttUSHORT(fc+nm+2);
+ stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4);
+
+ for (i=0; i < count; ++i) {
+ stbtt_uint32 loc = nm + 6 + 12 * i;
+ stbtt_int32 id = ttUSHORT(fc+loc+6);
+ if (id == target_id) {
+ // find the encoding
+ stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4);
+
+ // is this a Unicode encoding?
+ if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) {
+ stbtt_int32 slen = ttUSHORT(fc+loc+8);
+ stbtt_int32 off = ttUSHORT(fc+loc+10);
+
+ // check if there's a prefix match
+ stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen);
+ if (matchlen >= 0) {
+ // check for target_id+1 immediately following, with same encoding & language
+ if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) {
+ slen = ttUSHORT(fc+loc+12+8);
+ off = ttUSHORT(fc+loc+12+10);
+ if (slen == 0) {
+ if (matchlen == nlen)
+ return 1;
+ } else if (matchlen < nlen && name[matchlen] == ' ') {
+ ++matchlen;
+ if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen))
+ return 1;
+ }
+ } else {
+ // if nothing immediately following
+ if (matchlen == nlen)
+ return 1;
+ }
+ }
+ }
+
+ // @TODO handle other encodings
+ }
+ }
+ return 0;
+}
+
+static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags)
+{
+ stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name);
+ stbtt_uint32 nm,hd;
+ if (!stbtt__isfont(fc+offset)) return 0;
+
+ // check italics/bold/underline flags in macStyle...
+ if (flags) {
+ hd = stbtt__find_table(fc, offset, "head");
+ if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0;
+ }
+
+ nm = stbtt__find_table(fc, offset, "name");
+ if (!nm) return 0;
+
+ if (flags) {
+ // if we checked the macStyle flags, then just check the family and ignore the subfamily
+ if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1;
+ if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1;
+ if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1;
+ } else {
+ if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1;
+ if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1;
+ if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1;
+ }
+
+ return 0;
+}
+
+static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags)
+{
+ stbtt_int32 i;
+ for (i=0;;++i) {
+ stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i);
+ if (off < 0) return off;
+ if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags))
+ return off;
+ }
+}
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
+
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,
+ float pixel_height, unsigned char *pixels, int pw, int ph,
+ int first_char, int num_chars, stbtt_bakedchar *chardata)
+{
+ return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata);
+}
+
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
+{
+ return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index);
+}
+
+STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data)
+{
+ return stbtt_GetNumberOfFonts_internal((unsigned char *) data);
+}
+
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset)
+{
+ return stbtt_InitFont_internal(info, (unsigned char *) data, offset);
+}
+
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags)
+{
+ return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags);
+}
+
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2)
+{
+ return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2);
+}
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+
+#endif // STB_TRUETYPE_IMPLEMENTATION
+
+
+// FULL VERSION HISTORY
+//
+// 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod
+// 1.18 (2018-01-29) add missing function
+// 1.17 (2017-07-23) make more arguments const; doc fix
+// 1.16 (2017-07-12) SDF support
+// 1.15 (2017-03-03) make more arguments const
+// 1.14 (2017-01-16) num-fonts-in-TTC function
+// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts
+// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
+// 1.11 (2016-04-02) fix unused-variable warning
+// 1.10 (2016-04-02) allow user-defined fabs() replacement
+// fix memory leak if fontsize=0.0
+// fix warning from duplicate typedef
+// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges
+// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
+// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
+// allow PackFontRanges to pack and render in separate phases;
+// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?);
+// fixed an assert() bug in the new rasterizer
+// replace assert() with STBTT_assert() in new rasterizer
+// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine)
+// also more precise AA rasterizer, except if shapes overlap
+// remove need for STBTT_sort
+// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC
+// 1.04 (2015-04-15) typo in example
+// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes
+// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++
+// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match
+// non-oversampled; STBTT_POINT_SIZE for packed case only
+// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling
+// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg)
+// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID
+// 0.8b (2014-07-07) fix a warning
+// 0.8 (2014-05-25) fix a few more warnings
+// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back
+// 0.6c (2012-07-24) improve documentation
+// 0.6b (2012-07-20) fix a few more warnings
+// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels,
+// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty
+// 0.5 (2011-12-09) bugfixes:
+// subpixel glyph renderer computed wrong bounding box
+// first vertex of shape can be off-curve (FreeSans)
+// 0.4b (2011-12-03) fixed an error in the font baking example
+// 0.4 (2011-12-01) kerning, subpixel rendering (tor)
+// bugfixes for:
+// codepoint-to-glyph conversion using table fmt=12
+// codepoint-to-glyph conversion using table fmt=4
+// stbtt_GetBakedQuad with non-square texture (Zer)
+// updated Hello World! sample to use kerning and subpixel
+// fixed some warnings
+// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM)
+// userdata, malloc-from-userdata, non-zero fill (stb)
+// 0.2 (2009-03-11) Fix unsigned/signed char warnings
+// 0.1 (2009-03-09) First public release
+//
+
+/*
+------------------------------------------------------------------------------
+This software is available under 2 licenses -- choose whichever you prefer.
+------------------------------------------------------------------------------
+ALTERNATIVE A - MIT License
+Copyright (c) 2017 Sean Barrett
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+------------------------------------------------------------------------------
+ALTERNATIVE B - Public Domain (www.unlicense.org)
+This is free and unencumbered software released into the public domain.
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
+software, either in source code form or as a compiled binary, for any purpose,
+commercial or non-commercial, and by any means.
+In jurisdictions that recognize copyright laws, the author or authors of this
+software dedicate any and all copyright interest in the software to the public
+domain. We make this dedication for the benefit of the public at large and to
+the detriment of our heirs and successors. We intend this dedication to be an
+overt act of relinquishment in perpetuity of all present and future rights to
+this software under copyright law.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+------------------------------------------------------------------------------
+*/
diff --git a/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt b/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt
new file mode 100644
index 0000000..cc23e58
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_library(sajson STATIC sajson.cpp sajson.h)
+target_include_directories(sajson PUBLIC ..)
+
+set_target_properties(sajson PROPERTIES
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED YES
+ CXX_EXTENSIONS NO
+)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES sajson.cpp sajson.h)
diff --git a/Client/ThirdParty/Box2D/extern/sajson/sajson.cpp b/Client/ThirdParty/Box2D/extern/sajson/sajson.cpp
new file mode 100644
index 0000000..0a60a35
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/sajson/sajson.cpp
@@ -0,0 +1,2 @@
+// This cpp is here to force cmake to make a project file for sajson.
+int sajson_dummy;
diff --git a/Client/ThirdParty/Box2D/extern/sajson/sajson.h b/Client/ThirdParty/Box2D/extern/sajson/sajson.h
new file mode 100644
index 0000000..b7a816b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/extern/sajson/sajson.h
@@ -0,0 +1,2493 @@
+/*
+ * Copyright (c) 2012-2017 Chad Austin
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#pragma once
+
+#include <assert.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <string.h>
+#include <math.h>
+#include <limits.h>
+#include <algorithm>
+#include <cstdio>
+#include <limits>
+
+#ifndef SAJSON_NO_STD_STRING
+#include <string> // for convenient access to error messages and string values.
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+#define SAJSON_LIKELY(x) __builtin_expect(!!(x), 1)
+#define SAJSON_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#define SAJSON_ALWAYS_INLINE __attribute__((always_inline))
+#define SAJSON_UNREACHABLE() __builtin_unreachable()
+#define SAJSON_snprintf snprintf
+#elif defined(_MSC_VER)
+#define SAJSON_LIKELY(x) x
+#define SAJSON_UNLIKELY(x) x
+#define SAJSON_ALWAYS_INLINE __forceinline
+#define SAJSON_UNREACHABLE() __assume(0)
+#if (_MSC_VER <= 1800)
+#define SAJSON_snprintf _snprintf
+#else
+#define SAJSON_snprintf snprintf
+#endif
+#else
+#define SAJSON_LIKELY(x) x
+#define SAJSON_UNLIKELY(x) x
+#define SAJSON_ALWAYS_INLINE inline
+#define SAJSON_UNREACHABLE() assert(!"unreachable")
+#define SAJSON_snprintf snprintf
+#endif
+
+/**
+ * sajson Public API
+ */
+namespace sajson {
+
+ /// Tag indicating a JSON value's type.
+ enum type: uint8_t {
+ TYPE_INTEGER = 0,
+ TYPE_DOUBLE = 1,
+ TYPE_NULL = 2,
+ TYPE_FALSE = 3,
+ TYPE_TRUE = 4,
+ TYPE_STRING = 5,
+ TYPE_ARRAY = 6,
+ TYPE_OBJECT = 7,
+ };
+
+ namespace internal {
+ static const size_t TYPE_BITS = 3;
+ static const size_t TYPE_MASK = (1 << TYPE_BITS) - 1;
+ static const size_t VALUE_MASK = size_t(-1) >> TYPE_BITS;
+
+ static const size_t ROOT_MARKER = VALUE_MASK;
+
+ inline type get_element_type(size_t s) {
+ return static_cast<type>(s & TYPE_MASK);
+ }
+
+ inline size_t get_element_value(size_t s) {
+ return s >> TYPE_BITS;
+ }
+
+ inline size_t make_element(type t, size_t value) {
+ //assert((value & ~VALUE_MASK) == 0);
+ //value &= VALUE_MASK;
+ return static_cast<size_t>(t) | (value << TYPE_BITS);
+ }
+
+ // This template utilizes the One Definition Rule to create global arrays in a header.
+ // This trick courtesy of Rich Geldreich's Purple JSON parser.
+ template<typename unused=void>
+ struct globals_struct {
+ static const unsigned char parse_flags[256];
+ };
+ typedef globals_struct<> globals;
+
+ // bit 0 (1) - set if: plain ASCII string character
+ // bit 1 (2) - set if: whitespace
+ // bit 4 (0x10) - set if: 0-9 e E .
+ template<typename unused>
+ const uint8_t globals_struct<unused>::parse_flags[256] = {
+ // 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0, // 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
+ 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x11,1, // 2
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, 0x11,0x11,1, 1, 1, 1, 1, 1, // 3
+ 1, 1, 1, 1, 1, 0x11,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 5
+ 1, 1, 1, 1, 1, 0x11,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7
+
+ // 128-255
+ 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
+ };
+
+ inline bool is_plain_string_character(char c) {
+ //return c >= 0x20 && c <= 0x7f && c != 0x22 && c != 0x5c;
+ return (globals::parse_flags[static_cast<unsigned char>(c)] & 1) != 0;
+ }
+
+ inline bool is_whitespace(char c) {
+ //return c == '\r' || c == '\n' || c == '\t' || c == ' ';
+ return (globals::parse_flags[static_cast<unsigned char>(c)] & 2) != 0;
+ }
+
+ class allocated_buffer {
+ public:
+ allocated_buffer()
+ : memory(0)
+ {}
+
+ explicit allocated_buffer(size_t length) {
+ // throws std::bad_alloc upon allocation failure
+ void* buffer = operator new(sizeof(size_t) + length);
+ memory = static_cast<layout*>(buffer);
+ memory->refcount = 1;
+ }
+
+ allocated_buffer(const allocated_buffer& that)
+ : memory(that.memory)
+ {
+ incref();
+ }
+
+ allocated_buffer(allocated_buffer&& that)
+ : memory(that.memory)
+ {
+ that.memory = 0;
+ }
+
+ ~allocated_buffer() {
+ decref();
+ }
+
+ allocated_buffer& operator=(const allocated_buffer& that) {
+ if (this != &that) {
+ decref();
+ memory = that.memory;
+ incref();
+ }
+ return *this;
+ }
+
+ allocated_buffer& operator=(allocated_buffer&& that) {
+ if (this != &that) {
+ decref();
+ memory = that.memory;
+ that.memory = 0;
+ }
+ return *this;
+ }
+
+ char* get_data() const {
+ return memory ? memory->data : 0;
+ }
+
+ private:
+ void incref() const {
+ if (memory) {
+ ++(memory->refcount);
+ }
+ }
+
+ void decref() const {
+ if (memory && --(memory->refcount) == 0) {
+ operator delete(memory);
+ }
+ }
+
+ struct layout {
+ size_t refcount;
+ char data[1];
+ };
+
+ layout* memory;
+ };
+ }
+
+ /// A simple type encoding a pointer to some memory and a length (in bytes).
+ /// Does not maintain any memory.
+ class string {
+ public:
+ string(const char* text_, size_t length)
+ : text(text_)
+ , _length(length)
+ {}
+
+ const char* data() const {
+ return text;
+ }
+
+ size_t length() const {
+ return _length;
+ }
+
+#ifndef SAJSON_NO_STD_STRING
+ std::string as_string() const {
+ return std::string(text, text + _length);
+ }
+#endif
+
+ private:
+ const char* const text;
+ const size_t _length;
+
+ string(); /*=delete*/
+ };
+
+ /// A convenient way to parse JSON from a string literal. The string ends
+ /// at its first NUL character.
+ class literal : public string {
+ public:
+ template <size_t sz>
+ explicit literal(const char (&text_)[sz])
+ : string(text_, sz - 1)
+ {
+ static_assert(sz > 0, "!");
+ }
+ };
+
+ /// A pointer to a mutable buffer, its size in bytes, and strong ownership of any
+ /// copied memory.
+ class mutable_string_view {
+ public:
+ /// Creates an empty, zero-sized view.
+ mutable_string_view()
+ : length_(0)
+ , data(0)
+ , buffer()
+ {}
+
+ /// Given a length in bytes and a pointer, constructs a view
+ /// that does not allocate a copy of the data or maintain its life.
+ /// The given pointer must stay valid for the duration of the parse and the
+ /// resulting \ref document's life.
+ mutable_string_view(size_t length, char* data_)
+ : length_(length)
+ , data(data_)
+ , buffer()
+ {}
+
+ /// Allocates a copy of the given \ref literal string and exposes a
+ /// mutable view into it. Throws std::bad_alloc if allocation fails.
+ mutable_string_view(const literal& s)
+ : length_(s.length())
+ , buffer(length_)
+ {
+ data = buffer.get_data();
+ memcpy(data, s.data(), length_);
+ }
+
+ /// Allocates a copy of the given \ref string and exposes a mutable view
+ /// into it. Throws std::bad_alloc if allocation fails.
+ mutable_string_view(const string& s)
+ : length_(s.length())
+ , buffer(length_)
+ {
+ data = buffer.get_data();
+ memcpy(data, s.data(), length_);
+ }
+
+ /// Copies a mutable_string_view. If any backing memory has been
+ /// allocated, its refcount is incremented - both views can safely
+ /// use the memory.
+ mutable_string_view(const mutable_string_view& that)
+ : length_(that.length_)
+ , data(that.data)
+ , buffer(that.buffer)
+ {}
+
+ /// Move constructor - neuters the old mutable_string_view.
+ mutable_string_view(mutable_string_view&& that)
+ : length_(that.length_)
+ , data(that.data)
+ , buffer(std::move(that.buffer))
+ {
+ that.length_ = 0;
+ that.data = 0;
+ }
+
+ mutable_string_view& operator=(mutable_string_view&& that) {
+ if (this != &that) {
+ length_ = that.length_;
+ data = that.data;
+ buffer = std::move(that.buffer);
+ that.length_ = 0;
+ that.data = 0;
+ }
+ return *this;
+ }
+
+ mutable_string_view& operator=(const mutable_string_view& that) {
+ if (this != &that) {
+ length_ = that.length_;
+ data = that.data;
+ buffer = that.buffer;
+ }
+ return *this;
+ }
+
+ size_t length() const {
+ return length_;
+ }
+
+ char* get_data() const {
+ return data;
+ }
+
+ private:
+ size_t length_;
+ char* data;
+ internal::allocated_buffer buffer; // may not be allocated
+ };
+
+ namespace internal {
+ struct object_key_record {
+ size_t key_start;
+ size_t key_end;
+ size_t value;
+ };
+
+ struct object_key_comparator {
+ object_key_comparator(const char* object_data)
+ : data(object_data)
+ {}
+
+ bool operator()(const object_key_record& lhs, const string& rhs) const {
+ const size_t lhs_length = lhs.key_end - lhs.key_start;
+ const size_t rhs_length = rhs.length();
+ if (lhs_length < rhs_length) {
+ return true;
+ } else if (lhs_length > rhs_length) {
+ return false;
+ }
+ return memcmp(data + lhs.key_start, rhs.data(), lhs_length) < 0;
+ }
+
+ bool operator()(const string& lhs, const object_key_record& rhs) const {
+ return !(*this)(rhs, lhs);
+ }
+
+ bool operator()(
+ const object_key_record& lhs,
+ const object_key_record& rhs
+ ) {
+ const size_t lhs_length = lhs.key_end - lhs.key_start;
+ const size_t rhs_length = rhs.key_end - rhs.key_start;
+ if (lhs_length < rhs_length) {
+ return true;
+ } else if (lhs_length > rhs_length) {
+ return false;
+ }
+ return memcmp(
+ data + lhs.key_start,
+ data + rhs.key_start,
+ lhs_length
+ ) < 0;
+ }
+
+ const char* data;
+ };
+ }
+
+ namespace integer_storage {
+ enum {
+ word_length = 1
+ };
+
+ inline int load(const size_t* location) {
+ int value;
+ memcpy(&value, location, sizeof(value));
+ return value;
+ }
+
+ inline void store(size_t* location, int value) {
+ // NOTE: Most modern compilers optimize away this constant-size
+ // memcpy into a single instruction. If any don't, and treat
+ // punning through a union as legal, they can be special-cased.
+ static_assert(
+ sizeof(value) <= sizeof(*location),
+ "size_t must not be smaller than int");
+ memcpy(location, &value, sizeof(value));
+ }
+ }
+
+ namespace double_storage {
+ enum {
+ word_length = sizeof(double) / sizeof(size_t)
+ };
+
+ inline double load(const size_t* location) {
+ double value;
+ memcpy(&value, location, sizeof(double));
+ return value;
+ }
+
+ inline void store(size_t* location, double value) {
+ // NOTE: Most modern compilers optimize away this constant-size
+ // memcpy into a single instruction. If any don't, and treat
+ // punning through a union as legal, they can be special-cased.
+ memcpy(location, &value, sizeof(double));
+ }
+ }
+
+ /// Represents a JSON value. First, call get_type() to check its type,
+ /// which determines which methods are available.
+ ///
+ /// Note that \ref value does not maintain any backing memory, only the
+ /// corresponding \ref document does. It is illegal to access a \ref value
+ /// after its \ref document has been destroyed.
+ class value {
+ public:
+ /// Returns the JSON value's \ref type.
+ type get_type() const {
+ return value_type;
+ }
+
+ /// Returns the length of the object or array.
+ /// Only legal if get_type() is TYPE_ARRAY or TYPE_OBJECT.
+ size_t get_length() const {
+ assert_type_2(TYPE_ARRAY, TYPE_OBJECT);
+ return payload[0];
+ }
+
+ /// Returns the nth element of an array. Calling with an out-of-bound
+ /// index is undefined behavior.
+ /// Only legal if get_type() is TYPE_ARRAY.
+ value get_array_element(size_t index) const {
+ using namespace internal;
+ assert_type(TYPE_ARRAY);
+ size_t element = payload[1 + index];
+ return value(get_element_type(element), payload + get_element_value(element), text);
+ }
+
+ /// Returns the nth key of an object. Calling with an out-of-bound
+ /// index is undefined behavior.
+ /// Only legal if get_type() is TYPE_OBJECT.
+ string get_object_key(size_t index) const {
+ assert_type(TYPE_OBJECT);
+ const size_t* s = payload + 1 + index * 3;
+ return string(text + s[0], s[1] - s[0]);
+ }
+
+ /// Returns the nth value of an object. Calling with an out-of-bound
+ /// index is undefined behavior. Only legal if get_type() is TYPE_OBJECT.
+ value get_object_value(size_t index) const {
+ using namespace internal;
+ assert_type(TYPE_OBJECT);
+ size_t element = payload[3 + index * 3];
+ return value(get_element_type(element), payload + get_element_value(element), text);
+ }
+
+ /// Given a string key, returns the value with that key or a null value
+ /// if the key is not found. Running time is O(lg N).
+ /// Only legal if get_type() is TYPE_OBJECT.
+ value get_value_of_key(const string& key) const {
+ assert_type(TYPE_OBJECT);
+ size_t i = find_object_key(key);
+ if (i < get_length()) {
+ return get_object_value(i);
+ } else {
+ return value(TYPE_NULL, 0, 0);
+ }
+ }
+
+ /// Given a string key, returns the index of the associated value if
+ /// one exists. Returns get_length() if there is no such key.
+ /// Note: sajson sorts object keys, so the running time is O(lg N).
+ /// Only legal if get_type() is TYPE_OBJECT
+ size_t find_object_key(const string& key) const {
+ using namespace internal;
+ assert_type(TYPE_OBJECT);
+ const object_key_record* start = reinterpret_cast<const object_key_record*>(payload + 1);
+ const object_key_record* end = start + get_length();
+#ifdef SAJSON_UNSORTED_OBJECT_KEYS
+ for (const object_key_record* i = start; i != end; ++i)
+#else
+ const object_key_record* i = std::lower_bound(start, end, key, object_key_comparator(text));
+#endif
+ if (i != end
+ && (i->key_end - i->key_start) == key.length()
+ && memcmp(key.data(), text + i->key_start, key.length()) == 0) {
+ return i - start;
+ }
+ return get_length();
+ }
+
+ /// If a numeric value was parsed as a 32-bit integer, returns it.
+ /// Only legal if get_type() is TYPE_INTEGER.
+ int get_integer_value() const {
+ assert_type(TYPE_INTEGER);
+ return integer_storage::load(payload);
+ }
+
+ /// If a numeric value was parsed as a double, returns it.
+ /// Only legal if get_type() is TYPE_DOUBLE.
+ double get_double_value() const {
+ assert_type(TYPE_DOUBLE);
+ return double_storage::load(payload);
+ }
+
+ /// Returns a numeric value as a double-precision float.
+ /// Only legal if get_type() is TYPE_INTEGER or TYPE_DOUBLE.
+ double get_number_value() const {
+ assert_type_2(TYPE_INTEGER, TYPE_DOUBLE);
+ if (get_type() == TYPE_INTEGER) {
+ return get_integer_value();
+ } else {
+ return get_double_value();
+ }
+ }
+
+ /// Returns true and writes to the output argument if the numeric value
+ /// fits in a 53-bit integer. This is useful for timestamps and other
+ /// situations where integral values with greater than 32-bit precision
+ /// are used, as 64-bit values are not understood by all JSON
+ /// implementations or languages.
+ /// Returns false if the value is not an integer or not in range.
+ /// Only legal if get_type() is TYPE_INTEGER or TYPE_DOUBLE.
+ bool get_int53_value(int64_t* out) const {
+ // Make sure the output variable is always defined to avoid any
+ // possible situation like
+ // https://gist.github.com/chadaustin/2c249cb850619ddec05b23ca42cf7a18
+ *out = 0;
+
+ assert_type_2(TYPE_INTEGER, TYPE_DOUBLE);
+ if (get_type() == TYPE_INTEGER) {
+ *out = get_integer_value();
+ return true;
+ } else if (get_type() == TYPE_DOUBLE) {
+ double v = get_double_value();
+ if (v < -(1LL << 53) || v > (1LL << 53)) {
+ return false;
+ }
+ int64_t as_int = static_cast<int64_t>(v);
+ if (as_int != v) {
+ return false;
+ }
+ *out = as_int;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /// Returns the length of the string.
+ /// Only legal if get_type() is TYPE_STRING.
+ size_t get_string_length() const {
+ assert_type(TYPE_STRING);
+ return payload[1] - payload[0];
+ }
+
+ /// Returns a pointer to the beginning of a string value's data.
+ /// WARNING: Calling this function and using the return value as a
+ /// C-style string (that is, without also using get_string_length())
+ /// will cause the string to appear truncated if the string has
+ /// embedded NULs.
+ /// Only legal if get_type() is TYPE_STRING.
+ const char* as_cstring() const {
+ assert_type(TYPE_STRING);
+ return text + payload[0];
+ }
+
+#ifndef SAJSON_NO_STD_STRING
+ /// Returns a string's value as a std::string.
+ /// Only legal if get_type() is TYPE_STRING.
+ std::string as_string() const {
+ assert_type(TYPE_STRING);
+ return std::string(text + payload[0], text + payload[1]);
+ }
+#endif
+
+ /// \cond INTERNAL
+ const size_t* _internal_get_payload() const {
+ return payload;
+ }
+ /// \endcond
+
+ private:
+ explicit value(type value_type_, const size_t* payload_, const char* text_)
+ : value_type(value_type_)
+ , payload(payload_)
+ , text(text_)
+ {}
+
+ void assert_type(type expected) const {
+ assert(expected == get_type());
+ }
+
+ void assert_type_2(type e1, type e2) const {
+ assert(e1 == get_type() || e2 == get_type());
+ }
+
+ void assert_in_bounds(size_t i) const {
+ assert(i < get_length());
+ }
+
+ const type value_type;
+ const size_t* const payload;
+ const char* const text;
+
+ friend class document;
+ };
+
+ /// Error code indicating why parse failed.
+ enum error {
+ ERROR_NO_ERROR,
+ ERROR_OUT_OF_MEMORY,
+ ERROR_UNEXPECTED_END,
+ ERROR_MISSING_ROOT_ELEMENT,
+ ERROR_BAD_ROOT,
+ ERROR_EXPECTED_COMMA,
+ ERROR_MISSING_OBJECT_KEY,
+ ERROR_EXPECTED_COLON,
+ ERROR_EXPECTED_END_OF_INPUT,
+ ERROR_UNEXPECTED_COMMA,
+ ERROR_EXPECTED_VALUE,
+ ERROR_EXPECTED_NULL,
+ ERROR_EXPECTED_FALSE,
+ ERROR_EXPECTED_TRUE,
+ ERROR_INVALID_NUMBER,
+ ERROR_MISSING_EXPONENT,
+ ERROR_ILLEGAL_CODEPOINT,
+ ERROR_INVALID_UNICODE_ESCAPE,
+ ERROR_UNEXPECTED_END_OF_UTF16,
+ ERROR_EXPECTED_U,
+ ERROR_INVALID_UTF16_TRAIL_SURROGATE,
+ ERROR_UNKNOWN_ESCAPE,
+ ERROR_INVALID_UTF8,
+ };
+
+ namespace internal {
+ class ownership {
+ public:
+ ownership() = delete;
+ ownership(const ownership&) = delete;
+ void operator=(const ownership&) = delete;
+
+ explicit ownership(size_t* p_)
+ : p(p_)
+ {}
+
+ ownership(ownership&& p_)
+ : p(p_.p) {
+ p_.p = 0;
+ }
+
+ ~ownership() {
+ delete[] p;
+ }
+
+ bool is_valid() const {
+ return !!p;
+ }
+
+ private:
+ size_t* p;
+ };
+
+ inline const char* get_error_text(error error_code) {
+ switch (error_code) {
+ case ERROR_NO_ERROR: return "no error";
+ case ERROR_OUT_OF_MEMORY: return "out of memory";
+ case ERROR_UNEXPECTED_END: return "unexpected end of input";
+ case ERROR_MISSING_ROOT_ELEMENT: return "missing root element";
+ case ERROR_BAD_ROOT: return "document root must be object or array";
+ case ERROR_EXPECTED_COMMA: return "expected ,";
+ case ERROR_MISSING_OBJECT_KEY: return "missing object key";
+ case ERROR_EXPECTED_COLON: return "expected :";
+ case ERROR_EXPECTED_END_OF_INPUT: return "expected end of input";
+ case ERROR_UNEXPECTED_COMMA: return "unexpected comma";
+ case ERROR_EXPECTED_VALUE: return "expected value";
+ case ERROR_EXPECTED_NULL: return "expected 'null'";
+ case ERROR_EXPECTED_FALSE: return "expected 'false'";
+ case ERROR_EXPECTED_TRUE: return "expected 'true'";
+ case ERROR_INVALID_NUMBER: return "invalid number";
+ case ERROR_MISSING_EXPONENT: return "missing exponent";
+ case ERROR_ILLEGAL_CODEPOINT: return "illegal unprintable codepoint in string";
+ case ERROR_INVALID_UNICODE_ESCAPE: return "invalid character in unicode escape";
+ case ERROR_UNEXPECTED_END_OF_UTF16: return "unexpected end of input during UTF-16 surrogate pair";
+ case ERROR_EXPECTED_U: return "expected \\u";
+ case ERROR_INVALID_UTF16_TRAIL_SURROGATE: return "invalid UTF-16 trail surrogate";
+ case ERROR_UNKNOWN_ESCAPE: return "unknown escape";
+ case ERROR_INVALID_UTF8: return "invalid UTF-8";
+ }
+
+ SAJSON_UNREACHABLE();
+ }
+ }
+
+ /**
+ * Represents the result of a JSON parse: either is_valid() and the document
+ * contains a root value or parse error information is available.
+ *
+ * Note that the document holds a strong reference to any memory allocated:
+ * any mutable copy of the input text and any memory allocated for the
+ * AST data structure. Thus, the document must not be deallocated while any
+ * \ref value is in use.
+ */
+ class document {
+ public:
+ document(document&& rhs)
+ : input(rhs.input)
+ , structure(std::move(rhs.structure))
+ , root_type(rhs.root_type)
+ , root(rhs.root)
+ , error_line(rhs.error_line)
+ , error_column(rhs.error_column)
+ , error_code(rhs.error_code)
+ , error_arg(rhs.error_arg)
+ {
+ // Yikes... but strcpy is okay here because formatted_error is
+ // guaranteed to be null-terminated.
+ strcpy(formatted_error_message, rhs.formatted_error_message);
+ // should rhs's fields be zeroed too?
+ }
+
+ /**
+ * Returns true if the document was parsed successfully.
+ * If true, call get_root() to access the document's root value.
+ * If false, call get_error_line(), get_error_column(), and
+ * get_error_message_as_cstring() to see why the parse failed.
+ */
+ bool is_valid() const {
+ return root_type == TYPE_ARRAY || root_type == TYPE_OBJECT;
+ }
+
+ /// If is_valid(), returns the document's root \ref value.
+ value get_root() const {
+ return value(root_type, root, input.get_data());
+ }
+
+ /// If not is_valid(), returns the one-based line number where the parse failed.
+ size_t get_error_line() const {
+ return error_line;
+ }
+
+ /// If not is_valid(), returns the one-based column number where the parse failed.
+ size_t get_error_column() const {
+ return error_column;
+ }
+
+#ifndef SAJSON_NO_STD_STRING
+ /// If not is_valid(), returns a std::string indicating why the parse failed.
+ std::string get_error_message_as_string() const {
+ return formatted_error_message;
+ }
+#endif
+
+ /// If not is_valid(), returns a null-terminated C string indicating why the parse failed.
+ const char* get_error_message_as_cstring() const {
+ return formatted_error_message;
+ }
+
+ /// \cond INTERNAL
+
+ // WARNING: Internal function which is subject to change
+ error _internal_get_error_code() const {
+ return error_code;
+ }
+
+ // WARNING: Internal function which is subject to change
+ int _internal_get_error_argument() const {
+ return error_arg;
+ }
+
+ // WARNING: Internal function which is subject to change
+ const char* _internal_get_error_text() const {
+ return internal::get_error_text(error_code);
+ }
+
+ // WARNING: Internal function exposed only for high-performance language bindings.
+ type _internal_get_root_type() const {
+ return root_type;
+ }
+
+ // WARNING: Internal function exposed only for high-performance language bindings.
+ const size_t* _internal_get_root() const {
+ return root;
+ }
+
+ // WARNING: Internal function exposed only for high-performance language bindings.
+ const mutable_string_view& _internal_get_input() const {
+ return input;
+ }
+
+ /// \endcond
+
+ private:
+ document(const document&) = delete;
+ void operator=(const document&) = delete;
+
+ explicit document(const mutable_string_view& input_, internal::ownership&& structure_, type root_type_, const size_t* root_)
+ : input(input_)
+ , structure(std::move(structure_))
+ , root_type(root_type_)
+ , root(root_)
+ , error_line(0)
+ , error_column(0)
+ , error_code(ERROR_NO_ERROR)
+ , error_arg(0)
+ {
+ formatted_error_message[0] = 0;
+ }
+
+ explicit document(const mutable_string_view& input_, size_t error_line_, size_t error_column_, const error error_code_, int error_arg_)
+ : input(input_)
+ , structure(0)
+ , root_type(TYPE_NULL)
+ , root(0)
+ , error_line(error_line_)
+ , error_column(error_column_)
+ , error_code(error_code_)
+ , error_arg(error_arg_)
+ {
+ formatted_error_message[ERROR_BUFFER_LENGTH - 1] = 0;
+ int written = has_significant_error_arg()
+ ? SAJSON_snprintf(formatted_error_message, ERROR_BUFFER_LENGTH - 1, "%s: %d", _internal_get_error_text(), error_arg)
+ : SAJSON_snprintf(formatted_error_message, ERROR_BUFFER_LENGTH - 1, "%s", _internal_get_error_text());
+ (void)written;
+ assert(written >= 0 && written < ERROR_BUFFER_LENGTH);
+ }
+
+ bool has_significant_error_arg() const {
+ return error_code == ERROR_ILLEGAL_CODEPOINT;
+ }
+
+ mutable_string_view input;
+ internal::ownership structure;
+ const type root_type;
+ const size_t* const root;
+ const size_t error_line;
+ const size_t error_column;
+ const error error_code;
+ const int error_arg;
+
+ enum { ERROR_BUFFER_LENGTH = 128 };
+ char formatted_error_message[ERROR_BUFFER_LENGTH];
+
+ template<typename AllocationStrategy, typename StringType>
+ friend document parse(const AllocationStrategy& strategy, const StringType& string);
+ template<typename Allocator>
+ friend class parser;
+ };
+
+ /// Allocation policy that allocates one large buffer guaranteed to hold the
+ /// resulting AST. This allocation policy is the fastest since it requires
+ /// no conditionals to see if more memory must be allocated.
+ class single_allocation {
+ public:
+ /// \cond INTERNAL
+
+ class stack_head {
+ public:
+ stack_head(stack_head&& other)
+ : stack_bottom(other.stack_bottom)
+ , stack_top(other.stack_top)
+ {}
+
+ bool push(size_t element) {
+ *stack_top++ = element;
+ return true;
+ }
+
+ size_t* reserve(size_t amount, bool* success) {
+ size_t* rv = stack_top;
+ stack_top += amount;
+ *success = true;
+ return rv;
+ }
+
+ // The compiler does not see the stack_head (stored in a local)
+ // and the allocator (stored as a field) have the same stack_bottom
+ // values, so it does a bit of redundant work.
+ // So there's a microoptimization available here: introduce a type
+ // "stack_mark" and make it polymorphic on the allocator. For
+ // single_allocation, it merely needs to be a single pointer.
+
+ void reset(size_t new_top) {
+ stack_top = stack_bottom + new_top;
+ }
+
+ size_t get_size() {
+ return stack_top - stack_bottom;
+ }
+
+ size_t* get_top() {
+ return stack_top;
+ }
+
+ size_t* get_pointer_from_offset(size_t offset) {
+ return stack_bottom + offset;
+ }
+
+ private:
+ stack_head() = delete;
+ stack_head(const stack_head&) = delete;
+ void operator=(const stack_head&) = delete;
+
+ explicit stack_head(size_t* base)
+ : stack_bottom(base)
+ , stack_top(base)
+ {}
+
+ size_t* const stack_bottom;
+ size_t* stack_top;
+
+ friend class single_allocation;
+ };
+
+ class allocator {
+ public:
+ allocator() = delete;
+ allocator(const allocator&) = delete;
+ void operator=(const allocator&) = delete;
+
+ explicit allocator(size_t* buffer, size_t input_size, bool should_deallocate_)
+ : structure(buffer)
+ , structure_end(buffer ? buffer + input_size : 0)
+ , write_cursor(structure_end)
+ , should_deallocate(should_deallocate_)
+ {}
+
+ explicit allocator(std::nullptr_t)
+ : structure(0)
+ , structure_end(0)
+ , write_cursor(0)
+ , should_deallocate(false)
+ {}
+
+ allocator(allocator&& other)
+ : structure(other.structure)
+ , structure_end(other.structure_end)
+ , write_cursor(other.write_cursor)
+ , should_deallocate(other.should_deallocate)
+ {
+ other.structure = 0;
+ other.structure_end = 0;
+ other.write_cursor = 0;
+ other.should_deallocate = false;
+ }
+
+ ~allocator() {
+ if (should_deallocate) {
+ delete[] structure;
+ }
+ }
+
+ stack_head get_stack_head(bool* success) {
+ *success = true;
+ return stack_head(structure);
+ }
+
+ size_t get_write_offset() {
+ return structure_end - write_cursor;
+ }
+
+ size_t* get_write_pointer_of(size_t v) {
+ return structure_end - v;
+ }
+
+ size_t* reserve(size_t size, bool* success) {
+ *success = true;
+ write_cursor -= size;
+ return write_cursor;
+ }
+
+ size_t* get_ast_root() {
+ return write_cursor;
+ }
+
+ internal::ownership transfer_ownership() {
+ auto p = structure;
+ structure = 0;
+ structure_end = 0;
+ write_cursor = 0;
+ if (should_deallocate) {
+ return internal::ownership(p);
+ } else {
+ return internal::ownership(0);
+ }
+ }
+
+ private:
+ size_t* structure;
+ size_t* structure_end;
+ size_t* write_cursor;
+ bool should_deallocate;
+ };
+
+ /// \endcond
+
+ /// Allocate a single worst-case AST buffer with one word per byte in
+ /// the input document.
+ single_allocation()
+ : has_existing_buffer(false)
+ , existing_buffer(0)
+ , existing_buffer_size(0)
+ {}
+
+ /// Write the AST into an existing buffer. Will fail with an out of
+ /// memory error if the buffer is not guaranteed to be big enough for
+ /// the document. The caller must guarantee the memory is valid for
+ /// the duration of the parse and the AST traversal.
+ single_allocation(size_t* existing_buffer_, size_t size_in_words)
+ : has_existing_buffer(true)
+ , existing_buffer(existing_buffer_)
+ , existing_buffer_size(size_in_words)
+ {}
+
+ /// Convenience wrapper for single_allocation(size_t*, size_t) that
+ /// automatically infers the length of a given array.
+ template<size_t N>
+ explicit single_allocation(size_t (&existing_buffer_)[N])
+ : single_allocation(existing_buffer_, N)
+ {}
+
+ /// \cond INTERNAL
+
+ allocator make_allocator(size_t input_document_size_in_bytes, bool* succeeded) const {
+ if (has_existing_buffer) {
+ if (existing_buffer_size < input_document_size_in_bytes) {
+ *succeeded = false;
+ return allocator(nullptr);
+ }
+ *succeeded = true;
+ return allocator(existing_buffer, input_document_size_in_bytes, false);
+ } else {
+ size_t* buffer = new(std::nothrow) size_t[input_document_size_in_bytes];
+ if (!buffer) {
+ *succeeded = false;
+ return allocator(nullptr);
+ }
+ *succeeded = true;
+ return allocator(buffer, input_document_size_in_bytes, true);
+ }
+ }
+
+ /// \endcond
+
+ private:
+ bool has_existing_buffer;
+ size_t* existing_buffer;
+ size_t existing_buffer_size;
+ };
+
+ /// Allocation policy that uses dynamically-growing buffers for both the
+ /// parse stack and the AST. This allocation policy minimizes peak memory
+ /// usage at the cost of some allocation and copying churn.
+ class dynamic_allocation {
+ public:
+ /// \cond INTERNAL
+
+ class stack_head {
+ public:
+ stack_head(stack_head&& other)
+ : stack_top(other.stack_top)
+ , stack_bottom(other.stack_bottom)
+ , stack_limit(other.stack_limit)
+ {
+ other.stack_top = 0;
+ other.stack_bottom = 0;
+ other.stack_limit = 0;
+ }
+
+ ~stack_head() {
+ delete[] stack_bottom;
+ }
+
+ bool push(size_t element) {
+ if (can_grow(1)) {
+ *stack_top++ = element;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ size_t* reserve(size_t amount, bool* success) {
+ if (can_grow(amount)) {
+ size_t* rv = stack_top;
+ stack_top += amount;
+ *success = true;
+ return rv;
+ } else {
+ *success = false;
+ return 0;
+ }
+ }
+
+ void reset(size_t new_top) {
+ stack_top = stack_bottom + new_top;
+ }
+
+ size_t get_size() {
+ return stack_top - stack_bottom;
+ }
+
+ size_t* get_top() {
+ return stack_top;
+ }
+
+ size_t* get_pointer_from_offset(size_t offset) {
+ return stack_bottom + offset;
+ }
+
+ private:
+ stack_head(const stack_head&) = delete;
+ void operator=(const stack_head&) = delete;
+
+ explicit stack_head(size_t initial_capacity, bool* success) {
+ assert(initial_capacity);
+ stack_bottom = new(std::nothrow) size_t[initial_capacity];
+ stack_top = stack_bottom;
+ if (stack_bottom) {
+ stack_limit = stack_bottom + initial_capacity;
+ } else {
+ stack_limit = 0;
+ }
+ *success = !!stack_bottom;
+ }
+
+ bool can_grow(size_t amount) {
+ if (SAJSON_LIKELY(amount <= static_cast<size_t>(stack_limit - stack_top))) {
+ return true;
+ }
+
+ size_t current_size = stack_top - stack_bottom;
+ size_t old_capacity = stack_limit - stack_bottom;
+ size_t new_capacity = old_capacity * 2;
+ while (new_capacity < amount + current_size) {
+ new_capacity *= 2;
+ }
+ size_t* new_stack = new(std::nothrow) size_t[new_capacity];
+ if (!new_stack) {
+ stack_top = 0;
+ stack_bottom = 0;
+ stack_limit = 0;
+ return false;
+ }
+
+ memcpy(new_stack, stack_bottom, current_size * sizeof(size_t));
+ delete[] stack_bottom;
+ stack_top = new_stack + current_size;
+ stack_bottom = new_stack;
+ stack_limit = stack_bottom + new_capacity;
+ return true;
+ }
+
+ size_t* stack_top; // stack grows up: stack_top >= stack_bottom
+ size_t* stack_bottom;
+ size_t* stack_limit;
+
+ friend class dynamic_allocation;
+ };
+
+ class allocator {
+ public:
+ allocator() = delete;
+ allocator(const allocator&) = delete;
+ void operator=(const allocator&) = delete;
+
+ explicit allocator(size_t* buffer_, size_t current_capacity, size_t initial_stack_capacity_)
+ : ast_buffer_bottom(buffer_)
+ , ast_buffer_top(buffer_ + current_capacity)
+ , ast_write_head(ast_buffer_top)
+ , initial_stack_capacity(initial_stack_capacity_)
+ {}
+
+ explicit allocator(std::nullptr_t)
+ : ast_buffer_bottom(0)
+ , ast_buffer_top(0)
+ , ast_write_head(0)
+ , initial_stack_capacity(0)
+ {}
+
+ allocator(allocator&& other)
+ : ast_buffer_bottom(other.ast_buffer_bottom)
+ , ast_buffer_top(other.ast_buffer_top)
+ , ast_write_head(other.ast_write_head)
+ , initial_stack_capacity(other.initial_stack_capacity)
+ {
+ other.ast_buffer_bottom = 0;
+ other.ast_buffer_top = 0;
+ other.ast_write_head = 0;
+ }
+
+ ~allocator() {
+ delete[] ast_buffer_bottom;
+ }
+
+ stack_head get_stack_head(bool* success) {
+ return stack_head(initial_stack_capacity, success);
+ }
+
+ size_t get_write_offset() {
+ return ast_buffer_top - ast_write_head;
+ }
+
+ size_t* get_write_pointer_of(size_t v) {
+ return ast_buffer_top - v;
+ }
+
+ size_t* reserve(size_t size, bool* success) {
+ if (can_grow(size)) {
+ ast_write_head -= size;
+ *success = true;
+ return ast_write_head;
+ } else {
+ *success = false;
+ return 0;
+ }
+ }
+
+ size_t* get_ast_root() {
+ return ast_write_head;
+ }
+
+ internal::ownership transfer_ownership() {
+ auto p = ast_buffer_bottom;
+ ast_buffer_bottom = 0;
+ ast_buffer_top = 0;
+ ast_write_head = 0;
+ return internal::ownership(p);
+ }
+
+ private:
+ bool can_grow(size_t amount) {
+ if (SAJSON_LIKELY(amount <= static_cast<size_t>(ast_write_head - ast_buffer_bottom))) {
+ return true;
+ }
+ size_t current_capacity = ast_buffer_top - ast_buffer_bottom;
+
+ size_t current_size = ast_buffer_top - ast_write_head;
+ size_t new_capacity = current_capacity * 2;
+ while (new_capacity < amount + current_size) {
+ new_capacity *= 2;
+ }
+
+ size_t* old_buffer = ast_buffer_bottom;
+ size_t* new_buffer = new(std::nothrow) size_t[new_capacity];
+ if (!new_buffer) {
+ ast_buffer_bottom = 0;
+ ast_buffer_top = 0;
+ ast_write_head = 0;
+ return false;
+ }
+
+ size_t* old_write_head = ast_write_head;
+ ast_buffer_bottom = new_buffer;
+ ast_buffer_top = new_buffer + new_capacity;
+ ast_write_head = ast_buffer_top - current_size;
+ memcpy(ast_write_head, old_write_head, current_size * sizeof(size_t));
+ delete[] old_buffer;
+
+ return true;
+ }
+
+ size_t* ast_buffer_bottom; // base address of the ast buffer - it grows down
+ size_t* ast_buffer_top;
+ size_t* ast_write_head;
+ size_t initial_stack_capacity;
+ };
+
+ /// \endcond
+
+ /// Creates a dynamic_allocation policy with the given initial AST
+ /// and stack buffer sizes.
+ dynamic_allocation(size_t initial_ast_capacity_ = 0, size_t initial_stack_capacity_ = 0)
+ : initial_ast_capacity(initial_ast_capacity_)
+ , initial_stack_capacity(initial_stack_capacity_)
+ {}
+
+ /// \cond INTERNAL
+
+ allocator make_allocator(size_t, bool* succeeded) const {
+ size_t capacity = initial_ast_capacity;
+ if (!capacity) {
+ // TODO: guess based on input document size
+ capacity = 1024;
+ }
+
+ size_t* buffer = new(std::nothrow) size_t[capacity];
+ if (!buffer) {
+ *succeeded = false;
+ return allocator(nullptr);
+ }
+
+ size_t stack_capacity = initial_stack_capacity;
+ if (!stack_capacity) {
+ stack_capacity = 256;
+ }
+
+ *succeeded = true;
+ return allocator(buffer, capacity, stack_capacity);
+ }
+
+ /// \endcond
+
+ private:
+ size_t initial_ast_capacity;
+ size_t initial_stack_capacity;
+ };
+
+ /// Allocation policy that attempts to fit the parsed AST into an existing
+ /// memory buffer. This allocation policy is useful when using sajson in
+ /// a zero-allocation context or when there are constraints on the amount
+ // of memory that can be used.
+ class bounded_allocation {
+ public:
+ /// \cond INTERNAL
+
+ class allocator;
+
+ class stack_head {
+ public:
+ stack_head(stack_head&& other)
+ : source_allocator(other.source_allocator)
+ {
+ other.source_allocator = 0;
+ }
+
+ bool push(size_t element) {
+ if (SAJSON_LIKELY(source_allocator->can_grow(1))) {
+ *(source_allocator->stack_top)++ = element;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ size_t* reserve(size_t amount, bool* success) {
+ if (SAJSON_LIKELY(source_allocator->can_grow(amount))) {
+ size_t* rv = source_allocator->stack_top;
+ source_allocator->stack_top += amount;
+ *success = true;
+ return rv;
+ } else {
+ *success = false;
+ return 0;
+ }
+ }
+
+ void reset(size_t new_top) {
+ source_allocator->stack_top = source_allocator->structure + new_top;
+ }
+
+ size_t get_size() {
+ return source_allocator->stack_top - source_allocator->structure;
+ }
+
+ size_t* get_top() {
+ return source_allocator->stack_top;
+ }
+
+ size_t* get_pointer_from_offset(size_t offset) {
+ return source_allocator->structure + offset;
+ }
+
+ private:
+ stack_head(const stack_head&) = delete;
+ void operator=(const stack_head&) = delete;
+
+ explicit stack_head(allocator* source_allocator_)
+ : source_allocator(source_allocator_)
+ {}
+
+ allocator* source_allocator;
+
+ friend class bounded_allocation;
+ };
+
+ class allocator {
+ public:
+ allocator() = delete;
+ allocator(const allocator&) = delete;
+ void operator=(const allocator&) = delete;
+
+ explicit allocator(size_t* existing_buffer, size_t existing_buffer_size)
+ : structure(existing_buffer)
+ , structure_end(existing_buffer + existing_buffer_size)
+ , write_cursor(structure_end)
+ , stack_top(structure)
+ {}
+
+ allocator(allocator&& other)
+ : structure(other.structure)
+ , structure_end(other.structure_end)
+ , write_cursor(other.write_cursor)
+ , stack_top(other.stack_top)
+ {
+ other.structure = 0;
+ other.structure_end = 0;
+ other.write_cursor = 0;
+ other.stack_top = 0;
+ }
+
+ stack_head get_stack_head(bool* success) {
+ *success = true;
+ return stack_head(this);
+ }
+
+ size_t get_write_offset() {
+ return structure_end - write_cursor;
+ }
+
+ size_t* get_write_pointer_of(size_t v) {
+ return structure_end - v;
+ }
+
+ size_t* reserve(size_t size, bool* success) {
+ if (can_grow(size)) {
+ write_cursor -= size;
+ *success = true;
+ return write_cursor;
+ } else {
+ *success = false;
+ return 0;
+ }
+ }
+
+ size_t* get_ast_root() {
+ return write_cursor;
+ }
+
+ internal::ownership transfer_ownership() {
+ structure = 0;
+ structure_end = 0;
+ write_cursor = 0;
+ return internal::ownership(0);
+ }
+
+ private:
+ bool can_grow(size_t amount) {
+ // invariant: stack_top <= write_cursor
+ // thus: write_cursor - stack_top is positive
+ return static_cast<size_t>(write_cursor - stack_top) >= amount;
+ }
+
+ size_t* structure;
+ size_t* structure_end;
+ size_t* write_cursor;
+ size_t* stack_top;
+
+ friend class bounded_allocation;
+ };
+
+ /// \endcond
+
+ /// Uses an existing buffer to hold the parsed AST, if it fits. The
+ /// specified buffer must not be deallocated until after the document
+ /// is parsed and the AST traversed.
+ bounded_allocation(size_t* existing_buffer_, size_t size_in_words)
+ : existing_buffer(existing_buffer_)
+ , existing_buffer_size(size_in_words)
+ {}
+
+ /// Convenience wrapper for bounded_allocation(size_t*, size) that
+ /// automatically infers the size of the given array.
+ template<size_t N>
+ explicit bounded_allocation(size_t (&existing_buffer_)[N])
+ : bounded_allocation(existing_buffer_, N)
+ {}
+
+ /// \cond INTERNAL
+
+ allocator make_allocator(size_t, bool* succeeded) const {
+ *succeeded = true;
+ return allocator(existing_buffer, existing_buffer_size);
+ }
+
+ /// \endcond
+
+ private:
+ size_t* existing_buffer;
+ size_t existing_buffer_size;
+ };
+
+ // I thought about putting parser in the internal namespace but I don't
+ // want to indent it further...
+ /// \cond INTERNAL
+ template<typename Allocator>
+ class parser {
+ public:
+ parser(const mutable_string_view& msv, Allocator&& allocator_)
+ : input(msv)
+ , input_end(input.get_data() + input.length())
+ , allocator(std::move(allocator_))
+ , root_type(TYPE_NULL)
+ , error_line(0)
+ , error_column(0)
+ {}
+
+ document get_document() {
+ if (parse()) {
+ size_t* ast_root = allocator.get_ast_root();
+ return document(input, allocator.transfer_ownership(), root_type, ast_root);
+ } else {
+ return document(input, error_line, error_column, error_code, error_arg);
+ }
+ }
+
+ private:
+ struct error_result {
+ operator bool() const {
+ return false;
+ }
+ operator char*() const {
+ return 0;
+ }
+ };
+
+ bool at_eof(const char* p) {
+ return p == input_end;
+ }
+
+ char* skip_whitespace(char* p) {
+ // There is an opportunity to make better use of superscalar
+ // hardware here* but if someone cares about JSON parsing
+ // performance the first thing they do is minify, so prefer
+ // to optimize for code size here.
+ // * https://github.com/chadaustin/Web-Benchmarks/blob/master/json/third-party/pjson/pjson.h#L1873
+ for (;;) {
+ if (SAJSON_UNLIKELY(p == input_end)) {
+ return 0;
+ } else if (internal::is_whitespace(*p)) {
+ ++p;
+ } else {
+ return p;
+ }
+ }
+ }
+
+ error_result oom(char* p) {
+ return make_error(p, ERROR_OUT_OF_MEMORY);
+ }
+
+ error_result unexpected_end() {
+ return make_error(0, ERROR_UNEXPECTED_END);
+ }
+
+ error_result unexpected_end(char* p) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+
+ error_result make_error(char* p, error code, int arg = 0) {
+ if (!p) {
+ p = input_end;
+ }
+
+ error_line = 1;
+ error_column = 1;
+
+ char* c = input.get_data();
+ while (c < p) {
+ if (*c == '\r') {
+ if (c + 1 < p && c[1] == '\n') {
+ ++error_line;
+ error_column = 1;
+ ++c;
+ } else {
+ ++error_line;
+ error_column = 1;
+ }
+ } else if (*c == '\n') {
+ ++error_line;
+ error_column = 1;
+ } else {
+ // TODO: count UTF-8 characters
+ ++error_column;
+ }
+ ++c;
+ }
+
+ error_code = code;
+ error_arg = arg;
+ return error_result();
+ }
+
+ bool parse() {
+ using namespace internal;
+
+ // p points to the character currently being parsed
+ char* p = input.get_data();
+
+ bool success;
+ auto stack = allocator.get_stack_head(&success);
+ if (SAJSON_UNLIKELY(!success)) {
+ return oom(p);
+ }
+
+ p = skip_whitespace(p);
+ if (SAJSON_UNLIKELY(!p)) {
+ return make_error(p, ERROR_MISSING_ROOT_ELEMENT);
+ }
+
+ // current_base is an offset to the first element of the current structure (object or array)
+ size_t current_base = stack.get_size();
+ type current_structure_type;
+ if (*p == '[') {
+ current_structure_type = TYPE_ARRAY;
+ bool s = stack.push(make_element(current_structure_type, ROOT_MARKER));
+ if (SAJSON_UNLIKELY(!s)) {
+ return oom(p);
+ }
+ goto array_close_or_element;
+ } else if (*p == '{') {
+ current_structure_type = TYPE_OBJECT;
+ bool s = stack.push(make_element(current_structure_type, ROOT_MARKER));
+ if (SAJSON_UNLIKELY(!s)) {
+ return oom(p);
+ }
+ goto object_close_or_element;
+ } else {
+ return make_error(p, ERROR_BAD_ROOT);
+ }
+
+ // BEGIN STATE MACHINE
+
+ size_t pop_element; // used as an argument into the `pop` routine
+
+ if (0) { // purely for structure
+
+ // ASSUMES: byte at p SHOULD be skipped
+ array_close_or_element:
+ p = skip_whitespace(p + 1);
+ if (SAJSON_UNLIKELY(!p)) {
+ return unexpected_end();
+ }
+ if (*p == ']') {
+ goto pop_array;
+ } else {
+ goto next_element;
+ }
+ SAJSON_UNREACHABLE();
+
+ // ASSUMES: byte at p SHOULD be skipped
+ object_close_or_element:
+ p = skip_whitespace(p + 1);
+ if (SAJSON_UNLIKELY(!p)) {
+ return unexpected_end();
+ }
+ if (*p == '}') {
+ goto pop_object;
+ } else {
+ goto object_key;
+ }
+ SAJSON_UNREACHABLE();
+
+ // ASSUMES: byte at p SHOULD NOT be skipped
+ structure_close_or_comma:
+ p = skip_whitespace(p);
+ if (SAJSON_UNLIKELY(!p)) {
+ return unexpected_end();
+ }
+
+ if (current_structure_type == TYPE_ARRAY) {
+ if (*p == ']') {
+ goto pop_array;
+ } else {
+ if (SAJSON_UNLIKELY(*p != ',')) {
+ return make_error(p, ERROR_EXPECTED_COMMA);
+ }
+ ++p;
+ goto next_element;
+ }
+ } else {
+ assert(current_structure_type == TYPE_OBJECT);
+ if (*p == '}') {
+ goto pop_object;
+ } else {
+ if (SAJSON_UNLIKELY(*p != ',')) {
+ return make_error(p, ERROR_EXPECTED_COMMA);
+ }
+ ++p;
+ goto object_key;
+ }
+ }
+ SAJSON_UNREACHABLE();
+
+ // ASSUMES: *p == '}'
+ pop_object: {
+ ++p;
+ size_t* base_ptr = stack.get_pointer_from_offset(current_base);
+ pop_element = *base_ptr;
+ if (SAJSON_UNLIKELY(!install_object(base_ptr + 1, stack.get_top()))) {
+ return oom(p);
+ }
+ goto pop;
+ }
+
+ // ASSUMES: *p == ']'
+ pop_array: {
+ ++p;
+ size_t* base_ptr = stack.get_pointer_from_offset(current_base);
+ pop_element = *base_ptr;
+ if (SAJSON_UNLIKELY(!install_array(base_ptr + 1, stack.get_top()))) {
+ return oom(p);
+ }
+ goto pop;
+ }
+
+ // ASSUMES: byte at p SHOULD NOT be skipped
+ object_key: {
+ p = skip_whitespace(p);
+ if (SAJSON_UNLIKELY(!p)) {
+ return unexpected_end();
+ }
+ if (SAJSON_UNLIKELY(*p != '"')) {
+ return make_error(p, ERROR_MISSING_OBJECT_KEY);
+ }
+ bool success_;
+ size_t* out = stack.reserve(2, &success_);
+ if (SAJSON_UNLIKELY(!success_)) {
+ return oom(p);
+ }
+ p = parse_string(p, out);
+ if (SAJSON_UNLIKELY(!p)) {
+ return false;
+ }
+ p = skip_whitespace(p);
+ if (SAJSON_UNLIKELY(!p || *p != ':')) {
+ return make_error(p, ERROR_EXPECTED_COLON);
+ }
+ ++p;
+ goto next_element;
+ }
+
+ // ASSUMES: byte at p SHOULD NOT be skipped
+ next_element:
+ p = skip_whitespace(p);
+ if (SAJSON_UNLIKELY(!p)) {
+ return unexpected_end();
+ }
+
+ type value_type_result;
+ switch (*p) {
+ case 0:
+ return unexpected_end(p);
+ case 'n':
+ p = parse_null(p);
+ if (!p) {
+ return false;
+ }
+ value_type_result = TYPE_NULL;
+ break;
+ case 'f':
+ p = parse_false(p);
+ if (!p) {
+ return false;
+ }
+ value_type_result = TYPE_FALSE;
+ break;
+ case 't':
+ p = parse_true(p);
+ if (!p) {
+ return false;
+ }
+ value_type_result = TYPE_TRUE;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-': {
+ auto result = parse_number(p);
+ p = result.first;
+ if (!p) {
+ return false;
+ }
+ value_type_result = result.second;
+ break;
+ }
+ case '"': {
+ bool success_;
+ size_t* string_tag = allocator.reserve(2, &success_);
+ if (SAJSON_UNLIKELY(!success_)) {
+ return oom(p);
+ }
+ p = parse_string(p, string_tag);
+ if (!p) {
+ return false;
+ }
+ value_type_result = TYPE_STRING;
+ break;
+ }
+
+ case '[': {
+ size_t previous_base = current_base;
+ current_base = stack.get_size();
+ bool s = stack.push(make_element(current_structure_type, previous_base));
+ if (SAJSON_UNLIKELY(!s)) {
+ return oom(p);
+ }
+ current_structure_type = TYPE_ARRAY;
+ goto array_close_or_element;
+ }
+ case '{': {
+ size_t previous_base = current_base;
+ current_base = stack.get_size();
+ bool s = stack.push(make_element(current_structure_type, previous_base));
+ if (SAJSON_UNLIKELY(!s)) {
+ return oom(p);
+ }
+ current_structure_type = TYPE_OBJECT;
+ goto object_close_or_element;
+ }
+ pop: {
+ size_t parent = get_element_value(pop_element);
+ if (parent == ROOT_MARKER) {
+ root_type = current_structure_type;
+ p = skip_whitespace(p);
+ if (SAJSON_UNLIKELY(p)) {
+ return make_error(p, ERROR_EXPECTED_END_OF_INPUT);
+ }
+ return true;
+ }
+ stack.reset(current_base);
+ current_base = parent;
+ value_type_result = current_structure_type;
+ current_structure_type = get_element_type(pop_element);
+ break;
+ }
+
+ case ',':
+ return make_error(p, ERROR_UNEXPECTED_COMMA);
+ default:
+ return make_error(p, ERROR_EXPECTED_VALUE);
+ }
+
+ bool s = stack.push(make_element(
+ value_type_result,
+ allocator.get_write_offset()));
+ if (SAJSON_UNLIKELY(!s)) {
+ return oom(p);
+ }
+
+ goto structure_close_or_comma;
+ }
+
+ SAJSON_UNREACHABLE();
+ }
+
+ bool has_remaining_characters(char* p, ptrdiff_t remaining) {
+ return input_end - p >= remaining;
+ }
+
+ char* parse_null(char* p) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 4))) {
+ make_error(p, ERROR_UNEXPECTED_END);
+ return 0;
+ }
+ char p1 = p[1];
+ char p2 = p[2];
+ char p3 = p[3];
+ if (SAJSON_UNLIKELY(p1 != 'u' || p2 != 'l' || p3 != 'l')) {
+ make_error(p, ERROR_EXPECTED_NULL);
+ return 0;
+ }
+ return p + 4;
+ }
+
+ char* parse_false(char* p) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 5))) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+ char p1 = p[1];
+ char p2 = p[2];
+ char p3 = p[3];
+ char p4 = p[4];
+ if (SAJSON_UNLIKELY(p1 != 'a' || p2 != 'l' || p3 != 's' || p4 != 'e')) {
+ return make_error(p, ERROR_EXPECTED_FALSE);
+ }
+ return p + 5;
+ }
+
+ char* parse_true(char* p) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 4))) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+ char p1 = p[1];
+ char p2 = p[2];
+ char p3 = p[3];
+ if (SAJSON_UNLIKELY(p1 != 'r' || p2 != 'u' || p3 != 'e')) {
+ return make_error(p, ERROR_EXPECTED_TRUE);
+ }
+ return p + 4;
+ }
+
+ static double pow10(int64_t exponent) {
+ if (SAJSON_UNLIKELY(exponent > 308)) {
+ return std::numeric_limits<double>::infinity();
+ } else if (SAJSON_UNLIKELY(exponent < -323)) {
+ return 0.0;
+ }
+ static const double constants[] = {
+ 1e-323,1e-322,1e-321,1e-320,1e-319,1e-318,1e-317,1e-316,1e-315,1e-314,
+ 1e-313,1e-312,1e-311,1e-310,1e-309,1e-308,1e-307,1e-306,1e-305,1e-304,
+ 1e-303,1e-302,1e-301,1e-300,1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,
+ 1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,
+ 1e-283,1e-282,1e-281,1e-280,1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,
+ 1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,
+ 1e-263,1e-262,1e-261,1e-260,1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,
+ 1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,
+ 1e-243,1e-242,1e-241,1e-240,1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,
+ 1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,
+ 1e-223,1e-222,1e-221,1e-220,1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,
+ 1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,
+ 1e-203,1e-202,1e-201,1e-200,1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,
+ 1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,
+ 1e-183,1e-182,1e-181,1e-180,1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,
+ 1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,
+ 1e-163,1e-162,1e-161,1e-160,1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,
+ 1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,
+ 1e-143,1e-142,1e-141,1e-140,1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,
+ 1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,
+ 1e-123,1e-122,1e-121,1e-120,1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,
+ 1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,
+ 1e-103,1e-102,1e-101,1e-100,1e-99,1e-98,1e-97,1e-96,1e-95,1e-94,1e-93,
+ 1e-92,1e-91,1e-90,1e-89,1e-88,1e-87,1e-86,1e-85,1e-84,1e-83,1e-82,1e-81,
+ 1e-80,1e-79,1e-78,1e-77,1e-76,1e-75,1e-74,1e-73,1e-72,1e-71,1e-70,1e-69,
+ 1e-68,1e-67,1e-66,1e-65,1e-64,1e-63,1e-62,1e-61,1e-60,1e-59,1e-58,1e-57,
+ 1e-56,1e-55,1e-54,1e-53,1e-52,1e-51,1e-50,1e-49,1e-48,1e-47,1e-46,1e-45,
+ 1e-44,1e-43,1e-42,1e-41,1e-40,1e-39,1e-38,1e-37,1e-36,1e-35,1e-34,1e-33,
+ 1e-32,1e-31,1e-30,1e-29,1e-28,1e-27,1e-26,1e-25,1e-24,1e-23,1e-22,1e-21,
+ 1e-20,1e-19,1e-18,1e-17,1e-16,1e-15,1e-14,1e-13,1e-12,1e-11,1e-10,1e-9,
+ 1e-8,1e-7,1e-6,1e-5,1e-4,1e-3,1e-2,1e-1,1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,
+ 1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,
+ 1e22,1e23,1e24,1e25,1e26,1e27,1e28,1e29,1e30,1e31,1e32,1e33,1e34,1e35,
+ 1e36,1e37,1e38,1e39,1e40,1e41,1e42,1e43,1e44,1e45,1e46,1e47,1e48,1e49,
+ 1e50,1e51,1e52,1e53,1e54,1e55,1e56,1e57,1e58,1e59,1e60,1e61,1e62,1e63,
+ 1e64,1e65,1e66,1e67,1e68,1e69,1e70,1e71,1e72,1e73,1e74,1e75,1e76,1e77,
+ 1e78,1e79,1e80,1e81,1e82,1e83,1e84,1e85,1e86,1e87,1e88,1e89,1e90,1e91,
+ 1e92,1e93,1e94,1e95,1e96,1e97,1e98,1e99,1e100,1e101,1e102,1e103,1e104,
+ 1e105,1e106,1e107,1e108,1e109,1e110,1e111,1e112,1e113,1e114,1e115,1e116,
+ 1e117,1e118,1e119,1e120,1e121,1e122,1e123,1e124,1e125,1e126,1e127,1e128,
+ 1e129,1e130,1e131,1e132,1e133,1e134,1e135,1e136,1e137,1e138,1e139,1e140,
+ 1e141,1e142,1e143,1e144,1e145,1e146,1e147,1e148,1e149,1e150,1e151,1e152,
+ 1e153,1e154,1e155,1e156,1e157,1e158,1e159,1e160,1e161,1e162,1e163,1e164,
+ 1e165,1e166,1e167,1e168,1e169,1e170,1e171,1e172,1e173,1e174,1e175,1e176,
+ 1e177,1e178,1e179,1e180,1e181,1e182,1e183,1e184,1e185,1e186,1e187,1e188,
+ 1e189,1e190,1e191,1e192,1e193,1e194,1e195,1e196,1e197,1e198,1e199,1e200,
+ 1e201,1e202,1e203,1e204,1e205,1e206,1e207,1e208,1e209,1e210,1e211,1e212,
+ 1e213,1e214,1e215,1e216,1e217,1e218,1e219,1e220,1e221,1e222,1e223,1e224,
+ 1e225,1e226,1e227,1e228,1e229,1e230,1e231,1e232,1e233,1e234,1e235,1e236,
+ 1e237,1e238,1e239,1e240,1e241,1e242,1e243,1e244,1e245,1e246,1e247,1e248,
+ 1e249,1e250,1e251,1e252,1e253,1e254,1e255,1e256,1e257,1e258,1e259,1e260,
+ 1e261,1e262,1e263,1e264,1e265,1e266,1e267,1e268,1e269,1e270,1e271,1e272,
+ 1e273,1e274,1e275,1e276,1e277,1e278,1e279,1e280,1e281,1e282,1e283,1e284,
+ 1e285,1e286,1e287,1e288,1e289,1e290,1e291,1e292,1e293,1e294,1e295,1e296,
+ 1e297,1e298,1e299,1e300,1e301,1e302,1e303,1e304,1e305,1e306,1e307,1e308
+ };
+ return constants[exponent + 323];
+ }
+
+ std::pair<char*, type> parse_number(char* p) {
+ bool negative = false;
+ if ('-' == *p) {
+ ++p;
+ negative = true;
+
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+ }
+
+ bool try_double = false;
+
+ int i = 0;
+ double d = 0.0; // gcc complains that d might be used uninitialized which isn't true. appease the warning anyway.
+ if (*p == '0') {
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+ } else {
+ unsigned char c = *p;
+ if (c < '0' || c > '9') {
+ return std::make_pair(make_error(p, ERROR_INVALID_NUMBER), TYPE_NULL);
+ }
+
+ do {
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+
+ unsigned char digit = c - '0';
+
+ if (SAJSON_UNLIKELY(!try_double && i > INT_MAX / 10 - 9)) {
+ // TODO: could split this into two loops
+ try_double = true;
+ d = i;
+ }
+ if (SAJSON_UNLIKELY(try_double)) {
+ d = 10.0 * d + digit;
+ } else {
+ i = 10 * i + digit;
+ }
+
+ c = *p;
+ } while (c >= '0' && c <= '9');
+ }
+
+ int64_t exponent = 0;
+
+ if ('.' == *p) {
+ if (!try_double) {
+ try_double = true;
+ d = i;
+ }
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+ char c = *p;
+ if (c < '0' || c > '9') {
+ return std::make_pair(make_error(p, ERROR_INVALID_NUMBER), TYPE_NULL);
+ }
+
+ do {
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+ d = d * 10 + (c - '0');
+ // One option to avoid underflow would be to clamp
+ // to INT_MIN, but int64 subtraction is cheap and
+ // in the absurd case of parsing 2 GB of digits
+ // with an extremely high exponent, this will
+ // produce accurate results. Instead, we just
+ // leave exponent as int64_t and it will never
+ // underflow.
+ --exponent;
+
+ c = *p;
+ } while (c >= '0' && c <= '9');
+ }
+
+ char e = *p;
+ if ('e' == e || 'E' == e) {
+ if (!try_double) {
+ try_double = true;
+ d = i;
+ }
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+
+ bool negativeExponent = false;
+ if ('-' == *p) {
+ negativeExponent = true;
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+ } else if ('+' == *p) {
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+ }
+
+ int exp = 0;
+
+ char c = *p;
+ if (SAJSON_UNLIKELY(c < '0' || c > '9')) {
+ return std::make_pair(make_error(p, ERROR_MISSING_EXPONENT), TYPE_NULL);
+ }
+ for (;;) {
+ // c guaranteed to be between '0' and '9', inclusive
+ unsigned char digit = c - '0';
+ if (exp > (INT_MAX - digit) / 10) {
+ // The exponent overflowed. Keep parsing, but
+ // it will definitely be out of range when
+ // pow10 is called.
+ exp = INT_MAX;
+ } else {
+ exp = 10 * exp + digit;
+ }
+
+ ++p;
+ if (SAJSON_UNLIKELY(at_eof(p))) {
+ return std::make_pair(make_error(p, ERROR_UNEXPECTED_END), TYPE_NULL);
+ }
+
+ c = *p;
+ if (c < '0' || c > '9') {
+ break;
+ }
+ }
+ static_assert(-INT_MAX >= INT_MIN, "exp can be negated without loss or UB");
+ exponent += (negativeExponent ? -exp : exp);
+ }
+
+ if (exponent) {
+ assert(try_double);
+ // If d is zero but the exponent is huge, don't
+ // multiply zero by inf which gives nan.
+ if (d != 0.0) {
+ d *= pow10(exponent);
+ }
+ }
+
+ if (negative) {
+ if (try_double) {
+ d = -d;
+ } else {
+ i = -i;
+ }
+ }
+ if (try_double) {
+ bool success;
+ size_t* out = allocator.reserve(double_storage::word_length, &success);
+ if (SAJSON_UNLIKELY(!success)) {
+ return std::make_pair(oom(p), TYPE_NULL);
+ }
+ double_storage::store(out, d);
+ return std::make_pair(p, TYPE_DOUBLE);
+ } else {
+ bool success;
+ size_t* out = allocator.reserve(integer_storage::word_length, &success);
+ if (SAJSON_UNLIKELY(!success)) {
+ return std::make_pair(oom(p), TYPE_NULL);
+ }
+ integer_storage::store(out, i);
+ return std::make_pair(p, TYPE_INTEGER);
+ }
+ }
+
+ bool install_array(size_t* array_base, size_t* array_end) {
+ using namespace sajson::internal;
+
+ const size_t length = array_end - array_base;
+ bool success;
+ size_t* const new_base = allocator.reserve(length + 1, &success);
+ if (SAJSON_UNLIKELY(!success)) {
+ return false;
+ }
+ size_t* out = new_base + length + 1;
+ size_t* const structure_end = allocator.get_write_pointer_of(0);
+
+ while (array_end > array_base) {
+ size_t element = *--array_end;
+ type element_type = get_element_type(element);
+ size_t element_value = get_element_value(element);
+ size_t* element_ptr = structure_end - element_value;
+ *--out = make_element(element_type, element_ptr - new_base);
+ }
+ *--out = length;
+ return true;
+ }
+
+ bool install_object(size_t* object_base, size_t* object_end) {
+ using namespace internal;
+
+ assert((object_end - object_base) % 3 == 0);
+ const size_t length_times_3 = object_end - object_base;
+#ifndef SAJSON_UNSORTED_OBJECT_KEYS
+ std::sort(
+ reinterpret_cast<object_key_record*>(object_base),
+ reinterpret_cast<object_key_record*>(object_end),
+ object_key_comparator(input.get_data()));
+#endif
+
+ bool success;
+ size_t* const new_base = allocator.reserve(length_times_3 + 1, &success);
+ if (SAJSON_UNLIKELY(!success)) {
+ return false;
+ }
+ size_t* out = new_base + length_times_3 + 1;
+ size_t* const structure_end = allocator.get_write_pointer_of(0);
+
+ while (object_end > object_base) {
+ size_t element = *--object_end;
+ type element_type = get_element_type(element);
+ size_t element_value = get_element_value(element);
+ size_t* element_ptr = structure_end - element_value;
+
+ *--out = make_element(element_type, element_ptr - new_base);
+ *--out = *--object_end;
+ *--out = *--object_end;
+ }
+ *--out = length_times_3 / 3;
+ return true;
+ }
+
+ char* parse_string(char* p, size_t* tag) {
+ using namespace internal;
+
+ ++p; // "
+ size_t start = p - input.get_data();
+ char* input_end_local = input_end;
+ while (input_end_local - p >= 4) {
+ if (!is_plain_string_character(p[0])) { goto found; }
+ if (!is_plain_string_character(p[1])) { p += 1; goto found; }
+ if (!is_plain_string_character(p[2])) { p += 2; goto found; }
+ if (!is_plain_string_character(p[3])) { p += 3; goto found; }
+ p += 4;
+ }
+ for (;;) {
+ if (SAJSON_UNLIKELY(p >= input_end_local)) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+
+ if (!is_plain_string_character(*p)) {
+ break;
+ }
+
+ ++p;
+ }
+ found:
+ if (SAJSON_LIKELY(*p == '"')) {
+ tag[0] = start;
+ tag[1] = p - input.get_data();
+ *p = '\0';
+ return p + 1;
+ }
+
+ if (*p >= 0 && *p < 0x20) {
+ return make_error(p, ERROR_ILLEGAL_CODEPOINT, static_cast<int>(*p));
+ } else {
+ // backslash or >0x7f
+ return parse_string_slow(p, tag, start);
+ }
+ }
+
+ char* read_hex(char* p, unsigned& u) {
+ unsigned v = 0;
+ int i = 4;
+ while (i--) {
+ unsigned char c = *p++;
+ if (c >= '0' && c <= '9') {
+ c -= '0';
+ } else if (c >= 'a' && c <= 'f') {
+ c = c - 'a' + 10;
+ } else if (c >= 'A' && c <= 'F') {
+ c = c - 'A' + 10;
+ } else {
+ return make_error(p, ERROR_INVALID_UNICODE_ESCAPE);
+ }
+ v = (v << 4) + c;
+ }
+
+ u = v;
+ return p;
+ }
+
+ void write_utf8(unsigned codepoint, char*& end) {
+ if (codepoint < 0x80) {
+ *end++ = char(codepoint);
+ } else if (codepoint < 0x800) {
+ *end++ = 0xC0 | char(codepoint >> 6);
+ *end++ = 0x80 | char(codepoint & 0x3F);
+ } else if (codepoint < 0x10000) {
+ *end++ = 0xE0 | char(codepoint >> 12);
+ *end++ = 0x80 | char((codepoint >> 6) & 0x3F);
+ *end++ = 0x80 | char(codepoint & 0x3F);
+ } else {
+ assert(codepoint < 0x200000);
+ *end++ = 0xF0 | char(codepoint >> 18);
+ *end++ = 0x80 | char((codepoint >> 12) & 0x3F);
+ *end++ = 0x80 | char((codepoint >> 6) & 0x3F);
+ *end++ = 0x80 | char(codepoint & 0x3F);
+ }
+ }
+
+ char* parse_string_slow(char* p, size_t* tag, size_t start) {
+ char* end = p;
+ char* input_end_local = input_end;
+
+ for (;;) {
+ if (SAJSON_UNLIKELY(p >= input_end_local)) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+
+ if (SAJSON_UNLIKELY(*p >= 0 && *p < 0x20)) {
+ return make_error(p, ERROR_ILLEGAL_CODEPOINT, static_cast<int>(*p));
+ }
+
+ switch (*p) {
+ case '"':
+ tag[0] = start;
+ tag[1] = end - input.get_data();
+ *end = '\0';
+ return p + 1;
+
+ case '\\':
+ ++p;
+ if (SAJSON_UNLIKELY(p >= input_end_local)) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+
+ char replacement;
+ switch (*p) {
+ case '"': replacement = '"'; goto replace;
+ case '\\': replacement = '\\'; goto replace;
+ case '/': replacement = '/'; goto replace;
+ case 'b': replacement = '\b'; goto replace;
+ case 'f': replacement = '\f'; goto replace;
+ case 'n': replacement = '\n'; goto replace;
+ case 'r': replacement = '\r'; goto replace;
+ case 't': replacement = '\t'; goto replace;
+ replace:
+ *end++ = replacement;
+ ++p;
+ break;
+ case 'u': {
+ ++p;
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 4))) {
+ return make_error(p, ERROR_UNEXPECTED_END);
+ }
+ unsigned u = 0; // gcc's complaining that this could be used uninitialized. wrong.
+ p = read_hex(p, u);
+ if (!p) {
+ return 0;
+ }
+ if (u >= 0xD800 && u <= 0xDBFF) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 6))) {
+ return make_error(p, ERROR_UNEXPECTED_END_OF_UTF16);
+ }
+ char p0 = p[0];
+ char p1 = p[1];
+ if (p0 != '\\' || p1 != 'u') {
+ return make_error(p, ERROR_EXPECTED_U);
+ }
+ p += 2;
+ unsigned v = 0; // gcc's complaining that this could be used uninitialized. wrong.
+ p = read_hex(p, v);
+ if (!p) {
+ return p;
+ }
+
+ if (v < 0xDC00 || v > 0xDFFF) {
+ return make_error(p, ERROR_INVALID_UTF16_TRAIL_SURROGATE);
+ }
+ u = 0x10000 + (((u - 0xD800) << 10) | (v - 0xDC00));
+ }
+ write_utf8(u, end);
+ break;
+ }
+ default:
+ return make_error(p, ERROR_UNKNOWN_ESCAPE);
+ }
+ break;
+
+ default:
+ // validate UTF-8
+ unsigned char c0 = p[0];
+ if (c0 < 128) {
+ *end++ = *p++;
+ } else if (c0 < 224) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 2))) {
+ return unexpected_end(p);
+ }
+ unsigned char c1 = p[1];
+ if (c1 < 128 || c1 >= 192) {
+ return make_error(p + 1, ERROR_INVALID_UTF8);
+ }
+ end[0] = c0;
+ end[1] = c1;
+ end += 2;
+ p += 2;
+ } else if (c0 < 240) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 3))) {
+ return unexpected_end(p);
+ }
+ unsigned char c1 = p[1];
+ if (c1 < 128 || c1 >= 192) {
+ return make_error(p + 1, ERROR_INVALID_UTF8);
+ }
+ unsigned char c2 = p[2];
+ if (c2 < 128 || c2 >= 192) {
+ return make_error(p + 2, ERROR_INVALID_UTF8);
+ }
+ end[0] = c0;
+ end[1] = c1;
+ end[2] = c2;
+ end += 3;
+ p += 3;
+ } else if (c0 < 248) {
+ if (SAJSON_UNLIKELY(!has_remaining_characters(p, 4))) {
+ return unexpected_end(p);
+ }
+ unsigned char c1 = p[1];
+ if (c1 < 128 || c1 >= 192) {
+ return make_error(p + 1, ERROR_INVALID_UTF8);
+ }
+ unsigned char c2 = p[2];
+ if (c2 < 128 || c2 >= 192) {
+ return make_error(p + 2, ERROR_INVALID_UTF8);
+ }
+ unsigned char c3 = p[3];
+ if (c3 < 128 || c3 >= 192) {
+ return make_error(p + 3, ERROR_INVALID_UTF8);
+ }
+ end[0] = c0;
+ end[1] = c1;
+ end[2] = c2;
+ end[3] = c3;
+ end += 4;
+ p += 4;
+ } else {
+ return make_error(p, ERROR_INVALID_UTF8);
+ }
+ break;
+ }
+ }
+ }
+
+ mutable_string_view input;
+ char* const input_end;
+ Allocator allocator;
+
+ type root_type;
+ size_t error_line;
+ size_t error_column;
+ error error_code;
+ int error_arg; // optional argument for the error
+ };
+ /// \endcond
+
+ /**
+ * Parses a string of JSON bytes into a \ref document, given an allocation
+ * strategy instance. Any kind of string type is valid as long as a
+ * mutable_string_view can be constructed from it.
+ *
+ * Valid allocation strategies are \ref single_allocation,
+ * \ref dynamic_allocation, and \ref bounded_allocation.
+ *
+ * A \ref document is returned whether or not the parse succeeds: success
+ * state is available by calling document::is_valid().
+ */
+ template<typename AllocationStrategy, typename StringType>
+ document parse(const AllocationStrategy& strategy, const StringType& string) {
+ mutable_string_view input(string);
+
+ bool success;
+ auto allocator = strategy.make_allocator(input.length(), &success);
+ if (!success) {
+ return document(input, 1, 1, ERROR_OUT_OF_MEMORY, 0);
+ }
+
+ return parser<typename AllocationStrategy::allocator>(
+ input,
+ std::move(allocator)
+ ).get_document();
+ }
+}
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_api.h b/Client/ThirdParty/Box2D/include/box2d/b2_api.h
new file mode 100644
index 0000000..6730203
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_api.h
@@ -0,0 +1,52 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_API_H
+#define B2_API_H
+
+#ifdef B2_SHARED
+ #if defined _WIN32 || defined __CYGWIN__
+ #ifdef box2d_EXPORTS
+ #ifdef __GNUC__
+ #define B2_API __attribute__ ((dllexport))
+ #else
+ #define B2_API __declspec(dllexport)
+ #endif
+ #else
+ #ifdef __GNUC__
+ #define B2_API __attribute__ ((dllimport))
+ #else
+ #define B2_API __declspec(dllimport)
+ #endif
+ #endif
+ #else
+ #if __GNUC__ >= 4
+ #define B2_API __attribute__ ((visibility ("default")))
+ #else
+ #define B2_API
+ #endif
+ #endif
+#else
+ #define B2_API
+#endif
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_block_allocator.h b/Client/ThirdParty/Box2D/include/box2d/b2_block_allocator.h
new file mode 100644
index 0000000..95c12de
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_block_allocator.h
@@ -0,0 +1,60 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_BLOCK_ALLOCATOR_H
+#define B2_BLOCK_ALLOCATOR_H
+
+#include "b2_api.h"
+#include "b2_settings.h"
+
+const int32 b2_blockSizeCount = 14;
+
+struct b2Block;
+struct b2Chunk;
+
+/// This is a small object allocator used for allocating small
+/// objects that persist for more than one time step.
+/// See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp
+class B2_API b2BlockAllocator
+{
+public:
+ b2BlockAllocator();
+ ~b2BlockAllocator();
+
+ /// Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize.
+ void* Allocate(int32 size);
+
+ /// Free memory. This will use b2Free if the size is larger than b2_maxBlockSize.
+ void Free(void* p, int32 size);
+
+ void Clear();
+
+private:
+
+ b2Chunk* m_chunks;
+ int32 m_chunkCount;
+ int32 m_chunkSpace;
+
+ b2Block* m_freeLists[b2_blockSizeCount];
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_body.h b/Client/ThirdParty/Box2D/include/box2d/b2_body.h
new file mode 100644
index 0000000..ff4adec
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_body.h
@@ -0,0 +1,878 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_BODY_H
+#define B2_BODY_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+#include "b2_shape.h"
+
+class b2Fixture;
+class b2Joint;
+class b2Contact;
+class b2Controller;
+class b2World;
+struct b2FixtureDef;
+struct b2JointEdge;
+struct b2ContactEdge;
+
+/// The body type.
+/// static: zero mass, zero velocity, may be manually moved
+/// kinematic: zero mass, non-zero velocity set by user, moved by solver
+/// dynamic: positive mass, non-zero velocity determined by forces, moved by solver
+enum b2BodyType
+{
+ b2_staticBody = 0,
+ b2_kinematicBody,
+ b2_dynamicBody
+};
+
+/// A body definition holds all the data needed to construct a rigid body.
+/// You can safely re-use body definitions. Shapes are added to a body after construction.
+struct B2_API b2BodyDef
+{
+ /// This constructor sets the body definition default values.
+ b2BodyDef()
+ {
+ position.Set(0.0f, 0.0f);
+ angle = 0.0f;
+ linearVelocity.Set(0.0f, 0.0f);
+ angularVelocity = 0.0f;
+ linearDamping = 0.0f;
+ angularDamping = 0.0f;
+ allowSleep = true;
+ awake = true;
+ fixedRotation = false;
+ bullet = false;
+ type = b2_staticBody;
+ enabled = true;
+ gravityScale = 1.0f;
+ }
+
+ /// The body type: static, kinematic, or dynamic.
+ /// Note: if a dynamic body would have zero mass, the mass is set to one.
+ b2BodyType type;
+
+ /// The world position of the body. Avoid creating bodies at the origin
+ /// since this can lead to many overlapping shapes.
+ b2Vec2 position;
+
+ /// The world angle of the body in radians.
+ float angle;
+
+ /// The linear velocity of the body's origin in world co-ordinates.
+ b2Vec2 linearVelocity;
+
+ /// The angular velocity of the body.
+ float angularVelocity;
+
+ /// Linear damping is use to reduce the linear velocity. The damping parameter
+ /// can be larger than 1.0f but the damping effect becomes sensitive to the
+ /// time step when the damping parameter is large.
+ /// Units are 1/time
+ float linearDamping;
+
+ /// Angular damping is use to reduce the angular velocity. The damping parameter
+ /// can be larger than 1.0f but the damping effect becomes sensitive to the
+ /// time step when the damping parameter is large.
+ /// Units are 1/time
+ float angularDamping;
+
+ /// Set this flag to false if this body should never fall asleep. Note that
+ /// this increases CPU usage.
+ bool allowSleep;
+
+ /// Is this body initially awake or sleeping?
+ bool awake;
+
+ /// Should this body be prevented from rotating? Useful for characters.
+ bool fixedRotation;
+
+ /// Is this a fast moving body that should be prevented from tunneling through
+ /// other moving bodies? Note that all bodies are prevented from tunneling through
+ /// kinematic and static bodies. This setting is only considered on dynamic bodies.
+ /// @warning You should use this flag sparingly since it increases processing time.
+ bool bullet;
+
+ /// Does this body start out enabled?
+ bool enabled;
+
+ /// Use this to store application specific body data.
+ b2BodyUserData userData;
+
+ /// Scale the gravity applied to this body.
+ float gravityScale;
+};
+
+/// A rigid body. These are created via b2World::CreateBody.
+class B2_API b2Body
+{
+public:
+ /// Creates a fixture and attach it to this body. Use this function if you need
+ /// to set some fixture parameters, like friction. Otherwise you can create the
+ /// fixture directly from a shape.
+ /// If the density is non-zero, this function automatically updates the mass of the body.
+ /// Contacts are not created until the next time step.
+ /// @param def the fixture definition.
+ /// @warning This function is locked during callbacks.
+ b2Fixture* CreateFixture(const b2FixtureDef* def);
+
+ /// Creates a fixture from a shape and attach it to this body.
+ /// This is a convenience function. Use b2FixtureDef if you need to set parameters
+ /// like friction, restitution, user data, or filtering.
+ /// If the density is non-zero, this function automatically updates the mass of the body.
+ /// @param shape the shape to be cloned.
+ /// @param density the shape density (set to zero for static bodies).
+ /// @warning This function is locked during callbacks.
+ b2Fixture* CreateFixture(const b2Shape* shape, float density);
+
+ /// Destroy a fixture. This removes the fixture from the broad-phase and
+ /// destroys all contacts associated with this fixture. This will
+ /// automatically adjust the mass of the body if the body is dynamic and the
+ /// fixture has positive density.
+ /// All fixtures attached to a body are implicitly destroyed when the body is destroyed.
+ /// @param fixture the fixture to be removed.
+ /// @warning This function is locked during callbacks.
+ void DestroyFixture(b2Fixture* fixture);
+
+ /// Set the position of the body's origin and rotation.
+ /// Manipulating a body's transform may cause non-physical behavior.
+ /// Note: contacts are updated on the next call to b2World::Step.
+ /// @param position the world position of the body's local origin.
+ /// @param angle the world rotation in radians.
+ void SetTransform(const b2Vec2& position, float angle);
+
+ /// Get the body transform for the body's origin.
+ /// @return the world transform of the body's origin.
+ const b2Transform& GetTransform() const;
+
+ /// Get the world body origin position.
+ /// @return the world position of the body's origin.
+ const b2Vec2& GetPosition() const;
+
+ /// Get the angle in radians.
+ /// @return the current world rotation angle in radians.
+ float GetAngle() const;
+
+ /// Get the world position of the center of mass.
+ const b2Vec2& GetWorldCenter() const;
+
+ /// Get the local position of the center of mass.
+ const b2Vec2& GetLocalCenter() const;
+
+ /// Set the linear velocity of the center of mass.
+ /// @param v the new linear velocity of the center of mass.
+ void SetLinearVelocity(const b2Vec2& v);
+
+ /// Get the linear velocity of the center of mass.
+ /// @return the linear velocity of the center of mass.
+ const b2Vec2& GetLinearVelocity() const;
+
+ /// Set the angular velocity.
+ /// @param omega the new angular velocity in radians/second.
+ void SetAngularVelocity(float omega);
+
+ /// Get the angular velocity.
+ /// @return the angular velocity in radians/second.
+ float GetAngularVelocity() const;
+
+ /// Apply a force at a world point. If the force is not
+ /// applied at the center of mass, it will generate a torque and
+ /// affect the angular velocity. This wakes up the body.
+ /// @param force the world force vector, usually in Newtons (N).
+ /// @param point the world position of the point of application.
+ /// @param wake also wake up the body
+ void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake);
+
+ /// Apply a force to the center of mass. This wakes up the body.
+ /// @param force the world force vector, usually in Newtons (N).
+ /// @param wake also wake up the body
+ void ApplyForceToCenter(const b2Vec2& force, bool wake);
+
+ /// Apply a torque. This affects the angular velocity
+ /// without affecting the linear velocity of the center of mass.
+ /// @param torque about the z-axis (out of the screen), usually in N-m.
+ /// @param wake also wake up the body
+ void ApplyTorque(float torque, bool wake);
+
+ /// Apply an impulse at a point. This immediately modifies the velocity.
+ /// It also modifies the angular velocity if the point of application
+ /// is not at the center of mass. This wakes up the body.
+ /// @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
+ /// @param point the world position of the point of application.
+ /// @param wake also wake up the body
+ void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
+
+ /// Apply an impulse to the center of mass. This immediately modifies the velocity.
+ /// @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
+ /// @param wake also wake up the body
+ void ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake);
+
+ /// Apply an angular impulse.
+ /// @param impulse the angular impulse in units of kg*m*m/s
+ /// @param wake also wake up the body
+ void ApplyAngularImpulse(float impulse, bool wake);
+
+ /// Get the total mass of the body.
+ /// @return the mass, usually in kilograms (kg).
+ float GetMass() const;
+
+ /// Get the rotational inertia of the body about the local origin.
+ /// @return the rotational inertia, usually in kg-m^2.
+ float GetInertia() const;
+
+ /// Get the mass data of the body.
+ /// @return a struct containing the mass, inertia and center of the body.
+ void GetMassData(b2MassData* data) const;
+
+ /// Set the mass properties to override the mass properties of the fixtures.
+ /// Note that this changes the center of mass position.
+ /// Note that creating or destroying fixtures can also alter the mass.
+ /// This function has no effect if the body isn't dynamic.
+ /// @param data the mass properties.
+ void SetMassData(const b2MassData* data);
+
+ /// This resets the mass properties to the sum of the mass properties of the fixtures.
+ /// This normally does not need to be called unless you called SetMassData to override
+ /// the mass and you later want to reset the mass.
+ void ResetMassData();
+
+ /// Get the world coordinates of a point given the local coordinates.
+ /// @param localPoint a point on the body measured relative the the body's origin.
+ /// @return the same point expressed in world coordinates.
+ b2Vec2 GetWorldPoint(const b2Vec2& localPoint) const;
+
+ /// Get the world coordinates of a vector given the local coordinates.
+ /// @param localVector a vector fixed in the body.
+ /// @return the same vector expressed in world coordinates.
+ b2Vec2 GetWorldVector(const b2Vec2& localVector) const;
+
+ /// Gets a local point relative to the body's origin given a world point.
+ /// @param worldPoint a point in world coordinates.
+ /// @return the corresponding local point relative to the body's origin.
+ b2Vec2 GetLocalPoint(const b2Vec2& worldPoint) const;
+
+ /// Gets a local vector given a world vector.
+ /// @param worldVector a vector in world coordinates.
+ /// @return the corresponding local vector.
+ b2Vec2 GetLocalVector(const b2Vec2& worldVector) const;
+
+ /// Get the world linear velocity of a world point attached to this body.
+ /// @param worldPoint a point in world coordinates.
+ /// @return the world velocity of a point.
+ b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const;
+
+ /// Get the world velocity of a local point.
+ /// @param localPoint a point in local coordinates.
+ /// @return the world velocity of a point.
+ b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const;
+
+ /// Get the linear damping of the body.
+ float GetLinearDamping() const;
+
+ /// Set the linear damping of the body.
+ void SetLinearDamping(float linearDamping);
+
+ /// Get the angular damping of the body.
+ float GetAngularDamping() const;
+
+ /// Set the angular damping of the body.
+ void SetAngularDamping(float angularDamping);
+
+ /// Get the gravity scale of the body.
+ float GetGravityScale() const;
+
+ /// Set the gravity scale of the body.
+ void SetGravityScale(float scale);
+
+ /// Set the type of this body. This may alter the mass and velocity.
+ void SetType(b2BodyType type);
+
+ /// Get the type of this body.
+ b2BodyType GetType() const;
+
+ /// Should this body be treated like a bullet for continuous collision detection?
+ void SetBullet(bool flag);
+
+ /// Is this body treated like a bullet for continuous collision detection?
+ bool IsBullet() const;
+
+ /// You can disable sleeping on this body. If you disable sleeping, the
+ /// body will be woken.
+ void SetSleepingAllowed(bool flag);
+
+ /// Is this body allowed to sleep
+ bool IsSleepingAllowed() const;
+
+ /// Set the sleep state of the body. A sleeping body has very
+ /// low CPU cost.
+ /// @param flag set to true to wake the body, false to put it to sleep.
+ void SetAwake(bool flag);
+
+ /// Get the sleeping state of this body.
+ /// @return true if the body is awake.
+ bool IsAwake() const;
+
+ /// Allow a body to be disabled. A disabled body is not simulated and cannot
+ /// be collided with or woken up.
+ /// If you pass a flag of true, all fixtures will be added to the broad-phase.
+ /// If you pass a flag of false, all fixtures will be removed from the
+ /// broad-phase and all contacts will be destroyed.
+ /// Fixtures and joints are otherwise unaffected. You may continue
+ /// to create/destroy fixtures and joints on disabled bodies.
+ /// Fixtures on a disabled body are implicitly disabled and will
+ /// not participate in collisions, ray-casts, or queries.
+ /// Joints connected to a disabled body are implicitly disabled.
+ /// An diabled body is still owned by a b2World object and remains
+ /// in the body list.
+ void SetEnabled(bool flag);
+
+ /// Get the active state of the body.
+ bool IsEnabled() const;
+
+ /// Set this body to have fixed rotation. This causes the mass
+ /// to be reset.
+ void SetFixedRotation(bool flag);
+
+ /// Does this body have fixed rotation?
+ bool IsFixedRotation() const;
+
+ /// Get the list of all fixtures attached to this body.
+ b2Fixture* GetFixtureList();
+ const b2Fixture* GetFixtureList() const;
+
+ /// Get the list of all joints attached to this body.
+ b2JointEdge* GetJointList();
+ const b2JointEdge* GetJointList() const;
+
+ /// Get the list of all contacts attached to this body.
+ /// @warning this list changes during the time step and you may
+ /// miss some collisions if you don't use b2ContactListener.
+ b2ContactEdge* GetContactList();
+ const b2ContactEdge* GetContactList() const;
+
+ /// Get the next body in the world's body list.
+ b2Body* GetNext();
+ const b2Body* GetNext() const;
+
+ /// Get the user data pointer that was provided in the body definition.
+ b2BodyUserData& GetUserData();
+
+ /// Get the parent world of this body.
+ b2World* GetWorld();
+ const b2World* GetWorld() const;
+
+ /// Dump this body to a file
+ void Dump();
+
+private:
+
+ friend class b2World;
+ friend class b2Island;
+ friend class b2ContactManager;
+ friend class b2ContactSolver;
+ friend class b2Contact;
+
+ friend class b2DistanceJoint;
+ friend class b2FrictionJoint;
+ friend class b2GearJoint;
+ friend class b2MotorJoint;
+ friend class b2MouseJoint;
+ friend class b2PrismaticJoint;
+ friend class b2PulleyJoint;
+ friend class b2RevoluteJoint;
+ friend class b2RopeJoint;
+ friend class b2WeldJoint;
+ friend class b2WheelJoint;
+
+ // m_flags
+ enum
+ {
+ e_islandFlag = 0x0001,
+ e_awakeFlag = 0x0002,
+ e_autoSleepFlag = 0x0004,
+ e_bulletFlag = 0x0008,
+ e_fixedRotationFlag = 0x0010,
+ e_enabledFlag = 0x0020,
+ e_toiFlag = 0x0040
+ };
+
+ b2Body(const b2BodyDef* bd, b2World* world);
+ ~b2Body();
+
+ void SynchronizeFixtures();
+ void SynchronizeTransform();
+
+ // This is used to prevent connected bodies from colliding.
+ // It may lie, depending on the collideConnected flag.
+ bool ShouldCollide(const b2Body* other) const;
+
+ void Advance(float t);
+
+ b2BodyType m_type;
+
+ uint16 m_flags;
+
+ int32 m_islandIndex;
+
+ b2Transform m_xf; // the body origin transform
+ b2Sweep m_sweep; // the swept motion for CCD
+
+ b2Vec2 m_linearVelocity;
+ float m_angularVelocity;
+
+ b2Vec2 m_force;
+ float m_torque;
+
+ b2World* m_world;
+ b2Body* m_prev;
+ b2Body* m_next;
+
+ b2Fixture* m_fixtureList;
+ int32 m_fixtureCount;
+
+ b2JointEdge* m_jointList;
+ b2ContactEdge* m_contactList;
+
+ float m_mass, m_invMass;
+
+ // Rotational inertia about the center of mass.
+ float m_I, m_invI;
+
+ float m_linearDamping;
+ float m_angularDamping;
+ float m_gravityScale;
+
+ float m_sleepTime;
+
+ b2BodyUserData m_userData;
+};
+
+inline b2BodyType b2Body::GetType() const
+{
+ return m_type;
+}
+
+inline const b2Transform& b2Body::GetTransform() const
+{
+ return m_xf;
+}
+
+inline const b2Vec2& b2Body::GetPosition() const
+{
+ return m_xf.p;
+}
+
+inline float b2Body::GetAngle() const
+{
+ return m_sweep.a;
+}
+
+inline const b2Vec2& b2Body::GetWorldCenter() const
+{
+ return m_sweep.c;
+}
+
+inline const b2Vec2& b2Body::GetLocalCenter() const
+{
+ return m_sweep.localCenter;
+}
+
+inline void b2Body::SetLinearVelocity(const b2Vec2& v)
+{
+ if (m_type == b2_staticBody)
+ {
+ return;
+ }
+
+ if (b2Dot(v,v) > 0.0f)
+ {
+ SetAwake(true);
+ }
+
+ m_linearVelocity = v;
+}
+
+inline const b2Vec2& b2Body::GetLinearVelocity() const
+{
+ return m_linearVelocity;
+}
+
+inline void b2Body::SetAngularVelocity(float w)
+{
+ if (m_type == b2_staticBody)
+ {
+ return;
+ }
+
+ if (w * w > 0.0f)
+ {
+ SetAwake(true);
+ }
+
+ m_angularVelocity = w;
+}
+
+inline float b2Body::GetAngularVelocity() const
+{
+ return m_angularVelocity;
+}
+
+inline float b2Body::GetMass() const
+{
+ return m_mass;
+}
+
+inline float b2Body::GetInertia() const
+{
+ return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
+}
+
+inline void b2Body::GetMassData(b2MassData* data) const
+{
+ data->mass = m_mass;
+ data->I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
+ data->center = m_sweep.localCenter;
+}
+
+inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const
+{
+ return b2Mul(m_xf, localPoint);
+}
+
+inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const
+{
+ return b2Mul(m_xf.q, localVector);
+}
+
+inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const
+{
+ return b2MulT(m_xf, worldPoint);
+}
+
+inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const
+{
+ return b2MulT(m_xf.q, worldVector);
+}
+
+inline b2Vec2 b2Body::GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const
+{
+ return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c);
+}
+
+inline b2Vec2 b2Body::GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const
+{
+ return GetLinearVelocityFromWorldPoint(GetWorldPoint(localPoint));
+}
+
+inline float b2Body::GetLinearDamping() const
+{
+ return m_linearDamping;
+}
+
+inline void b2Body::SetLinearDamping(float linearDamping)
+{
+ m_linearDamping = linearDamping;
+}
+
+inline float b2Body::GetAngularDamping() const
+{
+ return m_angularDamping;
+}
+
+inline void b2Body::SetAngularDamping(float angularDamping)
+{
+ m_angularDamping = angularDamping;
+}
+
+inline float b2Body::GetGravityScale() const
+{
+ return m_gravityScale;
+}
+
+inline void b2Body::SetGravityScale(float scale)
+{
+ m_gravityScale = scale;
+}
+
+inline void b2Body::SetBullet(bool flag)
+{
+ if (flag)
+ {
+ m_flags |= e_bulletFlag;
+ }
+ else
+ {
+ m_flags &= ~e_bulletFlag;
+ }
+}
+
+inline bool b2Body::IsBullet() const
+{
+ return (m_flags & e_bulletFlag) == e_bulletFlag;
+}
+
+inline void b2Body::SetAwake(bool flag)
+{
+ if (m_type == b2_staticBody)
+ {
+ return;
+ }
+
+ if (flag)
+ {
+ m_flags |= e_awakeFlag;
+ m_sleepTime = 0.0f;
+ }
+ else
+ {
+ m_flags &= ~e_awakeFlag;
+ m_sleepTime = 0.0f;
+ m_linearVelocity.SetZero();
+ m_angularVelocity = 0.0f;
+ m_force.SetZero();
+ m_torque = 0.0f;
+ }
+}
+
+inline bool b2Body::IsAwake() const
+{
+ return (m_flags & e_awakeFlag) == e_awakeFlag;
+}
+
+inline bool b2Body::IsEnabled() const
+{
+ return (m_flags & e_enabledFlag) == e_enabledFlag;
+}
+
+inline bool b2Body::IsFixedRotation() const
+{
+ return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
+}
+
+inline void b2Body::SetSleepingAllowed(bool flag)
+{
+ if (flag)
+ {
+ m_flags |= e_autoSleepFlag;
+ }
+ else
+ {
+ m_flags &= ~e_autoSleepFlag;
+ SetAwake(true);
+ }
+}
+
+inline bool b2Body::IsSleepingAllowed() const
+{
+ return (m_flags & e_autoSleepFlag) == e_autoSleepFlag;
+}
+
+inline b2Fixture* b2Body::GetFixtureList()
+{
+ return m_fixtureList;
+}
+
+inline const b2Fixture* b2Body::GetFixtureList() const
+{
+ return m_fixtureList;
+}
+
+inline b2JointEdge* b2Body::GetJointList()
+{
+ return m_jointList;
+}
+
+inline const b2JointEdge* b2Body::GetJointList() const
+{
+ return m_jointList;
+}
+
+inline b2ContactEdge* b2Body::GetContactList()
+{
+ return m_contactList;
+}
+
+inline const b2ContactEdge* b2Body::GetContactList() const
+{
+ return m_contactList;
+}
+
+inline b2Body* b2Body::GetNext()
+{
+ return m_next;
+}
+
+inline const b2Body* b2Body::GetNext() const
+{
+ return m_next;
+}
+
+inline b2BodyUserData& b2Body::GetUserData()
+{
+ return m_userData;
+}
+
+inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake)
+{
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ if (wake && (m_flags & e_awakeFlag) == 0)
+ {
+ SetAwake(true);
+ }
+
+ // Don't accumulate a force if the body is sleeping.
+ if (m_flags & e_awakeFlag)
+ {
+ m_force += force;
+ m_torque += b2Cross(point - m_sweep.c, force);
+ }
+}
+
+inline void b2Body::ApplyForceToCenter(const b2Vec2& force, bool wake)
+{
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ if (wake && (m_flags & e_awakeFlag) == 0)
+ {
+ SetAwake(true);
+ }
+
+ // Don't accumulate a force if the body is sleeping
+ if (m_flags & e_awakeFlag)
+ {
+ m_force += force;
+ }
+}
+
+inline void b2Body::ApplyTorque(float torque, bool wake)
+{
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ if (wake && (m_flags & e_awakeFlag) == 0)
+ {
+ SetAwake(true);
+ }
+
+ // Don't accumulate a force if the body is sleeping
+ if (m_flags & e_awakeFlag)
+ {
+ m_torque += torque;
+ }
+}
+
+inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake)
+{
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ if (wake && (m_flags & e_awakeFlag) == 0)
+ {
+ SetAwake(true);
+ }
+
+ // Don't accumulate velocity if the body is sleeping
+ if (m_flags & e_awakeFlag)
+ {
+ m_linearVelocity += m_invMass * impulse;
+ m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse);
+ }
+}
+
+inline void b2Body::ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake)
+{
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ if (wake && (m_flags & e_awakeFlag) == 0)
+ {
+ SetAwake(true);
+ }
+
+ // Don't accumulate velocity if the body is sleeping
+ if (m_flags & e_awakeFlag)
+ {
+ m_linearVelocity += m_invMass * impulse;
+ }
+}
+
+inline void b2Body::ApplyAngularImpulse(float impulse, bool wake)
+{
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ if (wake && (m_flags & e_awakeFlag) == 0)
+ {
+ SetAwake(true);
+ }
+
+ // Don't accumulate velocity if the body is sleeping
+ if (m_flags & e_awakeFlag)
+ {
+ m_angularVelocity += m_invI * impulse;
+ }
+}
+
+inline void b2Body::SynchronizeTransform()
+{
+ m_xf.q.Set(m_sweep.a);
+ m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
+}
+
+inline void b2Body::Advance(float alpha)
+{
+ // Advance to the new safe time. This doesn't sync the broad-phase.
+ m_sweep.Advance(alpha);
+ m_sweep.c = m_sweep.c0;
+ m_sweep.a = m_sweep.a0;
+ m_xf.q.Set(m_sweep.a);
+ m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter);
+}
+
+inline b2World* b2Body::GetWorld()
+{
+ return m_world;
+}
+
+inline const b2World* b2Body::GetWorld() const
+{
+ return m_world;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_broad_phase.h b/Client/ThirdParty/Box2D/include/box2d/b2_broad_phase.h
new file mode 100644
index 0000000..cc882ab
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_broad_phase.h
@@ -0,0 +1,238 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_BROAD_PHASE_H
+#define B2_BROAD_PHASE_H
+
+#include "b2_api.h"
+#include "b2_settings.h"
+#include "b2_collision.h"
+#include "b2_dynamic_tree.h"
+
+struct B2_API b2Pair
+{
+ int32 proxyIdA;
+ int32 proxyIdB;
+};
+
+/// The broad-phase is used for computing pairs and performing volume queries and ray casts.
+/// This broad-phase does not persist pairs. Instead, this reports potentially new pairs.
+/// It is up to the client to consume the new pairs and to track subsequent overlap.
+class B2_API b2BroadPhase
+{
+public:
+
+ enum
+ {
+ e_nullProxy = -1
+ };
+
+ b2BroadPhase();
+ ~b2BroadPhase();
+
+ /// Create a proxy with an initial AABB. Pairs are not reported until
+ /// UpdatePairs is called.
+ int32 CreateProxy(const b2AABB& aabb, void* userData);
+
+ /// Destroy a proxy. It is up to the client to remove any pairs.
+ void DestroyProxy(int32 proxyId);
+
+ /// Call MoveProxy as many times as you like, then when you are done
+ /// call UpdatePairs to finalized the proxy pairs (for your time step).
+ void MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement);
+
+ /// Call to trigger a re-processing of it's pairs on the next call to UpdatePairs.
+ void TouchProxy(int32 proxyId);
+
+ /// Get the fat AABB for a proxy.
+ const b2AABB& GetFatAABB(int32 proxyId) const;
+
+ /// Get user data from a proxy. Returns nullptr if the id is invalid.
+ void* GetUserData(int32 proxyId) const;
+
+ /// Test overlap of fat AABBs.
+ bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const;
+
+ /// Get the number of proxies.
+ int32 GetProxyCount() const;
+
+ /// Update the pairs. This results in pair callbacks. This can only add pairs.
+ template <typename T>
+ void UpdatePairs(T* callback);
+
+ /// Query an AABB for overlapping proxies. The callback class
+ /// is called for each proxy that overlaps the supplied AABB.
+ template <typename T>
+ void Query(T* callback, const b2AABB& aabb) const;
+
+ /// Ray-cast against the proxies in the tree. This relies on the callback
+ /// to perform a exact ray-cast in the case were the proxy contains a shape.
+ /// The callback also performs the any collision filtering. This has performance
+ /// roughly equal to k * log(n), where k is the number of collisions and n is the
+ /// number of proxies in the tree.
+ /// @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
+ /// @param callback a callback class that is called for each proxy that is hit by the ray.
+ template <typename T>
+ void RayCast(T* callback, const b2RayCastInput& input) const;
+
+ /// Get the height of the embedded tree.
+ int32 GetTreeHeight() const;
+
+ /// Get the balance of the embedded tree.
+ int32 GetTreeBalance() const;
+
+ /// Get the quality metric of the embedded tree.
+ float GetTreeQuality() const;
+
+ /// Shift the world origin. Useful for large worlds.
+ /// The shift formula is: position -= newOrigin
+ /// @param newOrigin the new origin with respect to the old origin
+ void ShiftOrigin(const b2Vec2& newOrigin);
+
+private:
+
+ friend class b2DynamicTree;
+
+ void BufferMove(int32 proxyId);
+ void UnBufferMove(int32 proxyId);
+
+ bool QueryCallback(int32 proxyId);
+
+ b2DynamicTree m_tree;
+
+ int32 m_proxyCount;
+
+ int32* m_moveBuffer;
+ int32 m_moveCapacity;
+ int32 m_moveCount;
+
+ b2Pair* m_pairBuffer;
+ int32 m_pairCapacity;
+ int32 m_pairCount;
+
+ int32 m_queryProxyId;
+};
+
+inline void* b2BroadPhase::GetUserData(int32 proxyId) const
+{
+ return m_tree.GetUserData(proxyId);
+}
+
+inline bool b2BroadPhase::TestOverlap(int32 proxyIdA, int32 proxyIdB) const
+{
+ const b2AABB& aabbA = m_tree.GetFatAABB(proxyIdA);
+ const b2AABB& aabbB = m_tree.GetFatAABB(proxyIdB);
+ return b2TestOverlap(aabbA, aabbB);
+}
+
+inline const b2AABB& b2BroadPhase::GetFatAABB(int32 proxyId) const
+{
+ return m_tree.GetFatAABB(proxyId);
+}
+
+inline int32 b2BroadPhase::GetProxyCount() const
+{
+ return m_proxyCount;
+}
+
+inline int32 b2BroadPhase::GetTreeHeight() const
+{
+ return m_tree.GetHeight();
+}
+
+inline int32 b2BroadPhase::GetTreeBalance() const
+{
+ return m_tree.GetMaxBalance();
+}
+
+inline float b2BroadPhase::GetTreeQuality() const
+{
+ return m_tree.GetAreaRatio();
+}
+
+template <typename T>
+void b2BroadPhase::UpdatePairs(T* callback)
+{
+ // Reset pair buffer
+ m_pairCount = 0;
+
+ // Perform tree queries for all moving proxies.
+ for (int32 i = 0; i < m_moveCount; ++i)
+ {
+ m_queryProxyId = m_moveBuffer[i];
+ if (m_queryProxyId == e_nullProxy)
+ {
+ continue;
+ }
+
+ // We have to query the tree with the fat AABB so that
+ // we don't fail to create a pair that may touch later.
+ const b2AABB& fatAABB = m_tree.GetFatAABB(m_queryProxyId);
+
+ // Query tree, create pairs and add them pair buffer.
+ m_tree.Query(this, fatAABB);
+ }
+
+ // Send pairs to caller
+ for (int32 i = 0; i < m_pairCount; ++i)
+ {
+ b2Pair* primaryPair = m_pairBuffer + i;
+ void* userDataA = m_tree.GetUserData(primaryPair->proxyIdA);
+ void* userDataB = m_tree.GetUserData(primaryPair->proxyIdB);
+
+ callback->AddPair(userDataA, userDataB);
+ }
+
+ // Clear move flags
+ for (int32 i = 0; i < m_moveCount; ++i)
+ {
+ int32 proxyId = m_moveBuffer[i];
+ if (proxyId == e_nullProxy)
+ {
+ continue;
+ }
+
+ m_tree.ClearMoved(proxyId);
+ }
+
+ // Reset move buffer
+ m_moveCount = 0;
+}
+
+template <typename T>
+inline void b2BroadPhase::Query(T* callback, const b2AABB& aabb) const
+{
+ m_tree.Query(callback, aabb);
+}
+
+template <typename T>
+inline void b2BroadPhase::RayCast(T* callback, const b2RayCastInput& input) const
+{
+ m_tree.RayCast(callback, input);
+}
+
+inline void b2BroadPhase::ShiftOrigin(const b2Vec2& newOrigin)
+{
+ m_tree.ShiftOrigin(newOrigin);
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_chain_shape.h b/Client/ThirdParty/Box2D/include/box2d/b2_chain_shape.h
new file mode 100644
index 0000000..da2605d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_chain_shape.h
@@ -0,0 +1,101 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CHAIN_SHAPE_H
+#define B2_CHAIN_SHAPE_H
+
+#include "b2_api.h"
+#include "b2_shape.h"
+
+class b2EdgeShape;
+
+/// A chain shape is a free form sequence of line segments.
+/// The chain has one-sided collision, with the surface normal pointing to the right of the edge.
+/// This provides a counter-clockwise winding like the polygon shape.
+/// Connectivity information is used to create smooth collisions.
+/// @warning the chain will not collide properly if there are self-intersections.
+class B2_API b2ChainShape : public b2Shape
+{
+public:
+ b2ChainShape();
+
+ /// The destructor frees the vertices using b2Free.
+ ~b2ChainShape();
+
+ /// Clear all data.
+ void Clear();
+
+ /// Create a loop. This automatically adjusts connectivity.
+ /// @param vertices an array of vertices, these are copied
+ /// @param count the vertex count
+ void CreateLoop(const b2Vec2* vertices, int32 count);
+
+ /// Create a chain with ghost vertices to connect multiple chains together.
+ /// @param vertices an array of vertices, these are copied
+ /// @param count the vertex count
+ /// @param prevVertex previous vertex from chain that connects to the start
+ /// @param nextVertex next vertex from chain that connects to the end
+ void CreateChain(const b2Vec2* vertices, int32 count,
+ const b2Vec2& prevVertex, const b2Vec2& nextVertex);
+
+ /// Implement b2Shape. Vertices are cloned using b2Alloc.
+ b2Shape* Clone(b2BlockAllocator* allocator) const override;
+
+ /// @see b2Shape::GetChildCount
+ int32 GetChildCount() const override;
+
+ /// Get a child edge.
+ void GetChildEdge(b2EdgeShape* edge, int32 index) const;
+
+ /// This always return false.
+ /// @see b2Shape::TestPoint
+ bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override;
+
+ /// Implement b2Shape.
+ bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeAABB
+ void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override;
+
+ /// Chains have zero mass.
+ /// @see b2Shape::ComputeMass
+ void ComputeMass(b2MassData* massData, float density) const override;
+
+ /// The vertices. Owned by this class.
+ b2Vec2* m_vertices;
+
+ /// The vertex count.
+ int32 m_count;
+
+ b2Vec2 m_prevVertex, m_nextVertex;
+};
+
+inline b2ChainShape::b2ChainShape()
+{
+ m_type = e_chain;
+ m_radius = b2_polygonRadius;
+ m_vertices = nullptr;
+ m_count = 0;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_circle_shape.h b/Client/ThirdParty/Box2D/include/box2d/b2_circle_shape.h
new file mode 100644
index 0000000..5e330f5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_circle_shape.h
@@ -0,0 +1,67 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CIRCLE_SHAPE_H
+#define B2_CIRCLE_SHAPE_H
+
+#include "b2_api.h"
+#include "b2_shape.h"
+
+/// A solid circle shape
+class B2_API b2CircleShape : public b2Shape
+{
+public:
+ b2CircleShape();
+
+ /// Implement b2Shape.
+ b2Shape* Clone(b2BlockAllocator* allocator) const override;
+
+ /// @see b2Shape::GetChildCount
+ int32 GetChildCount() const override;
+
+ /// Implement b2Shape.
+ bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override;
+
+ /// Implement b2Shape.
+ /// @note because the circle is solid, rays that start inside do not hit because the normal is
+ /// not defined.
+ bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeAABB
+ void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeMass
+ void ComputeMass(b2MassData* massData, float density) const override;
+
+ /// Position
+ b2Vec2 m_p;
+};
+
+inline b2CircleShape::b2CircleShape()
+{
+ m_type = e_circle;
+ m_radius = 0.0f;
+ m_p.SetZero();
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_collision.h b/Client/ThirdParty/Box2D/include/box2d/b2_collision.h
new file mode 100644
index 0000000..4c45920
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_collision.h
@@ -0,0 +1,283 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_COLLISION_H
+#define B2_COLLISION_H
+
+#include <limits.h>
+
+#include "b2_api.h"
+#include "b2_math.h"
+
+/// @file
+/// Structures and functions used for computing contact points, distance
+/// queries, and TOI queries.
+
+class b2Shape;
+class b2CircleShape;
+class b2EdgeShape;
+class b2PolygonShape;
+
+const uint8 b2_nullFeature = UCHAR_MAX;
+
+/// The features that intersect to form the contact point
+/// This must be 4 bytes or less.
+struct B2_API b2ContactFeature
+{
+ enum Type
+ {
+ e_vertex = 0,
+ e_face = 1
+ };
+
+ uint8 indexA; ///< Feature index on shapeA
+ uint8 indexB; ///< Feature index on shapeB
+ uint8 typeA; ///< The feature type on shapeA
+ uint8 typeB; ///< The feature type on shapeB
+};
+
+/// Contact ids to facilitate warm starting.
+union B2_API b2ContactID
+{
+ b2ContactFeature cf;
+ uint32 key; ///< Used to quickly compare contact ids.
+};
+
+/// A manifold point is a contact point belonging to a contact
+/// manifold. It holds details related to the geometry and dynamics
+/// of the contact points.
+/// The local point usage depends on the manifold type:
+/// -e_circles: the local center of circleB
+/// -e_faceA: the local center of cirlceB or the clip point of polygonB
+/// -e_faceB: the clip point of polygonA
+/// This structure is stored across time steps, so we keep it small.
+/// Note: the impulses are used for internal caching and may not
+/// provide reliable contact forces, especially for high speed collisions.
+struct B2_API b2ManifoldPoint
+{
+ b2Vec2 localPoint; ///< usage depends on manifold type
+ float normalImpulse; ///< the non-penetration impulse
+ float tangentImpulse; ///< the friction impulse
+ b2ContactID id; ///< uniquely identifies a contact point between two shapes
+};
+
+/// A manifold for two touching convex shapes.
+/// Box2D supports multiple types of contact:
+/// - clip point versus plane with radius
+/// - point versus point with radius (circles)
+/// The local point usage depends on the manifold type:
+/// -e_circles: the local center of circleA
+/// -e_faceA: the center of faceA
+/// -e_faceB: the center of faceB
+/// Similarly the local normal usage:
+/// -e_circles: not used
+/// -e_faceA: the normal on polygonA
+/// -e_faceB: the normal on polygonB
+/// We store contacts in this way so that position correction can
+/// account for movement, which is critical for continuous physics.
+/// All contact scenarios must be expressed in one of these types.
+/// This structure is stored across time steps, so we keep it small.
+struct B2_API b2Manifold
+{
+ enum Type
+ {
+ e_circles,
+ e_faceA,
+ e_faceB
+ };
+
+ b2ManifoldPoint points[b2_maxManifoldPoints]; ///< the points of contact
+ b2Vec2 localNormal; ///< not use for Type::e_points
+ b2Vec2 localPoint; ///< usage depends on manifold type
+ Type type;
+ int32 pointCount; ///< the number of manifold points
+};
+
+/// This is used to compute the current state of a contact manifold.
+struct B2_API b2WorldManifold
+{
+ /// Evaluate the manifold with supplied transforms. This assumes
+ /// modest motion from the original state. This does not change the
+ /// point count, impulses, etc. The radii must come from the shapes
+ /// that generated the manifold.
+ void Initialize(const b2Manifold* manifold,
+ const b2Transform& xfA, float radiusA,
+ const b2Transform& xfB, float radiusB);
+
+ b2Vec2 normal; ///< world vector pointing from A to B
+ b2Vec2 points[b2_maxManifoldPoints]; ///< world contact point (point of intersection)
+ float separations[b2_maxManifoldPoints]; ///< a negative value indicates overlap, in meters
+};
+
+/// This is used for determining the state of contact points.
+enum b2PointState
+{
+ b2_nullState, ///< point does not exist
+ b2_addState, ///< point was added in the update
+ b2_persistState, ///< point persisted across the update
+ b2_removeState ///< point was removed in the update
+};
+
+/// Compute the point states given two manifolds. The states pertain to the transition from manifold1
+/// to manifold2. So state1 is either persist or remove while state2 is either add or persist.
+B2_API void b2GetPointStates(b2PointState state1[b2_maxManifoldPoints], b2PointState state2[b2_maxManifoldPoints],
+ const b2Manifold* manifold1, const b2Manifold* manifold2);
+
+/// Used for computing contact manifolds.
+struct B2_API b2ClipVertex
+{
+ b2Vec2 v;
+ b2ContactID id;
+};
+
+/// Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
+struct B2_API b2RayCastInput
+{
+ b2Vec2 p1, p2;
+ float maxFraction;
+};
+
+/// Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and p2
+/// come from b2RayCastInput.
+struct B2_API b2RayCastOutput
+{
+ b2Vec2 normal;
+ float fraction;
+};
+
+/// An axis aligned bounding box.
+struct B2_API b2AABB
+{
+ /// Verify that the bounds are sorted.
+ bool IsValid() const;
+
+ /// Get the center of the AABB.
+ b2Vec2 GetCenter() const
+ {
+ return 0.5f * (lowerBound + upperBound);
+ }
+
+ /// Get the extents of the AABB (half-widths).
+ b2Vec2 GetExtents() const
+ {
+ return 0.5f * (upperBound - lowerBound);
+ }
+
+ /// Get the perimeter length
+ float GetPerimeter() const
+ {
+ float wx = upperBound.x - lowerBound.x;
+ float wy = upperBound.y - lowerBound.y;
+ return 2.0f * (wx + wy);
+ }
+
+ /// Combine an AABB into this one.
+ void Combine(const b2AABB& aabb)
+ {
+ lowerBound = b2Min(lowerBound, aabb.lowerBound);
+ upperBound = b2Max(upperBound, aabb.upperBound);
+ }
+
+ /// Combine two AABBs into this one.
+ void Combine(const b2AABB& aabb1, const b2AABB& aabb2)
+ {
+ lowerBound = b2Min(aabb1.lowerBound, aabb2.lowerBound);
+ upperBound = b2Max(aabb1.upperBound, aabb2.upperBound);
+ }
+
+ /// Does this aabb contain the provided AABB.
+ bool Contains(const b2AABB& aabb) const
+ {
+ bool result = true;
+ result = result && lowerBound.x <= aabb.lowerBound.x;
+ result = result && lowerBound.y <= aabb.lowerBound.y;
+ result = result && aabb.upperBound.x <= upperBound.x;
+ result = result && aabb.upperBound.y <= upperBound.y;
+ return result;
+ }
+
+ bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input) const;
+
+ b2Vec2 lowerBound; ///< the lower vertex
+ b2Vec2 upperBound; ///< the upper vertex
+};
+
+/// Compute the collision manifold between two circles.
+B2_API void b2CollideCircles(b2Manifold* manifold,
+ const b2CircleShape* circleA, const b2Transform& xfA,
+ const b2CircleShape* circleB, const b2Transform& xfB);
+
+/// Compute the collision manifold between a polygon and a circle.
+B2_API void b2CollidePolygonAndCircle(b2Manifold* manifold,
+ const b2PolygonShape* polygonA, const b2Transform& xfA,
+ const b2CircleShape* circleB, const b2Transform& xfB);
+
+/// Compute the collision manifold between two polygons.
+B2_API void b2CollidePolygons(b2Manifold* manifold,
+ const b2PolygonShape* polygonA, const b2Transform& xfA,
+ const b2PolygonShape* polygonB, const b2Transform& xfB);
+
+/// Compute the collision manifold between an edge and a circle.
+B2_API void b2CollideEdgeAndCircle(b2Manifold* manifold,
+ const b2EdgeShape* polygonA, const b2Transform& xfA,
+ const b2CircleShape* circleB, const b2Transform& xfB);
+
+/// Compute the collision manifold between an edge and a polygon.
+B2_API void b2CollideEdgeAndPolygon(b2Manifold* manifold,
+ const b2EdgeShape* edgeA, const b2Transform& xfA,
+ const b2PolygonShape* circleB, const b2Transform& xfB);
+
+/// Clipping for contact manifolds.
+B2_API int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2],
+ const b2Vec2& normal, float offset, int32 vertexIndexA);
+
+/// Determine if two generic shapes overlap.
+B2_API bool b2TestOverlap( const b2Shape* shapeA, int32 indexA,
+ const b2Shape* shapeB, int32 indexB,
+ const b2Transform& xfA, const b2Transform& xfB);
+
+// ---------------- Inline Functions ------------------------------------------
+
+inline bool b2AABB::IsValid() const
+{
+ b2Vec2 d = upperBound - lowerBound;
+ bool valid = d.x >= 0.0f && d.y >= 0.0f;
+ valid = valid && lowerBound.IsValid() && upperBound.IsValid();
+ return valid;
+}
+
+inline bool b2TestOverlap(const b2AABB& a, const b2AABB& b)
+{
+ b2Vec2 d1, d2;
+ d1 = b.lowerBound - a.upperBound;
+ d2 = a.lowerBound - b.upperBound;
+
+ if (d1.x > 0.0f || d1.y > 0.0f)
+ return false;
+
+ if (d2.x > 0.0f || d2.y > 0.0f)
+ return false;
+
+ return true;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_common.h b/Client/ThirdParty/Box2D/include/box2d/b2_common.h
new file mode 100644
index 0000000..dfca8af
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_common.h
@@ -0,0 +1,138 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_COMMON_H
+#define B2_COMMON_H
+
+#include "b2_settings.h"
+
+#include <stddef.h>
+#include <assert.h>
+#include <float.h>
+
+#if !defined(NDEBUG)
+ #define b2DEBUG
+#endif
+
+#define B2_NOT_USED(x) ((void)(x))
+#define b2Assert(A) assert(A)
+
+#define b2_maxFloat FLT_MAX
+#define b2_epsilon FLT_EPSILON
+#define b2_pi 3.14159265359f
+
+/// @file
+/// Global tuning constants based on meters-kilograms-seconds (MKS) units.
+///
+
+// Collision
+
+/// The maximum number of contact points between two convex shapes. Do
+/// not change this value.
+#define b2_maxManifoldPoints 2
+
+/// This is used to fatten AABBs in the dynamic tree. This allows proxies
+/// to move by a small amount without triggering a tree adjustment.
+/// This is in meters.
+#define b2_aabbExtension (0.1f * b2_lengthUnitsPerMeter)
+
+/// This is used to fatten AABBs in the dynamic tree. This is used to predict
+/// the future position based on the current displacement.
+/// This is a dimensionless multiplier.
+#define b2_aabbMultiplier 4.0f
+
+/// A small length used as a collision and constraint tolerance. Usually it is
+/// chosen to be numerically significant, but visually insignificant. In meters.
+#define b2_linearSlop (0.005f * b2_lengthUnitsPerMeter)
+
+/// A small angle used as a collision and constraint tolerance. Usually it is
+/// chosen to be numerically significant, but visually insignificant.
+#define b2_angularSlop (2.0f / 180.0f * b2_pi)
+
+/// The radius of the polygon/edge shape skin. This should not be modified. Making
+/// this smaller means polygons will have an insufficient buffer for continuous collision.
+/// Making it larger may create artifacts for vertex collision.
+#define b2_polygonRadius (2.0f * b2_linearSlop)
+
+/// Maximum number of sub-steps per contact in continuous physics simulation.
+#define b2_maxSubSteps 8
+
+
+// Dynamics
+
+/// Maximum number of contacts to be handled to solve a TOI impact.
+#define b2_maxTOIContacts 32
+
+/// The maximum linear position correction used when solving constraints. This helps to
+/// prevent overshoot. Meters.
+#define b2_maxLinearCorrection (0.2f * b2_lengthUnitsPerMeter)
+
+/// The maximum angular position correction used when solving constraints. This helps to
+/// prevent overshoot.
+#define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi)
+
+/// The maximum linear translation of a body per step. This limit is very large and is used
+/// to prevent numerical problems. You shouldn't need to adjust this. Meters.
+#define b2_maxTranslation (2.0f * b2_lengthUnitsPerMeter)
+#define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation)
+
+/// The maximum angular velocity of a body. This limit is very large and is used
+/// to prevent numerical problems. You shouldn't need to adjust this.
+#define b2_maxRotation (0.5f * b2_pi)
+#define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation)
+
+/// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so
+/// that overlap is removed in one time step. However using values close to 1 often lead
+/// to overshoot.
+#define b2_baumgarte 0.2f
+#define b2_toiBaumgarte 0.75f
+
+
+// Sleep
+
+/// The time that a body must be still before it will go to sleep.
+#define b2_timeToSleep 0.5f
+
+/// A body cannot sleep if its linear velocity is above this tolerance.
+#define b2_linearSleepTolerance (0.01f * b2_lengthUnitsPerMeter)
+
+/// A body cannot sleep if its angular velocity is above this tolerance.
+#define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi)
+
+/// Dump to a file. Only one dump file allowed at a time.
+void b2OpenDump(const char* fileName);
+void b2Dump(const char* string, ...);
+void b2CloseDump();
+
+/// Version numbering scheme.
+/// See http://en.wikipedia.org/wiki/Software_versioning
+struct b2Version
+{
+ int32 major; ///< significant changes
+ int32 minor; ///< incremental changes
+ int32 revision; ///< bug fixes
+};
+
+/// Current version.
+extern B2_API b2Version b2_version;
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_contact.h b/Client/ThirdParty/Box2D/include/box2d/b2_contact.h
new file mode 100644
index 0000000..de7541f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_contact.h
@@ -0,0 +1,386 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CONTACT_H
+#define B2_CONTACT_H
+
+#include "b2_api.h"
+#include "b2_collision.h"
+#include "b2_fixture.h"
+#include "b2_math.h"
+#include "b2_shape.h"
+
+class b2Body;
+class b2Contact;
+class b2Fixture;
+class b2World;
+class b2BlockAllocator;
+class b2StackAllocator;
+class b2ContactListener;
+
+/// Friction mixing law. The idea is to allow either fixture to drive the friction to zero.
+/// For example, anything slides on ice.
+inline float b2MixFriction(float friction1, float friction2)
+{
+ return b2Sqrt(friction1 * friction2);
+}
+
+/// Restitution mixing law. The idea is allow for anything to bounce off an inelastic surface.
+/// For example, a superball bounces on anything.
+inline float b2MixRestitution(float restitution1, float restitution2)
+{
+ return restitution1 > restitution2 ? restitution1 : restitution2;
+}
+
+/// Restitution mixing law. This picks the lowest value.
+inline float b2MixRestitutionThreshold(float threshold1, float threshold2)
+{
+ return threshold1 < threshold2 ? threshold1 : threshold2;
+}
+
+typedef b2Contact* b2ContactCreateFcn( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB,
+ b2BlockAllocator* allocator);
+typedef void b2ContactDestroyFcn(b2Contact* contact, b2BlockAllocator* allocator);
+
+struct B2_API b2ContactRegister
+{
+ b2ContactCreateFcn* createFcn;
+ b2ContactDestroyFcn* destroyFcn;
+ bool primary;
+};
+
+/// A contact edge is used to connect bodies and contacts together
+/// in a contact graph where each body is a node and each contact
+/// is an edge. A contact edge belongs to a doubly linked list
+/// maintained in each attached body. Each contact has two contact
+/// nodes, one for each attached body.
+struct B2_API b2ContactEdge
+{
+ b2Body* other; ///< provides quick access to the other body attached.
+ b2Contact* contact; ///< the contact
+ b2ContactEdge* prev; ///< the previous contact edge in the body's contact list
+ b2ContactEdge* next; ///< the next contact edge in the body's contact list
+};
+
+/// The class manages contact between two shapes. A contact exists for each overlapping
+/// AABB in the broad-phase (except if filtered). Therefore a contact object may exist
+/// that has no contact points.
+class B2_API b2Contact
+{
+public:
+
+ /// Get the contact manifold. Do not modify the manifold unless you understand the
+ /// internals of Box2D.
+ b2Manifold* GetManifold();
+ const b2Manifold* GetManifold() const;
+
+ /// Get the world manifold.
+ void GetWorldManifold(b2WorldManifold* worldManifold) const;
+
+ /// Is this contact touching?
+ bool IsTouching() const;
+
+ /// Enable/disable this contact. This can be used inside the pre-solve
+ /// contact listener. The contact is only disabled for the current
+ /// time step (or sub-step in continuous collisions).
+ void SetEnabled(bool flag);
+
+ /// Has this contact been disabled?
+ bool IsEnabled() const;
+
+ /// Get the next contact in the world's contact list.
+ b2Contact* GetNext();
+ const b2Contact* GetNext() const;
+
+ /// Get fixture A in this contact.
+ b2Fixture* GetFixtureA();
+ const b2Fixture* GetFixtureA() const;
+
+ /// Get the child primitive index for fixture A.
+ int32 GetChildIndexA() const;
+
+ /// Get fixture B in this contact.
+ b2Fixture* GetFixtureB();
+ const b2Fixture* GetFixtureB() const;
+
+ /// Get the child primitive index for fixture B.
+ int32 GetChildIndexB() const;
+
+ /// Override the default friction mixture. You can call this in b2ContactListener::PreSolve.
+ /// This value persists until set or reset.
+ void SetFriction(float friction);
+
+ /// Get the friction.
+ float GetFriction() const;
+
+ /// Reset the friction mixture to the default value.
+ void ResetFriction();
+
+ /// Override the default restitution mixture. You can call this in b2ContactListener::PreSolve.
+ /// The value persists until you set or reset.
+ void SetRestitution(float restitution);
+
+ /// Get the restitution.
+ float GetRestitution() const;
+
+ /// Reset the restitution to the default value.
+ void ResetRestitution();
+
+ /// Override the default restitution velocity threshold mixture. You can call this in b2ContactListener::PreSolve.
+ /// The value persists until you set or reset.
+ void SetRestitutionThreshold(float threshold);
+
+ /// Get the restitution threshold.
+ float GetRestitutionThreshold() const;
+
+ /// Reset the restitution threshold to the default value.
+ void ResetRestitutionThreshold();
+
+ /// Set the desired tangent speed for a conveyor belt behavior. In meters per second.
+ void SetTangentSpeed(float speed);
+
+ /// Get the desired tangent speed. In meters per second.
+ float GetTangentSpeed() const;
+
+ /// Evaluate this contact with your own manifold and transforms.
+ virtual void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) = 0;
+
+protected:
+ friend class b2ContactManager;
+ friend class b2World;
+ friend class b2ContactSolver;
+ friend class b2Body;
+ friend class b2Fixture;
+
+ // Flags stored in m_flags
+ enum
+ {
+ // Used when crawling contact graph when forming islands.
+ e_islandFlag = 0x0001,
+
+ // Set when the shapes are touching.
+ e_touchingFlag = 0x0002,
+
+ // This contact can be disabled (by user)
+ e_enabledFlag = 0x0004,
+
+ // This contact needs filtering because a fixture filter was changed.
+ e_filterFlag = 0x0008,
+
+ // This bullet contact had a TOI event
+ e_bulletHitFlag = 0x0010,
+
+ // This contact has a valid TOI in m_toi
+ e_toiFlag = 0x0020
+ };
+
+ /// Flag this contact for filtering. Filtering will occur the next time step.
+ void FlagForFiltering();
+
+ static void AddType(b2ContactCreateFcn* createFcn, b2ContactDestroyFcn* destroyFcn,
+ b2Shape::Type typeA, b2Shape::Type typeB);
+ static void InitializeRegisters();
+ static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2Shape::Type typeA, b2Shape::Type typeB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2Contact() : m_fixtureA(nullptr), m_fixtureB(nullptr) {}
+ b2Contact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB);
+ virtual ~b2Contact() {}
+
+ void Update(b2ContactListener* listener);
+
+ static b2ContactRegister s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount];
+ static bool s_initialized;
+
+ uint32 m_flags;
+
+ // World pool and list pointers.
+ b2Contact* m_prev;
+ b2Contact* m_next;
+
+ // Nodes for connecting bodies.
+ b2ContactEdge m_nodeA;
+ b2ContactEdge m_nodeB;
+
+ b2Fixture* m_fixtureA;
+ b2Fixture* m_fixtureB;
+
+ int32 m_indexA;
+ int32 m_indexB;
+
+ b2Manifold m_manifold;
+
+ int32 m_toiCount;
+ float m_toi;
+
+ float m_friction;
+ float m_restitution;
+ float m_restitutionThreshold;
+
+ float m_tangentSpeed;
+};
+
+inline b2Manifold* b2Contact::GetManifold()
+{
+ return &m_manifold;
+}
+
+inline const b2Manifold* b2Contact::GetManifold() const
+{
+ return &m_manifold;
+}
+
+inline void b2Contact::GetWorldManifold(b2WorldManifold* worldManifold) const
+{
+ const b2Body* bodyA = m_fixtureA->GetBody();
+ const b2Body* bodyB = m_fixtureB->GetBody();
+ const b2Shape* shapeA = m_fixtureA->GetShape();
+ const b2Shape* shapeB = m_fixtureB->GetShape();
+
+ worldManifold->Initialize(&m_manifold, bodyA->GetTransform(), shapeA->m_radius, bodyB->GetTransform(), shapeB->m_radius);
+}
+
+inline void b2Contact::SetEnabled(bool flag)
+{
+ if (flag)
+ {
+ m_flags |= e_enabledFlag;
+ }
+ else
+ {
+ m_flags &= ~e_enabledFlag;
+ }
+}
+
+inline bool b2Contact::IsEnabled() const
+{
+ return (m_flags & e_enabledFlag) == e_enabledFlag;
+}
+
+inline bool b2Contact::IsTouching() const
+{
+ return (m_flags & e_touchingFlag) == e_touchingFlag;
+}
+
+inline b2Contact* b2Contact::GetNext()
+{
+ return m_next;
+}
+
+inline const b2Contact* b2Contact::GetNext() const
+{
+ return m_next;
+}
+
+inline b2Fixture* b2Contact::GetFixtureA()
+{
+ return m_fixtureA;
+}
+
+inline const b2Fixture* b2Contact::GetFixtureA() const
+{
+ return m_fixtureA;
+}
+
+inline b2Fixture* b2Contact::GetFixtureB()
+{
+ return m_fixtureB;
+}
+
+inline int32 b2Contact::GetChildIndexA() const
+{
+ return m_indexA;
+}
+
+inline const b2Fixture* b2Contact::GetFixtureB() const
+{
+ return m_fixtureB;
+}
+
+inline int32 b2Contact::GetChildIndexB() const
+{
+ return m_indexB;
+}
+
+inline void b2Contact::FlagForFiltering()
+{
+ m_flags |= e_filterFlag;
+}
+
+inline void b2Contact::SetFriction(float friction)
+{
+ m_friction = friction;
+}
+
+inline float b2Contact::GetFriction() const
+{
+ return m_friction;
+}
+
+inline void b2Contact::ResetFriction()
+{
+ m_friction = b2MixFriction(m_fixtureA->m_friction, m_fixtureB->m_friction);
+}
+
+inline void b2Contact::SetRestitution(float restitution)
+{
+ m_restitution = restitution;
+}
+
+inline float b2Contact::GetRestitution() const
+{
+ return m_restitution;
+}
+
+inline void b2Contact::ResetRestitution()
+{
+ m_restitution = b2MixRestitution(m_fixtureA->m_restitution, m_fixtureB->m_restitution);
+}
+
+inline void b2Contact::SetRestitutionThreshold(float threshold)
+{
+ m_restitutionThreshold = threshold;
+}
+
+inline float b2Contact::GetRestitutionThreshold() const
+{
+ return m_restitutionThreshold;
+}
+
+inline void b2Contact::ResetRestitutionThreshold()
+{
+ m_restitutionThreshold = b2MixRestitutionThreshold(m_fixtureA->m_restitutionThreshold, m_fixtureB->m_restitutionThreshold);
+}
+
+inline void b2Contact::SetTangentSpeed(float speed)
+{
+ m_tangentSpeed = speed;
+}
+
+inline float b2Contact::GetTangentSpeed() const
+{
+ return m_tangentSpeed;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_contact_manager.h b/Client/ThirdParty/Box2D/include/box2d/b2_contact_manager.h
new file mode 100644
index 0000000..fbd3b4d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_contact_manager.h
@@ -0,0 +1,57 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CONTACT_MANAGER_H
+#define B2_CONTACT_MANAGER_H
+
+#include "b2_api.h"
+#include "b2_broad_phase.h"
+
+class b2Contact;
+class b2ContactFilter;
+class b2ContactListener;
+class b2BlockAllocator;
+
+// Delegate of b2World.
+class B2_API b2ContactManager
+{
+public:
+ b2ContactManager();
+
+ // Broad-phase callback.
+ void AddPair(void* proxyUserDataA, void* proxyUserDataB);
+
+ void FindNewContacts();
+
+ void Destroy(b2Contact* c);
+
+ void Collide();
+
+ b2BroadPhase m_broadPhase;
+ b2Contact* m_contactList;
+ int32 m_contactCount;
+ b2ContactFilter* m_contactFilter;
+ b2ContactListener* m_contactListener;
+ b2BlockAllocator* m_allocator;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_distance.h b/Client/ThirdParty/Box2D/include/box2d/b2_distance.h
new file mode 100644
index 0000000..3e05773
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_distance.h
@@ -0,0 +1,171 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_DISTANCE_H
+#define B2_DISTANCE_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+
+class b2Shape;
+
+/// A distance proxy is used by the GJK algorithm.
+/// It encapsulates any shape.
+struct B2_API b2DistanceProxy
+{
+ b2DistanceProxy() : m_vertices(nullptr), m_count(0), m_radius(0.0f) {}
+
+ /// Initialize the proxy using the given shape. The shape
+ /// must remain in scope while the proxy is in use.
+ void Set(const b2Shape* shape, int32 index);
+
+ /// Initialize the proxy using a vertex cloud and radius. The vertices
+ /// must remain in scope while the proxy is in use.
+ void Set(const b2Vec2* vertices, int32 count, float radius);
+
+ /// Get the supporting vertex index in the given direction.
+ int32 GetSupport(const b2Vec2& d) const;
+
+ /// Get the supporting vertex in the given direction.
+ const b2Vec2& GetSupportVertex(const b2Vec2& d) const;
+
+ /// Get the vertex count.
+ int32 GetVertexCount() const;
+
+ /// Get a vertex by index. Used by b2Distance.
+ const b2Vec2& GetVertex(int32 index) const;
+
+ b2Vec2 m_buffer[2];
+ const b2Vec2* m_vertices;
+ int32 m_count;
+ float m_radius;
+};
+
+/// Used to warm start b2Distance.
+/// Set count to zero on first call.
+struct B2_API b2SimplexCache
+{
+ float metric; ///< length or area
+ uint16 count;
+ uint8 indexA[3]; ///< vertices on shape A
+ uint8 indexB[3]; ///< vertices on shape B
+};
+
+/// Input for b2Distance.
+/// You have to option to use the shape radii
+/// in the computation. Even
+struct B2_API b2DistanceInput
+{
+ b2DistanceProxy proxyA;
+ b2DistanceProxy proxyB;
+ b2Transform transformA;
+ b2Transform transformB;
+ bool useRadii;
+};
+
+/// Output for b2Distance.
+struct B2_API b2DistanceOutput
+{
+ b2Vec2 pointA; ///< closest point on shapeA
+ b2Vec2 pointB; ///< closest point on shapeB
+ float distance;
+ int32 iterations; ///< number of GJK iterations used
+};
+
+/// Compute the closest points between two shapes. Supports any combination of:
+/// b2CircleShape, b2PolygonShape, b2EdgeShape. The simplex cache is input/output.
+/// On the first call set b2SimplexCache.count to zero.
+B2_API void b2Distance(b2DistanceOutput* output,
+ b2SimplexCache* cache,
+ const b2DistanceInput* input);
+
+/// Input parameters for b2ShapeCast
+struct B2_API b2ShapeCastInput
+{
+ b2DistanceProxy proxyA;
+ b2DistanceProxy proxyB;
+ b2Transform transformA;
+ b2Transform transformB;
+ b2Vec2 translationB;
+};
+
+/// Output results for b2ShapeCast
+struct B2_API b2ShapeCastOutput
+{
+ b2Vec2 point;
+ b2Vec2 normal;
+ float lambda;
+ int32 iterations;
+};
+
+/// Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation fraction.
+/// @returns true if hit, false if there is no hit or an initial overlap
+B2_API bool b2ShapeCast(b2ShapeCastOutput* output, const b2ShapeCastInput* input);
+
+//////////////////////////////////////////////////////////////////////////
+
+inline int32 b2DistanceProxy::GetVertexCount() const
+{
+ return m_count;
+}
+
+inline const b2Vec2& b2DistanceProxy::GetVertex(int32 index) const
+{
+ b2Assert(0 <= index && index < m_count);
+ return m_vertices[index];
+}
+
+inline int32 b2DistanceProxy::GetSupport(const b2Vec2& d) const
+{
+ int32 bestIndex = 0;
+ float bestValue = b2Dot(m_vertices[0], d);
+ for (int32 i = 1; i < m_count; ++i)
+ {
+ float value = b2Dot(m_vertices[i], d);
+ if (value > bestValue)
+ {
+ bestIndex = i;
+ bestValue = value;
+ }
+ }
+
+ return bestIndex;
+}
+
+inline const b2Vec2& b2DistanceProxy::GetSupportVertex(const b2Vec2& d) const
+{
+ int32 bestIndex = 0;
+ float bestValue = b2Dot(m_vertices[0], d);
+ for (int32 i = 1; i < m_count; ++i)
+ {
+ float value = b2Dot(m_vertices[i], d);
+ if (value > bestValue)
+ {
+ bestIndex = i;
+ bestValue = value;
+ }
+ }
+
+ return m_vertices[bestIndex];
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_distance_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_distance_joint.h
new file mode 100644
index 0000000..cfc75fe
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_distance_joint.h
@@ -0,0 +1,176 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_DISTANCE_JOINT_H
+#define B2_DISTANCE_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Distance joint definition. This requires defining an anchor point on both
+/// bodies and the non-zero distance of the distance joint. The definition uses
+/// local anchor points so that the initial configuration can violate the
+/// constraint slightly. This helps when saving and loading a game.
+struct B2_API b2DistanceJointDef : public b2JointDef
+{
+ b2DistanceJointDef()
+ {
+ type = e_distanceJoint;
+ localAnchorA.Set(0.0f, 0.0f);
+ localAnchorB.Set(0.0f, 0.0f);
+ length = 1.0f;
+ minLength = 0.0f;
+ maxLength = FLT_MAX;
+ stiffness = 0.0f;
+ damping = 0.0f;
+ }
+
+ /// Initialize the bodies, anchors, and rest length using world space anchors.
+ /// The minimum and maximum lengths are set to the rest length.
+ void Initialize(b2Body* bodyA, b2Body* bodyB,
+ const b2Vec2& anchorA, const b2Vec2& anchorB);
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The rest length of this joint. Clamped to a stable minimum value.
+ float length;
+
+ /// Minimum length. Clamped to a stable minimum value.
+ float minLength;
+
+ /// Maximum length. Must be greater than or equal to the minimum length.
+ float maxLength;
+
+ /// The linear stiffness in N/m.
+ float stiffness;
+
+ /// The linear damping in N*s/m.
+ float damping;
+};
+
+/// A distance joint constrains two points on two bodies to remain at a fixed
+/// distance from each other. You can view this as a massless, rigid rod.
+class B2_API b2DistanceJoint : public b2Joint
+{
+public:
+
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ /// Get the reaction force given the inverse time step.
+ /// Unit is N.
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+
+ /// Get the reaction torque given the inverse time step.
+ /// Unit is N*m. This is always zero for a distance joint.
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// The local anchor point relative to bodyA's origin.
+ const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
+
+ /// The local anchor point relative to bodyB's origin.
+ const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
+
+ /// Get the rest length
+ float GetLength() const { return m_length; }
+
+ /// Set the rest length
+ /// @returns clamped rest length
+ float SetLength(float length);
+
+ /// Get the minimum length
+ float GetMinLength() const { return m_minLength; }
+
+ /// Set the minimum length
+ /// @returns the clamped minimum length
+ float SetMinLength(float minLength);
+
+ /// Get the maximum length
+ float GetMaxLength() const { return m_maxLength; }
+
+ /// Set the maximum length
+ /// @returns the clamped maximum length
+ float SetMaxLength(float maxLength);
+
+ /// Get the current length
+ float GetCurrentLength() const;
+
+ /// Set/get the linear stiffness in N/m
+ void SetStiffness(float stiffness) { m_stiffness = stiffness; }
+ float GetStiffness() const { return m_stiffness; }
+
+ /// Set/get linear damping in N*s/m
+ void SetDamping(float damping) { m_damping = damping; }
+ float GetDamping() const { return m_damping; }
+
+ /// Dump joint to dmLog
+ void Dump() override;
+
+ ///
+ void Draw(b2Draw* draw) const override;
+
+protected:
+
+ friend class b2Joint;
+ b2DistanceJoint(const b2DistanceJointDef* data);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ float m_stiffness;
+ float m_damping;
+ float m_bias;
+ float m_length;
+ float m_minLength;
+ float m_maxLength;
+
+ // Solver shared
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ float m_gamma;
+ float m_impulse;
+ float m_lowerImpulse;
+ float m_upperImpulse;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_u;
+ b2Vec2 m_rA;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_currentLength;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ float m_softMass;
+ float m_mass;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_draw.h b/Client/ThirdParty/Box2D/include/box2d/b2_draw.h
new file mode 100644
index 0000000..a4d1711
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_draw.h
@@ -0,0 +1,102 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_DRAW_H
+#define B2_DRAW_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+
+/// Color for debug drawing. Each value has the range [0,1].
+struct B2_API b2Color
+{
+ b2Color() {}
+ b2Color(float rIn, float gIn, float bIn, float aIn = 1.0f)
+ {
+ r = rIn; g = gIn; b = bIn; a = aIn;
+ }
+
+ void Set(float rIn, float gIn, float bIn, float aIn = 1.0f)
+ {
+ r = rIn; g = gIn; b = bIn; a = aIn;
+ }
+
+ float r, g, b, a;
+};
+
+/// Implement and register this class with a b2World to provide debug drawing of physics
+/// entities in your game.
+class B2_API b2Draw
+{
+public:
+ b2Draw();
+
+ virtual ~b2Draw() {}
+
+ enum
+ {
+ e_shapeBit = 0x0001, ///< draw shapes
+ e_jointBit = 0x0002, ///< draw joint connections
+ e_aabbBit = 0x0004, ///< draw axis aligned bounding boxes
+ e_pairBit = 0x0008, ///< draw broad-phase pairs
+ e_centerOfMassBit = 0x0010 ///< draw center of mass frame
+ };
+
+ /// Set the drawing flags.
+ void SetFlags(uint32 flags);
+
+ /// Get the drawing flags.
+ uint32 GetFlags() const;
+
+ /// Append flags to the current flags.
+ void AppendFlags(uint32 flags);
+
+ /// Clear flags from the current flags.
+ void ClearFlags(uint32 flags);
+
+ /// Draw a closed polygon provided in CCW order.
+ virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0;
+
+ /// Draw a solid closed polygon provided in CCW order.
+ virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0;
+
+ /// Draw a circle.
+ virtual void DrawCircle(const b2Vec2& center, float radius, const b2Color& color) = 0;
+
+ /// Draw a solid circle.
+ virtual void DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color) = 0;
+
+ /// Draw a line segment.
+ virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) = 0;
+
+ /// Draw a transform. Choose your own length scale.
+ /// @param xf a transform.
+ virtual void DrawTransform(const b2Transform& xf) = 0;
+
+ /// Draw a point.
+ virtual void DrawPoint(const b2Vec2& p, float size, const b2Color& color) = 0;
+
+protected:
+ uint32 m_drawFlags;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_dynamic_tree.h b/Client/ThirdParty/Box2D/include/box2d/b2_dynamic_tree.h
new file mode 100644
index 0000000..b854919
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_dynamic_tree.h
@@ -0,0 +1,308 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_DYNAMIC_TREE_H
+#define B2_DYNAMIC_TREE_H
+
+#include "b2_api.h"
+#include "b2_collision.h"
+#include "b2_growable_stack.h"
+
+#define b2_nullNode (-1)
+
+/// A node in the dynamic tree. The client does not interact with this directly.
+struct B2_API b2TreeNode
+{
+ bool IsLeaf() const
+ {
+ return child1 == b2_nullNode;
+ }
+
+ /// Enlarged AABB
+ b2AABB aabb;
+
+ void* userData;
+
+ union
+ {
+ int32 parent;
+ int32 next;
+ };
+
+ int32 child1;
+ int32 child2;
+
+ // leaf = 0, free node = -1
+ int32 height;
+
+ bool moved;
+};
+
+/// A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt.
+/// A dynamic tree arranges data in a binary tree to accelerate
+/// queries such as volume queries and ray casts. Leafs are proxies
+/// with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor
+/// so that the proxy AABB is bigger than the client object. This allows the client
+/// object to move by small amounts without triggering a tree update.
+///
+/// Nodes are pooled and relocatable, so we use node indices rather than pointers.
+class B2_API b2DynamicTree
+{
+public:
+ /// Constructing the tree initializes the node pool.
+ b2DynamicTree();
+
+ /// Destroy the tree, freeing the node pool.
+ ~b2DynamicTree();
+
+ /// Create a proxy. Provide a tight fitting AABB and a userData pointer.
+ int32 CreateProxy(const b2AABB& aabb, void* userData);
+
+ /// Destroy a proxy. This asserts if the id is invalid.
+ void DestroyProxy(int32 proxyId);
+
+ /// Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB,
+ /// then the proxy is removed from the tree and re-inserted. Otherwise
+ /// the function returns immediately.
+ /// @return true if the proxy was re-inserted.
+ bool MoveProxy(int32 proxyId, const b2AABB& aabb1, const b2Vec2& displacement);
+
+ /// Get proxy user data.
+ /// @return the proxy user data or 0 if the id is invalid.
+ void* GetUserData(int32 proxyId) const;
+
+ bool WasMoved(int32 proxyId) const;
+ void ClearMoved(int32 proxyId);
+
+ /// Get the fat AABB for a proxy.
+ const b2AABB& GetFatAABB(int32 proxyId) const;
+
+ /// Query an AABB for overlapping proxies. The callback class
+ /// is called for each proxy that overlaps the supplied AABB.
+ template <typename T>
+ void Query(T* callback, const b2AABB& aabb) const;
+
+ /// Ray-cast against the proxies in the tree. This relies on the callback
+ /// to perform a exact ray-cast in the case were the proxy contains a shape.
+ /// The callback also performs the any collision filtering. This has performance
+ /// roughly equal to k * log(n), where k is the number of collisions and n is the
+ /// number of proxies in the tree.
+ /// @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
+ /// @param callback a callback class that is called for each proxy that is hit by the ray.
+ template <typename T>
+ void RayCast(T* callback, const b2RayCastInput& input) const;
+
+ /// Validate this tree. For testing.
+ void Validate() const;
+
+ /// Compute the height of the binary tree in O(N) time. Should not be
+ /// called often.
+ int32 GetHeight() const;
+
+ /// Get the maximum balance of an node in the tree. The balance is the difference
+ /// in height of the two children of a node.
+ int32 GetMaxBalance() const;
+
+ /// Get the ratio of the sum of the node areas to the root area.
+ float GetAreaRatio() const;
+
+ /// Build an optimal tree. Very expensive. For testing.
+ void RebuildBottomUp();
+
+ /// Shift the world origin. Useful for large worlds.
+ /// The shift formula is: position -= newOrigin
+ /// @param newOrigin the new origin with respect to the old origin
+ void ShiftOrigin(const b2Vec2& newOrigin);
+
+private:
+
+ int32 AllocateNode();
+ void FreeNode(int32 node);
+
+ void InsertLeaf(int32 node);
+ void RemoveLeaf(int32 node);
+
+ int32 Balance(int32 index);
+
+ int32 ComputeHeight() const;
+ int32 ComputeHeight(int32 nodeId) const;
+
+ void ValidateStructure(int32 index) const;
+ void ValidateMetrics(int32 index) const;
+
+ int32 m_root;
+
+ b2TreeNode* m_nodes;
+ int32 m_nodeCount;
+ int32 m_nodeCapacity;
+
+ int32 m_freeList;
+
+ int32 m_insertionCount;
+};
+
+inline void* b2DynamicTree::GetUserData(int32 proxyId) const
+{
+ b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
+ return m_nodes[proxyId].userData;
+}
+
+inline bool b2DynamicTree::WasMoved(int32 proxyId) const
+{
+ b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
+ return m_nodes[proxyId].moved;
+}
+
+inline void b2DynamicTree::ClearMoved(int32 proxyId)
+{
+ b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
+ m_nodes[proxyId].moved = false;
+}
+
+inline const b2AABB& b2DynamicTree::GetFatAABB(int32 proxyId) const
+{
+ b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
+ return m_nodes[proxyId].aabb;
+}
+
+template <typename T>
+inline void b2DynamicTree::Query(T* callback, const b2AABB& aabb) const
+{
+ b2GrowableStack<int32, 256> stack;
+ stack.Push(m_root);
+
+ while (stack.GetCount() > 0)
+ {
+ int32 nodeId = stack.Pop();
+ if (nodeId == b2_nullNode)
+ {
+ continue;
+ }
+
+ const b2TreeNode* node = m_nodes + nodeId;
+
+ if (b2TestOverlap(node->aabb, aabb))
+ {
+ if (node->IsLeaf())
+ {
+ bool proceed = callback->QueryCallback(nodeId);
+ if (proceed == false)
+ {
+ return;
+ }
+ }
+ else
+ {
+ stack.Push(node->child1);
+ stack.Push(node->child2);
+ }
+ }
+ }
+}
+
+template <typename T>
+inline void b2DynamicTree::RayCast(T* callback, const b2RayCastInput& input) const
+{
+ b2Vec2 p1 = input.p1;
+ b2Vec2 p2 = input.p2;
+ b2Vec2 r = p2 - p1;
+ b2Assert(r.LengthSquared() > 0.0f);
+ r.Normalize();
+
+ // v is perpendicular to the segment.
+ b2Vec2 v = b2Cross(1.0f, r);
+ b2Vec2 abs_v = b2Abs(v);
+
+ // Separating axis for segment (Gino, p80).
+ // |dot(v, p1 - c)| > dot(|v|, h)
+
+ float maxFraction = input.maxFraction;
+
+ // Build a bounding box for the segment.
+ b2AABB segmentAABB;
+ {
+ b2Vec2 t = p1 + maxFraction * (p2 - p1);
+ segmentAABB.lowerBound = b2Min(p1, t);
+ segmentAABB.upperBound = b2Max(p1, t);
+ }
+
+ b2GrowableStack<int32, 256> stack;
+ stack.Push(m_root);
+
+ while (stack.GetCount() > 0)
+ {
+ int32 nodeId = stack.Pop();
+ if (nodeId == b2_nullNode)
+ {
+ continue;
+ }
+
+ const b2TreeNode* node = m_nodes + nodeId;
+
+ if (b2TestOverlap(node->aabb, segmentAABB) == false)
+ {
+ continue;
+ }
+
+ // Separating axis for segment (Gino, p80).
+ // |dot(v, p1 - c)| > dot(|v|, h)
+ b2Vec2 c = node->aabb.GetCenter();
+ b2Vec2 h = node->aabb.GetExtents();
+ float separation = b2Abs(b2Dot(v, p1 - c)) - b2Dot(abs_v, h);
+ if (separation > 0.0f)
+ {
+ continue;
+ }
+
+ if (node->IsLeaf())
+ {
+ b2RayCastInput subInput;
+ subInput.p1 = input.p1;
+ subInput.p2 = input.p2;
+ subInput.maxFraction = maxFraction;
+
+ float value = callback->RayCastCallback(subInput, nodeId);
+
+ if (value == 0.0f)
+ {
+ // The client has terminated the ray cast.
+ return;
+ }
+
+ if (value > 0.0f)
+ {
+ // Update segment bounding box.
+ maxFraction = value;
+ b2Vec2 t = p1 + maxFraction * (p2 - p1);
+ segmentAABB.lowerBound = b2Min(p1, t);
+ segmentAABB.upperBound = b2Max(p1, t);
+ }
+ }
+ else
+ {
+ stack.Push(node->child1);
+ stack.Push(node->child2);
+ }
+ }
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_edge_shape.h b/Client/ThirdParty/Box2D/include/box2d/b2_edge_shape.h
new file mode 100644
index 0000000..b930ee8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_edge_shape.h
@@ -0,0 +1,86 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_EDGE_SHAPE_H
+#define B2_EDGE_SHAPE_H
+
+#include "b2_api.h"
+#include "b2_shape.h"
+
+/// A line segment (edge) shape. These can be connected in chains or loops
+/// to other edge shapes. Edges created independently are two-sided and do
+/// no provide smooth movement across junctions.
+class B2_API b2EdgeShape : public b2Shape
+{
+public:
+ b2EdgeShape();
+
+ /// Set this as a part of a sequence. Vertex v0 precedes the edge and vertex v3
+ /// follows. These extra vertices are used to provide smooth movement
+ /// across junctions. This also makes the collision one-sided. The edge
+ /// normal points to the right looking from v1 to v2.
+ void SetOneSided(const b2Vec2& v0, const b2Vec2& v1,const b2Vec2& v2, const b2Vec2& v3);
+
+ /// Set this as an isolated edge. Collision is two-sided.
+ void SetTwoSided(const b2Vec2& v1, const b2Vec2& v2);
+
+ /// Implement b2Shape.
+ b2Shape* Clone(b2BlockAllocator* allocator) const override;
+
+ /// @see b2Shape::GetChildCount
+ int32 GetChildCount() const override;
+
+ /// @see b2Shape::TestPoint
+ bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override;
+
+ /// Implement b2Shape.
+ bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeAABB
+ void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeMass
+ void ComputeMass(b2MassData* massData, float density) const override;
+
+ /// These are the edge vertices
+ b2Vec2 m_vertex1, m_vertex2;
+
+ /// Optional adjacent vertices. These are used for smooth collision.
+ b2Vec2 m_vertex0, m_vertex3;
+
+ /// Uses m_vertex0 and m_vertex3 to create smooth collision.
+ bool m_oneSided;
+};
+
+inline b2EdgeShape::b2EdgeShape()
+{
+ m_type = e_edge;
+ m_radius = b2_polygonRadius;
+ m_vertex0.x = 0.0f;
+ m_vertex0.y = 0.0f;
+ m_vertex3.x = 0.0f;
+ m_vertex3.y = 0.0f;
+ m_oneSided = false;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_fixture.h b/Client/ThirdParty/Box2D/include/box2d/b2_fixture.h
new file mode 100644
index 0000000..f12789b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_fixture.h
@@ -0,0 +1,365 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_FIXTURE_H
+#define B2_FIXTURE_H
+
+#include "b2_api.h"
+#include "b2_body.h"
+#include "b2_collision.h"
+#include "b2_shape.h"
+
+class b2BlockAllocator;
+class b2Body;
+class b2BroadPhase;
+class b2Fixture;
+
+/// This holds contact filtering data.
+struct B2_API b2Filter
+{
+ b2Filter()
+ {
+ categoryBits = 0x0001;
+ maskBits = 0xFFFF;
+ groupIndex = 0;
+ }
+
+ /// The collision category bits. Normally you would just set one bit.
+ uint16 categoryBits;
+
+ /// The collision mask bits. This states the categories that this
+ /// shape would accept for collision.
+ uint16 maskBits;
+
+ /// Collision groups allow a certain group of objects to never collide (negative)
+ /// or always collide (positive). Zero means no collision group. Non-zero group
+ /// filtering always wins against the mask bits.
+ int16 groupIndex;
+};
+
+/// A fixture definition is used to create a fixture. This class defines an
+/// abstract fixture definition. You can reuse fixture definitions safely.
+struct B2_API b2FixtureDef
+{
+ /// The constructor sets the default fixture definition values.
+ b2FixtureDef()
+ {
+ shape = nullptr;
+ friction = 0.2f;
+ restitution = 0.0f;
+ restitutionThreshold = 1.0f * b2_lengthUnitsPerMeter;
+ density = 0.0f;
+ isSensor = false;
+ }
+
+ /// The shape, this must be set. The shape will be cloned, so you
+ /// can create the shape on the stack.
+ const b2Shape* shape;
+
+ /// Use this to store application specific fixture data.
+ b2FixtureUserData userData;
+
+ /// The friction coefficient, usually in the range [0,1].
+ float friction;
+
+ /// The restitution (elasticity) usually in the range [0,1].
+ float restitution;
+
+ /// Restitution velocity threshold, usually in m/s. Collisions above this
+ /// speed have restitution applied (will bounce).
+ float restitutionThreshold;
+
+ /// The density, usually in kg/m^2.
+ float density;
+
+ /// A sensor shape collects contact information but never generates a collision
+ /// response.
+ bool isSensor;
+
+ /// Contact filtering data.
+ b2Filter filter;
+};
+
+/// This proxy is used internally to connect fixtures to the broad-phase.
+struct B2_API b2FixtureProxy
+{
+ b2AABB aabb;
+ b2Fixture* fixture;
+ int32 childIndex;
+ int32 proxyId;
+};
+
+/// A fixture is used to attach a shape to a body for collision detection. A fixture
+/// inherits its transform from its parent. Fixtures hold additional non-geometric data
+/// such as friction, collision filters, etc.
+/// Fixtures are created via b2Body::CreateFixture.
+/// @warning you cannot reuse fixtures.
+class B2_API b2Fixture
+{
+public:
+ /// Get the type of the child shape. You can use this to down cast to the concrete shape.
+ /// @return the shape type.
+ b2Shape::Type GetType() const;
+
+ /// Get the child shape. You can modify the child shape, however you should not change the
+ /// number of vertices because this will crash some collision caching mechanisms.
+ /// Manipulating the shape may lead to non-physical behavior.
+ b2Shape* GetShape();
+ const b2Shape* GetShape() const;
+
+ /// Set if this fixture is a sensor.
+ void SetSensor(bool sensor);
+
+ /// Is this fixture a sensor (non-solid)?
+ /// @return the true if the shape is a sensor.
+ bool IsSensor() const;
+
+ /// Set the contact filtering data. This will not update contacts until the next time
+ /// step when either parent body is active and awake.
+ /// This automatically calls Refilter.
+ void SetFilterData(const b2Filter& filter);
+
+ /// Get the contact filtering data.
+ const b2Filter& GetFilterData() const;
+
+ /// Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide.
+ void Refilter();
+
+ /// Get the parent body of this fixture. This is nullptr if the fixture is not attached.
+ /// @return the parent body.
+ b2Body* GetBody();
+ const b2Body* GetBody() const;
+
+ /// Get the next fixture in the parent body's fixture list.
+ /// @return the next shape.
+ b2Fixture* GetNext();
+ const b2Fixture* GetNext() const;
+
+ /// Get the user data that was assigned in the fixture definition. Use this to
+ /// store your application specific data.
+ b2FixtureUserData& GetUserData();
+
+ /// Test a point for containment in this fixture.
+ /// @param p a point in world coordinates.
+ bool TestPoint(const b2Vec2& p) const;
+
+ /// Cast a ray against this shape.
+ /// @param output the ray-cast results.
+ /// @param input the ray-cast input parameters.
+ /// @param childIndex the child shape index (e.g. edge index)
+ bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, int32 childIndex) const;
+
+ /// Get the mass data for this fixture. The mass data is based on the density and
+ /// the shape. The rotational inertia is about the shape's origin. This operation
+ /// may be expensive.
+ void GetMassData(b2MassData* massData) const;
+
+ /// Set the density of this fixture. This will _not_ automatically adjust the mass
+ /// of the body. You must call b2Body::ResetMassData to update the body's mass.
+ void SetDensity(float density);
+
+ /// Get the density of this fixture.
+ float GetDensity() const;
+
+ /// Get the coefficient of friction.
+ float GetFriction() const;
+
+ /// Set the coefficient of friction. This will _not_ change the friction of
+ /// existing contacts.
+ void SetFriction(float friction);
+
+ /// Get the coefficient of restitution.
+ float GetRestitution() const;
+
+ /// Set the coefficient of restitution. This will _not_ change the restitution of
+ /// existing contacts.
+ void SetRestitution(float restitution);
+
+ /// Get the restitution velocity threshold.
+ float GetRestitutionThreshold() const;
+
+ /// Set the restitution threshold. This will _not_ change the restitution threshold of
+ /// existing contacts.
+ void SetRestitutionThreshold(float threshold);
+
+ /// Get the fixture's AABB. This AABB may be enlarge and/or stale.
+ /// If you need a more accurate AABB, compute it using the shape and
+ /// the body transform.
+ const b2AABB& GetAABB(int32 childIndex) const;
+
+ /// Dump this fixture to the log file.
+ void Dump(int32 bodyIndex);
+
+protected:
+
+ friend class b2Body;
+ friend class b2World;
+ friend class b2Contact;
+ friend class b2ContactManager;
+
+ b2Fixture();
+
+ // We need separation create/destroy functions from the constructor/destructor because
+ // the destructor cannot access the allocator (no destructor arguments allowed by C++).
+ void Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def);
+ void Destroy(b2BlockAllocator* allocator);
+
+ // These support body activation/deactivation.
+ void CreateProxies(b2BroadPhase* broadPhase, const b2Transform& xf);
+ void DestroyProxies(b2BroadPhase* broadPhase);
+
+ void Synchronize(b2BroadPhase* broadPhase, const b2Transform& xf1, const b2Transform& xf2);
+
+ float m_density;
+
+ b2Fixture* m_next;
+ b2Body* m_body;
+
+ b2Shape* m_shape;
+
+ float m_friction;
+ float m_restitution;
+ float m_restitutionThreshold;
+
+ b2FixtureProxy* m_proxies;
+ int32 m_proxyCount;
+
+ b2Filter m_filter;
+
+ bool m_isSensor;
+
+ b2FixtureUserData m_userData;
+};
+
+inline b2Shape::Type b2Fixture::GetType() const
+{
+ return m_shape->GetType();
+}
+
+inline b2Shape* b2Fixture::GetShape()
+{
+ return m_shape;
+}
+
+inline const b2Shape* b2Fixture::GetShape() const
+{
+ return m_shape;
+}
+
+inline bool b2Fixture::IsSensor() const
+{
+ return m_isSensor;
+}
+
+inline const b2Filter& b2Fixture::GetFilterData() const
+{
+ return m_filter;
+}
+
+inline b2FixtureUserData& b2Fixture::GetUserData()
+{
+ return m_userData;
+}
+
+inline b2Body* b2Fixture::GetBody()
+{
+ return m_body;
+}
+
+inline const b2Body* b2Fixture::GetBody() const
+{
+ return m_body;
+}
+
+inline b2Fixture* b2Fixture::GetNext()
+{
+ return m_next;
+}
+
+inline const b2Fixture* b2Fixture::GetNext() const
+{
+ return m_next;
+}
+
+inline void b2Fixture::SetDensity(float density)
+{
+ b2Assert(b2IsValid(density) && density >= 0.0f);
+ m_density = density;
+}
+
+inline float b2Fixture::GetDensity() const
+{
+ return m_density;
+}
+
+inline float b2Fixture::GetFriction() const
+{
+ return m_friction;
+}
+
+inline void b2Fixture::SetFriction(float friction)
+{
+ m_friction = friction;
+}
+
+inline float b2Fixture::GetRestitution() const
+{
+ return m_restitution;
+}
+
+inline void b2Fixture::SetRestitution(float restitution)
+{
+ m_restitution = restitution;
+}
+
+inline float b2Fixture::GetRestitutionThreshold() const
+{
+ return m_restitutionThreshold;
+}
+
+inline void b2Fixture::SetRestitutionThreshold(float threshold)
+{
+ m_restitutionThreshold = threshold;
+}
+
+inline bool b2Fixture::TestPoint(const b2Vec2& p) const
+{
+ return m_shape->TestPoint(m_body->GetTransform(), p);
+}
+
+inline bool b2Fixture::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, int32 childIndex) const
+{
+ return m_shape->RayCast(output, input, m_body->GetTransform(), childIndex);
+}
+
+inline void b2Fixture::GetMassData(b2MassData* massData) const
+{
+ m_shape->ComputeMass(massData, m_density);
+}
+
+inline const b2AABB& b2Fixture::GetAABB(int32 childIndex) const
+{
+ b2Assert(0 <= childIndex && childIndex < m_proxyCount);
+ return m_proxies[childIndex].aabb;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_friction_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_friction_joint.h
new file mode 100644
index 0000000..99922c3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_friction_joint.h
@@ -0,0 +1,124 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_FRICTION_JOINT_H
+#define B2_FRICTION_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Friction joint definition.
+struct B2_API b2FrictionJointDef : public b2JointDef
+{
+ b2FrictionJointDef()
+ {
+ type = e_frictionJoint;
+ localAnchorA.SetZero();
+ localAnchorB.SetZero();
+ maxForce = 0.0f;
+ maxTorque = 0.0f;
+ }
+
+ /// Initialize the bodies, anchors, axis, and reference angle using the world
+ /// anchor and world axis.
+ void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The maximum friction force in N.
+ float maxForce;
+
+ /// The maximum friction torque in N-m.
+ float maxTorque;
+};
+
+/// Friction joint. This is used for top-down friction.
+/// It provides 2D translational friction and angular friction.
+class B2_API b2FrictionJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// The local anchor point relative to bodyA's origin.
+ const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
+
+ /// The local anchor point relative to bodyB's origin.
+ const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
+
+ /// Set the maximum friction force in N.
+ void SetMaxForce(float force);
+
+ /// Get the maximum friction force in N.
+ float GetMaxForce() const;
+
+ /// Set the maximum friction torque in N*m.
+ void SetMaxTorque(float torque);
+
+ /// Get the maximum friction torque in N*m.
+ float GetMaxTorque() const;
+
+ /// Dump joint to dmLog
+ void Dump() override;
+
+protected:
+
+ friend class b2Joint;
+
+ b2FrictionJoint(const b2FrictionJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+
+ // Solver shared
+ b2Vec2 m_linearImpulse;
+ float m_angularImpulse;
+ float m_maxForce;
+ float m_maxTorque;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_rA;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ b2Mat22 m_linearMass;
+ float m_angularMass;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_gear_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_gear_joint.h
new file mode 100644
index 0000000..1c40687
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_gear_joint.h
@@ -0,0 +1,130 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_GEAR_JOINT_H
+#define B2_GEAR_JOINT_H
+
+#include "b2_joint.h"
+
+/// Gear joint definition. This definition requires two existing
+/// revolute or prismatic joints (any combination will work).
+/// @warning bodyB on the input joints must both be dynamic
+struct B2_API b2GearJointDef : public b2JointDef
+{
+ b2GearJointDef()
+ {
+ type = e_gearJoint;
+ joint1 = nullptr;
+ joint2 = nullptr;
+ ratio = 1.0f;
+ }
+
+ /// The first revolute/prismatic joint attached to the gear joint.
+ b2Joint* joint1;
+
+ /// The second revolute/prismatic joint attached to the gear joint.
+ b2Joint* joint2;
+
+ /// The gear ratio.
+ /// @see b2GearJoint for explanation.
+ float ratio;
+};
+
+/// A gear joint is used to connect two joints together. Either joint
+/// can be a revolute or prismatic joint. You specify a gear ratio
+/// to bind the motions together:
+/// coordinate1 + ratio * coordinate2 = constant
+/// The ratio can be negative or positive. If one joint is a revolute joint
+/// and the other joint is a prismatic joint, then the ratio will have units
+/// of length or units of 1/length.
+/// @warning You have to manually destroy the gear joint if joint1 or joint2
+/// is destroyed.
+class B2_API b2GearJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// Get the first joint.
+ b2Joint* GetJoint1() { return m_joint1; }
+
+ /// Get the second joint.
+ b2Joint* GetJoint2() { return m_joint2; }
+
+ /// Set/Get the gear ratio.
+ void SetRatio(float ratio);
+ float GetRatio() const;
+
+ /// Dump joint to dmLog
+ void Dump() override;
+
+protected:
+
+ friend class b2Joint;
+ b2GearJoint(const b2GearJointDef* data);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ b2Joint* m_joint1;
+ b2Joint* m_joint2;
+
+ b2JointType m_typeA;
+ b2JointType m_typeB;
+
+ // Body A is connected to body C
+ // Body B is connected to body D
+ b2Body* m_bodyC;
+ b2Body* m_bodyD;
+
+ // Solver shared
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ b2Vec2 m_localAnchorC;
+ b2Vec2 m_localAnchorD;
+
+ b2Vec2 m_localAxisC;
+ b2Vec2 m_localAxisD;
+
+ float m_referenceAngleA;
+ float m_referenceAngleB;
+
+ float m_constant;
+ float m_ratio;
+
+ float m_impulse;
+
+ // Solver temp
+ int32 m_indexA, m_indexB, m_indexC, m_indexD;
+ b2Vec2 m_lcA, m_lcB, m_lcC, m_lcD;
+ float m_mA, m_mB, m_mC, m_mD;
+ float m_iA, m_iB, m_iC, m_iD;
+ b2Vec2 m_JvAC, m_JvBD;
+ float m_JwA, m_JwB, m_JwC, m_JwD;
+ float m_mass;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_growable_stack.h b/Client/ThirdParty/Box2D/include/box2d/b2_growable_stack.h
new file mode 100644
index 0000000..ec42e5e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_growable_stack.h
@@ -0,0 +1,91 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_GROWABLE_STACK_H
+#define B2_GROWABLE_STACK_H
+
+#include <string.h>
+
+#include "b2_settings.h"
+
+/// This is a growable LIFO stack with an initial capacity of N.
+/// If the stack size exceeds the initial capacity, the heap is used
+/// to increase the size of the stack.
+template <typename T, int32 N>
+class b2GrowableStack
+{
+public:
+ b2GrowableStack()
+ {
+ m_stack = m_array;
+ m_count = 0;
+ m_capacity = N;
+ }
+
+ ~b2GrowableStack()
+ {
+ if (m_stack != m_array)
+ {
+ b2Free(m_stack);
+ m_stack = nullptr;
+ }
+ }
+
+ void Push(const T& element)
+ {
+ if (m_count == m_capacity)
+ {
+ T* old = m_stack;
+ m_capacity *= 2;
+ m_stack = (T*)b2Alloc(m_capacity * sizeof(T));
+ memcpy(m_stack, old, m_count * sizeof(T));
+ if (old != m_array)
+ {
+ b2Free(old);
+ }
+ }
+
+ m_stack[m_count] = element;
+ ++m_count;
+ }
+
+ T Pop()
+ {
+ b2Assert(m_count > 0);
+ --m_count;
+ return m_stack[m_count];
+ }
+
+ int32 GetCount()
+ {
+ return m_count;
+ }
+
+private:
+ T* m_stack;
+ T m_array[N];
+ int32 m_count;
+ int32 m_capacity;
+};
+
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_joint.h
new file mode 100644
index 0000000..2b4d586
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_joint.h
@@ -0,0 +1,228 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_JOINT_H
+#define B2_JOINT_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+
+class b2Body;
+class b2Draw;
+class b2Joint;
+struct b2SolverData;
+class b2BlockAllocator;
+
+enum b2JointType
+{
+ e_unknownJoint,
+ e_revoluteJoint,
+ e_prismaticJoint,
+ e_distanceJoint,
+ e_pulleyJoint,
+ e_mouseJoint,
+ e_gearJoint,
+ e_wheelJoint,
+ e_weldJoint,
+ e_frictionJoint,
+ e_ropeJoint,
+ e_motorJoint
+};
+
+struct B2_API b2Jacobian
+{
+ b2Vec2 linear;
+ float angularA;
+ float angularB;
+};
+
+/// A joint edge is used to connect bodies and joints together
+/// in a joint graph where each body is a node and each joint
+/// is an edge. A joint edge belongs to a doubly linked list
+/// maintained in each attached body. Each joint has two joint
+/// nodes, one for each attached body.
+struct B2_API b2JointEdge
+{
+ b2Body* other; ///< provides quick access to the other body attached.
+ b2Joint* joint; ///< the joint
+ b2JointEdge* prev; ///< the previous joint edge in the body's joint list
+ b2JointEdge* next; ///< the next joint edge in the body's joint list
+};
+
+/// Joint definitions are used to construct joints.
+struct B2_API b2JointDef
+{
+ b2JointDef()
+ {
+ type = e_unknownJoint;
+ bodyA = nullptr;
+ bodyB = nullptr;
+ collideConnected = false;
+ }
+
+ /// The joint type is set automatically for concrete joint types.
+ b2JointType type;
+
+ /// Use this to attach application specific data to your joints.
+ b2JointUserData userData;
+
+ /// The first attached body.
+ b2Body* bodyA;
+
+ /// The second attached body.
+ b2Body* bodyB;
+
+ /// Set this flag to true if the attached bodies should collide.
+ bool collideConnected;
+};
+
+/// Utility to compute linear stiffness values from frequency and damping ratio
+B2_API void b2LinearStiffness(float& stiffness, float& damping,
+ float frequencyHertz, float dampingRatio,
+ const b2Body* bodyA, const b2Body* bodyB);
+
+/// Utility to compute rotational stiffness values frequency and damping ratio
+B2_API void b2AngularStiffness(float& stiffness, float& damping,
+ float frequencyHertz, float dampingRatio,
+ const b2Body* bodyA, const b2Body* bodyB);
+
+/// The base joint class. Joints are used to constraint two bodies together in
+/// various fashions. Some joints also feature limits and motors.
+class B2_API b2Joint
+{
+public:
+
+ /// Get the type of the concrete joint.
+ b2JointType GetType() const;
+
+ /// Get the first body attached to this joint.
+ b2Body* GetBodyA();
+
+ /// Get the second body attached to this joint.
+ b2Body* GetBodyB();
+
+ /// Get the anchor point on bodyA in world coordinates.
+ virtual b2Vec2 GetAnchorA() const = 0;
+
+ /// Get the anchor point on bodyB in world coordinates.
+ virtual b2Vec2 GetAnchorB() const = 0;
+
+ /// Get the reaction force on bodyB at the joint anchor in Newtons.
+ virtual b2Vec2 GetReactionForce(float inv_dt) const = 0;
+
+ /// Get the reaction torque on bodyB in N*m.
+ virtual float GetReactionTorque(float inv_dt) const = 0;
+
+ /// Get the next joint the world joint list.
+ b2Joint* GetNext();
+ const b2Joint* GetNext() const;
+
+ /// Get the user data pointer.
+ b2JointUserData& GetUserData();
+
+ /// Short-cut function to determine if either body is enabled.
+ bool IsEnabled() const;
+
+ /// Get collide connected.
+ /// Note: modifying the collide connect flag won't work correctly because
+ /// the flag is only checked when fixture AABBs begin to overlap.
+ bool GetCollideConnected() const;
+
+ /// Dump this joint to the log file.
+ virtual void Dump() { b2Dump("// Dump is not supported for this joint type.\n"); }
+
+ /// Shift the origin for any points stored in world coordinates.
+ virtual void ShiftOrigin(const b2Vec2& newOrigin) { B2_NOT_USED(newOrigin); }
+
+ /// Debug draw this joint
+ virtual void Draw(b2Draw* draw) const;
+
+protected:
+ friend class b2World;
+ friend class b2Body;
+ friend class b2Island;
+ friend class b2GearJoint;
+
+ static b2Joint* Create(const b2JointDef* def, b2BlockAllocator* allocator);
+ static void Destroy(b2Joint* joint, b2BlockAllocator* allocator);
+
+ b2Joint(const b2JointDef* def);
+ virtual ~b2Joint() {}
+
+ virtual void InitVelocityConstraints(const b2SolverData& data) = 0;
+ virtual void SolveVelocityConstraints(const b2SolverData& data) = 0;
+
+ // This returns true if the position errors are within tolerance.
+ virtual bool SolvePositionConstraints(const b2SolverData& data) = 0;
+
+ b2JointType m_type;
+ b2Joint* m_prev;
+ b2Joint* m_next;
+ b2JointEdge m_edgeA;
+ b2JointEdge m_edgeB;
+ b2Body* m_bodyA;
+ b2Body* m_bodyB;
+
+ int32 m_index;
+
+ bool m_islandFlag;
+ bool m_collideConnected;
+
+ b2JointUserData m_userData;
+};
+
+inline b2JointType b2Joint::GetType() const
+{
+ return m_type;
+}
+
+inline b2Body* b2Joint::GetBodyA()
+{
+ return m_bodyA;
+}
+
+inline b2Body* b2Joint::GetBodyB()
+{
+ return m_bodyB;
+}
+
+inline b2Joint* b2Joint::GetNext()
+{
+ return m_next;
+}
+
+inline const b2Joint* b2Joint::GetNext() const
+{
+ return m_next;
+}
+
+inline b2JointUserData& b2Joint::GetUserData()
+{
+ return m_userData;
+}
+
+inline bool b2Joint::GetCollideConnected() const
+{
+ return m_collideConnected;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_math.h b/Client/ThirdParty/Box2D/include/box2d/b2_math.h
new file mode 100644
index 0000000..479e667
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_math.h
@@ -0,0 +1,715 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_MATH_H
+#define B2_MATH_H
+
+#include <math.h>
+
+#include "b2_api.h"
+#include "b2_settings.h"
+
+/// This function is used to ensure that a floating point number is not a NaN or infinity.
+inline bool b2IsValid(float x)
+{
+ return isfinite(x);
+}
+
+#define b2Sqrt(x) sqrtf(x)
+#define b2Atan2(y, x) atan2f(y, x)
+
+/// A 2D column vector.
+struct B2_API b2Vec2
+{
+ /// Default constructor does nothing (for performance).
+ b2Vec2() {}
+
+ /// Construct using coordinates.
+ b2Vec2(float xIn, float yIn) : x(xIn), y(yIn) {}
+
+ /// Set this vector to all zeros.
+ void SetZero() { x = 0.0f; y = 0.0f; }
+
+ /// Set this vector to some specified coordinates.
+ void Set(float x_, float y_) { x = x_; y = y_; }
+
+ /// Negate this vector.
+ b2Vec2 operator -() const { b2Vec2 v; v.Set(-x, -y); return v; }
+
+ /// Read from and indexed element.
+ float operator () (int32 i) const
+ {
+ return (&x)[i];
+ }
+
+ /// Write to an indexed element.
+ float& operator () (int32 i)
+ {
+ return (&x)[i];
+ }
+
+ /// Add a vector to this vector.
+ void operator += (const b2Vec2& v)
+ {
+ x += v.x; y += v.y;
+ }
+
+ /// Subtract a vector from this vector.
+ void operator -= (const b2Vec2& v)
+ {
+ x -= v.x; y -= v.y;
+ }
+
+ /// Multiply this vector by a scalar.
+ void operator *= (float a)
+ {
+ x *= a; y *= a;
+ }
+
+ /// Get the length of this vector (the norm).
+ float Length() const
+ {
+ return b2Sqrt(x * x + y * y);
+ }
+
+ /// Get the length squared. For performance, use this instead of
+ /// b2Vec2::Length (if possible).
+ float LengthSquared() const
+ {
+ return x * x + y * y;
+ }
+
+ /// Convert this vector into a unit vector. Returns the length.
+ float Normalize()
+ {
+ float length = Length();
+ if (length < b2_epsilon)
+ {
+ return 0.0f;
+ }
+ float invLength = 1.0f / length;
+ x *= invLength;
+ y *= invLength;
+
+ return length;
+ }
+
+ /// Does this vector contain finite coordinates?
+ bool IsValid() const
+ {
+ return b2IsValid(x) && b2IsValid(y);
+ }
+
+ /// Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
+ b2Vec2 Skew() const
+ {
+ return b2Vec2(-y, x);
+ }
+
+ float x, y;
+};
+
+/// A 2D column vector with 3 elements.
+struct B2_API b2Vec3
+{
+ /// Default constructor does nothing (for performance).
+ b2Vec3() {}
+
+ /// Construct using coordinates.
+ b2Vec3(float xIn, float yIn, float zIn) : x(xIn), y(yIn), z(zIn) {}
+
+ /// Set this vector to all zeros.
+ void SetZero() { x = 0.0f; y = 0.0f; z = 0.0f; }
+
+ /// Set this vector to some specified coordinates.
+ void Set(float x_, float y_, float z_) { x = x_; y = y_; z = z_; }
+
+ /// Negate this vector.
+ b2Vec3 operator -() const { b2Vec3 v; v.Set(-x, -y, -z); return v; }
+
+ /// Add a vector to this vector.
+ void operator += (const b2Vec3& v)
+ {
+ x += v.x; y += v.y; z += v.z;
+ }
+
+ /// Subtract a vector from this vector.
+ void operator -= (const b2Vec3& v)
+ {
+ x -= v.x; y -= v.y; z -= v.z;
+ }
+
+ /// Multiply this vector by a scalar.
+ void operator *= (float s)
+ {
+ x *= s; y *= s; z *= s;
+ }
+
+ float x, y, z;
+};
+
+/// A 2-by-2 matrix. Stored in column-major order.
+struct B2_API b2Mat22
+{
+ /// The default constructor does nothing (for performance).
+ b2Mat22() {}
+
+ /// Construct this matrix using columns.
+ b2Mat22(const b2Vec2& c1, const b2Vec2& c2)
+ {
+ ex = c1;
+ ey = c2;
+ }
+
+ /// Construct this matrix using scalars.
+ b2Mat22(float a11, float a12, float a21, float a22)
+ {
+ ex.x = a11; ex.y = a21;
+ ey.x = a12; ey.y = a22;
+ }
+
+ /// Initialize this matrix using columns.
+ void Set(const b2Vec2& c1, const b2Vec2& c2)
+ {
+ ex = c1;
+ ey = c2;
+ }
+
+ /// Set this to the identity matrix.
+ void SetIdentity()
+ {
+ ex.x = 1.0f; ey.x = 0.0f;
+ ex.y = 0.0f; ey.y = 1.0f;
+ }
+
+ /// Set this matrix to all zeros.
+ void SetZero()
+ {
+ ex.x = 0.0f; ey.x = 0.0f;
+ ex.y = 0.0f; ey.y = 0.0f;
+ }
+
+ b2Mat22 GetInverse() const
+ {
+ float a = ex.x, b = ey.x, c = ex.y, d = ey.y;
+ b2Mat22 B;
+ float det = a * d - b * c;
+ if (det != 0.0f)
+ {
+ det = 1.0f / det;
+ }
+ B.ex.x = det * d; B.ey.x = -det * b;
+ B.ex.y = -det * c; B.ey.y = det * a;
+ return B;
+ }
+
+ /// Solve A * x = b, where b is a column vector. This is more efficient
+ /// than computing the inverse in one-shot cases.
+ b2Vec2 Solve(const b2Vec2& b) const
+ {
+ float a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
+ float det = a11 * a22 - a12 * a21;
+ if (det != 0.0f)
+ {
+ det = 1.0f / det;
+ }
+ b2Vec2 x;
+ x.x = det * (a22 * b.x - a12 * b.y);
+ x.y = det * (a11 * b.y - a21 * b.x);
+ return x;
+ }
+
+ b2Vec2 ex, ey;
+};
+
+/// A 3-by-3 matrix. Stored in column-major order.
+struct B2_API b2Mat33
+{
+ /// The default constructor does nothing (for performance).
+ b2Mat33() {}
+
+ /// Construct this matrix using columns.
+ b2Mat33(const b2Vec3& c1, const b2Vec3& c2, const b2Vec3& c3)
+ {
+ ex = c1;
+ ey = c2;
+ ez = c3;
+ }
+
+ /// Set this matrix to all zeros.
+ void SetZero()
+ {
+ ex.SetZero();
+ ey.SetZero();
+ ez.SetZero();
+ }
+
+ /// Solve A * x = b, where b is a column vector. This is more efficient
+ /// than computing the inverse in one-shot cases.
+ b2Vec3 Solve33(const b2Vec3& b) const;
+
+ /// Solve A * x = b, where b is a column vector. This is more efficient
+ /// than computing the inverse in one-shot cases. Solve only the upper
+ /// 2-by-2 matrix equation.
+ b2Vec2 Solve22(const b2Vec2& b) const;
+
+ /// Get the inverse of this matrix as a 2-by-2.
+ /// Returns the zero matrix if singular.
+ void GetInverse22(b2Mat33* M) const;
+
+ /// Get the symmetric inverse of this matrix as a 3-by-3.
+ /// Returns the zero matrix if singular.
+ void GetSymInverse33(b2Mat33* M) const;
+
+ b2Vec3 ex, ey, ez;
+};
+
+/// Rotation
+struct B2_API b2Rot
+{
+ b2Rot() {}
+
+ /// Initialize from an angle in radians
+ explicit b2Rot(float angle)
+ {
+ /// TODO_ERIN optimize
+ s = sinf(angle);
+ c = cosf(angle);
+ }
+
+ /// Set using an angle in radians.
+ void Set(float angle)
+ {
+ /// TODO_ERIN optimize
+ s = sinf(angle);
+ c = cosf(angle);
+ }
+
+ /// Set to the identity rotation
+ void SetIdentity()
+ {
+ s = 0.0f;
+ c = 1.0f;
+ }
+
+ /// Get the angle in radians
+ float GetAngle() const
+ {
+ return b2Atan2(s, c);
+ }
+
+ /// Get the x-axis
+ b2Vec2 GetXAxis() const
+ {
+ return b2Vec2(c, s);
+ }
+
+ /// Get the u-axis
+ b2Vec2 GetYAxis() const
+ {
+ return b2Vec2(-s, c);
+ }
+
+ /// Sine and cosine
+ float s, c;
+};
+
+/// A transform contains translation and rotation. It is used to represent
+/// the position and orientation of rigid frames.
+struct B2_API b2Transform
+{
+ /// The default constructor does nothing.
+ b2Transform() {}
+
+ /// Initialize using a position vector and a rotation.
+ b2Transform(const b2Vec2& position, const b2Rot& rotation) : p(position), q(rotation) {}
+
+ /// Set this to the identity transform.
+ void SetIdentity()
+ {
+ p.SetZero();
+ q.SetIdentity();
+ }
+
+ /// Set this based on the position and angle.
+ void Set(const b2Vec2& position, float angle)
+ {
+ p = position;
+ q.Set(angle);
+ }
+
+ b2Vec2 p;
+ b2Rot q;
+};
+
+/// This describes the motion of a body/shape for TOI computation.
+/// Shapes are defined with respect to the body origin, which may
+/// no coincide with the center of mass. However, to support dynamics
+/// we must interpolate the center of mass position.
+struct B2_API b2Sweep
+{
+ /// Get the interpolated transform at a specific time.
+ /// @param transform the output transform
+ /// @param beta is a factor in [0,1], where 0 indicates alpha0.
+ void GetTransform(b2Transform* transform, float beta) const;
+
+ /// Advance the sweep forward, yielding a new initial state.
+ /// @param alpha the new initial time.
+ void Advance(float alpha);
+
+ /// Normalize the angles.
+ void Normalize();
+
+ b2Vec2 localCenter; ///< local center of mass position
+ b2Vec2 c0, c; ///< center world positions
+ float a0, a; ///< world angles
+
+ /// Fraction of the current time step in the range [0,1]
+ /// c0 and a0 are the positions at alpha0.
+ float alpha0;
+};
+
+/// Useful constant
+extern B2_API const b2Vec2 b2Vec2_zero;
+
+/// Perform the dot product on two vectors.
+inline float b2Dot(const b2Vec2& a, const b2Vec2& b)
+{
+ return a.x * b.x + a.y * b.y;
+}
+
+/// Perform the cross product on two vectors. In 2D this produces a scalar.
+inline float b2Cross(const b2Vec2& a, const b2Vec2& b)
+{
+ return a.x * b.y - a.y * b.x;
+}
+
+/// Perform the cross product on a vector and a scalar. In 2D this produces
+/// a vector.
+inline b2Vec2 b2Cross(const b2Vec2& a, float s)
+{
+ return b2Vec2(s * a.y, -s * a.x);
+}
+
+/// Perform the cross product on a scalar and a vector. In 2D this produces
+/// a vector.
+inline b2Vec2 b2Cross(float s, const b2Vec2& a)
+{
+ return b2Vec2(-s * a.y, s * a.x);
+}
+
+/// Multiply a matrix times a vector. If a rotation matrix is provided,
+/// then this transforms the vector from one frame to another.
+inline b2Vec2 b2Mul(const b2Mat22& A, const b2Vec2& v)
+{
+ return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
+}
+
+/// Multiply a matrix transpose times a vector. If a rotation matrix is provided,
+/// then this transforms the vector from one frame to another (inverse transform).
+inline b2Vec2 b2MulT(const b2Mat22& A, const b2Vec2& v)
+{
+ return b2Vec2(b2Dot(v, A.ex), b2Dot(v, A.ey));
+}
+
+/// Add two vectors component-wise.
+inline b2Vec2 operator + (const b2Vec2& a, const b2Vec2& b)
+{
+ return b2Vec2(a.x + b.x, a.y + b.y);
+}
+
+/// Subtract two vectors component-wise.
+inline b2Vec2 operator - (const b2Vec2& a, const b2Vec2& b)
+{
+ return b2Vec2(a.x - b.x, a.y - b.y);
+}
+
+inline b2Vec2 operator * (float s, const b2Vec2& a)
+{
+ return b2Vec2(s * a.x, s * a.y);
+}
+
+inline bool operator == (const b2Vec2& a, const b2Vec2& b)
+{
+ return a.x == b.x && a.y == b.y;
+}
+
+inline bool operator != (const b2Vec2& a, const b2Vec2& b)
+{
+ return a.x != b.x || a.y != b.y;
+}
+
+inline float b2Distance(const b2Vec2& a, const b2Vec2& b)
+{
+ b2Vec2 c = a - b;
+ return c.Length();
+}
+
+inline float b2DistanceSquared(const b2Vec2& a, const b2Vec2& b)
+{
+ b2Vec2 c = a - b;
+ return b2Dot(c, c);
+}
+
+inline b2Vec3 operator * (float s, const b2Vec3& a)
+{
+ return b2Vec3(s * a.x, s * a.y, s * a.z);
+}
+
+/// Add two vectors component-wise.
+inline b2Vec3 operator + (const b2Vec3& a, const b2Vec3& b)
+{
+ return b2Vec3(a.x + b.x, a.y + b.y, a.z + b.z);
+}
+
+/// Subtract two vectors component-wise.
+inline b2Vec3 operator - (const b2Vec3& a, const b2Vec3& b)
+{
+ return b2Vec3(a.x - b.x, a.y - b.y, a.z - b.z);
+}
+
+/// Perform the dot product on two vectors.
+inline float b2Dot(const b2Vec3& a, const b2Vec3& b)
+{
+ return a.x * b.x + a.y * b.y + a.z * b.z;
+}
+
+/// Perform the cross product on two vectors.
+inline b2Vec3 b2Cross(const b2Vec3& a, const b2Vec3& b)
+{
+ return b2Vec3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
+}
+
+inline b2Mat22 operator + (const b2Mat22& A, const b2Mat22& B)
+{
+ return b2Mat22(A.ex + B.ex, A.ey + B.ey);
+}
+
+// A * B
+inline b2Mat22 b2Mul(const b2Mat22& A, const b2Mat22& B)
+{
+ return b2Mat22(b2Mul(A, B.ex), b2Mul(A, B.ey));
+}
+
+// A^T * B
+inline b2Mat22 b2MulT(const b2Mat22& A, const b2Mat22& B)
+{
+ b2Vec2 c1(b2Dot(A.ex, B.ex), b2Dot(A.ey, B.ex));
+ b2Vec2 c2(b2Dot(A.ex, B.ey), b2Dot(A.ey, B.ey));
+ return b2Mat22(c1, c2);
+}
+
+/// Multiply a matrix times a vector.
+inline b2Vec3 b2Mul(const b2Mat33& A, const b2Vec3& v)
+{
+ return v.x * A.ex + v.y * A.ey + v.z * A.ez;
+}
+
+/// Multiply a matrix times a vector.
+inline b2Vec2 b2Mul22(const b2Mat33& A, const b2Vec2& v)
+{
+ return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
+}
+
+/// Multiply two rotations: q * r
+inline b2Rot b2Mul(const b2Rot& q, const b2Rot& r)
+{
+ // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]
+ // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]
+ // s = qs * rc + qc * rs
+ // c = qc * rc - qs * rs
+ b2Rot qr;
+ qr.s = q.s * r.c + q.c * r.s;
+ qr.c = q.c * r.c - q.s * r.s;
+ return qr;
+}
+
+/// Transpose multiply two rotations: qT * r
+inline b2Rot b2MulT(const b2Rot& q, const b2Rot& r)
+{
+ // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]
+ // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]
+ // s = qc * rs - qs * rc
+ // c = qc * rc + qs * rs
+ b2Rot qr;
+ qr.s = q.c * r.s - q.s * r.c;
+ qr.c = q.c * r.c + q.s * r.s;
+ return qr;
+}
+
+/// Rotate a vector
+inline b2Vec2 b2Mul(const b2Rot& q, const b2Vec2& v)
+{
+ return b2Vec2(q.c * v.x - q.s * v.y, q.s * v.x + q.c * v.y);
+}
+
+/// Inverse rotate a vector
+inline b2Vec2 b2MulT(const b2Rot& q, const b2Vec2& v)
+{
+ return b2Vec2(q.c * v.x + q.s * v.y, -q.s * v.x + q.c * v.y);
+}
+
+inline b2Vec2 b2Mul(const b2Transform& T, const b2Vec2& v)
+{
+ float x = (T.q.c * v.x - T.q.s * v.y) + T.p.x;
+ float y = (T.q.s * v.x + T.q.c * v.y) + T.p.y;
+
+ return b2Vec2(x, y);
+}
+
+inline b2Vec2 b2MulT(const b2Transform& T, const b2Vec2& v)
+{
+ float px = v.x - T.p.x;
+ float py = v.y - T.p.y;
+ float x = (T.q.c * px + T.q.s * py);
+ float y = (-T.q.s * px + T.q.c * py);
+
+ return b2Vec2(x, y);
+}
+
+// v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p
+// = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p
+inline b2Transform b2Mul(const b2Transform& A, const b2Transform& B)
+{
+ b2Transform C;
+ C.q = b2Mul(A.q, B.q);
+ C.p = b2Mul(A.q, B.p) + A.p;
+ return C;
+}
+
+// v2 = A.q' * (B.q * v1 + B.p - A.p)
+// = A.q' * B.q * v1 + A.q' * (B.p - A.p)
+inline b2Transform b2MulT(const b2Transform& A, const b2Transform& B)
+{
+ b2Transform C;
+ C.q = b2MulT(A.q, B.q);
+ C.p = b2MulT(A.q, B.p - A.p);
+ return C;
+}
+
+template <typename T>
+inline T b2Abs(T a)
+{
+ return a > T(0) ? a : -a;
+}
+
+inline b2Vec2 b2Abs(const b2Vec2& a)
+{
+ return b2Vec2(b2Abs(a.x), b2Abs(a.y));
+}
+
+inline b2Mat22 b2Abs(const b2Mat22& A)
+{
+ return b2Mat22(b2Abs(A.ex), b2Abs(A.ey));
+}
+
+template <typename T>
+inline T b2Min(T a, T b)
+{
+ return a < b ? a : b;
+}
+
+inline b2Vec2 b2Min(const b2Vec2& a, const b2Vec2& b)
+{
+ return b2Vec2(b2Min(a.x, b.x), b2Min(a.y, b.y));
+}
+
+template <typename T>
+inline T b2Max(T a, T b)
+{
+ return a > b ? a : b;
+}
+
+inline b2Vec2 b2Max(const b2Vec2& a, const b2Vec2& b)
+{
+ return b2Vec2(b2Max(a.x, b.x), b2Max(a.y, b.y));
+}
+
+template <typename T>
+inline T b2Clamp(T a, T low, T high)
+{
+ return b2Max(low, b2Min(a, high));
+}
+
+inline b2Vec2 b2Clamp(const b2Vec2& a, const b2Vec2& low, const b2Vec2& high)
+{
+ return b2Max(low, b2Min(a, high));
+}
+
+template<typename T> inline void b2Swap(T& a, T& b)
+{
+ T tmp = a;
+ a = b;
+ b = tmp;
+}
+
+/// "Next Largest Power of 2
+/// Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm
+/// that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with
+/// the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next
+/// largest power of 2. For a 32-bit value:"
+inline uint32 b2NextPowerOfTwo(uint32 x)
+{
+ x |= (x >> 1);
+ x |= (x >> 2);
+ x |= (x >> 4);
+ x |= (x >> 8);
+ x |= (x >> 16);
+ return x + 1;
+}
+
+inline bool b2IsPowerOfTwo(uint32 x)
+{
+ bool result = x > 0 && (x & (x - 1)) == 0;
+ return result;
+}
+
+// https://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/
+inline void b2Sweep::GetTransform(b2Transform* xf, float beta) const
+{
+ xf->p = (1.0f - beta) * c0 + beta * c;
+ float angle = (1.0f - beta) * a0 + beta * a;
+ xf->q.Set(angle);
+
+ // Shift to origin
+ xf->p -= b2Mul(xf->q, localCenter);
+}
+
+inline void b2Sweep::Advance(float alpha)
+{
+ b2Assert(alpha0 < 1.0f);
+ float beta = (alpha - alpha0) / (1.0f - alpha0);
+ c0 += beta * (c - c0);
+ a0 += beta * (a - a0);
+ alpha0 = alpha;
+}
+
+/// Normalize an angle in radians to be between -pi and pi
+inline void b2Sweep::Normalize()
+{
+ float twoPi = 2.0f * b2_pi;
+ float d = twoPi * floorf(a0 / twoPi);
+ a0 -= d;
+ a -= d;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_motor_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_motor_joint.h
new file mode 100644
index 0000000..c88115f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_motor_joint.h
@@ -0,0 +1,138 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_MOTOR_JOINT_H
+#define B2_MOTOR_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Motor joint definition.
+struct B2_API b2MotorJointDef : public b2JointDef
+{
+ b2MotorJointDef()
+ {
+ type = e_motorJoint;
+ linearOffset.SetZero();
+ angularOffset = 0.0f;
+ maxForce = 1.0f;
+ maxTorque = 1.0f;
+ correctionFactor = 0.3f;
+ }
+
+ /// Initialize the bodies and offsets using the current transforms.
+ void Initialize(b2Body* bodyA, b2Body* bodyB);
+
+ /// Position of bodyB minus the position of bodyA, in bodyA's frame, in meters.
+ b2Vec2 linearOffset;
+
+ /// The bodyB angle minus bodyA angle in radians.
+ float angularOffset;
+
+ /// The maximum motor force in N.
+ float maxForce;
+
+ /// The maximum motor torque in N-m.
+ float maxTorque;
+
+ /// Position correction factor in the range [0,1].
+ float correctionFactor;
+};
+
+/// A motor joint is used to control the relative motion
+/// between two bodies. A typical usage is to control the movement
+/// of a dynamic body with respect to the ground.
+class B2_API b2MotorJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// Set/get the target linear offset, in frame A, in meters.
+ void SetLinearOffset(const b2Vec2& linearOffset);
+ const b2Vec2& GetLinearOffset() const;
+
+ /// Set/get the target angular offset, in radians.
+ void SetAngularOffset(float angularOffset);
+ float GetAngularOffset() const;
+
+ /// Set the maximum friction force in N.
+ void SetMaxForce(float force);
+
+ /// Get the maximum friction force in N.
+ float GetMaxForce() const;
+
+ /// Set the maximum friction torque in N*m.
+ void SetMaxTorque(float torque);
+
+ /// Get the maximum friction torque in N*m.
+ float GetMaxTorque() const;
+
+ /// Set the position correction factor in the range [0,1].
+ void SetCorrectionFactor(float factor);
+
+ /// Get the position correction factor in the range [0,1].
+ float GetCorrectionFactor() const;
+
+ /// Dump to b2Log
+ void Dump() override;
+
+protected:
+
+ friend class b2Joint;
+
+ b2MotorJoint(const b2MotorJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ // Solver shared
+ b2Vec2 m_linearOffset;
+ float m_angularOffset;
+ b2Vec2 m_linearImpulse;
+ float m_angularImpulse;
+ float m_maxForce;
+ float m_maxTorque;
+ float m_correctionFactor;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_rA;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ b2Vec2 m_linearError;
+ float m_angularError;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ b2Mat22 m_linearMass;
+ float m_angularMass;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_mouse_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_mouse_joint.h
new file mode 100644
index 0000000..fcbc56a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_mouse_joint.h
@@ -0,0 +1,134 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_MOUSE_JOINT_H
+#define B2_MOUSE_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Mouse joint definition. This requires a world target point,
+/// tuning parameters, and the time step.
+struct B2_API b2MouseJointDef : public b2JointDef
+{
+ b2MouseJointDef()
+ {
+ type = e_mouseJoint;
+ target.Set(0.0f, 0.0f);
+ maxForce = 0.0f;
+ stiffness = 0.0f;
+ damping = 0.0f;
+ }
+
+ /// The initial world target point. This is assumed
+ /// to coincide with the body anchor initially.
+ b2Vec2 target;
+
+ /// The maximum constraint force that can be exerted
+ /// to move the candidate body. Usually you will express
+ /// as some multiple of the weight (multiplier * mass * gravity).
+ float maxForce;
+
+ /// The linear stiffness in N/m
+ float stiffness;
+
+ /// The linear damping in N*s/m
+ float damping;
+};
+
+/// A mouse joint is used to make a point on a body track a
+/// specified world point. This a soft constraint with a maximum
+/// force. This allows the constraint to stretch and without
+/// applying huge forces.
+/// NOTE: this joint is not documented in the manual because it was
+/// developed to be used in the testbed. If you want to learn how to
+/// use the mouse joint, look at the testbed.
+class B2_API b2MouseJoint : public b2Joint
+{
+public:
+
+ /// Implements b2Joint.
+ b2Vec2 GetAnchorA() const override;
+
+ /// Implements b2Joint.
+ b2Vec2 GetAnchorB() const override;
+
+ /// Implements b2Joint.
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+
+ /// Implements b2Joint.
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// Use this to update the target point.
+ void SetTarget(const b2Vec2& target);
+ const b2Vec2& GetTarget() const;
+
+ /// Set/get the maximum force in Newtons.
+ void SetMaxForce(float force);
+ float GetMaxForce() const;
+
+ /// Set/get the linear stiffness in N/m
+ void SetStiffness(float stiffness) { m_stiffness = stiffness; }
+ float GetStiffness() const { return m_stiffness; }
+
+ /// Set/get linear damping in N*s/m
+ void SetDamping(float damping) { m_damping = damping; }
+ float GetDamping() const { return m_damping; }
+
+ /// The mouse joint does not support dumping.
+ void Dump() override { b2Log("Mouse joint dumping is not supported.\n"); }
+
+ /// Implement b2Joint::ShiftOrigin
+ void ShiftOrigin(const b2Vec2& newOrigin) override;
+
+protected:
+ friend class b2Joint;
+
+ b2MouseJoint(const b2MouseJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ b2Vec2 m_localAnchorB;
+ b2Vec2 m_targetA;
+ float m_stiffness;
+ float m_damping;
+ float m_beta;
+
+ // Solver shared
+ b2Vec2 m_impulse;
+ float m_maxForce;
+ float m_gamma;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterB;
+ float m_invMassB;
+ float m_invIB;
+ b2Mat22 m_mass;
+ b2Vec2 m_C;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_polygon_shape.h b/Client/ThirdParty/Box2D/include/box2d/b2_polygon_shape.h
new file mode 100644
index 0000000..5a4e563
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_polygon_shape.h
@@ -0,0 +1,95 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+#ifndef B2_POLYGON_SHAPE_H
+#define B2_POLYGON_SHAPE_H
+
+#include "b2_api.h"
+#include "b2_shape.h"
+
+/// A solid convex polygon. It is assumed that the interior of the polygon is to
+/// the left of each edge.
+/// Polygons have a maximum number of vertices equal to b2_maxPolygonVertices.
+/// In most cases you should not need many vertices for a convex polygon.
+class B2_API b2PolygonShape : public b2Shape
+{
+public:
+ b2PolygonShape();
+
+ /// Implement b2Shape.
+ b2Shape* Clone(b2BlockAllocator* allocator) const override;
+
+ /// @see b2Shape::GetChildCount
+ int32 GetChildCount() const override;
+
+ /// Create a convex hull from the given array of local points.
+ /// The count must be in the range [3, b2_maxPolygonVertices].
+ /// @warning the points may be re-ordered, even if they form a convex polygon
+ /// @warning collinear points are handled but not removed. Collinear points
+ /// may lead to poor stacking behavior.
+ void Set(const b2Vec2* points, int32 count);
+
+ /// Build vertices to represent an axis-aligned box centered on the local origin.
+ /// @param hx the half-width.
+ /// @param hy the half-height.
+ void SetAsBox(float hx, float hy);
+
+ /// Build vertices to represent an oriented box.
+ /// @param hx the half-width.
+ /// @param hy the half-height.
+ /// @param center the center of the box in local coordinates.
+ /// @param angle the rotation of the box in local coordinates.
+ void SetAsBox(float hx, float hy, const b2Vec2& center, float angle);
+
+ /// @see b2Shape::TestPoint
+ bool TestPoint(const b2Transform& transform, const b2Vec2& p) const override;
+
+ /// Implement b2Shape.
+ /// @note because the polygon is solid, rays that start inside do not hit because the normal is
+ /// not defined.
+ bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeAABB
+ void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const override;
+
+ /// @see b2Shape::ComputeMass
+ void ComputeMass(b2MassData* massData, float density) const override;
+
+ /// Validate convexity. This is a very time consuming operation.
+ /// @returns true if valid
+ bool Validate() const;
+
+ b2Vec2 m_centroid;
+ b2Vec2 m_vertices[b2_maxPolygonVertices];
+ b2Vec2 m_normals[b2_maxPolygonVertices];
+ int32 m_count;
+};
+
+inline b2PolygonShape::b2PolygonShape()
+{
+ m_type = e_polygon;
+ m_radius = b2_polygonRadius;
+ m_count = 0;
+ m_centroid.SetZero();
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_prismatic_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_prismatic_joint.h
new file mode 100644
index 0000000..9d12d21
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_prismatic_joint.h
@@ -0,0 +1,205 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_PRISMATIC_JOINT_H
+#define B2_PRISMATIC_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Prismatic joint definition. This requires defining a line of
+/// motion using an axis and an anchor point. The definition uses local
+/// anchor points and a local axis so that the initial configuration
+/// can violate the constraint slightly. The joint translation is zero
+/// when the local anchor points coincide in world space. Using local
+/// anchors and a local axis helps when saving and loading a game.
+struct B2_API b2PrismaticJointDef : public b2JointDef
+{
+ b2PrismaticJointDef()
+ {
+ type = e_prismaticJoint;
+ localAnchorA.SetZero();
+ localAnchorB.SetZero();
+ localAxisA.Set(1.0f, 0.0f);
+ referenceAngle = 0.0f;
+ enableLimit = false;
+ lowerTranslation = 0.0f;
+ upperTranslation = 0.0f;
+ enableMotor = false;
+ maxMotorForce = 0.0f;
+ motorSpeed = 0.0f;
+ }
+
+ /// Initialize the bodies, anchors, axis, and reference angle using the world
+ /// anchor and unit world axis.
+ void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor, const b2Vec2& axis);
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The local translation unit axis in bodyA.
+ b2Vec2 localAxisA;
+
+ /// The constrained angle between the bodies: bodyB_angle - bodyA_angle.
+ float referenceAngle;
+
+ /// Enable/disable the joint limit.
+ bool enableLimit;
+
+ /// The lower translation limit, usually in meters.
+ float lowerTranslation;
+
+ /// The upper translation limit, usually in meters.
+ float upperTranslation;
+
+ /// Enable/disable the joint motor.
+ bool enableMotor;
+
+ /// The maximum motor torque, usually in N-m.
+ float maxMotorForce;
+
+ /// The desired motor speed in radians per second.
+ float motorSpeed;
+};
+
+/// A prismatic joint. This joint provides one degree of freedom: translation
+/// along an axis fixed in bodyA. Relative rotation is prevented. You can
+/// use a joint limit to restrict the range of motion and a joint motor to
+/// drive the motion or to model joint friction.
+class B2_API b2PrismaticJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// The local anchor point relative to bodyA's origin.
+ const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
+
+ /// The local anchor point relative to bodyB's origin.
+ const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
+
+ /// The local joint axis relative to bodyA.
+ const b2Vec2& GetLocalAxisA() const { return m_localXAxisA; }
+
+ /// Get the reference angle.
+ float GetReferenceAngle() const { return m_referenceAngle; }
+
+ /// Get the current joint translation, usually in meters.
+ float GetJointTranslation() const;
+
+ /// Get the current joint translation speed, usually in meters per second.
+ float GetJointSpeed() const;
+
+ /// Is the joint limit enabled?
+ bool IsLimitEnabled() const;
+
+ /// Enable/disable the joint limit.
+ void EnableLimit(bool flag);
+
+ /// Get the lower joint limit, usually in meters.
+ float GetLowerLimit() const;
+
+ /// Get the upper joint limit, usually in meters.
+ float GetUpperLimit() const;
+
+ /// Set the joint limits, usually in meters.
+ void SetLimits(float lower, float upper);
+
+ /// Is the joint motor enabled?
+ bool IsMotorEnabled() const;
+
+ /// Enable/disable the joint motor.
+ void EnableMotor(bool flag);
+
+ /// Set the motor speed, usually in meters per second.
+ void SetMotorSpeed(float speed);
+
+ /// Get the motor speed, usually in meters per second.
+ float GetMotorSpeed() const;
+
+ /// Set the maximum motor force, usually in N.
+ void SetMaxMotorForce(float force);
+ float GetMaxMotorForce() const { return m_maxMotorForce; }
+
+ /// Get the current motor force given the inverse time step, usually in N.
+ float GetMotorForce(float inv_dt) const;
+
+ /// Dump to b2Log
+ void Dump() override;
+
+ ///
+ void Draw(b2Draw* draw) const override;
+
+protected:
+ friend class b2Joint;
+ friend class b2GearJoint;
+ b2PrismaticJoint(const b2PrismaticJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ b2Vec2 m_localXAxisA;
+ b2Vec2 m_localYAxisA;
+ float m_referenceAngle;
+ b2Vec2 m_impulse;
+ float m_motorImpulse;
+ float m_lowerImpulse;
+ float m_upperImpulse;
+ float m_lowerTranslation;
+ float m_upperTranslation;
+ float m_maxMotorForce;
+ float m_motorSpeed;
+ bool m_enableLimit;
+ bool m_enableMotor;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ b2Vec2 m_axis, m_perp;
+ float m_s1, m_s2;
+ float m_a1, m_a2;
+ b2Mat22 m_K;
+ float m_translation;
+ float m_axialMass;
+};
+
+inline float b2PrismaticJoint::GetMotorSpeed() const
+{
+ return m_motorSpeed;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_pulley_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_pulley_joint.h
new file mode 100644
index 0000000..6b14456
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_pulley_joint.h
@@ -0,0 +1,157 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_PULLEY_JOINT_H
+#define B2_PULLEY_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+const float b2_minPulleyLength = 2.0f;
+
+/// Pulley joint definition. This requires two ground anchors,
+/// two dynamic body anchor points, and a pulley ratio.
+struct B2_API b2PulleyJointDef : public b2JointDef
+{
+ b2PulleyJointDef()
+ {
+ type = e_pulleyJoint;
+ groundAnchorA.Set(-1.0f, 1.0f);
+ groundAnchorB.Set(1.0f, 1.0f);
+ localAnchorA.Set(-1.0f, 0.0f);
+ localAnchorB.Set(1.0f, 0.0f);
+ lengthA = 0.0f;
+ lengthB = 0.0f;
+ ratio = 1.0f;
+ collideConnected = true;
+ }
+
+ /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
+ void Initialize(b2Body* bodyA, b2Body* bodyB,
+ const b2Vec2& groundAnchorA, const b2Vec2& groundAnchorB,
+ const b2Vec2& anchorA, const b2Vec2& anchorB,
+ float ratio);
+
+ /// The first ground anchor in world coordinates. This point never moves.
+ b2Vec2 groundAnchorA;
+
+ /// The second ground anchor in world coordinates. This point never moves.
+ b2Vec2 groundAnchorB;
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The a reference length for the segment attached to bodyA.
+ float lengthA;
+
+ /// The a reference length for the segment attached to bodyB.
+ float lengthB;
+
+ /// The pulley ratio, used to simulate a block-and-tackle.
+ float ratio;
+};
+
+/// The pulley joint is connected to two bodies and two fixed ground points.
+/// The pulley supports a ratio such that:
+/// length1 + ratio * length2 <= constant
+/// Yes, the force transmitted is scaled by the ratio.
+/// Warning: the pulley joint can get a bit squirrelly by itself. They often
+/// work better when combined with prismatic joints. You should also cover the
+/// the anchor points with static shapes to prevent one side from going to
+/// zero length.
+class B2_API b2PulleyJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// Get the first ground anchor.
+ b2Vec2 GetGroundAnchorA() const;
+
+ /// Get the second ground anchor.
+ b2Vec2 GetGroundAnchorB() const;
+
+ /// Get the current length of the segment attached to bodyA.
+ float GetLengthA() const;
+
+ /// Get the current length of the segment attached to bodyB.
+ float GetLengthB() const;
+
+ /// Get the pulley ratio.
+ float GetRatio() const;
+
+ /// Get the current length of the segment attached to bodyA.
+ float GetCurrentLengthA() const;
+
+ /// Get the current length of the segment attached to bodyB.
+ float GetCurrentLengthB() const;
+
+ /// Dump joint to dmLog
+ void Dump() override;
+
+ /// Implement b2Joint::ShiftOrigin
+ void ShiftOrigin(const b2Vec2& newOrigin) override;
+
+protected:
+
+ friend class b2Joint;
+ b2PulleyJoint(const b2PulleyJointDef* data);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ b2Vec2 m_groundAnchorA;
+ b2Vec2 m_groundAnchorB;
+ float m_lengthA;
+ float m_lengthB;
+
+ // Solver shared
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ float m_constant;
+ float m_ratio;
+ float m_impulse;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_uA;
+ b2Vec2 m_uB;
+ b2Vec2 m_rA;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ float m_mass;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_revolute_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_revolute_joint.h
new file mode 100644
index 0000000..36ad531
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_revolute_joint.h
@@ -0,0 +1,211 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_REVOLUTE_JOINT_H
+#define B2_REVOLUTE_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Revolute joint definition. This requires defining an anchor point where the
+/// bodies are joined. The definition uses local anchor points so that the
+/// initial configuration can violate the constraint slightly. You also need to
+/// specify the initial relative angle for joint limits. This helps when saving
+/// and loading a game.
+/// The local anchor points are measured from the body's origin
+/// rather than the center of mass because:
+/// 1. you might not know where the center of mass will be.
+/// 2. if you add/remove shapes from a body and recompute the mass,
+/// the joints will be broken.
+struct B2_API b2RevoluteJointDef : public b2JointDef
+{
+ b2RevoluteJointDef()
+ {
+ type = e_revoluteJoint;
+ localAnchorA.Set(0.0f, 0.0f);
+ localAnchorB.Set(0.0f, 0.0f);
+ referenceAngle = 0.0f;
+ lowerAngle = 0.0f;
+ upperAngle = 0.0f;
+ maxMotorTorque = 0.0f;
+ motorSpeed = 0.0f;
+ enableLimit = false;
+ enableMotor = false;
+ }
+
+ /// Initialize the bodies, anchors, and reference angle using a world
+ /// anchor point.
+ void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The bodyB angle minus bodyA angle in the reference state (radians).
+ float referenceAngle;
+
+ /// A flag to enable joint limits.
+ bool enableLimit;
+
+ /// The lower angle for the joint limit (radians).
+ float lowerAngle;
+
+ /// The upper angle for the joint limit (radians).
+ float upperAngle;
+
+ /// A flag to enable the joint motor.
+ bool enableMotor;
+
+ /// The desired motor speed. Usually in radians per second.
+ float motorSpeed;
+
+ /// The maximum motor torque used to achieve the desired motor speed.
+ /// Usually in N-m.
+ float maxMotorTorque;
+};
+
+/// A revolute joint constrains two bodies to share a common point while they
+/// are free to rotate about the point. The relative rotation about the shared
+/// point is the joint angle. You can limit the relative rotation with
+/// a joint limit that specifies a lower and upper angle. You can use a motor
+/// to drive the relative rotation about the shared point. A maximum motor torque
+/// is provided so that infinite forces are not generated.
+class B2_API b2RevoluteJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ /// The local anchor point relative to bodyA's origin.
+ const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
+
+ /// The local anchor point relative to bodyB's origin.
+ const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
+
+ /// Get the reference angle.
+ float GetReferenceAngle() const { return m_referenceAngle; }
+
+ /// Get the current joint angle in radians.
+ float GetJointAngle() const;
+
+ /// Get the current joint angle speed in radians per second.
+ float GetJointSpeed() const;
+
+ /// Is the joint limit enabled?
+ bool IsLimitEnabled() const;
+
+ /// Enable/disable the joint limit.
+ void EnableLimit(bool flag);
+
+ /// Get the lower joint limit in radians.
+ float GetLowerLimit() const;
+
+ /// Get the upper joint limit in radians.
+ float GetUpperLimit() const;
+
+ /// Set the joint limits in radians.
+ void SetLimits(float lower, float upper);
+
+ /// Is the joint motor enabled?
+ bool IsMotorEnabled() const;
+
+ /// Enable/disable the joint motor.
+ void EnableMotor(bool flag);
+
+ /// Set the motor speed in radians per second.
+ void SetMotorSpeed(float speed);
+
+ /// Get the motor speed in radians per second.
+ float GetMotorSpeed() const;
+
+ /// Set the maximum motor torque, usually in N-m.
+ void SetMaxMotorTorque(float torque);
+ float GetMaxMotorTorque() const { return m_maxMotorTorque; }
+
+ /// Get the reaction force given the inverse time step.
+ /// Unit is N.
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+
+ /// Get the reaction torque due to the joint limit given the inverse time step.
+ /// Unit is N*m.
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// Get the current motor torque given the inverse time step.
+ /// Unit is N*m.
+ float GetMotorTorque(float inv_dt) const;
+
+ /// Dump to b2Log.
+ void Dump() override;
+
+ ///
+ void Draw(b2Draw* draw) const override;
+
+protected:
+
+ friend class b2Joint;
+ friend class b2GearJoint;
+
+ b2RevoluteJoint(const b2RevoluteJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ // Solver shared
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ b2Vec2 m_impulse;
+ float m_motorImpulse;
+ float m_lowerImpulse;
+ float m_upperImpulse;
+ bool m_enableMotor;
+ float m_maxMotorTorque;
+ float m_motorSpeed;
+ bool m_enableLimit;
+ float m_referenceAngle;
+ float m_lowerAngle;
+ float m_upperAngle;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_rA;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ b2Mat22 m_K;
+ float m_angle;
+ float m_axialMass;
+};
+
+inline float b2RevoluteJoint::GetMotorSpeed() const
+{
+ return m_motorSpeed;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_rope.h b/Client/ThirdParty/Box2D/include/box2d/b2_rope.h
new file mode 100644
index 0000000..47f5fc4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_rope.h
@@ -0,0 +1,153 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_ROPE_H
+#define B2_ROPE_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+
+class b2Draw;
+struct b2RopeStretch;
+struct b2RopeBend;
+
+enum b2StretchingModel
+{
+ b2_pbdStretchingModel,
+ b2_xpbdStretchingModel
+};
+
+enum b2BendingModel
+{
+ b2_springAngleBendingModel = 0,
+ b2_pbdAngleBendingModel,
+ b2_xpbdAngleBendingModel,
+ b2_pbdDistanceBendingModel,
+ b2_pbdHeightBendingModel,
+ b2_pbdTriangleBendingModel
+};
+
+///
+struct B2_API b2RopeTuning
+{
+ b2RopeTuning()
+ {
+ stretchingModel = b2_pbdStretchingModel;
+ bendingModel = b2_pbdAngleBendingModel;
+ damping = 0.0f;
+ stretchStiffness = 1.0f;
+ bendStiffness = 0.5f;
+ bendHertz = 1.0f;
+ bendDamping = 0.0f;
+ isometric = false;
+ fixedEffectiveMass = false;
+ warmStart = false;
+ }
+
+ b2StretchingModel stretchingModel;
+ b2BendingModel bendingModel;
+ float damping;
+ float stretchStiffness;
+ float stretchHertz;
+ float stretchDamping;
+ float bendStiffness;
+ float bendHertz;
+ float bendDamping;
+ bool isometric;
+ bool fixedEffectiveMass;
+ bool warmStart;
+};
+
+///
+struct B2_API b2RopeDef
+{
+ b2RopeDef()
+ {
+ position.SetZero();
+ vertices = nullptr;
+ count = 0;
+ masses = nullptr;
+ gravity.SetZero();
+ }
+
+ b2Vec2 position;
+ b2Vec2* vertices;
+ int32 count;
+ float* masses;
+ b2Vec2 gravity;
+ b2RopeTuning tuning;
+};
+
+///
+class B2_API b2Rope
+{
+public:
+ b2Rope();
+ ~b2Rope();
+
+ ///
+ void Create(const b2RopeDef& def);
+
+ ///
+ void SetTuning(const b2RopeTuning& tuning);
+
+ ///
+ void Step(float timeStep, int32 iterations, const b2Vec2& position);
+
+ ///
+ void Reset(const b2Vec2& position);
+
+ ///
+ void Draw(b2Draw* draw) const;
+
+private:
+
+ void SolveStretch_PBD();
+ void SolveStretch_XPBD(float dt);
+ void SolveBend_PBD_Angle();
+ void SolveBend_XPBD_Angle(float dt);
+ void SolveBend_PBD_Distance();
+ void SolveBend_PBD_Height();
+ void SolveBend_PBD_Triangle();
+ void ApplyBendForces(float dt);
+
+ b2Vec2 m_position;
+
+ int32 m_count;
+ int32 m_stretchCount;
+ int32 m_bendCount;
+
+ b2RopeStretch* m_stretchConstraints;
+ b2RopeBend* m_bendConstraints;
+
+ b2Vec2* m_bindPositions;
+ b2Vec2* m_ps;
+ b2Vec2* m_p0s;
+ b2Vec2* m_vs;
+
+ float* m_invMasses;
+ b2Vec2 m_gravity;
+
+ b2RopeTuning m_tuning;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_settings.h b/Client/ThirdParty/Box2D/include/box2d/b2_settings.h
new file mode 100644
index 0000000..48cd95d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_settings.h
@@ -0,0 +1,127 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_SETTINGS_H
+#define B2_SETTINGS_H
+
+#include "b2_types.h"
+#include "b2_api.h"
+
+/// @file
+/// Settings that can be overriden for your application
+///
+
+/// Define this macro in your build if you want to override settings
+#ifdef B2_USER_SETTINGS
+
+/// This is a user file that includes custom definitions of the macros, structs, and functions
+/// defined below.
+#include "b2_user_settings.h"
+
+#else
+
+#include <stdarg.h>
+#include <stdint.h>
+
+// Tunable Constants
+
+/// You can use this to change the length scale used by your game.
+/// For example for inches you could use 39.4.
+#define b2_lengthUnitsPerMeter 1.0f
+
+/// The maximum number of vertices on a convex polygon. You cannot increase
+/// this too much because b2BlockAllocator has a maximum object size.
+#define b2_maxPolygonVertices 8
+
+// User data
+
+/// You can define this to inject whatever data you want in b2Body
+struct B2_API b2BodyUserData
+{
+ b2BodyUserData()
+ {
+ pointer = 0;
+ }
+
+ /// For legacy compatibility
+ uintptr_t pointer;
+};
+
+/// You can define this to inject whatever data you want in b2Fixture
+struct B2_API b2FixtureUserData
+{
+ b2FixtureUserData()
+ {
+ pointer = 0;
+ }
+
+ /// For legacy compatibility
+ uintptr_t pointer;
+};
+
+/// You can define this to inject whatever data you want in b2Joint
+struct B2_API b2JointUserData
+{
+ b2JointUserData()
+ {
+ pointer = 0;
+ }
+
+ /// For legacy compatibility
+ uintptr_t pointer;
+};
+
+// Memory Allocation
+
+/// Default allocation functions
+B2_API void* b2Alloc_Default(int32 size);
+B2_API void b2Free_Default(void* mem);
+
+/// Implement this function to use your own memory allocator.
+inline void* b2Alloc(int32 size)
+{
+ return b2Alloc_Default(size);
+}
+
+/// If you implement b2Alloc, you should also implement this function.
+inline void b2Free(void* mem)
+{
+ b2Free_Default(mem);
+}
+
+/// Default logging function
+B2_API void b2Log_Default(const char* string, va_list args);
+
+/// Implement this to use your own logging.
+inline void b2Log(const char* string, ...)
+{
+ va_list args;
+ va_start(args, string);
+ b2Log_Default(string, args);
+ va_end(args);
+}
+
+#endif // B2_USER_SETTINGS
+
+#include "b2_common.h"
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_shape.h b/Client/ThirdParty/Box2D/include/box2d/b2_shape.h
new file mode 100644
index 0000000..cbed2b8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_shape.h
@@ -0,0 +1,110 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_SHAPE_H
+#define B2_SHAPE_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+#include "b2_collision.h"
+
+class b2BlockAllocator;
+
+/// This holds the mass data computed for a shape.
+struct B2_API b2MassData
+{
+ /// The mass of the shape, usually in kilograms.
+ float mass;
+
+ /// The position of the shape's centroid relative to the shape's origin.
+ b2Vec2 center;
+
+ /// The rotational inertia of the shape about the local origin.
+ float I;
+};
+
+/// A shape is used for collision detection. You can create a shape however you like.
+/// Shapes used for simulation in b2World are created automatically when a b2Fixture
+/// is created. Shapes may encapsulate a one or more child shapes.
+class B2_API b2Shape
+{
+public:
+
+ enum Type
+ {
+ e_circle = 0,
+ e_edge = 1,
+ e_polygon = 2,
+ e_chain = 3,
+ e_typeCount = 4
+ };
+
+ virtual ~b2Shape() {}
+
+ /// Clone the concrete shape using the provided allocator.
+ virtual b2Shape* Clone(b2BlockAllocator* allocator) const = 0;
+
+ /// Get the type of this shape. You can use this to down cast to the concrete shape.
+ /// @return the shape type.
+ Type GetType() const;
+
+ /// Get the number of child primitives.
+ virtual int32 GetChildCount() const = 0;
+
+ /// Test a point for containment in this shape. This only works for convex shapes.
+ /// @param xf the shape world transform.
+ /// @param p a point in world coordinates.
+ virtual bool TestPoint(const b2Transform& xf, const b2Vec2& p) const = 0;
+
+ /// Cast a ray against a child shape.
+ /// @param output the ray-cast results.
+ /// @param input the ray-cast input parameters.
+ /// @param transform the transform to be applied to the shape.
+ /// @param childIndex the child shape index
+ virtual bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& transform, int32 childIndex) const = 0;
+
+ /// Given a transform, compute the associated axis aligned bounding box for a child shape.
+ /// @param aabb returns the axis aligned box.
+ /// @param xf the world transform of the shape.
+ /// @param childIndex the child shape
+ virtual void ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const = 0;
+
+ /// Compute the mass properties of this shape using its dimensions and density.
+ /// The inertia tensor is computed about the local origin.
+ /// @param massData returns the mass data for this shape.
+ /// @param density the density in kilograms per meter squared.
+ virtual void ComputeMass(b2MassData* massData, float density) const = 0;
+
+ Type m_type;
+
+ /// Radius of a shape. For polygonal shapes this must be b2_polygonRadius. There is no support for
+ /// making rounded polygons.
+ float m_radius;
+};
+
+inline b2Shape::Type b2Shape::GetType() const
+{
+ return m_type;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_stack_allocator.h b/Client/ThirdParty/Box2D/include/box2d/b2_stack_allocator.h
new file mode 100644
index 0000000..1db2af5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_stack_allocator.h
@@ -0,0 +1,65 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_STACK_ALLOCATOR_H
+#define B2_STACK_ALLOCATOR_H
+
+#include "b2_api.h"
+#include "b2_settings.h"
+
+const int32 b2_stackSize = 100 * 1024; // 100k
+const int32 b2_maxStackEntries = 32;
+
+struct B2_API b2StackEntry
+{
+ char* data;
+ int32 size;
+ bool usedMalloc;
+};
+
+// This is a stack allocator used for fast per step allocations.
+// You must nest allocate/free pairs. The code will assert
+// if you try to interleave multiple allocate/free pairs.
+class B2_API b2StackAllocator
+{
+public:
+ b2StackAllocator();
+ ~b2StackAllocator();
+
+ void* Allocate(int32 size);
+ void Free(void* p);
+
+ int32 GetMaxAllocation() const;
+
+private:
+
+ char m_data[b2_stackSize];
+ int32 m_index;
+
+ int32 m_allocation;
+ int32 m_maxAllocation;
+
+ b2StackEntry m_entries[b2_maxStackEntries];
+ int32 m_entryCount;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_time_of_impact.h b/Client/ThirdParty/Box2D/include/box2d/b2_time_of_impact.h
new file mode 100644
index 0000000..04d4626
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_time_of_impact.h
@@ -0,0 +1,63 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_TIME_OF_IMPACT_H
+#define B2_TIME_OF_IMPACT_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+#include "b2_distance.h"
+
+/// Input parameters for b2TimeOfImpact
+struct B2_API b2TOIInput
+{
+ b2DistanceProxy proxyA;
+ b2DistanceProxy proxyB;
+ b2Sweep sweepA;
+ b2Sweep sweepB;
+ float tMax; // defines sweep interval [0, tMax]
+};
+
+/// Output parameters for b2TimeOfImpact.
+struct B2_API b2TOIOutput
+{
+ enum State
+ {
+ e_unknown,
+ e_failed,
+ e_overlapped,
+ e_touching,
+ e_separated
+ };
+
+ State state;
+ float t;
+};
+
+/// Compute the upper bound on time before two shapes penetrate. Time is represented as
+/// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate,
+/// non-tunneling collisions. If you change the time interval, you should call this function
+/// again.
+/// Note: use b2Distance to compute the contact point and normal at the time of impact.
+B2_API void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input);
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_time_step.h b/Client/ThirdParty/Box2D/include/box2d/b2_time_step.h
new file mode 100644
index 0000000..13d6292
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_time_step.h
@@ -0,0 +1,74 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+#ifndef B2_TIME_STEP_H
+#define B2_TIME_STEP_H
+
+#include "b2_api.h"
+#include "b2_math.h"
+
+/// Profiling data. Times are in milliseconds.
+struct B2_API b2Profile
+{
+ float step;
+ float collide;
+ float solve;
+ float solveInit;
+ float solveVelocity;
+ float solvePosition;
+ float broadphase;
+ float solveTOI;
+};
+
+/// This is an internal structure.
+struct B2_API b2TimeStep
+{
+ float dt; // time step
+ float inv_dt; // inverse time step (0 if dt == 0).
+ float dtRatio; // dt * inv_dt0
+ int32 velocityIterations;
+ int32 positionIterations;
+ bool warmStarting;
+};
+
+/// This is an internal structure.
+struct B2_API b2Position
+{
+ b2Vec2 c;
+ float a;
+};
+
+/// This is an internal structure.
+struct B2_API b2Velocity
+{
+ b2Vec2 v;
+ float w;
+};
+
+/// Solver Data
+struct B2_API b2SolverData
+{
+ b2TimeStep step;
+ b2Position* positions;
+ b2Velocity* velocities;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_timer.h b/Client/ThirdParty/Box2D/include/box2d/b2_timer.h
new file mode 100644
index 0000000..7893c32
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_timer.h
@@ -0,0 +1,55 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_TIMER_H
+#define B2_TIMER_H
+
+#include "b2_api.h"
+#include "b2_settings.h"
+
+/// Timer for profiling. This has platform specific code and may
+/// not work on every platform.
+class B2_API b2Timer
+{
+public:
+
+ /// Constructor
+ b2Timer();
+
+ /// Reset the timer.
+ void Reset();
+
+ /// Get the time since construction or the last reset.
+ float GetMilliseconds() const;
+
+private:
+
+#if defined(_WIN32)
+ double m_start;
+ static double s_invFrequency;
+#elif defined(__linux__) || defined (__APPLE__)
+ unsigned long long m_start_sec;
+ unsigned long long m_start_usec;
+#endif
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_types.h b/Client/ThirdParty/Box2D/include/box2d/b2_types.h
new file mode 100644
index 0000000..e0d4377
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_types.h
@@ -0,0 +1,33 @@
+// MIT License
+
+// Copyright (c) 2020 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_TYPES_H
+#define B2_TYPES_H
+
+typedef signed char int8;
+typedef signed short int16;
+typedef signed int int32;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_weld_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_weld_joint.h
new file mode 100644
index 0000000..f226c8a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_weld_joint.h
@@ -0,0 +1,133 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_WELD_JOINT_H
+#define B2_WELD_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Weld joint definition. You need to specify local anchor points
+/// where they are attached and the relative body angle. The position
+/// of the anchor points is important for computing the reaction torque.
+struct B2_API b2WeldJointDef : public b2JointDef
+{
+ b2WeldJointDef()
+ {
+ type = e_weldJoint;
+ localAnchorA.Set(0.0f, 0.0f);
+ localAnchorB.Set(0.0f, 0.0f);
+ referenceAngle = 0.0f;
+ stiffness = 0.0f;
+ damping = 0.0f;
+ }
+
+ /// Initialize the bodies, anchors, reference angle, stiffness, and damping.
+ /// @param bodyA the first body connected by this joint
+ /// @param bodyB the second body connected by this joint
+ /// @param anchor the point of connection in world coordinates
+ void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The bodyB angle minus bodyA angle in the reference state (radians).
+ float referenceAngle;
+
+ /// The rotational stiffness in N*m
+ /// Disable softness with a value of 0
+ float stiffness;
+
+ /// The rotational damping in N*m*s
+ float damping;
+};
+
+/// A weld joint essentially glues two bodies together. A weld joint may
+/// distort somewhat because the island constraint solver is approximate.
+class B2_API b2WeldJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// The local anchor point relative to bodyA's origin.
+ const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
+
+ /// The local anchor point relative to bodyB's origin.
+ const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
+
+ /// Get the reference angle.
+ float GetReferenceAngle() const { return m_referenceAngle; }
+
+ /// Set/get stiffness in N*m
+ void SetStiffness(float hz) { m_stiffness = hz; }
+ float GetStiffness() const { return m_stiffness; }
+
+ /// Set/get damping in N*m*s
+ void SetDamping(float damping) { m_damping = damping; }
+ float GetDamping() const { return m_damping; }
+
+ /// Dump to b2Log
+ void Dump() override;
+
+protected:
+
+ friend class b2Joint;
+
+ b2WeldJoint(const b2WeldJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ float m_stiffness;
+ float m_damping;
+ float m_bias;
+
+ // Solver shared
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ float m_referenceAngle;
+ float m_gamma;
+ b2Vec3 m_impulse;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_rA;
+ b2Vec2 m_rB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+ b2Mat33 m_mass;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_wheel_joint.h b/Client/ThirdParty/Box2D/include/box2d/b2_wheel_joint.h
new file mode 100644
index 0000000..8576adb
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_wheel_joint.h
@@ -0,0 +1,240 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_WHEEL_JOINT_H
+#define B2_WHEEL_JOINT_H
+
+#include "b2_api.h"
+#include "b2_joint.h"
+
+/// Wheel joint definition. This requires defining a line of
+/// motion using an axis and an anchor point. The definition uses local
+/// anchor points and a local axis so that the initial configuration
+/// can violate the constraint slightly. The joint translation is zero
+/// when the local anchor points coincide in world space. Using local
+/// anchors and a local axis helps when saving and loading a game.
+struct B2_API b2WheelJointDef : public b2JointDef
+{
+ b2WheelJointDef()
+ {
+ type = e_wheelJoint;
+ localAnchorA.SetZero();
+ localAnchorB.SetZero();
+ localAxisA.Set(1.0f, 0.0f);
+ enableLimit = false;
+ lowerTranslation = 0.0f;
+ upperTranslation = 0.0f;
+ enableMotor = false;
+ maxMotorTorque = 0.0f;
+ motorSpeed = 0.0f;
+ stiffness = 0.0f;
+ damping = 0.0f;
+ }
+
+ /// Initialize the bodies, anchors, axis, and reference angle using the world
+ /// anchor and world axis.
+ void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor, const b2Vec2& axis);
+
+ /// The local anchor point relative to bodyA's origin.
+ b2Vec2 localAnchorA;
+
+ /// The local anchor point relative to bodyB's origin.
+ b2Vec2 localAnchorB;
+
+ /// The local translation axis in bodyA.
+ b2Vec2 localAxisA;
+
+ /// Enable/disable the joint limit.
+ bool enableLimit;
+
+ /// The lower translation limit, usually in meters.
+ float lowerTranslation;
+
+ /// The upper translation limit, usually in meters.
+ float upperTranslation;
+
+ /// Enable/disable the joint motor.
+ bool enableMotor;
+
+ /// The maximum motor torque, usually in N-m.
+ float maxMotorTorque;
+
+ /// The desired motor speed in radians per second.
+ float motorSpeed;
+
+ /// Suspension stiffness. Typically in units N/m.
+ float stiffness;
+
+ /// Suspension damping. Typically in units of N*s/m.
+ float damping;
+};
+
+/// A wheel joint. This joint provides two degrees of freedom: translation
+/// along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to
+/// line constraint with a rotational motor and a linear spring/damper. The spring/damper is
+/// initialized upon creation. This joint is designed for vehicle suspensions.
+class B2_API b2WheelJoint : public b2Joint
+{
+public:
+ b2Vec2 GetAnchorA() const override;
+ b2Vec2 GetAnchorB() const override;
+
+ b2Vec2 GetReactionForce(float inv_dt) const override;
+ float GetReactionTorque(float inv_dt) const override;
+
+ /// The local anchor point relative to bodyA's origin.
+ const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
+
+ /// The local anchor point relative to bodyB's origin.
+ const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
+
+ /// The local joint axis relative to bodyA.
+ const b2Vec2& GetLocalAxisA() const { return m_localXAxisA; }
+
+ /// Get the current joint translation, usually in meters.
+ float GetJointTranslation() const;
+
+ /// Get the current joint linear speed, usually in meters per second.
+ float GetJointLinearSpeed() const;
+
+ /// Get the current joint angle in radians.
+ float GetJointAngle() const;
+
+ /// Get the current joint angular speed in radians per second.
+ float GetJointAngularSpeed() const;
+
+ /// Is the joint limit enabled?
+ bool IsLimitEnabled() const;
+
+ /// Enable/disable the joint translation limit.
+ void EnableLimit(bool flag);
+
+ /// Get the lower joint translation limit, usually in meters.
+ float GetLowerLimit() const;
+
+ /// Get the upper joint translation limit, usually in meters.
+ float GetUpperLimit() const;
+
+ /// Set the joint translation limits, usually in meters.
+ void SetLimits(float lower, float upper);
+
+ /// Is the joint motor enabled?
+ bool IsMotorEnabled() const;
+
+ /// Enable/disable the joint motor.
+ void EnableMotor(bool flag);
+
+ /// Set the motor speed, usually in radians per second.
+ void SetMotorSpeed(float speed);
+
+ /// Get the motor speed, usually in radians per second.
+ float GetMotorSpeed() const;
+
+ /// Set/Get the maximum motor force, usually in N-m.
+ void SetMaxMotorTorque(float torque);
+ float GetMaxMotorTorque() const;
+
+ /// Get the current motor torque given the inverse time step, usually in N-m.
+ float GetMotorTorque(float inv_dt) const;
+
+ /// Access spring stiffness
+ void SetStiffness(float stiffness);
+ float GetStiffness() const;
+
+ /// Access damping
+ void SetDamping(float damping);
+ float GetDamping() const;
+
+ /// Dump to b2Log
+ void Dump() override;
+
+ ///
+ void Draw(b2Draw* draw) const override;
+
+protected:
+
+ friend class b2Joint;
+ b2WheelJoint(const b2WheelJointDef* def);
+
+ void InitVelocityConstraints(const b2SolverData& data) override;
+ void SolveVelocityConstraints(const b2SolverData& data) override;
+ bool SolvePositionConstraints(const b2SolverData& data) override;
+
+ b2Vec2 m_localAnchorA;
+ b2Vec2 m_localAnchorB;
+ b2Vec2 m_localXAxisA;
+ b2Vec2 m_localYAxisA;
+
+ float m_impulse;
+ float m_motorImpulse;
+ float m_springImpulse;
+
+ float m_lowerImpulse;
+ float m_upperImpulse;
+ float m_translation;
+ float m_lowerTranslation;
+ float m_upperTranslation;
+
+ float m_maxMotorTorque;
+ float m_motorSpeed;
+
+ bool m_enableLimit;
+ bool m_enableMotor;
+
+ float m_stiffness;
+ float m_damping;
+
+ // Solver temp
+ int32 m_indexA;
+ int32 m_indexB;
+ b2Vec2 m_localCenterA;
+ b2Vec2 m_localCenterB;
+ float m_invMassA;
+ float m_invMassB;
+ float m_invIA;
+ float m_invIB;
+
+ b2Vec2 m_ax, m_ay;
+ float m_sAx, m_sBx;
+ float m_sAy, m_sBy;
+
+ float m_mass;
+ float m_motorMass;
+ float m_axialMass;
+ float m_springMass;
+
+ float m_bias;
+ float m_gamma;
+
+};
+
+inline float b2WheelJoint::GetMotorSpeed() const
+{
+ return m_motorSpeed;
+}
+
+inline float b2WheelJoint::GetMaxMotorTorque() const
+{
+ return m_maxMotorTorque;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_world.h b/Client/ThirdParty/Box2D/include/box2d/b2_world.h
new file mode 100644
index 0000000..57d3709
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_world.h
@@ -0,0 +1,345 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_WORLD_H
+#define B2_WORLD_H
+
+#include "b2_api.h"
+#include "b2_block_allocator.h"
+#include "b2_contact_manager.h"
+#include "b2_math.h"
+#include "b2_stack_allocator.h"
+#include "b2_time_step.h"
+#include "b2_world_callbacks.h"
+
+struct b2AABB;
+struct b2BodyDef;
+struct b2Color;
+struct b2JointDef;
+class b2Body;
+class b2Draw;
+class b2Fixture;
+class b2Joint;
+
+/// The world class manages all physics entities, dynamic simulation,
+/// and asynchronous queries. The world also contains efficient memory
+/// management facilities.
+class B2_API b2World
+{
+public:
+ /// Construct a world object.
+ /// @param gravity the world gravity vector.
+ b2World(const b2Vec2& gravity);
+
+ /// Destruct the world. All physics entities are destroyed and all heap memory is released.
+ ~b2World();
+
+ /// Register a destruction listener. The listener is owned by you and must
+ /// remain in scope.
+ void SetDestructionListener(b2DestructionListener* listener);
+
+ /// Register a contact filter to provide specific control over collision.
+ /// Otherwise the default filter is used (b2_defaultFilter). The listener is
+ /// owned by you and must remain in scope.
+ void SetContactFilter(b2ContactFilter* filter);
+
+ /// Register a contact event listener. The listener is owned by you and must
+ /// remain in scope.
+ void SetContactListener(b2ContactListener* listener);
+
+ /// Register a routine for debug drawing. The debug draw functions are called
+ /// inside with b2World::DebugDraw method. The debug draw object is owned
+ /// by you and must remain in scope.
+ void SetDebugDraw(b2Draw* debugDraw);
+
+ /// Create a rigid body given a definition. No reference to the definition
+ /// is retained.
+ /// @warning This function is locked during callbacks.
+ b2Body* CreateBody(const b2BodyDef* def);
+
+ /// Destroy a rigid body given a definition. No reference to the definition
+ /// is retained. This function is locked during callbacks.
+ /// @warning This automatically deletes all associated shapes and joints.
+ /// @warning This function is locked during callbacks.
+ void DestroyBody(b2Body* body);
+
+ /// Create a joint to constrain bodies together. No reference to the definition
+ /// is retained. This may cause the connected bodies to cease colliding.
+ /// @warning This function is locked during callbacks.
+ b2Joint* CreateJoint(const b2JointDef* def);
+
+ /// Destroy a joint. This may cause the connected bodies to begin colliding.
+ /// @warning This function is locked during callbacks.
+ void DestroyJoint(b2Joint* joint);
+
+ /// Take a time step. This performs collision detection, integration,
+ /// and constraint solution.
+ /// @param timeStep the amount of time to simulate, this should not vary.
+ /// @param velocityIterations for the velocity constraint solver.
+ /// @param positionIterations for the position constraint solver.
+ void Step( float timeStep,
+ int32 velocityIterations,
+ int32 positionIterations);
+
+ /// Manually clear the force buffer on all bodies. By default, forces are cleared automatically
+ /// after each call to Step. The default behavior is modified by calling SetAutoClearForces.
+ /// The purpose of this function is to support sub-stepping. Sub-stepping is often used to maintain
+ /// a fixed sized time step under a variable frame-rate.
+ /// When you perform sub-stepping you will disable auto clearing of forces and instead call
+ /// ClearForces after all sub-steps are complete in one pass of your game loop.
+ /// @see SetAutoClearForces
+ void ClearForces();
+
+ /// Call this to draw shapes and other debug draw data. This is intentionally non-const.
+ void DebugDraw();
+
+ /// Query the world for all fixtures that potentially overlap the
+ /// provided AABB.
+ /// @param callback a user implemented callback class.
+ /// @param aabb the query box.
+ void QueryAABB(b2QueryCallback* callback, const b2AABB& aabb) const;
+
+ /// Ray-cast the world for all fixtures in the path of the ray. Your callback
+ /// controls whether you get the closest point, any point, or n-points.
+ /// The ray-cast ignores shapes that contain the starting point.
+ /// @param callback a user implemented callback class.
+ /// @param point1 the ray starting point
+ /// @param point2 the ray ending point
+ void RayCast(b2RayCastCallback* callback, const b2Vec2& point1, const b2Vec2& point2) const;
+
+ /// Get the world body list. With the returned body, use b2Body::GetNext to get
+ /// the next body in the world list. A nullptr body indicates the end of the list.
+ /// @return the head of the world body list.
+ b2Body* GetBodyList();
+ const b2Body* GetBodyList() const;
+
+ /// Get the world joint list. With the returned joint, use b2Joint::GetNext to get
+ /// the next joint in the world list. A nullptr joint indicates the end of the list.
+ /// @return the head of the world joint list.
+ b2Joint* GetJointList();
+ const b2Joint* GetJointList() const;
+
+ /// Get the world contact list. With the returned contact, use b2Contact::GetNext to get
+ /// the next contact in the world list. A nullptr contact indicates the end of the list.
+ /// @return the head of the world contact list.
+ /// @warning contacts are created and destroyed in the middle of a time step.
+ /// Use b2ContactListener to avoid missing contacts.
+ b2Contact* GetContactList();
+ const b2Contact* GetContactList() const;
+
+ /// Enable/disable sleep.
+ void SetAllowSleeping(bool flag);
+ bool GetAllowSleeping() const { return m_allowSleep; }
+
+ /// Enable/disable warm starting. For testing.
+ void SetWarmStarting(bool flag) { m_warmStarting = flag; }
+ bool GetWarmStarting() const { return m_warmStarting; }
+
+ /// Enable/disable continuous physics. For testing.
+ void SetContinuousPhysics(bool flag) { m_continuousPhysics = flag; }
+ bool GetContinuousPhysics() const { return m_continuousPhysics; }
+
+ /// Enable/disable single stepped continuous physics. For testing.
+ void SetSubStepping(bool flag) { m_subStepping = flag; }
+ bool GetSubStepping() const { return m_subStepping; }
+
+ /// Get the number of broad-phase proxies.
+ int32 GetProxyCount() const;
+
+ /// Get the number of bodies.
+ int32 GetBodyCount() const;
+
+ /// Get the number of joints.
+ int32 GetJointCount() const;
+
+ /// Get the number of contacts (each may have 0 or more contact points).
+ int32 GetContactCount() const;
+
+ /// Get the height of the dynamic tree.
+ int32 GetTreeHeight() const;
+
+ /// Get the balance of the dynamic tree.
+ int32 GetTreeBalance() const;
+
+ /// Get the quality metric of the dynamic tree. The smaller the better.
+ /// The minimum is 1.
+ float GetTreeQuality() const;
+
+ /// Change the global gravity vector.
+ void SetGravity(const b2Vec2& gravity);
+
+ /// Get the global gravity vector.
+ b2Vec2 GetGravity() const;
+
+ /// Is the world locked (in the middle of a time step).
+ bool IsLocked() const;
+
+ /// Set flag to control automatic clearing of forces after each time step.
+ void SetAutoClearForces(bool flag);
+
+ /// Get the flag that controls automatic clearing of forces after each time step.
+ bool GetAutoClearForces() const;
+
+ /// Shift the world origin. Useful for large worlds.
+ /// The body shift formula is: position -= newOrigin
+ /// @param newOrigin the new origin with respect to the old origin
+ void ShiftOrigin(const b2Vec2& newOrigin);
+
+ /// Get the contact manager for testing.
+ const b2ContactManager& GetContactManager() const;
+
+ /// Get the current profile.
+ const b2Profile& GetProfile() const;
+
+ /// Dump the world into the log file.
+ /// @warning this should be called outside of a time step.
+ void Dump();
+
+private:
+
+ friend class b2Body;
+ friend class b2Fixture;
+ friend class b2ContactManager;
+ friend class b2Controller;
+
+ void Solve(const b2TimeStep& step);
+ void SolveTOI(const b2TimeStep& step);
+
+ void DrawShape(b2Fixture* shape, const b2Transform& xf, const b2Color& color);
+
+ b2BlockAllocator m_blockAllocator;
+ b2StackAllocator m_stackAllocator;
+
+ b2ContactManager m_contactManager;
+
+ b2Body* m_bodyList;
+ b2Joint* m_jointList;
+
+ int32 m_bodyCount;
+ int32 m_jointCount;
+
+ b2Vec2 m_gravity;
+ bool m_allowSleep;
+
+ b2DestructionListener* m_destructionListener;
+ b2Draw* m_debugDraw;
+
+ // This is used to compute the time step ratio to
+ // support a variable time step.
+ float m_inv_dt0;
+
+ bool m_newContacts;
+ bool m_locked;
+ bool m_clearForces;
+
+ // These are for debugging the solver.
+ bool m_warmStarting;
+ bool m_continuousPhysics;
+ bool m_subStepping;
+
+ bool m_stepComplete;
+
+ b2Profile m_profile;
+};
+
+inline b2Body* b2World::GetBodyList()
+{
+ return m_bodyList;
+}
+
+inline const b2Body* b2World::GetBodyList() const
+{
+ return m_bodyList;
+}
+
+inline b2Joint* b2World::GetJointList()
+{
+ return m_jointList;
+}
+
+inline const b2Joint* b2World::GetJointList() const
+{
+ return m_jointList;
+}
+
+inline b2Contact* b2World::GetContactList()
+{
+ return m_contactManager.m_contactList;
+}
+
+inline const b2Contact* b2World::GetContactList() const
+{
+ return m_contactManager.m_contactList;
+}
+
+inline int32 b2World::GetBodyCount() const
+{
+ return m_bodyCount;
+}
+
+inline int32 b2World::GetJointCount() const
+{
+ return m_jointCount;
+}
+
+inline int32 b2World::GetContactCount() const
+{
+ return m_contactManager.m_contactCount;
+}
+
+inline void b2World::SetGravity(const b2Vec2& gravity)
+{
+ m_gravity = gravity;
+}
+
+inline b2Vec2 b2World::GetGravity() const
+{
+ return m_gravity;
+}
+
+inline bool b2World::IsLocked() const
+{
+ return m_locked;
+}
+
+inline void b2World::SetAutoClearForces(bool flag)
+{
+ m_clearForces = flag;
+}
+
+/// Get the flag that controls automatic clearing of forces after each time step.
+inline bool b2World::GetAutoClearForces() const
+{
+ return m_clearForces;
+}
+
+inline const b2ContactManager& b2World::GetContactManager() const
+{
+ return m_contactManager;
+}
+
+inline const b2Profile& b2World::GetProfile() const
+{
+ return m_profile;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/b2_world_callbacks.h b/Client/ThirdParty/Box2D/include/box2d/b2_world_callbacks.h
new file mode 100644
index 0000000..da45640
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/b2_world_callbacks.h
@@ -0,0 +1,161 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_WORLD_CALLBACKS_H
+#define B2_WORLD_CALLBACKS_H
+
+#include "b2_api.h"
+#include "b2_settings.h"
+
+struct b2Vec2;
+struct b2Transform;
+class b2Fixture;
+class b2Body;
+class b2Joint;
+class b2Contact;
+struct b2ContactResult;
+struct b2Manifold;
+
+/// Joints and fixtures are destroyed when their associated
+/// body is destroyed. Implement this listener so that you
+/// may nullify references to these joints and shapes.
+class B2_API b2DestructionListener
+{
+public:
+ virtual ~b2DestructionListener() {}
+
+ /// Called when any joint is about to be destroyed due
+ /// to the destruction of one of its attached bodies.
+ virtual void SayGoodbye(b2Joint* joint) = 0;
+
+ /// Called when any fixture is about to be destroyed due
+ /// to the destruction of its parent body.
+ virtual void SayGoodbye(b2Fixture* fixture) = 0;
+};
+
+/// Implement this class to provide collision filtering. In other words, you can implement
+/// this class if you want finer control over contact creation.
+class B2_API b2ContactFilter
+{
+public:
+ virtual ~b2ContactFilter() {}
+
+ /// Return true if contact calculations should be performed between these two shapes.
+ /// @warning for performance reasons this is only called when the AABBs begin to overlap.
+ virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB);
+};
+
+/// Contact impulses for reporting. Impulses are used instead of forces because
+/// sub-step forces may approach infinity for rigid body collisions. These
+/// match up one-to-one with the contact points in b2Manifold.
+struct B2_API b2ContactImpulse
+{
+ float normalImpulses[b2_maxManifoldPoints];
+ float tangentImpulses[b2_maxManifoldPoints];
+ int32 count;
+};
+
+/// Implement this class to get contact information. You can use these results for
+/// things like sounds and game logic. You can also get contact results by
+/// traversing the contact lists after the time step. However, you might miss
+/// some contacts because continuous physics leads to sub-stepping.
+/// Additionally you may receive multiple callbacks for the same contact in a
+/// single time step.
+/// You should strive to make your callbacks efficient because there may be
+/// many callbacks per time step.
+/// @warning You cannot create/destroy Box2D entities inside these callbacks.
+class B2_API b2ContactListener
+{
+public:
+ virtual ~b2ContactListener() {}
+
+ /// Called when two fixtures begin to touch.
+ virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
+
+ /// Called when two fixtures cease to touch.
+ virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
+
+ /// This is called after a contact is updated. This allows you to inspect a
+ /// contact before it goes to the solver. If you are careful, you can modify the
+ /// contact manifold (e.g. disable contact).
+ /// A copy of the old manifold is provided so that you can detect changes.
+ /// Note: this is called only for awake bodies.
+ /// Note: this is called even when the number of contact points is zero.
+ /// Note: this is not called for sensors.
+ /// Note: if you set the number of contact points to zero, you will not
+ /// get an EndContact callback. However, you may get a BeginContact callback
+ /// the next step.
+ virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
+ {
+ B2_NOT_USED(contact);
+ B2_NOT_USED(oldManifold);
+ }
+
+ /// This lets you inspect a contact after the solver is finished. This is useful
+ /// for inspecting impulses.
+ /// Note: the contact manifold does not include time of impact impulses, which can be
+ /// arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly
+ /// in a separate data structure.
+ /// Note: this is only called for contacts that are touching, solid, and awake.
+ virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse)
+ {
+ B2_NOT_USED(contact);
+ B2_NOT_USED(impulse);
+ }
+};
+
+/// Callback class for AABB queries.
+/// See b2World::Query
+class B2_API b2QueryCallback
+{
+public:
+ virtual ~b2QueryCallback() {}
+
+ /// Called for each fixture found in the query AABB.
+ /// @return false to terminate the query.
+ virtual bool ReportFixture(b2Fixture* fixture) = 0;
+};
+
+/// Callback class for ray casts.
+/// See b2World::RayCast
+class B2_API b2RayCastCallback
+{
+public:
+ virtual ~b2RayCastCallback() {}
+
+ /// Called for each fixture found in the query. You control how the ray cast
+ /// proceeds by returning a float:
+ /// return -1: ignore this fixture and continue
+ /// return 0: terminate the ray cast
+ /// return fraction: clip the ray to this point
+ /// return 1: don't clip the ray and continue
+ /// @param fixture the fixture hit by the ray
+ /// @param point the point of initial intersection
+ /// @param normal the normal vector at the point of intersection
+ /// @param fraction the fraction along the ray at the point of intersection
+ /// @return -1 to filter, 0 to terminate, fraction to clip the ray for
+ /// closest hit, 1 to continue
+ virtual float ReportFixture( b2Fixture* fixture, const b2Vec2& point,
+ const b2Vec2& normal, float fraction) = 0;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/include/box2d/box2d.h b/Client/ThirdParty/Box2D/include/box2d/box2d.h
new file mode 100644
index 0000000..55c6958
--- /dev/null
+++ b/Client/ThirdParty/Box2D/include/box2d/box2d.h
@@ -0,0 +1,58 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef BOX2D_H
+#define BOX2D_H
+
+// These include files constitute the main Box2D API
+
+#include "b2_settings.h"
+#include "b2_draw.h"
+#include "b2_timer.h"
+
+#include "b2_chain_shape.h"
+#include "b2_circle_shape.h"
+#include "b2_edge_shape.h"
+#include "b2_polygon_shape.h"
+
+#include "b2_broad_phase.h"
+#include "b2_dynamic_tree.h"
+
+#include "b2_body.h"
+#include "b2_contact.h"
+#include "b2_fixture.h"
+#include "b2_time_step.h"
+#include "b2_world.h"
+#include "b2_world_callbacks.h"
+
+#include "b2_distance_joint.h"
+#include "b2_friction_joint.h"
+#include "b2_gear_joint.h"
+#include "b2_motor_joint.h"
+#include "b2_mouse_joint.h"
+#include "b2_prismatic_joint.h"
+#include "b2_pulley_joint.h"
+#include "b2_revolute_joint.h"
+#include "b2_weld_joint.h"
+#include "b2_wheel_joint.h"
+
+#endif
diff --git a/Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj b/Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj
new file mode 100644
index 0000000..d8a2af6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>ALL_BUILD</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\box2d.vcxproj">
+ <Project>{4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}</Project>
+ <Name>box2d</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\glad.vcxproj">
+ <Project>{29408AB9-D01F-3745-93F3-94160B037370}</Project>
+ <Name>glad</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\glfw.vcxproj">
+ <Project>{7F32E689-3D5C-3885-9B34-0860DAE8BE92}</Project>
+ <Name>glfw</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\imgui.vcxproj">
+ <Project>{B288C97F-F14F-33EA-9CAC-B55922D1FDC7}</Project>
+ <Name>imgui</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\sajson.vcxproj">
+ <Project>{EE68EE8F-E321-3CD7-A04C-C0A66C401380}</Project>
+ <Name>sajson</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\testbed.vcxproj">
+ <Project>{A168F045-AE5A-3724-B305-AA2A8C4749BA}</Project>
+ <Name>testbed</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\unit_test.vcxproj">
+ <Project>{7ED467E4-0B19-329B-B677-9C4C01A3EC52}</Project>
+ <Name>unit_test</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj.filters b/Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj.filters
new file mode 100644
index 0000000..9443b67
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/ALL_BUILD.vcxproj.filters
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/CMakeCache.txt b/Client/ThirdParty/Box2D/proj/CMakeCache.txt
new file mode 100644
index 0000000..545df5f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeCache.txt
@@ -0,0 +1,441 @@
+# This is the CMakeCache file.
+# For build in directory: d:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj
+# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe
+# You can edit this file to change values found and used by cmake.
+# If you do not want to change any of the values, simply exit the editor.
+# If you do want to change a value, simply edit, save, and exit the editor.
+# The syntax for the file is as follows:
+# KEY:TYPE=VALUE
+# KEY is the name of a variable in the cache.
+# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
+# VALUE is the current value for the KEY.
+
+########################
+# EXTERNAL cache entries
+########################
+
+//Build the Box2D documentation
+BOX2D_BUILD_DOCS:BOOL=OFF
+
+//Build the Box2D testbed
+BOX2D_BUILD_TESTBED:BOOL=ON
+
+//Build the Box2D unit tests
+BOX2D_BUILD_UNIT_TESTS:BOOL=ON
+
+//Override Box2D settings with b2UserSettings.h
+BOX2D_USER_SETTINGS:BOOL=OFF
+
+//Build Box2D as a shared library
+BUILD_SHARED_LIBS:BOOL=OFF
+
+//Path to a program.
+CMAKE_AR:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/lib.exe
+
+//Semicolon separated list of supported configuration types, only
+// supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything
+// else will be ignored.
+CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;MinSizeRel;RelWithDebInfo
+
+//Flags used by the CXX compiler during all build types.
+CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc
+
+//Flags used by the CXX compiler during DEBUG builds.
+CMAKE_CXX_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1
+
+//Flags used by the CXX compiler during MINSIZEREL builds.
+CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG
+
+//Flags used by the CXX compiler during RELEASE builds.
+CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG
+
+//Flags used by the CXX compiler during RELWITHDEBINFO builds.
+CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG
+
+//Libraries linked by default with all C++ applications.
+CMAKE_CXX_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
+
+//Flags used by the C compiler during all build types.
+CMAKE_C_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3
+
+//Flags used by the C compiler during DEBUG builds.
+CMAKE_C_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1
+
+//Flags used by the C compiler during MINSIZEREL builds.
+CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG
+
+//Flags used by the C compiler during RELEASE builds.
+CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG
+
+//Flags used by the C compiler during RELWITHDEBINFO builds.
+CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG
+
+//Libraries linked by default with all C applications.
+CMAKE_C_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
+
+//Flags used by the linker during all build types.
+CMAKE_EXE_LINKER_FLAGS:STRING=/machine:X86
+
+//Flags used by the linker during DEBUG builds.
+CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
+
+//Flags used by the linker during MINSIZEREL builds.
+CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
+
+//Flags used by the linker during RELEASE builds.
+CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO
+
+//Flags used by the linker during RELWITHDEBINFO builds.
+CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
+
+//User executables (bin)
+CMAKE_INSTALL_BINDIR:PATH=bin
+
+//Read-only architecture-independent data (DATAROOTDIR)
+CMAKE_INSTALL_DATADIR:PATH=
+
+//Read-only architecture-independent data root (share)
+CMAKE_INSTALL_DATAROOTDIR:PATH=share
+
+//Documentation root (DATAROOTDIR/doc/PROJECT_NAME)
+CMAKE_INSTALL_DOCDIR:PATH=
+
+//C header files (include)
+CMAKE_INSTALL_INCLUDEDIR:PATH=include
+
+//Info documentation (DATAROOTDIR/info)
+CMAKE_INSTALL_INFODIR:PATH=
+
+//Object code libraries (lib)
+CMAKE_INSTALL_LIBDIR:PATH=lib
+
+//Program executables (libexec)
+CMAKE_INSTALL_LIBEXECDIR:PATH=libexec
+
+//Locale-dependent data (DATAROOTDIR/locale)
+CMAKE_INSTALL_LOCALEDIR:PATH=
+
+//Modifiable single-machine data (var)
+CMAKE_INSTALL_LOCALSTATEDIR:PATH=var
+
+//Man documentation (DATAROOTDIR/man)
+CMAKE_INSTALL_MANDIR:PATH=
+
+//C header files for non-gcc (/usr/include)
+CMAKE_INSTALL_OLDINCLUDEDIR:PATH=/usr/include
+
+//Install path prefix, prepended onto install directories.
+CMAKE_INSTALL_PREFIX:PATH=C:/Program Files (x86)/box2d
+
+//Run-time variable data (LOCALSTATEDIR/run)
+CMAKE_INSTALL_RUNSTATEDIR:PATH=
+
+//System admin executables (sbin)
+CMAKE_INSTALL_SBINDIR:PATH=sbin
+
+//Modifiable architecture-independent data (com)
+CMAKE_INSTALL_SHAREDSTATEDIR:PATH=com
+
+//Read-only single-machine data (etc)
+CMAKE_INSTALL_SYSCONFDIR:PATH=etc
+
+//Path to a program.
+CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/link.exe
+
+//Flags used by the linker during the creation of modules during
+// all build types.
+CMAKE_MODULE_LINKER_FLAGS:STRING=/machine:X86
+
+//Flags used by the linker during the creation of modules during
+// DEBUG builds.
+CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
+
+//Flags used by the linker during the creation of modules during
+// MINSIZEREL builds.
+CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
+
+//Flags used by the linker during the creation of modules during
+// RELEASE builds.
+CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO
+
+//Flags used by the linker during the creation of modules during
+// RELWITHDEBINFO builds.
+CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
+
+//Path to a program.
+CMAKE_MT:FILEPATH=CMAKE_MT-NOTFOUND
+
+//Value Computed by CMake
+CMAKE_PROJECT_DESCRIPTION:STATIC=
+
+//Value Computed by CMake
+CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
+
+//Value Computed by CMake
+CMAKE_PROJECT_NAME:STATIC=box2d
+
+//Value Computed by CMake
+CMAKE_PROJECT_VERSION:STATIC=2.4.1
+
+//Value Computed by CMake
+CMAKE_PROJECT_VERSION_MAJOR:STATIC=2
+
+//Value Computed by CMake
+CMAKE_PROJECT_VERSION_MINOR:STATIC=4
+
+//Value Computed by CMake
+CMAKE_PROJECT_VERSION_PATCH:STATIC=1
+
+//Value Computed by CMake
+CMAKE_PROJECT_VERSION_TWEAK:STATIC=
+
+//RC compiler
+CMAKE_RC_COMPILER:FILEPATH=rc
+
+//Flags for Windows Resource Compiler during all build types.
+CMAKE_RC_FLAGS:STRING=-DWIN32
+
+//Flags for Windows Resource Compiler during DEBUG builds.
+CMAKE_RC_FLAGS_DEBUG:STRING=-D_DEBUG
+
+//Flags for Windows Resource Compiler during MINSIZEREL builds.
+CMAKE_RC_FLAGS_MINSIZEREL:STRING=
+
+//Flags for Windows Resource Compiler during RELEASE builds.
+CMAKE_RC_FLAGS_RELEASE:STRING=
+
+//Flags for Windows Resource Compiler during RELWITHDEBINFO builds.
+CMAKE_RC_FLAGS_RELWITHDEBINFO:STRING=
+
+//Flags used by the linker during the creation of shared libraries
+// during all build types.
+CMAKE_SHARED_LINKER_FLAGS:STRING=/machine:X86
+
+//Flags used by the linker during the creation of shared libraries
+// during DEBUG builds.
+CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL
+
+//Flags used by the linker during the creation of shared libraries
+// during MINSIZEREL builds.
+CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO
+
+//Flags used by the linker during the creation of shared libraries
+// during RELEASE builds.
+CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO
+
+//Flags used by the linker during the creation of shared libraries
+// during RELWITHDEBINFO builds.
+CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL
+
+//If set, runtime paths are not added when installing shared libraries,
+// but are added when building.
+CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
+
+//If set, runtime paths are not added when using shared libraries.
+CMAKE_SKIP_RPATH:BOOL=NO
+
+//Flags used by the linker during the creation of static libraries
+// during all build types.
+CMAKE_STATIC_LINKER_FLAGS:STRING=/machine:X86
+
+//Flags used by the linker during the creation of static libraries
+// during DEBUG builds.
+CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
+
+//Flags used by the linker during the creation of static libraries
+// during MINSIZEREL builds.
+CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
+
+//Flags used by the linker during the creation of static libraries
+// during RELEASE builds.
+CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
+
+//Flags used by the linker during the creation of static libraries
+// during RELWITHDEBINFO builds.
+CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
+
+//If this value is on, makefiles will be generated without the
+// .SILENT directive, and all commands will be echoed to the console
+// during the make. This is useful for debugging only. With Visual
+// Studio IDE projects all commands are done without /nologo.
+CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
+
+//Value Computed by CMake
+box2d_BINARY_DIR:STATIC=D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj
+
+//Value Computed by CMake
+box2d_IS_TOP_LEVEL:STATIC=ON
+
+//Value Computed by CMake
+box2d_SOURCE_DIR:STATIC=D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D
+
+
+########################
+# INTERNAL cache entries
+########################
+
+//ADVANCED property for variable: CMAKE_AR
+CMAKE_AR-ADVANCED:INTERNAL=1
+//This is the directory where this CMakeCache.txt was created
+CMAKE_CACHEFILE_DIR:INTERNAL=d:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj
+//Major version of cmake used to create the current loaded cache
+CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
+//Minor version of cmake used to create the current loaded cache
+CMAKE_CACHE_MINOR_VERSION:INTERNAL=22
+//Patch version of cmake used to create the current loaded cache
+CMAKE_CACHE_PATCH_VERSION:INTERNAL=0
+//Path to CMake executable.
+CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe
+//Path to cpack program executable.
+CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe
+//Path to ctest program executable.
+CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe
+//ADVANCED property for variable: CMAKE_CXX_FLAGS
+CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
+CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
+CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
+CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
+CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_CXX_STANDARD_LIBRARIES
+CMAKE_CXX_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS
+CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
+CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
+CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
+CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
+CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_C_STANDARD_LIBRARIES
+CMAKE_C_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
+//Executable file format
+CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
+CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
+CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
+CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
+CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//Name of external makefile project generator.
+CMAKE_EXTRA_GENERATOR:INTERNAL=
+//Name of generator.
+CMAKE_GENERATOR:INTERNAL=Visual Studio 15 2017
+//Generator instance identifier.
+CMAKE_GENERATOR_INSTANCE:INTERNAL=C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise
+//Name of generator platform.
+CMAKE_GENERATOR_PLATFORM:INTERNAL=
+//Name of generator toolset.
+CMAKE_GENERATOR_TOOLSET:INTERNAL=
+//Have include pthread.h
+CMAKE_HAVE_PTHREAD_H:INTERNAL=
+//Source directory with the top level CMakeLists.txt file for this
+// project
+CMAKE_HOME_DIRECTORY:INTERNAL=D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D
+//ADVANCED property for variable: CMAKE_INSTALL_BINDIR
+CMAKE_INSTALL_BINDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_DATADIR
+CMAKE_INSTALL_DATADIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_DATAROOTDIR
+CMAKE_INSTALL_DATAROOTDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_DOCDIR
+CMAKE_INSTALL_DOCDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_INCLUDEDIR
+CMAKE_INSTALL_INCLUDEDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_INFODIR
+CMAKE_INSTALL_INFODIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_LIBDIR
+CMAKE_INSTALL_LIBDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_LIBEXECDIR
+CMAKE_INSTALL_LIBEXECDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_LOCALEDIR
+CMAKE_INSTALL_LOCALEDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_LOCALSTATEDIR
+CMAKE_INSTALL_LOCALSTATEDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_MANDIR
+CMAKE_INSTALL_MANDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_OLDINCLUDEDIR
+CMAKE_INSTALL_OLDINCLUDEDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_RUNSTATEDIR
+CMAKE_INSTALL_RUNSTATEDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_SBINDIR
+CMAKE_INSTALL_SBINDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_SHAREDSTATEDIR
+CMAKE_INSTALL_SHAREDSTATEDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_INSTALL_SYSCONFDIR
+CMAKE_INSTALL_SYSCONFDIR-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_LINKER
+CMAKE_LINKER-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
+CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
+CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
+CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
+CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_MT
+CMAKE_MT-ADVANCED:INTERNAL=1
+//number of local generators
+CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=8
+//Platform information initialized
+CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
+//noop for ranlib
+CMAKE_RANLIB:INTERNAL=:
+//ADVANCED property for variable: CMAKE_RC_COMPILER
+CMAKE_RC_COMPILER-ADVANCED:INTERNAL=1
+CMAKE_RC_COMPILER_WORKS:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_FLAGS
+CMAKE_RC_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_FLAGS_DEBUG
+CMAKE_RC_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_FLAGS_MINSIZEREL
+CMAKE_RC_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_FLAGS_RELEASE
+CMAKE_RC_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_RC_FLAGS_RELWITHDEBINFO
+CMAKE_RC_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//Path to CMake installation.
+CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-3.22
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
+CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
+CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
+CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
+CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_SKIP_RPATH
+CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
+CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
+CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
+CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
+CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
+CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
+//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
+CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
+//Details about finding Threads
+FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()]
+//CMAKE_INSTALL_PREFIX during last run
+_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX:INTERNAL=C:/Program Files (x86)/box2d
+
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/049e1eb7380682ec4cf9a2c62dad57db/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/049e1eb7380682ec4cf9a2c62dad57db/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/049e1eb7380682ec4cf9a2c62dad57db/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/14f8a92cc8883d19b638672092016c39/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/14f8a92cc8883d19b638672092016c39/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/14f8a92cc8883d19b638672092016c39/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake
new file mode 100644
index 0000000..08969aa
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake
@@ -0,0 +1,72 @@
+set(CMAKE_C_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe")
+set(CMAKE_C_COMPILER_ARG1 "")
+set(CMAKE_C_COMPILER_ID "MSVC")
+set(CMAKE_C_COMPILER_VERSION "19.16.27045.0")
+set(CMAKE_C_COMPILER_VERSION_INTERNAL "")
+set(CMAKE_C_COMPILER_WRAPPER "")
+set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "90")
+set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "OFF")
+set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_std_99;c_std_11;c_function_prototypes;c_variadic_macros")
+set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
+set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_variadic_macros")
+set(CMAKE_C11_COMPILE_FEATURES "c_std_11")
+set(CMAKE_C17_COMPILE_FEATURES "")
+set(CMAKE_C23_COMPILE_FEATURES "")
+
+set(CMAKE_C_PLATFORM_ID "Windows")
+set(CMAKE_C_SIMULATE_ID "")
+set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
+set(CMAKE_C_SIMULATE_VERSION "")
+set(CMAKE_C_COMPILER_ARCHITECTURE_ID X86)
+
+set(MSVC_C_ARCHITECTURE_ID X86)
+
+set(CMAKE_AR "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/lib.exe")
+set(CMAKE_C_COMPILER_AR "")
+set(CMAKE_RANLIB ":")
+set(CMAKE_C_COMPILER_RANLIB "")
+set(CMAKE_LINKER "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/link.exe")
+set(CMAKE_MT "CMAKE_MT-NOTFOUND")
+set(CMAKE_COMPILER_IS_GNUCC )
+set(CMAKE_C_COMPILER_LOADED 1)
+set(CMAKE_C_COMPILER_WORKS TRUE)
+set(CMAKE_C_ABI_COMPILED TRUE)
+
+set(CMAKE_C_COMPILER_ENV_VAR "CC")
+
+set(CMAKE_C_COMPILER_ID_RUN 1)
+set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
+set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
+set(CMAKE_C_LINKER_PREFERENCE 10)
+
+# Save compiler ABI information.
+set(CMAKE_C_SIZEOF_DATA_PTR "4")
+set(CMAKE_C_COMPILER_ABI "")
+set(CMAKE_C_BYTE_ORDER "LITTLE_ENDIAN")
+set(CMAKE_C_LIBRARY_ARCHITECTURE "")
+
+if(CMAKE_C_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_C_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
+endif()
+
+if(CMAKE_C_LIBRARY_ARCHITECTURE)
+ set(CMAKE_LIBRARY_ARCHITECTURE "")
+endif()
+
+set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "")
+if(CMAKE_C_CL_SHOWINCLUDES_PREFIX)
+ set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}")
+endif()
+
+
+
+
+
+set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "")
+set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
+set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "")
+set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake
new file mode 100644
index 0000000..e905aa1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake
@@ -0,0 +1,83 @@
+set(CMAKE_CXX_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe")
+set(CMAKE_CXX_COMPILER_ARG1 "")
+set(CMAKE_CXX_COMPILER_ID "MSVC")
+set(CMAKE_CXX_COMPILER_VERSION "19.16.27045.0")
+set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
+set(CMAKE_CXX_COMPILER_WRAPPER "")
+set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")
+set(CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT "OFF")
+set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17;cxx_std_20")
+set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
+set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
+set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
+set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
+set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20")
+set(CMAKE_CXX23_COMPILE_FEATURES "")
+
+set(CMAKE_CXX_PLATFORM_ID "Windows")
+set(CMAKE_CXX_SIMULATE_ID "")
+set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "")
+set(CMAKE_CXX_SIMULATE_VERSION "")
+set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID X86)
+
+set(MSVC_CXX_ARCHITECTURE_ID X86)
+
+set(CMAKE_AR "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/lib.exe")
+set(CMAKE_CXX_COMPILER_AR "")
+set(CMAKE_RANLIB ":")
+set(CMAKE_CXX_COMPILER_RANLIB "")
+set(CMAKE_LINKER "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/link.exe")
+set(CMAKE_MT "CMAKE_MT-NOTFOUND")
+set(CMAKE_COMPILER_IS_GNUCXX )
+set(CMAKE_CXX_COMPILER_LOADED 1)
+set(CMAKE_CXX_COMPILER_WORKS TRUE)
+set(CMAKE_CXX_ABI_COMPILED TRUE)
+
+set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
+
+set(CMAKE_CXX_COMPILER_ID_RUN 1)
+set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm)
+set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
+
+foreach (lang C OBJC OBJCXX)
+ if (CMAKE_${lang}_COMPILER_ID_RUN)
+ foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
+ list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
+ endforeach()
+ endif()
+endforeach()
+
+set(CMAKE_CXX_LINKER_PREFERENCE 30)
+set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
+
+# Save compiler ABI information.
+set(CMAKE_CXX_SIZEOF_DATA_PTR "4")
+set(CMAKE_CXX_COMPILER_ABI "")
+set(CMAKE_CXX_BYTE_ORDER "LITTLE_ENDIAN")
+set(CMAKE_CXX_LIBRARY_ARCHITECTURE "")
+
+if(CMAKE_CXX_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_CXX_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
+endif()
+
+if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
+ set(CMAKE_LIBRARY_ARCHITECTURE "")
+endif()
+
+set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
+if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
+ set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
+endif()
+
+
+
+
+
+set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")
+set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
+set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
+set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_C.bin b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_C.bin
new file mode 100644
index 0000000..1f16555
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_C.bin
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_CXX.bin b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_CXX.bin
new file mode 100644
index 0000000..54e380e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeDetermineCompilerABI_CXX.bin
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake
new file mode 100644
index 0000000..0f61961
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_RC_COMPILER "rc")
+set(CMAKE_RC_COMPILER_ARG1 "")
+set(CMAKE_RC_COMPILER_LOADED 1)
+set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC)
+set(CMAKE_RC_OUTPUT_EXTENSION .res)
+set(CMAKE_RC_COMPILER_ENV_VAR "RC")
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeSystem.cmake b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeSystem.cmake
new file mode 100644
index 0000000..013b053
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeSystem.cmake
@@ -0,0 +1,15 @@
+set(CMAKE_HOST_SYSTEM "Windows-10.0.19042")
+set(CMAKE_HOST_SYSTEM_NAME "Windows")
+set(CMAKE_HOST_SYSTEM_VERSION "10.0.19042")
+set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")
+
+
+
+set(CMAKE_SYSTEM "Windows-10.0.19042")
+set(CMAKE_SYSTEM_NAME "Windows")
+set(CMAKE_SYSTEM_VERSION "10.0.19042")
+set(CMAKE_SYSTEM_PROCESSOR "AMD64")
+
+set(CMAKE_CROSSCOMPILING "FALSE")
+
+set(CMAKE_SYSTEM_LOADED 1)
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CMakeCCompilerId.c b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CMakeCCompilerId.c
new file mode 100644
index 0000000..55753d5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CMakeCCompilerId.c
@@ -0,0 +1,803 @@
+#ifdef __cplusplus
+# error "A C++ compiler has been selected for C."
+#endif
+
+#if defined(__18CXX)
+# define ID_VOID_MAIN
+#endif
+#if defined(__CLASSIC_C__)
+/* cv-qualifiers did not exist in K&R C */
+# define const
+# define volatile
+#endif
+
+#if !defined(__has_include)
+/* If the compiler does not have __has_include, pretend the answer is
+ always no. */
+# define __has_include(x) 0
+#endif
+
+
+/* Version number components: V=Version, R=Revision, P=Patch
+ Version date components: YYYY=Year, MM=Month, DD=Day */
+
+#if defined(__INTEL_COMPILER) || defined(__ICC)
+# define COMPILER_ID "Intel"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_ID "GNU"
+# endif
+ /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
+ except that a few beta releases use the old format with V=2021. */
+# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
+# if defined(__INTEL_COMPILER_UPDATE)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
+# else
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
+# endif
+# else
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
+ /* The third version component from --version is an update index,
+ but no macro is provided for it. */
+# define COMPILER_VERSION_PATCH DEC(0)
+# endif
+# if defined(__INTEL_COMPILER_BUILD_DATE)
+ /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
+# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
+# endif
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
+# elif defined(__GNUG__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
+# define COMPILER_ID "IntelLLVM"
+#if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+#endif
+#if defined(__GNUC__)
+# define SIMULATE_ID "GNU"
+#endif
+/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
+ * later. Look for 6 digit vs. 8 digit version number to decide encoding.
+ * VVVV is no smaller than the current year when a version is released.
+ */
+#if __INTEL_LLVM_COMPILER < 1000000L
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
+#else
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
+#endif
+#if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+#endif
+#if defined(__GNUC__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
+#elif defined(__GNUG__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
+#endif
+#if defined(__GNUC_MINOR__)
+# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
+#endif
+#if defined(__GNUC_PATCHLEVEL__)
+# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+#endif
+
+#elif defined(__PATHCC__)
+# define COMPILER_ID "PathScale"
+# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
+# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
+# if defined(__PATHCC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
+# endif
+
+#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
+# define COMPILER_ID "Embarcadero"
+# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
+# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
+# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
+
+#elif defined(__BORLANDC__)
+# define COMPILER_ID "Borland"
+ /* __BORLANDC__ = 0xVRR */
+# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
+# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
+
+#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
+# define COMPILER_ID "Watcom"
+ /* __WATCOMC__ = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__WATCOMC__)
+# define COMPILER_ID "OpenWatcom"
+ /* __WATCOMC__ = VVRP + 1100 */
+# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__SUNPRO_C)
+# define COMPILER_ID "SunPro"
+# if __SUNPRO_C >= 0x5100
+ /* __SUNPRO_C = 0xVRRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
+# else
+ /* __SUNPRO_CC = 0xVRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
+# endif
+
+#elif defined(__HP_cc)
+# define COMPILER_ID "HP"
+ /* __HP_cc = VVRRPP */
+# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
+# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
+# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
+
+#elif defined(__DECC)
+# define COMPILER_ID "Compaq"
+ /* __DECC_VER = VVRRTPPPP */
+# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
+# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
+# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
+
+#elif defined(__IBMC__) && defined(__COMPILER_VER__)
+# define COMPILER_ID "zOS"
+ /* __IBMC__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
+
+#elif defined(__ibmxl__) && defined(__clang__)
+# define COMPILER_ID "XLClang"
+# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
+# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
+# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
+# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
+
+
+#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
+# define COMPILER_ID "XL"
+ /* __IBMC__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
+
+#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
+# define COMPILER_ID "VisualAge"
+ /* __IBMC__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
+
+#elif defined(__NVCOMPILER)
+# define COMPILER_ID "NVHPC"
+# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
+# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
+# if defined(__NVCOMPILER_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
+# endif
+
+#elif defined(__PGI)
+# define COMPILER_ID "PGI"
+# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
+# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# endif
+
+#elif defined(_CRAYC)
+# define COMPILER_ID "Cray"
+# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
+# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
+
+#elif defined(__TI_COMPILER_VERSION__)
+# define COMPILER_ID "TI"
+ /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
+# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
+# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
+# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
+
+#elif defined(__CLANG_FUJITSU)
+# define COMPILER_ID "FujitsuClang"
+# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
+# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
+# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
+# define COMPILER_VERSION_INTERNAL_STR __clang_version__
+
+
+#elif defined(__FUJITSU)
+# define COMPILER_ID "Fujitsu"
+# if defined(__FCC_version__)
+# define COMPILER_VERSION __FCC_version__
+# elif defined(__FCC_major__)
+# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
+# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
+# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
+# endif
+# if defined(__fcc_version)
+# define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
+# elif defined(__FCC_VERSION)
+# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
+# endif
+
+
+#elif defined(__ghs__)
+# define COMPILER_ID "GHS"
+/* __GHS_VERSION_NUMBER = VVVVRP */
+# ifdef __GHS_VERSION_NUMBER
+# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
+# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
+# endif
+
+#elif defined(__TINYC__)
+# define COMPILER_ID "TinyCC"
+
+#elif defined(__BCC__)
+# define COMPILER_ID "Bruce"
+
+#elif defined(__SCO_VERSION__)
+# define COMPILER_ID "SCO"
+
+#elif defined(__ARMCC_VERSION) && !defined(__clang__)
+# define COMPILER_ID "ARMCC"
+#if __ARMCC_VERSION >= 1000000
+ /* __ARMCC_VERSION = VRRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#else
+ /* __ARMCC_VERSION = VRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#endif
+
+
+#elif defined(__clang__) && defined(__apple_build_version__)
+# define COMPILER_ID "AppleClang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
+
+#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
+# define COMPILER_ID "ARMClang"
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
+# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
+
+#elif defined(__clang__)
+# define COMPILER_ID "Clang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+
+#elif defined(__GNUC__)
+# define COMPILER_ID "GNU"
+# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
+# if defined(__GNUC_MINOR__)
+# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif defined(_MSC_VER)
+# define COMPILER_ID "MSVC"
+ /* _MSC_VER = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+# if _MSC_VER >= 1400
+ /* _MSC_FULL_VER = VVRRPPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+# else
+ /* _MSC_FULL_VER = VVRRPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+# endif
+# endif
+# if defined(_MSC_BUILD)
+# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif
+
+#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
+# define COMPILER_ID "ADSP"
+#if defined(__VISUALDSPVERSION__)
+ /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
+# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
+# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
+#endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# define COMPILER_ID "IAR"
+# if defined(__VER__) && defined(__ICCARM__)
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
+# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
+# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
+# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
+# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# endif
+
+#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
+# define COMPILER_ID "SDCC"
+# if defined(__SDCC_VERSION_MAJOR)
+# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
+# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
+# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
+# else
+ /* SDCC = VRP */
+# define COMPILER_VERSION_MAJOR DEC(SDCC/100)
+# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(SDCC % 10)
+# endif
+
+
+/* These compilers are either not known or too old to define an
+ identification macro. Try to identify the platform and guess that
+ it is the native compiler. */
+#elif defined(__hpux) || defined(__hpua)
+# define COMPILER_ID "HP"
+
+#else /* unknown compiler */
+# define COMPILER_ID ""
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+#ifdef __QNXNTO__
+char const* qnxnto = "INFO" ":" "qnxnto[]";
+#endif
+
+#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
+char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
+#endif
+
+#define STRINGIFY_HELPER(X) #X
+#define STRINGIFY(X) STRINGIFY_HELPER(X)
+
+/* Identify known platforms by name. */
+#if defined(__linux) || defined(__linux__) || defined(linux)
+# define PLATFORM_ID "Linux"
+
+#elif defined(__MSYS__)
+# define PLATFORM_ID "MSYS"
+
+#elif defined(__CYGWIN__)
+# define PLATFORM_ID "Cygwin"
+
+#elif defined(__MINGW32__)
+# define PLATFORM_ID "MinGW"
+
+#elif defined(__APPLE__)
+# define PLATFORM_ID "Darwin"
+
+#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+# define PLATFORM_ID "Windows"
+
+#elif defined(__FreeBSD__) || defined(__FreeBSD)
+# define PLATFORM_ID "FreeBSD"
+
+#elif defined(__NetBSD__) || defined(__NetBSD)
+# define PLATFORM_ID "NetBSD"
+
+#elif defined(__OpenBSD__) || defined(__OPENBSD)
+# define PLATFORM_ID "OpenBSD"
+
+#elif defined(__sun) || defined(sun)
+# define PLATFORM_ID "SunOS"
+
+#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
+# define PLATFORM_ID "AIX"
+
+#elif defined(__hpux) || defined(__hpux__)
+# define PLATFORM_ID "HP-UX"
+
+#elif defined(__HAIKU__)
+# define PLATFORM_ID "Haiku"
+
+#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
+# define PLATFORM_ID "BeOS"
+
+#elif defined(__QNX__) || defined(__QNXNTO__)
+# define PLATFORM_ID "QNX"
+
+#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
+# define PLATFORM_ID "Tru64"
+
+#elif defined(__riscos) || defined(__riscos__)
+# define PLATFORM_ID "RISCos"
+
+#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
+# define PLATFORM_ID "SINIX"
+
+#elif defined(__UNIX_SV__)
+# define PLATFORM_ID "UNIX_SV"
+
+#elif defined(__bsdos__)
+# define PLATFORM_ID "BSDOS"
+
+#elif defined(_MPRAS) || defined(MPRAS)
+# define PLATFORM_ID "MP-RAS"
+
+#elif defined(__osf) || defined(__osf__)
+# define PLATFORM_ID "OSF1"
+
+#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
+# define PLATFORM_ID "SCO_SV"
+
+#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
+# define PLATFORM_ID "ULTRIX"
+
+#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
+# define PLATFORM_ID "Xenix"
+
+#elif defined(__WATCOMC__)
+# if defined(__LINUX__)
+# define PLATFORM_ID "Linux"
+
+# elif defined(__DOS__)
+# define PLATFORM_ID "DOS"
+
+# elif defined(__OS2__)
+# define PLATFORM_ID "OS2"
+
+# elif defined(__WINDOWS__)
+# define PLATFORM_ID "Windows3x"
+
+# elif defined(__VXWORKS__)
+# define PLATFORM_ID "VxWorks"
+
+# else /* unknown platform */
+# define PLATFORM_ID
+# endif
+
+#elif defined(__INTEGRITY)
+# if defined(INT_178B)
+# define PLATFORM_ID "Integrity178"
+
+# else /* regular Integrity */
+# define PLATFORM_ID "Integrity"
+# endif
+
+#else /* unknown platform */
+# define PLATFORM_ID
+
+#endif
+
+/* For windows compilers MSVC and Intel we can determine
+ the architecture of the compiler being used. This is because
+ the compilers do not have flags that can change the architecture,
+ but rather depend on which compiler is being used
+*/
+#if defined(_WIN32) && defined(_MSC_VER)
+# if defined(_M_IA64)
+# define ARCHITECTURE_ID "IA64"
+
+# elif defined(_M_ARM64EC)
+# define ARCHITECTURE_ID "ARM64EC"
+
+# elif defined(_M_X64) || defined(_M_AMD64)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# elif defined(_M_ARM64)
+# define ARCHITECTURE_ID "ARM64"
+
+# elif defined(_M_ARM)
+# if _M_ARM == 4
+# define ARCHITECTURE_ID "ARMV4I"
+# elif _M_ARM == 5
+# define ARCHITECTURE_ID "ARMV5I"
+# else
+# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
+# endif
+
+# elif defined(_M_MIPS)
+# define ARCHITECTURE_ID "MIPS"
+
+# elif defined(_M_SH)
+# define ARCHITECTURE_ID "SHx"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__WATCOMC__)
+# if defined(_M_I86)
+# define ARCHITECTURE_ID "I86"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# if defined(__ICCARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__ICCRX__)
+# define ARCHITECTURE_ID "RX"
+
+# elif defined(__ICCRH850__)
+# define ARCHITECTURE_ID "RH850"
+
+# elif defined(__ICCRL78__)
+# define ARCHITECTURE_ID "RL78"
+
+# elif defined(__ICCRISCV__)
+# define ARCHITECTURE_ID "RISCV"
+
+# elif defined(__ICCAVR__)
+# define ARCHITECTURE_ID "AVR"
+
+# elif defined(__ICC430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__ICCV850__)
+# define ARCHITECTURE_ID "V850"
+
+# elif defined(__ICC8051__)
+# define ARCHITECTURE_ID "8051"
+
+# elif defined(__ICCSTM8__)
+# define ARCHITECTURE_ID "STM8"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__ghs__)
+# if defined(__PPC64__)
+# define ARCHITECTURE_ID "PPC64"
+
+# elif defined(__ppc__)
+# define ARCHITECTURE_ID "PPC"
+
+# elif defined(__ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__x86_64__)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(__i386__)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__TI_COMPILER_VERSION__)
+# if defined(__TI_ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__MSP430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__TMS320C28XX__)
+# define ARCHITECTURE_ID "TMS320C28x"
+
+# elif defined(__TMS320C6X__) || defined(_TMS320C6X)
+# define ARCHITECTURE_ID "TMS320C6x"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#else
+# define ARCHITECTURE_ID
+#endif
+
+/* Convert integer to decimal digit literals. */
+#define DEC(n) \
+ ('0' + (((n) / 10000000)%10)), \
+ ('0' + (((n) / 1000000)%10)), \
+ ('0' + (((n) / 100000)%10)), \
+ ('0' + (((n) / 10000)%10)), \
+ ('0' + (((n) / 1000)%10)), \
+ ('0' + (((n) / 100)%10)), \
+ ('0' + (((n) / 10)%10)), \
+ ('0' + ((n) % 10))
+
+/* Convert integer to hex digit literals. */
+#define HEX(n) \
+ ('0' + ((n)>>28 & 0xF)), \
+ ('0' + ((n)>>24 & 0xF)), \
+ ('0' + ((n)>>20 & 0xF)), \
+ ('0' + ((n)>>16 & 0xF)), \
+ ('0' + ((n)>>12 & 0xF)), \
+ ('0' + ((n)>>8 & 0xF)), \
+ ('0' + ((n)>>4 & 0xF)), \
+ ('0' + ((n) & 0xF))
+
+/* Construct a string literal encoding the version number. */
+#ifdef COMPILER_VERSION
+char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
+
+/* Construct a string literal encoding the version number components. */
+#elif defined(COMPILER_VERSION_MAJOR)
+char const info_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
+ COMPILER_VERSION_MAJOR,
+# ifdef COMPILER_VERSION_MINOR
+ '.', COMPILER_VERSION_MINOR,
+# ifdef COMPILER_VERSION_PATCH
+ '.', COMPILER_VERSION_PATCH,
+# ifdef COMPILER_VERSION_TWEAK
+ '.', COMPILER_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct a string literal encoding the internal version number. */
+#ifdef COMPILER_VERSION_INTERNAL
+char const info_version_internal[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
+ 'i','n','t','e','r','n','a','l','[',
+ COMPILER_VERSION_INTERNAL,']','\0'};
+#elif defined(COMPILER_VERSION_INTERNAL_STR)
+char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
+#endif
+
+/* Construct a string literal encoding the version number components. */
+#ifdef SIMULATE_VERSION_MAJOR
+char const info_simulate_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
+ SIMULATE_VERSION_MAJOR,
+# ifdef SIMULATE_VERSION_MINOR
+ '.', SIMULATE_VERSION_MINOR,
+# ifdef SIMULATE_VERSION_PATCH
+ '.', SIMULATE_VERSION_PATCH,
+# ifdef SIMULATE_VERSION_TWEAK
+ '.', SIMULATE_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
+char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
+
+
+
+#if !defined(__STDC__) && !defined(__clang__)
+# if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__)
+# define C_VERSION "90"
+# else
+# define C_VERSION
+# endif
+#elif __STDC_VERSION__ > 201710L
+# define C_VERSION "23"
+#elif __STDC_VERSION__ >= 201710L
+# define C_VERSION "17"
+#elif __STDC_VERSION__ >= 201000L
+# define C_VERSION "11"
+#elif __STDC_VERSION__ >= 199901L
+# define C_VERSION "99"
+#else
+# define C_VERSION "90"
+#endif
+const char* info_language_standard_default =
+ "INFO" ":" "standard_default[" C_VERSION "]";
+
+const char* info_language_extensions_default = "INFO" ":" "extensions_default["
+// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode.
+#if (defined(__clang__) || defined(__GNUC__) || \
+ defined(__TI_COMPILER_VERSION__)) && \
+ !defined(__STRICT_ANSI__) && !defined(_MSC_VER)
+ "ON"
+#else
+ "OFF"
+#endif
+"]";
+
+/*--------------------------------------------------------------------------*/
+
+#ifdef ID_VOID_MAIN
+void main() {}
+#else
+# if defined(__CLASSIC_C__)
+int main(argc, argv) int argc; char *argv[];
+# else
+int main(int argc, char* argv[])
+# endif
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+ require += info_arch[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
+ require += info_cray[argc];
+#endif
+ require += info_language_standard_default[argc];
+ require += info_language_extensions_default[argc];
+ (void)argv;
+ return require;
+}
+#endif
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.exe b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.exe
new file mode 100644
index 0000000..3d8110a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.exe
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.vcxproj b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.vcxproj
new file mode 100644
index 0000000..a96ed0a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.vcxproj
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
+ <RootNamespace>CompilerIdC</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+
+
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+
+
+
+
+ </PropertyGroup>
+
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup>
+
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+
+ </ImportGroup>
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>false</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>TurnOffAllWarnings</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+
+ <Link>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+
+ </Link>
+ <PostBuildEvent>
+ <Command>for %%i in (cl.exe) do %40echo CMAKE_C_COMPILER=%%~$PATH:i</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="CMakeCCompilerId.c" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+
+ </ImportGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj
new file mode 100644
index 0000000..c0c9d27
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CMakeCCompilerId.obj
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..1f3c250
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.command.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..ee0a19b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.read.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..b0bc733
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CL.write.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate
new file mode 100644
index 0000000..3773964
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/CompilerIdC.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
+Debug|Win32|D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdC\|
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog
new file mode 100644
index 0000000..d89b4b2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.command.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog
new file mode 100644
index 0000000..022717c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.read.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog
new file mode 100644
index 0000000..958b952
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/Debug/CompilerIdC.tlog/link.write.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CMakeCXXCompilerId.cpp b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CMakeCXXCompilerId.cpp
new file mode 100644
index 0000000..adc0bb8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CMakeCXXCompilerId.cpp
@@ -0,0 +1,791 @@
+/* This source file must have a .cpp extension so that all C++ compilers
+ recognize the extension without flags. Borland does not know .cxx for
+ example. */
+#ifndef __cplusplus
+# error "A C compiler has been selected for C++."
+#endif
+
+#if !defined(__has_include)
+/* If the compiler does not have __has_include, pretend the answer is
+ always no. */
+# define __has_include(x) 0
+#endif
+
+
+/* Version number components: V=Version, R=Revision, P=Patch
+ Version date components: YYYY=Year, MM=Month, DD=Day */
+
+#if defined(__COMO__)
+# define COMPILER_ID "Comeau"
+ /* __COMO_VERSION__ = VRR */
+# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
+# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
+
+#elif defined(__INTEL_COMPILER) || defined(__ICC)
+# define COMPILER_ID "Intel"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_ID "GNU"
+# endif
+ /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
+ except that a few beta releases use the old format with V=2021. */
+# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
+# if defined(__INTEL_COMPILER_UPDATE)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
+# else
+# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
+# endif
+# else
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
+ /* The third version component from --version is an update index,
+ but no macro is provided for it. */
+# define COMPILER_VERSION_PATCH DEC(0)
+# endif
+# if defined(__INTEL_COMPILER_BUILD_DATE)
+ /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
+# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
+# endif
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# if defined(__GNUC__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
+# elif defined(__GNUG__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
+# define COMPILER_ID "IntelLLVM"
+#if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+#endif
+#if defined(__GNUC__)
+# define SIMULATE_ID "GNU"
+#endif
+/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
+ * later. Look for 6 digit vs. 8 digit version number to decide encoding.
+ * VVVV is no smaller than the current year when a version is released.
+ */
+#if __INTEL_LLVM_COMPILER < 1000000L
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
+#else
+# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
+# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
+# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
+#endif
+#if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+#endif
+#if defined(__GNUC__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
+#elif defined(__GNUG__)
+# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
+#endif
+#if defined(__GNUC_MINOR__)
+# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
+#endif
+#if defined(__GNUC_PATCHLEVEL__)
+# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+#endif
+
+#elif defined(__PATHCC__)
+# define COMPILER_ID "PathScale"
+# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
+# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
+# if defined(__PATHCC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
+# endif
+
+#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
+# define COMPILER_ID "Embarcadero"
+# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
+# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
+# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
+
+#elif defined(__BORLANDC__)
+# define COMPILER_ID "Borland"
+ /* __BORLANDC__ = 0xVRR */
+# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
+# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
+
+#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
+# define COMPILER_ID "Watcom"
+ /* __WATCOMC__ = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__WATCOMC__)
+# define COMPILER_ID "OpenWatcom"
+ /* __WATCOMC__ = VVRP + 1100 */
+# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
+
+#elif defined(__SUNPRO_CC)
+# define COMPILER_ID "SunPro"
+# if __SUNPRO_CC >= 0x5100
+ /* __SUNPRO_CC = 0xVRRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
+# else
+ /* __SUNPRO_CC = 0xVRP */
+# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
+# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
+# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
+# endif
+
+#elif defined(__HP_aCC)
+# define COMPILER_ID "HP"
+ /* __HP_aCC = VVRRPP */
+# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
+# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
+# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
+
+#elif defined(__DECCXX)
+# define COMPILER_ID "Compaq"
+ /* __DECCXX_VER = VVRRTPPPP */
+# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
+# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
+# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
+
+#elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
+# define COMPILER_ID "zOS"
+ /* __IBMCPP__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
+
+#elif defined(__ibmxl__) && defined(__clang__)
+# define COMPILER_ID "XLClang"
+# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
+# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
+# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
+# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
+
+
+#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800
+# define COMPILER_ID "XL"
+ /* __IBMCPP__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
+
+#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
+# define COMPILER_ID "VisualAge"
+ /* __IBMCPP__ = VRP */
+# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
+
+#elif defined(__NVCOMPILER)
+# define COMPILER_ID "NVHPC"
+# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
+# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
+# if defined(__NVCOMPILER_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
+# endif
+
+#elif defined(__PGI)
+# define COMPILER_ID "PGI"
+# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
+# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# endif
+
+#elif defined(_CRAYC)
+# define COMPILER_ID "Cray"
+# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
+# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
+
+#elif defined(__TI_COMPILER_VERSION__)
+# define COMPILER_ID "TI"
+ /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
+# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
+# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
+# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
+
+#elif defined(__CLANG_FUJITSU)
+# define COMPILER_ID "FujitsuClang"
+# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
+# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
+# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
+# define COMPILER_VERSION_INTERNAL_STR __clang_version__
+
+
+#elif defined(__FUJITSU)
+# define COMPILER_ID "Fujitsu"
+# if defined(__FCC_version__)
+# define COMPILER_VERSION __FCC_version__
+# elif defined(__FCC_major__)
+# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
+# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
+# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
+# endif
+# if defined(__fcc_version)
+# define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
+# elif defined(__FCC_VERSION)
+# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
+# endif
+
+
+#elif defined(__ghs__)
+# define COMPILER_ID "GHS"
+/* __GHS_VERSION_NUMBER = VVVVRP */
+# ifdef __GHS_VERSION_NUMBER
+# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
+# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
+# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
+# endif
+
+#elif defined(__SCO_VERSION__)
+# define COMPILER_ID "SCO"
+
+#elif defined(__ARMCC_VERSION) && !defined(__clang__)
+# define COMPILER_ID "ARMCC"
+#if __ARMCC_VERSION >= 1000000
+ /* __ARMCC_VERSION = VRRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#else
+ /* __ARMCC_VERSION = VRPPPP */
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
+#endif
+
+
+#elif defined(__clang__) && defined(__apple_build_version__)
+# define COMPILER_ID "AppleClang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
+
+#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
+# define COMPILER_ID "ARMClang"
+ # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
+ # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
+ # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
+# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
+
+#elif defined(__clang__)
+# define COMPILER_ID "Clang"
+# if defined(_MSC_VER)
+# define SIMULATE_ID "MSVC"
+# endif
+# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+ /* _MSC_VER = VVRR */
+# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif
+
+#elif defined(__GNUC__) || defined(__GNUG__)
+# define COMPILER_ID "GNU"
+# if defined(__GNUC__)
+# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
+# else
+# define COMPILER_VERSION_MAJOR DEC(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif
+
+#elif defined(_MSC_VER)
+# define COMPILER_ID "MSVC"
+ /* _MSC_VER = VVRR */
+# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+# if _MSC_VER >= 1400
+ /* _MSC_FULL_VER = VVRRPPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+# else
+ /* _MSC_FULL_VER = VVRRPPPP */
+# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+# endif
+# endif
+# if defined(_MSC_BUILD)
+# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif
+
+#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
+# define COMPILER_ID "ADSP"
+#if defined(__VISUALDSPVERSION__)
+ /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
+# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
+# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
+# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
+#endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# define COMPILER_ID "IAR"
+# if defined(__VER__) && defined(__ICCARM__)
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
+# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
+# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
+# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
+# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
+# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
+# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
+# endif
+
+
+/* These compilers are either not known or too old to define an
+ identification macro. Try to identify the platform and guess that
+ it is the native compiler. */
+#elif defined(__hpux) || defined(__hpua)
+# define COMPILER_ID "HP"
+
+#else /* unknown compiler */
+# define COMPILER_ID ""
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+#ifdef __QNXNTO__
+char const* qnxnto = "INFO" ":" "qnxnto[]";
+#endif
+
+#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
+char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
+#endif
+
+#define STRINGIFY_HELPER(X) #X
+#define STRINGIFY(X) STRINGIFY_HELPER(X)
+
+/* Identify known platforms by name. */
+#if defined(__linux) || defined(__linux__) || defined(linux)
+# define PLATFORM_ID "Linux"
+
+#elif defined(__MSYS__)
+# define PLATFORM_ID "MSYS"
+
+#elif defined(__CYGWIN__)
+# define PLATFORM_ID "Cygwin"
+
+#elif defined(__MINGW32__)
+# define PLATFORM_ID "MinGW"
+
+#elif defined(__APPLE__)
+# define PLATFORM_ID "Darwin"
+
+#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+# define PLATFORM_ID "Windows"
+
+#elif defined(__FreeBSD__) || defined(__FreeBSD)
+# define PLATFORM_ID "FreeBSD"
+
+#elif defined(__NetBSD__) || defined(__NetBSD)
+# define PLATFORM_ID "NetBSD"
+
+#elif defined(__OpenBSD__) || defined(__OPENBSD)
+# define PLATFORM_ID "OpenBSD"
+
+#elif defined(__sun) || defined(sun)
+# define PLATFORM_ID "SunOS"
+
+#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
+# define PLATFORM_ID "AIX"
+
+#elif defined(__hpux) || defined(__hpux__)
+# define PLATFORM_ID "HP-UX"
+
+#elif defined(__HAIKU__)
+# define PLATFORM_ID "Haiku"
+
+#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
+# define PLATFORM_ID "BeOS"
+
+#elif defined(__QNX__) || defined(__QNXNTO__)
+# define PLATFORM_ID "QNX"
+
+#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
+# define PLATFORM_ID "Tru64"
+
+#elif defined(__riscos) || defined(__riscos__)
+# define PLATFORM_ID "RISCos"
+
+#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
+# define PLATFORM_ID "SINIX"
+
+#elif defined(__UNIX_SV__)
+# define PLATFORM_ID "UNIX_SV"
+
+#elif defined(__bsdos__)
+# define PLATFORM_ID "BSDOS"
+
+#elif defined(_MPRAS) || defined(MPRAS)
+# define PLATFORM_ID "MP-RAS"
+
+#elif defined(__osf) || defined(__osf__)
+# define PLATFORM_ID "OSF1"
+
+#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
+# define PLATFORM_ID "SCO_SV"
+
+#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
+# define PLATFORM_ID "ULTRIX"
+
+#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
+# define PLATFORM_ID "Xenix"
+
+#elif defined(__WATCOMC__)
+# if defined(__LINUX__)
+# define PLATFORM_ID "Linux"
+
+# elif defined(__DOS__)
+# define PLATFORM_ID "DOS"
+
+# elif defined(__OS2__)
+# define PLATFORM_ID "OS2"
+
+# elif defined(__WINDOWS__)
+# define PLATFORM_ID "Windows3x"
+
+# elif defined(__VXWORKS__)
+# define PLATFORM_ID "VxWorks"
+
+# else /* unknown platform */
+# define PLATFORM_ID
+# endif
+
+#elif defined(__INTEGRITY)
+# if defined(INT_178B)
+# define PLATFORM_ID "Integrity178"
+
+# else /* regular Integrity */
+# define PLATFORM_ID "Integrity"
+# endif
+
+#else /* unknown platform */
+# define PLATFORM_ID
+
+#endif
+
+/* For windows compilers MSVC and Intel we can determine
+ the architecture of the compiler being used. This is because
+ the compilers do not have flags that can change the architecture,
+ but rather depend on which compiler is being used
+*/
+#if defined(_WIN32) && defined(_MSC_VER)
+# if defined(_M_IA64)
+# define ARCHITECTURE_ID "IA64"
+
+# elif defined(_M_ARM64EC)
+# define ARCHITECTURE_ID "ARM64EC"
+
+# elif defined(_M_X64) || defined(_M_AMD64)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# elif defined(_M_ARM64)
+# define ARCHITECTURE_ID "ARM64"
+
+# elif defined(_M_ARM)
+# if _M_ARM == 4
+# define ARCHITECTURE_ID "ARMV4I"
+# elif _M_ARM == 5
+# define ARCHITECTURE_ID "ARMV5I"
+# else
+# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
+# endif
+
+# elif defined(_M_MIPS)
+# define ARCHITECTURE_ID "MIPS"
+
+# elif defined(_M_SH)
+# define ARCHITECTURE_ID "SHx"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__WATCOMC__)
+# if defined(_M_I86)
+# define ARCHITECTURE_ID "I86"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# if defined(__ICCARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__ICCRX__)
+# define ARCHITECTURE_ID "RX"
+
+# elif defined(__ICCRH850__)
+# define ARCHITECTURE_ID "RH850"
+
+# elif defined(__ICCRL78__)
+# define ARCHITECTURE_ID "RL78"
+
+# elif defined(__ICCRISCV__)
+# define ARCHITECTURE_ID "RISCV"
+
+# elif defined(__ICCAVR__)
+# define ARCHITECTURE_ID "AVR"
+
+# elif defined(__ICC430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__ICCV850__)
+# define ARCHITECTURE_ID "V850"
+
+# elif defined(__ICC8051__)
+# define ARCHITECTURE_ID "8051"
+
+# elif defined(__ICCSTM8__)
+# define ARCHITECTURE_ID "STM8"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__ghs__)
+# if defined(__PPC64__)
+# define ARCHITECTURE_ID "PPC64"
+
+# elif defined(__ppc__)
+# define ARCHITECTURE_ID "PPC"
+
+# elif defined(__ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__x86_64__)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(__i386__)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__TI_COMPILER_VERSION__)
+# if defined(__TI_ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__MSP430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__TMS320C28XX__)
+# define ARCHITECTURE_ID "TMS320C28x"
+
+# elif defined(__TMS320C6X__) || defined(_TMS320C6X)
+# define ARCHITECTURE_ID "TMS320C6x"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#else
+# define ARCHITECTURE_ID
+#endif
+
+/* Convert integer to decimal digit literals. */
+#define DEC(n) \
+ ('0' + (((n) / 10000000)%10)), \
+ ('0' + (((n) / 1000000)%10)), \
+ ('0' + (((n) / 100000)%10)), \
+ ('0' + (((n) / 10000)%10)), \
+ ('0' + (((n) / 1000)%10)), \
+ ('0' + (((n) / 100)%10)), \
+ ('0' + (((n) / 10)%10)), \
+ ('0' + ((n) % 10))
+
+/* Convert integer to hex digit literals. */
+#define HEX(n) \
+ ('0' + ((n)>>28 & 0xF)), \
+ ('0' + ((n)>>24 & 0xF)), \
+ ('0' + ((n)>>20 & 0xF)), \
+ ('0' + ((n)>>16 & 0xF)), \
+ ('0' + ((n)>>12 & 0xF)), \
+ ('0' + ((n)>>8 & 0xF)), \
+ ('0' + ((n)>>4 & 0xF)), \
+ ('0' + ((n) & 0xF))
+
+/* Construct a string literal encoding the version number. */
+#ifdef COMPILER_VERSION
+char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
+
+/* Construct a string literal encoding the version number components. */
+#elif defined(COMPILER_VERSION_MAJOR)
+char const info_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
+ COMPILER_VERSION_MAJOR,
+# ifdef COMPILER_VERSION_MINOR
+ '.', COMPILER_VERSION_MINOR,
+# ifdef COMPILER_VERSION_PATCH
+ '.', COMPILER_VERSION_PATCH,
+# ifdef COMPILER_VERSION_TWEAK
+ '.', COMPILER_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct a string literal encoding the internal version number. */
+#ifdef COMPILER_VERSION_INTERNAL
+char const info_version_internal[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
+ 'i','n','t','e','r','n','a','l','[',
+ COMPILER_VERSION_INTERNAL,']','\0'};
+#elif defined(COMPILER_VERSION_INTERNAL_STR)
+char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
+#endif
+
+/* Construct a string literal encoding the version number components. */
+#ifdef SIMULATE_VERSION_MAJOR
+char const info_simulate_version[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
+ SIMULATE_VERSION_MAJOR,
+# ifdef SIMULATE_VERSION_MINOR
+ '.', SIMULATE_VERSION_MINOR,
+# ifdef SIMULATE_VERSION_PATCH
+ '.', SIMULATE_VERSION_PATCH,
+# ifdef SIMULATE_VERSION_TWEAK
+ '.', SIMULATE_VERSION_TWEAK,
+# endif
+# endif
+# endif
+ ']','\0'};
+#endif
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
+char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
+
+
+
+#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
+# if defined(__INTEL_CXX11_MODE__)
+# if defined(__cpp_aggregate_nsdmi)
+# define CXX_STD 201402L
+# else
+# define CXX_STD 201103L
+# endif
+# else
+# define CXX_STD 199711L
+# endif
+#elif defined(_MSC_VER) && defined(_MSVC_LANG)
+# define CXX_STD _MSVC_LANG
+#else
+# define CXX_STD __cplusplus
+#endif
+
+const char* info_language_standard_default = "INFO" ":" "standard_default["
+#if CXX_STD > 202002L
+ "23"
+#elif CXX_STD > 201703L
+ "20"
+#elif CXX_STD >= 201703L
+ "17"
+#elif CXX_STD >= 201402L
+ "14"
+#elif CXX_STD >= 201103L
+ "11"
+#else
+ "98"
+#endif
+"]";
+
+const char* info_language_extensions_default = "INFO" ":" "extensions_default["
+// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode.
+#if (defined(__clang__) || defined(__GNUC__) || \
+ defined(__TI_COMPILER_VERSION__)) && \
+ !defined(__STRICT_ANSI__) && !defined(_MSC_VER)
+ "ON"
+#else
+ "OFF"
+#endif
+"]";
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
+ require += info_cray[argc];
+#endif
+ require += info_language_standard_default[argc];
+ require += info_language_extensions_default[argc];
+ (void)argv;
+ return require;
+}
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.exe b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.exe
new file mode 100644
index 0000000..d241921
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.exe
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.vcxproj b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.vcxproj
new file mode 100644
index 0000000..2bf082a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.vcxproj
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
+ <RootNamespace>CompilerIdCXX</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+
+
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+
+
+
+
+ </PropertyGroup>
+
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup>
+
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+
+ </ImportGroup>
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>false</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>TurnOffAllWarnings</WarningLevel>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+
+ <Link>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+
+ </Link>
+ <PostBuildEvent>
+ <Command>for %%i in (cl.exe) do %40echo CMAKE_CXX_COMPILER=%%~$PATH:i</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="CMakeCXXCompilerId.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+
+ </ImportGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj
new file mode 100644
index 0000000..f963658
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog
new file mode 100644
index 0000000..8c79403
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog
new file mode 100644
index 0000000..ebb0c38
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog
new file mode 100644
index 0000000..5a23772
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate
new file mode 100644
index 0000000..17c7430
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
+Debug|Win32|D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdCXX\|
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog
new file mode 100644
index 0000000..e4d58e8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog
new file mode 100644
index 0000000..270e397
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog
new file mode 100644
index 0000000..864cc81
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog
Binary files differ
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate
new file mode 100644
index 0000000..9bf662b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate
@@ -0,0 +1,2 @@
+#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
+Debug|Win32|D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\|
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.txt b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.txt
new file mode 100644
index 0000000..80259da
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.txt
@@ -0,0 +1 @@
+C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/VC/VCTargets
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.vcxproj b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.vcxproj
new file mode 100644
index 0000000..84ac03b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/VCTargetsPath.vcxproj
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{F3FC6D86-508D-3FB1-96D2-995F08B142EC}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
+ <ItemDefinitionGroup>
+ <PostBuildEvent>
+ <Command>echo VCTargetsPath=$(VCTargetsPath)</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/generate.stamp.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/generate.stamp.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/3f042071a51acdc6d8fcb5e7be7244c8/generate.stamp.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/455517aeb2285a20077dbce51065d1ef/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/455517aeb2285a20077dbce51065d1ef/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/455517aeb2285a20077dbce51065d1ef/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/5db6461968e3a28c7176c305697cc35c/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/5db6461968e3a28c7176c305697cc35c/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/5db6461968e3a28c7176c305697cc35c/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/6ddefecedef78174b7ed9b2bc8a1e035/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/6ddefecedef78174b7ed9b2bc8a1e035/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/6ddefecedef78174b7ed9b2bc8a1e035/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/9ab13db7d2176474a16e440b6b1b97a8/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/9ab13db7d2176474a16e440b6b1b97a8/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/9ab13db7d2176474a16e440b6b1b97a8/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeError.log b/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeError.log
new file mode 100644
index 0000000..e554191
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeError.log
@@ -0,0 +1,16 @@
+Determining if the include file pthread.h exists failed with the following output:
+Change Dir: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeTmp
+
+Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe cmTC_ba595.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=15.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
+版权所有(C) Microsoft Corporation。保留所有权利。
+
+ 用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版
+ 版权所有(C) Microsoft Corporation。保留所有权利。
+
+ cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_ba595.dir\Debug\\" /Fd"cmTC_ba595.dir\Debug\vc141.pdb" /Gd /TC /analyze- /errorReport:queue D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\CMakeTmp\CheckIncludeFile.c
+ CheckIncludeFile.c
+
+D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\CMakeTmp\CheckIncludeFile.c(1): fatal error C1083: 无法打开包括文件: “pthread.h”: No such file or directory [D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\CMakeTmp\cmTC_ba595.vcxproj]
+
+
+
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeOutput.log b/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeOutput.log
new file mode 100644
index 0000000..56666a2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeOutput.log
@@ -0,0 +1,123 @@
+The system is: Windows - 10.0.19042 - AMD64
+Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
+Compiler:
+Build flags:
+Id flags:
+
+The output was:
+0
+用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
+版权所有(C) Microsoft Corporation。保留所有权利。
+
+生成启动时间为 2021/12/10 0:31:45。
+节点 1 上的项目“D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdC\CompilerIdC.vcxproj”(默认目标)。
+PrepareForBuild:
+ 正在创建目录“Debug\”。
+ 正在创建目录“Debug\CompilerIdC.tlog\”。
+InitializeBuildStatus:
+ 正在创建“Debug\CompilerIdC.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
+ClCompile:
+ C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TC /analyze- /FC /errorReport:queue CMakeCCompilerId.c
+ CMakeCCompilerId.c
+Link:
+ C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X86 /SAFESEH Debug\CMakeCCompilerId.obj
+ CompilerIdC.vcxproj -> D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdC\.\CompilerIdC.exe
+PostBuildEvent:
+ for %%i in (cl.exe) do @echo CMAKE_C_COMPILER=%%~$PATH:i
+ :VCEnd
+ CMAKE_C_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\cl.exe
+FinalizeBuildStatus:
+ 正在删除文件“Debug\CompilerIdC.tlog\unsuccessfulbuild”。
+ 正在对“Debug\CompilerIdC.tlog\CompilerIdC.lastbuildstate”执行 Touch 任务。
+已完成生成项目“D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdC\CompilerIdC.vcxproj”(默认目标)的操作。
+
+已成功生成。
+ 0 个警告
+ 0 个错误
+
+已用时间 00:00:02.03
+
+
+Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.exe"
+
+Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.vcxproj"
+
+The C compiler identification is MSVC, found in "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdC/CompilerIdC.exe"
+
+Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
+Compiler:
+Build flags:
+Id flags:
+
+The output was:
+0
+用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
+版权所有(C) Microsoft Corporation。保留所有权利。
+
+生成启动时间为 2021/12/10 0:31:48。
+节点 1 上的项目“D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj”(默认目标)。
+PrepareForBuild:
+ 正在创建目录“Debug\”。
+ 正在创建目录“Debug\CompilerIdCXX.tlog\”。
+InitializeBuildStatus:
+ 正在创建“Debug\CompilerIdCXX.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
+ClCompile:
+ C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\CL.exe /c /nologo /W0 /WX- /diagnostics:classic /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc141.pdb" /Gd /TP /analyze- /FC /errorReport:queue CMakeCXXCompilerId.cpp
+ CMakeCXXCompilerId.cpp
+Link:
+ C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X86 /SAFESEH Debug\CMakeCXXCompilerId.obj
+ CompilerIdCXX.vcxproj -> D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdCXX\.\CompilerIdCXX.exe
+PostBuildEvent:
+ for %%i in (cl.exe) do @echo CMAKE_CXX_COMPILER=%%~$PATH:i
+ :VCEnd
+ CMAKE_CXX_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\cl.exe
+FinalizeBuildStatus:
+ 正在删除文件“Debug\CompilerIdCXX.tlog\unsuccessfulbuild”。
+ 正在对“Debug\CompilerIdCXX.tlog\CompilerIdCXX.lastbuildstate”执行 Touch 任务。
+已完成生成项目“D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CompilerIdCXX\CompilerIdCXX.vcxproj”(默认目标)的操作。
+
+已成功生成。
+ 0 个警告
+ 0 个错误
+
+已用时间 00:00:01.06
+
+
+Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.exe"
+
+Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.vcxproj"
+
+The CXX compiler identification is MSVC, found in "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CompilerIdCXX/CompilerIdCXX.exe"
+
+Detecting C compiler ABI info compiled with the following output:
+Change Dir: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeTmp
+
+Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe cmTC_33301.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=15.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
+版权所有(C) Microsoft Corporation。保留所有权利。
+
+ 用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版
+ 版权所有(C) Microsoft Corporation。保留所有权利。
+
+ cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_33301.dir\Debug\\" /Fd"cmTC_33301.dir\Debug\vc141.pdb" /Gd /TC /analyze- /errorReport:queue "C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c"
+ CMakeCCompilerABI.c
+
+ cmTC_33301.vcxproj -> D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\CMakeTmp\Debug\cmTC_33301.exe
+
+
+
+Detecting CXX compiler ABI info compiled with the following output:
+Change Dir: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/CMakeTmp
+
+Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe cmTC_3f802.vcxproj /p:Configuration=Debug /p:Platform=Win32 /p:VisualStudioVersion=15.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
+版权所有(C) Microsoft Corporation。保留所有权利。
+
+ 用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.16.27045 版
+ 版权所有(C) Microsoft Corporation。保留所有权利。
+
+ cl /c /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /Oy- /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_3f802.dir\Debug\\" /Fd"cmTC_3f802.dir\Debug\vc141.pdb" /Gd /TP /analyze- /errorReport:queue "C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp"
+ CMakeCXXCompilerABI.cpp
+
+ cmTC_3f802.vcxproj -> D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\CMakeTmp\Debug\cmTC_3f802.exe
+
+
+
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/TargetDirectories.txt b/Client/ThirdParty/Box2D/proj/CMakeFiles/TargetDirectories.txt
new file mode 100644
index 0000000..312a8c9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/TargetDirectories.txt
@@ -0,0 +1,17 @@
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/ALL_BUILD.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/ZERO_CHECK.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/box2d.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/unit_test.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/glad.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/glfw.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/imgui.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/sajson.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/INSTALL.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/testbed.dir
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/INSTALL.dir
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/bfe9de955132cd9d067c24acf7d98bef/INSTALL_force.rule b/Client/ThirdParty/Box2D/proj/CMakeFiles/bfe9de955132cd9d067c24acf7d98bef/INSTALL_force.rule
new file mode 100644
index 0000000..2d3998c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/bfe9de955132cd9d067c24acf7d98bef/INSTALL_force.rule
@@ -0,0 +1 @@
+# generated from CMake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/cmake.check_cache b/Client/ThirdParty/Box2D/proj/CMakeFiles/cmake.check_cache
new file mode 100644
index 0000000..3dccd73
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/cmake.check_cache
@@ -0,0 +1 @@
+# This file is generated by cmake for dependency checking of the CMakeCache.txt file
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..ac4d405
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,96 @@
+# CMake generation dependency list for this directory.
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCCompiler.cmake.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCCompilerABI.c
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCInformation.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXCompiler.cmake.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXCompilerABI.cpp
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCXXInformation.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeCompilerIdDetection.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompileFeatures.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompilerABI.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompilerId.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineRCCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeFindBinUtils.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeGenericSystem.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeParseImplicitIncludeInfo.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeParseImplicitLinkInfo.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeParseLibraryArchitecture.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeRCCompiler.cmake.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeRCInformation.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystem.cmake.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCompilerCommon.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestRCCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/ADSP-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/ARMCC-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/ARMClang-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/AppleClang-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Borland-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Bruce-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Clang-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Clang-DetermineCompilerInternal.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Compaq-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Cray-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Embarcadero-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Fujitsu-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GHS-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/HP-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/HP-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IAR-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Intel-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/IntelLLVM-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/MSVC-C.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/MSVC-CXX.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/MSVC-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/NVHPC-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/NVIDIA-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/PGI-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/PathScale-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SCO-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SDCC-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SunPro-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/TI-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/Watcom-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XL-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XL-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XLClang-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/zOS-C-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CompilerId/VS-10.vcxproj.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/GNUInstallDirs.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Internal/FeatureTesting.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-Determine-CXX.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-MSVC-C.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-MSVC-CXX.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows-MSVC.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/Windows.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Platform/WindowsPaths.cmake
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/CMakeLists.txt
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCCompiler.cmake
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeCXXCompiler.cmake
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeRCCompiler.cmake
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/3.22.0-rc2/CMakeSystem.cmake
diff --git a/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.list b/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.list
new file mode 100644
index 0000000..9ff9311
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp.list
@@ -0,0 +1,8 @@
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
diff --git a/Client/ThirdParty/Box2D/proj/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/INSTALL.vcxproj
new file mode 100644
index 0000000..53a7ff2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3f042071a51acdc6d8fcb5e7be7244c8\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..8aed76c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3f042071a51acdc6d8fcb5e7be7244c8\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj b/Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj
new file mode 100644
index 0000000..afb370d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>ZERO_CHECK</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <Midl>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3f042071a51acdc6d8fcb5e7be7244c8\generate.stamp.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Checking Build System</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-list CMakeFiles/generate.stamp.list --vs-solution-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/box2d.sln
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\CMakeLists.txt;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Checking Build System</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-list CMakeFiles/generate.stamp.list --vs-solution-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/box2d.sln
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\CMakeLists.txt;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Checking Build System</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-list CMakeFiles/generate.stamp.list --vs-solution-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/box2d.sln
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\CMakeLists.txt;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Checking Build System</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-list CMakeFiles/generate.stamp.list --vs-solution-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/box2d.sln
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCCompilerABI.c;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXCompilerABI.cpp;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCXXInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCommonLanguageInclude.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeCompilerIdDetection.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompileFeatures.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerABI.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineCompilerId.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeDetermineSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeFindBinUtils.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeGenericSystem.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeInitializeConfigs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeLanguageInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitIncludeInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseImplicitLinkInfo.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeParseLibraryArchitecture.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCCompiler.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeRCInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystem.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInformation.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeSystemSpecificInitialize.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCXXCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestCompilerCommon.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakeTestRCCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ADSP-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMCC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\ARMClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\AppleClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Borland-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Bruce-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\CMakeCommonCompilerMacros.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Clang-DetermineCompilerInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Comeau-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Compaq-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Cray-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Embarcadero-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Fujitsu-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\FujitsuClang-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GHS-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\GNU-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\HP-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IAR-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-C-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IBMCPP-CXX-DetermineVersionInternal.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Intel-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\IntelLLVM-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\MSVC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVHPC-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\NVIDIA-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\OpenWatcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PGI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\PathScale-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SCO-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SDCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\SunPro-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TI-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\TinyCC-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\VisualAge-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\Watcom-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XL-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\XLClang-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-C-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Compiler\zOS-CXX-DetermineCompiler.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CompilerId\VS-10.vcxproj.in;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\GNUInstallDirs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\FeatureTesting.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-Determine-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-C.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC-CXX.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows-MSVC.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\Windows.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Platform\WindowsPaths.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeCXXCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeRCCompiler.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3.22.0-rc2\CMakeSystem.cmake;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\CMakeLists.txt;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\CMakeLists.txt;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj.filters b/Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj.filters
new file mode 100644
index 0000000..9347418
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/ZERO_CHECK.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\3f042071a51acdc6d8fcb5e7be7244c8\generate.stamp.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/box2d.sln b/Client/ThirdParty/Box2D/proj/box2d.sln
new file mode 100644
index 0000000..e4d5968
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/box2d.sln
@@ -0,0 +1,164 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMakePredefinedTargets", "CMakePredefinedTargets", "{71FC76BE-FD8A-37AA-B070-4AD8DFF9C5B9}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testbed", "testbed\testbed.vcxproj", "{A168F045-AE5A-3724-B305-AA2A8C4749BA}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E} = {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}
+ {29408AB9-D01F-3745-93F3-94160B037370} = {29408AB9-D01F-3745-93F3-94160B037370}
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92} = {7F32E689-3D5C-3885-9B34-0860DAE8BE92}
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7} = {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380} = {EE68EE8F-E321-3CD7-A04C-C0A66C401380}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{2BA85667-24FF-36F3-825F-79CEC5AB3361}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E} = {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}
+ {29408AB9-D01F-3745-93F3-94160B037370} = {29408AB9-D01F-3745-93F3-94160B037370}
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92} = {7F32E689-3D5C-3885-9B34-0860DAE8BE92}
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7} = {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380} = {EE68EE8F-E321-3CD7-A04C-C0A66C401380}
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA} = {A168F045-AE5A-3724-B305-AA2A8C4749BA}
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52} = {7ED467E4-0B19-329B-B677-9C4C01A3EC52}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INSTALL", "INSTALL.vcxproj", "{9AC23237-8AB3-35CD-9010-F378760CC445}"
+ ProjectSection(ProjectDependencies) = postProject
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361} = {2BA85667-24FF-36F3-825F-79CEC5AB3361}
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "box2d", "src\box2d.vcxproj", "{4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glad", "extern\glad\glad.vcxproj", "{29408AB9-D01F-3745-93F3-94160B037370}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glfw", "extern\glfw\glfw.vcxproj", "{7F32E689-3D5C-3885-9B34-0860DAE8BE92}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgui", "extern\imgui\imgui.vcxproj", "{B288C97F-F14F-33EA-9CAC-B55922D1FDC7}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sajson", "extern\sajson\sajson.vcxproj", "{EE68EE8F-E321-3CD7-A04C-C0A66C401380}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit_test", "unit-test\unit_test.vcxproj", "{7ED467E4-0B19-329B-B677-9C4C01A3EC52}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E} = {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ MinSizeRel|Win32 = MinSizeRel|Win32
+ RelWithDebInfo|Win32 = RelWithDebInfo|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.Debug|Win32.Build.0 = Debug|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.Release|Win32.ActiveCfg = Release|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.Release|Win32.Build.0 = Release|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {A168F045-AE5A-3724-B305-AA2A8C4749BA}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.Debug|Win32.Build.0 = Debug|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.Release|Win32.ActiveCfg = Release|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.Release|Win32.Build.0 = Release|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {9AC23237-8AB3-35CD-9010-F378760CC445}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9AC23237-8AB3-35CD-9010-F378760CC445}.Release|Win32.ActiveCfg = Release|Win32
+ {9AC23237-8AB3-35CD-9010-F378760CC445}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {9AC23237-8AB3-35CD-9010-F378760CC445}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.Debug|Win32.Build.0 = Debug|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.Release|Win32.ActiveCfg = Release|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.Release|Win32.Build.0 = Release|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.Debug|Win32.Build.0 = Debug|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.Release|Win32.ActiveCfg = Release|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.Release|Win32.Build.0 = Release|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.Debug|Win32.ActiveCfg = Debug|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.Debug|Win32.Build.0 = Debug|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.Release|Win32.ActiveCfg = Release|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.Release|Win32.Build.0 = Release|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {29408AB9-D01F-3745-93F3-94160B037370}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.Debug|Win32.Build.0 = Debug|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.Release|Win32.ActiveCfg = Release|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.Release|Win32.Build.0 = Release|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {7F32E689-3D5C-3885-9B34-0860DAE8BE92}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.Debug|Win32.Build.0 = Debug|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.Release|Win32.ActiveCfg = Release|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.Release|Win32.Build.0 = Release|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {B288C97F-F14F-33EA-9CAC-B55922D1FDC7}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.Debug|Win32.Build.0 = Debug|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.Release|Win32.ActiveCfg = Release|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.Release|Win32.Build.0 = Release|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {EE68EE8F-E321-3CD7-A04C-C0A66C401380}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.Debug|Win32.Build.0 = Debug|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.Release|Win32.ActiveCfg = Release|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.Release|Win32.Build.0 = Release|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {7ED467E4-0B19-329B-B677-9C4C01A3EC52}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {2BA85667-24FF-36F3-825F-79CEC5AB3361} = {71FC76BE-FD8A-37AA-B070-4AD8DFF9C5B9}
+ {9AC23237-8AB3-35CD-9010-F378760CC445} = {71FC76BE-FD8A-37AA-B070-4AD8DFF9C5B9}
+ {BE3FCA9C-E0F7-3263-BFDC-D625CD827C80} = {71FC76BE-FD8A-37AA-B070-4AD8DFF9C5B9}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {97ED1C2D-8C4A-3AB8-B57A-98BCD6D53BC0}
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Client/ThirdParty/Box2D/proj/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/cmake_install.cmake
new file mode 100644
index 0000000..c934970
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/cmake_install.cmake
@@ -0,0 +1,60 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
+if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/include" TYPE DIRECTORY FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/include/box2d")
+endif()
+
+if(NOT CMAKE_INSTALL_LOCAL_ONLY)
+ # Include the install script for each subdirectory.
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/cmake_install.cmake")
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/cmake_install.cmake")
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/cmake_install.cmake")
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/cmake_install.cmake")
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/cmake_install.cmake")
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/cmake_install.cmake")
+ include("D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/cmake_install.cmake")
+
+endif()
+
+if(CMAKE_INSTALL_COMPONENT)
+ set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
+else()
+ set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
+endif()
+
+string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
+ "${CMAKE_INSTALL_MANIFEST_FILES}")
+file(WRITE "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/${CMAKE_INSTALL_MANIFEST}"
+ "${CMAKE_INSTALL_MANIFEST_CONTENT}")
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..360d398
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,2 @@
+# CMake generation dependency list for this directory.
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj
new file mode 100644
index 0000000..190e04c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\14f8a92cc8883d19b638672092016c39\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..73b4ed6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\14f8a92cc8883d19b638672092016c39\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/extern/glad/cmake_install.cmake
new file mode 100644
index 0000000..1fb9427
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/cmake_install.cmake
@@ -0,0 +1,34 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glad
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj b/Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj
new file mode 100644
index 0000000..586e8c1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj
@@ -0,0 +1,279 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{29408AB9-D01F-3745-93F3-94160B037370}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>glad</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">glad.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">glad</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">glad.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">glad</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">glad.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">glad</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">glad.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">glad</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.lib</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glad/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glad/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\src\gl.c" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include\glad\gl.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include\KHR\khrplatform.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj.filters
new file mode 100644
index 0000000..e492470
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glad/glad.vcxproj.filters
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\src\gl.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include\glad\gl.h">
+ <Filter>include\glad</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include\KHR\khrplatform.h">
+ <Filter>include\KHR</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="include">
+ <UniqueIdentifier>{2B754068-BECE-3CED-9144-9AA210967EB9}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="include\KHR">
+ <UniqueIdentifier>{247E20A5-3102-3368-AEA3-7C6A2608F1DA}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="include\glad">
+ <UniqueIdentifier>{6C0DE5BF-9EF7-3060-890B-9D628058E4B7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src">
+ <UniqueIdentifier>{A24BD43B-5C67-30C5-8AF1-02F4AF819691}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..ee5692b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,10 @@
+# CMake generation dependency list for this directory.
+C:/Program Files/CMake/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CheckIncludeFile.c.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/CheckIncludeFile.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/CheckLibraryExists.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageMessage.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/FindThreads.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj
new file mode 100644
index 0000000..c925fa4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\455517aeb2285a20077dbce51065d1ef\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..774c4c0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\455517aeb2285a20077dbce51065d1ef\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/extern/glfw/cmake_install.cmake
new file mode 100644
index 0000000..3e26128
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/cmake_install.cmake
@@ -0,0 +1,34 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glfw
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj b/Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj
new file mode 100644
index 0000000..8709b95
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj
@@ -0,0 +1,300 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{7F32E689-3D5C-3885-9B34-0860DAE8BE92}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>glfw</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">glfw.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">glfw</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">glfw.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">glfw</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">glfw.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">glfw</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">glfw.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">glfw</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.lib</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>
+ </ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/glfw/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/glfw/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\CheckCSourceCompiles.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.c.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckIncludeFile.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\CheckLibraryExists.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageHandleStandardArgs.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindPackageMessage.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\FindThreads.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\Internal\CheckSourceCompiles.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\context.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\init.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\input.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\monitor.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\vulkan.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\window.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_init.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_joystick.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_monitor.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_time.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_thread.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_window.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\wgl_context.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\egl_context.c" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\osmesa_context.c" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\internal.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\mappings.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include\GLFW\glfw3.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include\GLFW\glfw3native.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_platform.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_joystick.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\wgl_context.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\egl_context.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\osmesa_context.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj.filters
new file mode 100644
index 0000000..ec923bf
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/glfw/glfw.vcxproj.filters
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\context.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\init.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\input.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\monitor.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\vulkan.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\window.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_init.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_joystick.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_monitor.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_time.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_thread.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_window.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\wgl_context.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\egl_context.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\osmesa_context.c">
+ <Filter>src</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\internal.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\mappings.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include\GLFW\glfw3.h">
+ <Filter>include\GLFW</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include\GLFW\glfw3native.h">
+ <Filter>include\GLFW</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_platform.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\win32_joystick.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\wgl_context.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\egl_context.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\src\osmesa_context.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="include">
+ <UniqueIdentifier>{2B754068-BECE-3CED-9144-9AA210967EB9}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="include\GLFW">
+ <UniqueIdentifier>{8046E0DF-0536-3330-8D73-CADA49EA10AD}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src">
+ <UniqueIdentifier>{A24BD43B-5C67-30C5-8AF1-02F4AF819691}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..0fee0f9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,2 @@
+# CMake generation dependency list for this directory.
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj
new file mode 100644
index 0000000..ad0fed8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\9ab13db7d2176474a16e440b6b1b97a8\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..3cf65ec
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\9ab13db7d2176474a16e440b6b1b97a8\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/extern/imgui/cmake_install.cmake
new file mode 100644
index 0000000..78732f0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/cmake_install.cmake
@@ -0,0 +1,34 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/imgui
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj b/Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj
new file mode 100644
index 0000000..449cae4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{B288C97F-F14F-33EA-9CAC-B55922D1FDC7}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>imgui</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">imgui.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">imgui</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">imgui.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">imgui</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">imgui.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">imgui</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">imgui.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">imgui</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.lib</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/imgui/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/imgui/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_demo.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_draw.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_widgets.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imconfig.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_internal.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imstb_rectpack.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imstb_textedit.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imstb_truetype.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj.filters
new file mode 100644
index 0000000..513764a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/imgui/imgui.vcxproj.filters
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_demo.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_draw.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_widgets.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imconfig.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imgui_internal.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imstb_rectpack.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imstb_textedit.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\imstb_truetype.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..6358b51
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,2 @@
+# CMake generation dependency list for this directory.
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj
new file mode 100644
index 0000000..3966786
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\049e1eb7380682ec4cf9a2c62dad57db\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..068dfc2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\049e1eb7380682ec4cf9a2c62dad57db\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/extern/sajson/cmake_install.cmake
new file mode 100644
index 0000000..9de7c41
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/cmake_install.cmake
@@ -0,0 +1,34 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/sajson
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj b/Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj
new file mode 100644
index 0000000..0a2534b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj
@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{EE68EE8F-E321-3CD7-A04C-C0A66C401380}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>sajson</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">sajson.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">sajson</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">sajson.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">sajson</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">sajson.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">sajson</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">sajson.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">sajson</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.lib</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/extern/sajson/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/extern/sajson/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\sajson.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\sajson.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj.filters b/Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj.filters
new file mode 100644
index 0000000..cfcef01
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/extern/sajson/sajson.vcxproj.filters
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\sajson.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\sajson.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-debug.cmake b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-debug.cmake
new file mode 100644
index 0000000..786d951
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-debug.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "Debug".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "box2d::box2d" for configuration "Debug"
+set_property(TARGET box2d::box2d APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+set_target_properties(box2d::box2d PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
+ IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/box2d.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS box2d::box2d )
+list(APPEND _IMPORT_CHECK_FILES_FOR_box2d::box2d "${_IMPORT_PREFIX}/lib/box2d.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-minsizerel.cmake b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-minsizerel.cmake
new file mode 100644
index 0000000..330120c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-minsizerel.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "MinSizeRel".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "box2d::box2d" for configuration "MinSizeRel"
+set_property(TARGET box2d::box2d APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
+set_target_properties(box2d::box2d PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_MINSIZEREL "CXX"
+ IMPORTED_LOCATION_MINSIZEREL "${_IMPORT_PREFIX}/lib/box2d.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS box2d::box2d )
+list(APPEND _IMPORT_CHECK_FILES_FOR_box2d::box2d "${_IMPORT_PREFIX}/lib/box2d.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-release.cmake b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-release.cmake
new file mode 100644
index 0000000..e29ee82
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-release.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "Release".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "box2d::box2d" for configuration "Release"
+set_property(TARGET box2d::box2d APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(box2d::box2d PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
+ IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/box2d.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS box2d::box2d )
+list(APPEND _IMPORT_CHECK_FILES_FOR_box2d::box2d "${_IMPORT_PREFIX}/lib/box2d.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-relwithdebinfo.cmake b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-relwithdebinfo.cmake
new file mode 100644
index 0000000..a41bfce
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-relwithdebinfo.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "RelWithDebInfo".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "box2d::box2d" for configuration "RelWithDebInfo"
+set_property(TARGET box2d::box2d APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
+set_target_properties(box2d::box2d PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO "CXX"
+ IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib/box2d.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS box2d::box2d )
+list(APPEND _IMPORT_CHECK_FILES_FOR_box2d::box2d "${_IMPORT_PREFIX}/lib/box2d.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig.cmake b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig.cmake
new file mode 100644
index 0000000..5a32fdc
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig.cmake
@@ -0,0 +1,94 @@
+# Generated by CMake
+
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+ message(FATAL_ERROR "CMake >= 2.6.0 required")
+endif()
+cmake_policy(PUSH)
+cmake_policy(VERSION 2.6...3.20)
+#----------------------------------------------------------------
+# Generated CMake target import file.
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Protect against multiple inclusion, which would fail when already imported targets are added once more.
+set(_targetsDefined)
+set(_targetsNotDefined)
+set(_expectedTargets)
+foreach(_expectedTarget box2d::box2d)
+ list(APPEND _expectedTargets ${_expectedTarget})
+ if(NOT TARGET ${_expectedTarget})
+ list(APPEND _targetsNotDefined ${_expectedTarget})
+ endif()
+ if(TARGET ${_expectedTarget})
+ list(APPEND _targetsDefined ${_expectedTarget})
+ endif()
+endforeach()
+if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
+ unset(_targetsDefined)
+ unset(_targetsNotDefined)
+ unset(_expectedTargets)
+ set(CMAKE_IMPORT_FILE_VERSION)
+ cmake_policy(POP)
+ return()
+endif()
+if(NOT "${_targetsDefined}" STREQUAL "")
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
+endif()
+unset(_targetsDefined)
+unset(_targetsNotDefined)
+unset(_expectedTargets)
+
+
+# Compute the installation prefix relative to this file.
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+ set(_IMPORT_PREFIX "")
+endif()
+
+# Create imported target box2d::box2d
+add_library(box2d::box2d STATIC IMPORTED)
+
+set_target_properties(box2d::box2d PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
+)
+
+# Load information for each installed configuration.
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+file(GLOB CONFIG_FILES "${_DIR}/box2dConfig-*.cmake")
+foreach(f ${CONFIG_FILES})
+ include(${f})
+endforeach()
+
+# Cleanup temporary variables.
+set(_IMPORT_PREFIX)
+
+# Loop over all imported files and verify that they actually exist
+foreach(target ${_IMPORT_CHECK_TARGETS} )
+ foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
+ if(NOT EXISTS "${file}" )
+ message(FATAL_ERROR "The imported target \"${target}\" references the file
+ \"${file}\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \"${CMAKE_CURRENT_LIST_FILE}\"
+but not all the files it references.
+")
+ endif()
+ endforeach()
+ unset(_IMPORT_CHECK_FILES_FOR_${target})
+endforeach()
+unset(_IMPORT_CHECK_TARGETS)
+
+# This file does not depend on other imported targets which have
+# been exported from the same project but in a separate export set.
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
+cmake_policy(POP)
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..36bdce4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,5 @@
+# CMake generation dependency list for this directory.
+C:/Program Files/CMake/share/cmake-3.22/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
+C:/Program Files/CMake/share/cmake-3.22/Modules/CMakePackageConfigHelpers.cmake
+C:/Program Files/CMake/share/cmake-3.22/Modules/WriteBasicConfigVersionFile.cmake
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/src/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj
new file mode 100644
index 0000000..c715096
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\5db6461968e3a28c7176c305697cc35c\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..d373820
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\5db6461968e3a28c7176c305697cc35c\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/src/box2d.vcxproj b/Client/ThirdParty/Box2D/proj/src/box2d.vcxproj
new file mode 100644
index 0000000..4c28ee3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/box2d.vcxproj
@@ -0,0 +1,374 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>box2d</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">box2d.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">box2d</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">box2d.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">box2d</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">box2d.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">box2d</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.lib</TargetExt>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">box2d.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">box2d</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.lib</TargetExt>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\Debug\box2d.pdb</ProgramDataBaseFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <ProgramDataBaseFileName>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\Release\box2d.pdb</ProgramDataBaseFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ <ProgramDataBaseFileName>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\MinSizeRel\box2d.pdb</ProgramDataBaseFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\RelWithDebInfo\box2d.pdb</ProgramDataBaseFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Lib>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/src/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/src/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/src/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/src/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">C:\Program Files\CMake\share\cmake-3.22\Modules\BasicConfigVersion-SameMajorVersion.cmake.in;C:\Program Files\CMake\share\cmake-3.22\Modules\CMakePackageConfigHelpers.cmake;C:\Program Files\CMake\share\cmake-3.22\Modules\WriteBasicConfigVersionFile.cmake;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_broad_phase.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_chain_shape.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_circle_shape.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collide_circle.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collide_edge.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collide_polygon.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collision.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_distance.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_dynamic_tree.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_edge_shape.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_polygon_shape.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_time_of_impact.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_block_allocator.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_draw.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_math.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_settings.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_stack_allocator.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_timer.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_body.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_circle_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_circle_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_polygon_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_polygon_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_circle_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_circle_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact_manager.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact_solver.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact_solver.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_distance_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_circle_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_circle_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_polygon_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_polygon_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_fixture.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_friction_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_gear_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_island.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_island.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_motor_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_mouse_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_circle_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_circle_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_contact.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_contact.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_prismatic_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_pulley_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_revolute_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_weld_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_wheel_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_world.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_world_callbacks.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\rope\b2_rope.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_api.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_block_allocator.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_body.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_broad_phase.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_chain_shape.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_circle_shape.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_collision.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_common.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_contact.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_contact_manager.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_distance.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_distance_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_draw.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_dynamic_tree.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_edge_shape.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_fixture.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_friction_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_gear_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_growable_stack.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_math.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_motor_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_mouse_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_polygon_shape.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_prismatic_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_pulley_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_revolute_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_rope.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_settings.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_shape.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_stack_allocator.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_time_of_impact.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_timer.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_time_step.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_types.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_weld_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_wheel_joint.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_world.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_world_callbacks.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\box2d.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/src/box2d.vcxproj.filters b/Client/ThirdParty/Box2D/proj/src/box2d.vcxproj.filters
new file mode 100644
index 0000000..6a9ca63
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/box2d.vcxproj.filters
@@ -0,0 +1,315 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_broad_phase.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_chain_shape.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_circle_shape.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collide_circle.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collide_edge.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collide_polygon.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_collision.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_distance.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_dynamic_tree.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_edge_shape.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_polygon_shape.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\collision\b2_time_of_impact.cpp">
+ <Filter>src\collision</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_block_allocator.cpp">
+ <Filter>src\common</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_draw.cpp">
+ <Filter>src\common</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_math.cpp">
+ <Filter>src\common</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_settings.cpp">
+ <Filter>src\common</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_stack_allocator.cpp">
+ <Filter>src\common</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\common\b2_timer.cpp">
+ <Filter>src\common</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_body.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_circle_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_polygon_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_circle_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact_manager.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact_solver.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_distance_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_circle_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_polygon_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_fixture.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_friction_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_gear_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_island.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_motor_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_mouse_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_circle_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_contact.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_prismatic_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_pulley_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_revolute_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_weld_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_wheel_joint.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_world.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_world_callbacks.cpp">
+ <Filter>src\dynamics</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\rope\b2_rope.cpp">
+ <Filter>src\rope</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_circle_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_chain_polygon_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_circle_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_contact_solver.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_circle_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_edge_polygon_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_island.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_circle_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\dynamics\b2_polygon_contact.h">
+ <Filter>src\dynamics</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_api.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_block_allocator.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_body.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_broad_phase.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_chain_shape.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_circle_shape.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_collision.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_common.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_contact.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_contact_manager.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_distance.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_distance_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_draw.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_dynamic_tree.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_edge_shape.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_fixture.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_friction_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_gear_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_growable_stack.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_math.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_motor_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_mouse_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_polygon_shape.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_prismatic_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_pulley_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_revolute_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_rope.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_settings.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_shape.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_stack_allocator.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_time_of_impact.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_timer.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_time_step.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_types.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_weld_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_wheel_joint.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_world.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\b2_world_callbacks.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\include\box2d\box2d.h">
+ <Filter>include\box2d</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="include">
+ <UniqueIdentifier>{2B754068-BECE-3CED-9144-9AA210967EB9}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="include\box2d">
+ <UniqueIdentifier>{44BE8560-7149-31D1-86F4-77906E2C0964}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src">
+ <UniqueIdentifier>{A24BD43B-5C67-30C5-8AF1-02F4AF819691}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src\collision">
+ <UniqueIdentifier>{44A461AD-15F1-3F81-9DD3-2F84788CC206}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src\common">
+ <UniqueIdentifier>{E64D37AD-9345-3075-89E6-11CF67457044}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src\dynamics">
+ <UniqueIdentifier>{322B13ED-462E-37F0-920F-C4B6752E7654}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="src\rope">
+ <UniqueIdentifier>{BC484391-F853-356A-BCD3-79E86AF80865}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/src/box2dConfigVersion.cmake b/Client/ThirdParty/Box2D/proj/src/box2dConfigVersion.cmake
new file mode 100644
index 0000000..e1421d4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/box2dConfigVersion.cmake
@@ -0,0 +1,70 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
+# but only if the requested major version is the same as the current one.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+
+set(PACKAGE_VERSION "2.4.1")
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+
+ if("2.4.1" MATCHES "^([0-9]+)\\.")
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
+ endif()
+ else()
+ set(CVF_VERSION_MAJOR "2.4.1")
+ endif()
+
+ if(PACKAGE_FIND_VERSION_RANGE)
+ # both endpoints of the range must have the expected major version
+ math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
+ if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+ AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+ else()
+ if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+ endif()
+endif()
+
+
+# if the installed project requested no architecture check, don't perform the check
+if("FALSE")
+ return()
+endif()
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "4" STREQUAL "")
+ return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "4")
+ math(EXPR installedBits "4 * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/Client/ThirdParty/Box2D/proj/src/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/src/cmake_install.cmake
new file mode 100644
index 0000000..eaa7515
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/src/cmake_install.cmake
@@ -0,0 +1,90 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/src
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
+if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
+ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE OPTIONAL FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/Debug/box2d.pdb")
+ elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE OPTIONAL FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/Release/box2d.pdb")
+ elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE OPTIONAL FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/MinSizeRel/box2d.pdb")
+ elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE OPTIONAL FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/RelWithDebInfo/box2d.pdb")
+ endif()
+endif()
+
+if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
+ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Debug/box2d.lib")
+ elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Release/box2d.lib")
+ elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/MinSizeRel/box2d.lib")
+ elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE STATIC_LIBRARY FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/RelWithDebInfo/box2d.lib")
+ endif()
+endif()
+
+if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
+ if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d/box2dConfig.cmake")
+ file(DIFFERENT EXPORT_FILE_CHANGED FILES
+ "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d/box2dConfig.cmake"
+ "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig.cmake")
+ if(EXPORT_FILE_CHANGED)
+ file(GLOB OLD_CONFIG_FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d/box2dConfig-*.cmake")
+ if(OLD_CONFIG_FILES)
+ message(STATUS "Old export file \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d/box2dConfig.cmake\" will be replaced. Removing files [${OLD_CONFIG_FILES}].")
+ file(REMOVE ${OLD_CONFIG_FILES})
+ endif()
+ endif()
+ endif()
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d" TYPE FILE FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig.cmake")
+ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d" TYPE FILE FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-debug.cmake")
+ endif()
+ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d" TYPE FILE FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-minsizerel.cmake")
+ endif()
+ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d" TYPE FILE FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-relwithdebinfo.cmake")
+ endif()
+ if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d" TYPE FILE FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/CMakeFiles/Export/lib/cmake/box2d/box2dConfig-release.cmake")
+ endif()
+endif()
+
+if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
+ file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/box2d" TYPE FILE FILES "D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/src/box2dConfigVersion.cmake")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..d9dafb9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,2 @@
+# CMake generation dependency list for this directory.
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj
new file mode 100644
index 0000000..c4594d2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\bfe9de955132cd9d067c24acf7d98bef\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..53254e6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\bfe9de955132cd9d067c24acf7d98bef\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/testbed/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/testbed/cmake_install.cmake
new file mode 100644
index 0000000..56b763e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/cmake_install.cmake
@@ -0,0 +1,34 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj b/Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj
new file mode 100644
index 0000000..6bd4fe2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj
@@ -0,0 +1,465 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{A168F045-AE5A-3724-B305-AA2A8C4749BA}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>testbed</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <LocalDebuggerWorkingDirectory Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed</LocalDebuggerWorkingDirectory>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">testbed.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">testbed</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
+ <LocalDebuggerWorkingDirectory Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed</LocalDebuggerWorkingDirectory>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">testbed.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">testbed</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
+ <LocalDebuggerWorkingDirectory Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed</LocalDebuggerWorkingDirectory>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">testbed.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">testbed</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">true</GenerateManifest>
+ <LocalDebuggerWorkingDirectory Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed</LocalDebuggerWorkingDirectory>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">testbed.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">testbed</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">true</GenerateManifest>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -E copy_directory D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/data/ D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/data/
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ <Link>
+ <AdditionalDependencies>..\bin\Debug\box2d.lib;..\bin\Debug\glfw.lib;..\bin\Debug\imgui.lib;..\bin\Debug\sajson.lib;..\bin\Debug\glad.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Debug/testbed.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Debug/testbed.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -E copy_directory D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/data/ D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/data/
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ <Link>
+ <AdditionalDependencies>..\bin\Release\box2d.lib;..\bin\Release\glfw.lib;..\bin\Release\imgui.lib;..\bin\Release\sajson.lib;..\bin\Release\glad.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Release/testbed.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Release/testbed.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -E copy_directory D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/data/ D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/data/
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ <Link>
+ <AdditionalDependencies>..\bin\MinSizeRel\box2d.lib;..\bin\MinSizeRel\glfw.lib;..\bin\MinSizeRel\imgui.lib;..\bin\MinSizeRel\sajson.lib;..\bin\MinSizeRel\glad.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/MinSizeRel/testbed.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/MinSizeRel/testbed.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glfw\include;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\imgui\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\sajson\..;D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\extern\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -E copy_directory D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/data/ D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/data/
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ <Link>
+ <AdditionalDependencies>..\bin\RelWithDebInfo\box2d.lib;..\bin\RelWithDebInfo\glfw.lib;..\bin\RelWithDebInfo\imgui.lib;..\bin\RelWithDebInfo\sajson.lib;..\bin\RelWithDebInfo\glad.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/RelWithDebInfo/testbed.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/RelWithDebInfo/testbed.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/testbed/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/testbed/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\testbed\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\draw.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\draw.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_glfw.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_glfw.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_opengl3.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_opengl3.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\main.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\settings.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\settings.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\test.cpp" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\test.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\add_pair.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\apply_force.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\body_types.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\box_stack.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\breakable.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\bridge.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\bullet_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\cantilever.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\car.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\chain.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\chain_problem.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\character_collision.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\circle_stack.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\collision_filtering.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\collision_processing.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\compound_shapes.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\confined.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\continuous_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\convex_hull.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\conveyor_belt.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\distance_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\distance_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\dominos.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\dump_loader.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\dynamic_tree.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\edge_shapes.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\edge_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\friction.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\gear_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\heavy1.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\heavy2.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\mobile_balanced.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\mobile_unbalanced.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\motor_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\pinball.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\platformer.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\polygon_collision.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\polygon_shapes.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\prismatic_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\pulley_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\pyramid.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\ray_cast.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\restitution.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\revolute_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\rope.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\sensor.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\shape_cast.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\shape_editing.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\skier.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\slider_crank_1.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\slider_crank_2.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\theo_jansen.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\tiles.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\time_of_impact.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\tumbler.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\web.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\wheel_joint.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\wrecking_ball.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\box2d.vcxproj">
+ <Project>{4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}</Project>
+ <Name>box2d</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glad\glad.vcxproj">
+ <Project>{29408AB9-D01F-3745-93F3-94160B037370}</Project>
+ <Name>glad</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\glfw\glfw.vcxproj">
+ <Project>{7F32E689-3D5C-3885-9B34-0860DAE8BE92}</Project>
+ <Name>glfw</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\imgui\imgui.vcxproj">
+ <Project>{B288C97F-F14F-33EA-9CAC-B55922D1FDC7}</Project>
+ <Name>imgui</Name>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\extern\sajson\sajson.vcxproj">
+ <Project>{EE68EE8F-E321-3CD7-A04C-C0A66C401380}</Project>
+ <Name>sajson</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj.filters b/Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj.filters
new file mode 100644
index 0000000..2781f18
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/testbed/testbed.vcxproj.filters
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\draw.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_glfw.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_opengl3.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\main.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\settings.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\add_pair.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\apply_force.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\body_types.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\box_stack.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\breakable.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\bridge.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\bullet_test.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\cantilever.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\car.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\chain.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\chain_problem.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\character_collision.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\circle_stack.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\collision_filtering.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\collision_processing.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\compound_shapes.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\confined.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\continuous_test.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\convex_hull.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\conveyor_belt.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\distance_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\distance_test.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\dominos.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\dump_loader.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\dynamic_tree.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\edge_shapes.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\edge_test.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\friction.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\gear_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\heavy1.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\heavy2.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\mobile_balanced.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\mobile_unbalanced.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\motor_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\pinball.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\platformer.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\polygon_collision.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\polygon_shapes.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\prismatic_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\pulley_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\pyramid.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\ray_cast.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\restitution.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\revolute_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\rope.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\sensor.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\shape_cast.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\shape_editing.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\skier.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\slider_crank_1.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\slider_crank_2.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\theo_jansen.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\tiles.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\time_of_impact.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\tumbler.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\web.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\wheel_joint.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\tests\wrecking_ball.cpp">
+ <Filter>tests</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\draw.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_glfw.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\imgui_impl_opengl3.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\settings.h" />
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\test.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\testbed\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="tests">
+ <UniqueIdentifier>{E24537DA-4173-36D5-9B2A-0CFE337F0649}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp b/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
new file mode 100644
index 0000000..9b5f49f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
@@ -0,0 +1 @@
+# CMake generation timestamp file for this directory.
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp.depend b/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp.depend
new file mode 100644
index 0000000..e940e58
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp.depend
@@ -0,0 +1,2 @@
+# CMake generation dependency list for this directory.
+D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj b/Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj
new file mode 100644
index 0000000..42b9eb6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{9AC23237-8AB3-35CD-9010-F378760CC445}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>INSTALL</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <PostBuildEvent>
+ <Message></Message>
+ <Command>setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=$(Configuration) -P cmake_install.cmake
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ </PostBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\6ddefecedef78174b7ed9b2bc8a1e035\INSTALL_force.rule">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+cd .
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\INSTALL_force</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ALL_BUILD.vcxproj">
+ <Project>{2BA85667-24FF-36F3-825F-79CEC5AB3361}</Project>
+ <Name>ALL_BUILD</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj.filters b/Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj.filters
new file mode 100644
index 0000000..82a060e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/INSTALL.vcxproj.filters
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\CMakeFiles\6ddefecedef78174b7ed9b2bc8a1e035\INSTALL_force.rule">
+ <Filter>CMake Rules</Filter>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="CMake Rules">
+ <UniqueIdentifier>{403DEAA2-503F-3ECB-A013-6CDC0F5B48FC}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/cmake_install.cmake b/Client/ThirdParty/Box2D/proj/unit-test/cmake_install.cmake
new file mode 100644
index 0000000..e76260f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/cmake_install.cmake
@@ -0,0 +1,34 @@
+# Install script for directory: D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/unit-test
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/box2d")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+ if(BUILD_TYPE)
+ string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+ CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+ else()
+ set(CMAKE_INSTALL_CONFIG_NAME "Release")
+ endif()
+ message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+ if(COMPONENT)
+ message(STATUS "Install component: \"${COMPONENT}\"")
+ set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+ else()
+ set(CMAKE_INSTALL_COMPONENT)
+ endif()
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj b/Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj
new file mode 100644
index 0000000..38beb60
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj
@@ -0,0 +1,334 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="MinSizeRel|Win32">
+ <Configuration>MinSizeRel</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="RelWithDebInfo|Win32">
+ <Configuration>RelWithDebInfo</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{7ED467E4-0B19-329B-B677-9C4C01A3EC52}</ProjectGuid>
+ <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+ <Keyword>Win32Proj</Keyword>
+ <Platform>Win32</Platform>
+ <ProjectName>unit_test</ProjectName>
+ <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Debug\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">unit_test.dir\Debug\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">unit_test</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">unit_test.dir\Release\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">unit_test</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\MinSizeRel\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">unit_test.dir\MinSizeRel\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">unit_test</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">true</GenerateManifest>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\bin\RelWithDebInfo\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">unit_test.dir\RelWithDebInfo\</IntDir>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">unit_test</TargetName>
+ <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.exe</TargetExt>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">true</LinkIncremental>
+ <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">true</GenerateManifest>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
+ <Optimization>Disabled</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Link>
+ <AdditionalDependencies>..\bin\Debug\box2d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Debug/unit_test.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Debug/unit_test.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Link>
+ <AdditionalDependencies>..\bin\Release\box2d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Release/unit_test.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/Release/unit_test.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MinSpace</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="MinSizeRel"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <DebugInformationFormat>
+ </DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"MinSizeRel\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Link>
+ <AdditionalDependencies>..\bin\MinSizeRel\box2d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/MinSizeRel/unit_test.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/MinSizeRel/unit_test.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <Optimization>MaxSpeed</Optimization>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <UseFullPaths>false</UseFullPaths>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR="RelWithDebInfo"</PreprocessorDefinitions>
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;CMAKE_INTDIR=\"RelWithDebInfo\"</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Midl>
+ <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\src\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
+ <HeaderFileName>%(Filename).h</HeaderFileName>
+ <TypeLibraryName>%(Filename).tlb</TypeLibraryName>
+ <InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
+ <ProxyFileName>%(Filename)_p.c</ProxyFileName>
+ </Midl>
+ <Link>
+ <AdditionalDependencies>..\bin\RelWithDebInfo\box2d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
+ <ImportLibrary>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/RelWithDebInfo/unit_test.lib</ImportLibrary>
+ <ProgramDataBaseFile>D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/bin/RelWithDebInfo/unit_test.pdb</ProgramDataBaseFile>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ <ProjectReference>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\CMakeLists.txt">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
+ <Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Building Custom Rule D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
+"C:\Program Files\CMake\bin\cmake.exe" -SD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D -BD:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj --check-stamp-file D:/Documents/VisualStudio2017/Projects/Ragdolls/Client/ThirdParty/Box2D/proj/unit-test/CMakeFiles/generate.stamp
+if %errorlevel% neq 0 goto :cmEnd
+:cmEnd
+endlocal &amp; call :cmErrorLevel %errorlevel% &amp; goto :cmDone
+:cmErrorLevel
+exit /b %1
+:cmDone
+if %errorlevel% neq 0 goto :VCEnd</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\unit-test\CMakeFiles\generate.stamp</Outputs>
+ <LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\doctest.h" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\hello_world.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\collision_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\joint_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\math_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\world_test.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\ZERO_CHECK.vcxproj">
+ <Project>{BE3FCA9C-E0F7-3263-BFDC-D625CD827C80}</Project>
+ <Name>ZERO_CHECK</Name>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyToOutputDirectory>Never</CopyToOutputDirectory>
+ </ProjectReference>
+ <ProjectReference Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\proj\src\box2d.vcxproj">
+ <Project>{4C709A21-ABF6-3B27-8C03-FCEBEB527A6E}</Project>
+ <Name>box2d</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj.filters b/Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj.filters
new file mode 100644
index 0000000..993ecd0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/proj/unit-test/unit_test.vcxproj.filters
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\hello_world.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\collision_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\joint_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\math_test.cpp" />
+ <ClCompile Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\world_test.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\doctest.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="D:\Documents\VisualStudio2017\Projects\Ragdolls\Client\ThirdParty\Box2D\unit-test\CMakeLists.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ </ItemGroup>
+</Project>
diff --git a/Client/ThirdParty/Box2D/src/CMakeLists.txt b/Client/ThirdParty/Box2D/src/CMakeLists.txt
new file mode 100644
index 0000000..7b76c78
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/CMakeLists.txt
@@ -0,0 +1,163 @@
+set(BOX2D_SOURCE_FILES
+ collision/b2_broad_phase.cpp
+ collision/b2_chain_shape.cpp
+ collision/b2_circle_shape.cpp
+ collision/b2_collide_circle.cpp
+ collision/b2_collide_edge.cpp
+ collision/b2_collide_polygon.cpp
+ collision/b2_collision.cpp
+ collision/b2_distance.cpp
+ collision/b2_dynamic_tree.cpp
+ collision/b2_edge_shape.cpp
+ collision/b2_polygon_shape.cpp
+ collision/b2_time_of_impact.cpp
+ common/b2_block_allocator.cpp
+ common/b2_draw.cpp
+ common/b2_math.cpp
+ common/b2_settings.cpp
+ common/b2_stack_allocator.cpp
+ common/b2_timer.cpp
+ dynamics/b2_body.cpp
+ dynamics/b2_chain_circle_contact.cpp
+ dynamics/b2_chain_circle_contact.h
+ dynamics/b2_chain_polygon_contact.cpp
+ dynamics/b2_chain_polygon_contact.h
+ dynamics/b2_circle_contact.cpp
+ dynamics/b2_circle_contact.h
+ dynamics/b2_contact.cpp
+ dynamics/b2_contact_manager.cpp
+ dynamics/b2_contact_solver.cpp
+ dynamics/b2_contact_solver.h
+ dynamics/b2_distance_joint.cpp
+ dynamics/b2_edge_circle_contact.cpp
+ dynamics/b2_edge_circle_contact.h
+ dynamics/b2_edge_polygon_contact.cpp
+ dynamics/b2_edge_polygon_contact.h
+ dynamics/b2_fixture.cpp
+ dynamics/b2_friction_joint.cpp
+ dynamics/b2_gear_joint.cpp
+ dynamics/b2_island.cpp
+ dynamics/b2_island.h
+ dynamics/b2_joint.cpp
+ dynamics/b2_motor_joint.cpp
+ dynamics/b2_mouse_joint.cpp
+ dynamics/b2_polygon_circle_contact.cpp
+ dynamics/b2_polygon_circle_contact.h
+ dynamics/b2_polygon_contact.cpp
+ dynamics/b2_polygon_contact.h
+ dynamics/b2_prismatic_joint.cpp
+ dynamics/b2_pulley_joint.cpp
+ dynamics/b2_revolute_joint.cpp
+ dynamics/b2_weld_joint.cpp
+ dynamics/b2_wheel_joint.cpp
+ dynamics/b2_world.cpp
+ dynamics/b2_world_callbacks.cpp
+ rope/b2_rope.cpp)
+
+set(BOX2D_HEADER_FILES
+ ../include/box2d/b2_api.h
+ ../include/box2d/b2_block_allocator.h
+ ../include/box2d/b2_body.h
+ ../include/box2d/b2_broad_phase.h
+ ../include/box2d/b2_chain_shape.h
+ ../include/box2d/b2_circle_shape.h
+ ../include/box2d/b2_collision.h
+ ../include/box2d/b2_common.h
+ ../include/box2d/b2_contact.h
+ ../include/box2d/b2_contact_manager.h
+ ../include/box2d/b2_distance.h
+ ../include/box2d/b2_distance_joint.h
+ ../include/box2d/b2_draw.h
+ ../include/box2d/b2_dynamic_tree.h
+ ../include/box2d/b2_edge_shape.h
+ ../include/box2d/b2_fixture.h
+ ../include/box2d/b2_friction_joint.h
+ ../include/box2d/b2_gear_joint.h
+ ../include/box2d/b2_growable_stack.h
+ ../include/box2d/b2_joint.h
+ ../include/box2d/b2_math.h
+ ../include/box2d/b2_motor_joint.h
+ ../include/box2d/b2_mouse_joint.h
+ ../include/box2d/b2_polygon_shape.h
+ ../include/box2d/b2_prismatic_joint.h
+ ../include/box2d/b2_pulley_joint.h
+ ../include/box2d/b2_revolute_joint.h
+ ../include/box2d/b2_rope.h
+ ../include/box2d/b2_settings.h
+ ../include/box2d/b2_shape.h
+ ../include/box2d/b2_stack_allocator.h
+ ../include/box2d/b2_time_of_impact.h
+ ../include/box2d/b2_timer.h
+ ../include/box2d/b2_time_step.h
+ ../include/box2d/b2_types.h
+ ../include/box2d/b2_weld_joint.h
+ ../include/box2d/b2_wheel_joint.h
+ ../include/box2d/b2_world.h
+ ../include/box2d/b2_world_callbacks.h
+ ../include/box2d/box2d.h)
+
+add_library(box2d ${BOX2D_SOURCE_FILES} ${BOX2D_HEADER_FILES})
+target_include_directories(box2d
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+set_target_properties(box2d PROPERTIES
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED YES
+ CXX_EXTENSIONS NO
+ VERSION ${PROJECT_VERSION}
+ SOVERSION ${PROJECT_VERSION_MAJOR}
+)
+
+if(MSVC)
+ set_target_properties(box2d PROPERTIES
+ COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ COMPILE_PDB_NAME box2d
+ )
+
+ install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/box2d.pdb"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ OPTIONAL
+ )
+endif()
+
+if (BUILD_SHARED_LIBS)
+ target_compile_definitions(box2d
+ PUBLIC
+ B2_SHARED
+ )
+endif()
+
+source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX "src" FILES ${BOX2D_SOURCE_FILES})
+source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include" PREFIX "include" FILES ${BOX2D_HEADER_FILES})
+
+install(
+ TARGETS box2d
+ EXPORT box2dConfig
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
+
+install(
+ EXPORT box2dConfig
+ NAMESPACE box2d::
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/box2d"
+)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/box2dConfigVersion.cmake"
+ COMPATIBILITY SameMajorVersion
+)
+
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/box2dConfigVersion.cmake"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/box2d"
+)
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_broad_phase.cpp b/Client/ThirdParty/Box2D/src/collision/b2_broad_phase.cpp
new file mode 100644
index 0000000..d063a3a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_broad_phase.cpp
@@ -0,0 +1,131 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_broad_phase.h"
+#include <string.h>
+
+b2BroadPhase::b2BroadPhase()
+{
+ m_proxyCount = 0;
+
+ m_pairCapacity = 16;
+ m_pairCount = 0;
+ m_pairBuffer = (b2Pair*)b2Alloc(m_pairCapacity * sizeof(b2Pair));
+
+ m_moveCapacity = 16;
+ m_moveCount = 0;
+ m_moveBuffer = (int32*)b2Alloc(m_moveCapacity * sizeof(int32));
+}
+
+b2BroadPhase::~b2BroadPhase()
+{
+ b2Free(m_moveBuffer);
+ b2Free(m_pairBuffer);
+}
+
+int32 b2BroadPhase::CreateProxy(const b2AABB& aabb, void* userData)
+{
+ int32 proxyId = m_tree.CreateProxy(aabb, userData);
+ ++m_proxyCount;
+ BufferMove(proxyId);
+ return proxyId;
+}
+
+void b2BroadPhase::DestroyProxy(int32 proxyId)
+{
+ UnBufferMove(proxyId);
+ --m_proxyCount;
+ m_tree.DestroyProxy(proxyId);
+}
+
+void b2BroadPhase::MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement)
+{
+ bool buffer = m_tree.MoveProxy(proxyId, aabb, displacement);
+ if (buffer)
+ {
+ BufferMove(proxyId);
+ }
+}
+
+void b2BroadPhase::TouchProxy(int32 proxyId)
+{
+ BufferMove(proxyId);
+}
+
+void b2BroadPhase::BufferMove(int32 proxyId)
+{
+ if (m_moveCount == m_moveCapacity)
+ {
+ int32* oldBuffer = m_moveBuffer;
+ m_moveCapacity *= 2;
+ m_moveBuffer = (int32*)b2Alloc(m_moveCapacity * sizeof(int32));
+ memcpy(m_moveBuffer, oldBuffer, m_moveCount * sizeof(int32));
+ b2Free(oldBuffer);
+ }
+
+ m_moveBuffer[m_moveCount] = proxyId;
+ ++m_moveCount;
+}
+
+void b2BroadPhase::UnBufferMove(int32 proxyId)
+{
+ for (int32 i = 0; i < m_moveCount; ++i)
+ {
+ if (m_moveBuffer[i] == proxyId)
+ {
+ m_moveBuffer[i] = e_nullProxy;
+ }
+ }
+}
+
+// This is called from b2DynamicTree::Query when we are gathering pairs.
+bool b2BroadPhase::QueryCallback(int32 proxyId)
+{
+ // A proxy cannot form a pair with itself.
+ if (proxyId == m_queryProxyId)
+ {
+ return true;
+ }
+
+ const bool moved = m_tree.WasMoved(proxyId);
+ if (moved && proxyId > m_queryProxyId)
+ {
+ // Both proxies are moving. Avoid duplicate pairs.
+ return true;
+ }
+
+ // Grow the pair buffer as needed.
+ if (m_pairCount == m_pairCapacity)
+ {
+ b2Pair* oldBuffer = m_pairBuffer;
+ m_pairCapacity = m_pairCapacity + (m_pairCapacity >> 1);
+ m_pairBuffer = (b2Pair*)b2Alloc(m_pairCapacity * sizeof(b2Pair));
+ memcpy(m_pairBuffer, oldBuffer, m_pairCount * sizeof(b2Pair));
+ b2Free(oldBuffer);
+ }
+
+ m_pairBuffer[m_pairCount].proxyIdA = b2Min(proxyId, m_queryProxyId);
+ m_pairBuffer[m_pairCount].proxyIdB = b2Max(proxyId, m_queryProxyId);
+ ++m_pairCount;
+
+ return true;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_chain_shape.cpp b/Client/ThirdParty/Box2D/src/collision/b2_chain_shape.cpp
new file mode 100644
index 0000000..b964a43
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_chain_shape.cpp
@@ -0,0 +1,185 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_chain_shape.h"
+#include "box2d/b2_edge_shape.h"
+
+#include "box2d/b2_block_allocator.h"
+
+#include <new>
+#include <string.h>
+
+b2ChainShape::~b2ChainShape()
+{
+ Clear();
+}
+
+void b2ChainShape::Clear()
+{
+ b2Free(m_vertices);
+ m_vertices = nullptr;
+ m_count = 0;
+}
+
+void b2ChainShape::CreateLoop(const b2Vec2* vertices, int32 count)
+{
+ b2Assert(m_vertices == nullptr && m_count == 0);
+ b2Assert(count >= 3);
+ if (count < 3)
+ {
+ return;
+ }
+
+ for (int32 i = 1; i < count; ++i)
+ {
+ b2Vec2 v1 = vertices[i-1];
+ b2Vec2 v2 = vertices[i];
+ // If the code crashes here, it means your vertices are too close together.
+ b2Assert(b2DistanceSquared(v1, v2) > b2_linearSlop * b2_linearSlop);
+ }
+
+ m_count = count + 1;
+ m_vertices = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2));
+ memcpy(m_vertices, vertices, count * sizeof(b2Vec2));
+ m_vertices[count] = m_vertices[0];
+ m_prevVertex = m_vertices[m_count - 2];
+ m_nextVertex = m_vertices[1];
+}
+
+void b2ChainShape::CreateChain(const b2Vec2* vertices, int32 count, const b2Vec2& prevVertex, const b2Vec2& nextVertex)
+{
+ b2Assert(m_vertices == nullptr && m_count == 0);
+ b2Assert(count >= 2);
+ for (int32 i = 1; i < count; ++i)
+ {
+ // If the code crashes here, it means your vertices are too close together.
+ b2Assert(b2DistanceSquared(vertices[i-1], vertices[i]) > b2_linearSlop * b2_linearSlop);
+ }
+
+ m_count = count;
+ m_vertices = (b2Vec2*)b2Alloc(count * sizeof(b2Vec2));
+ memcpy(m_vertices, vertices, m_count * sizeof(b2Vec2));
+
+ m_prevVertex = prevVertex;
+ m_nextVertex = nextVertex;
+}
+
+b2Shape* b2ChainShape::Clone(b2BlockAllocator* allocator) const
+{
+ void* mem = allocator->Allocate(sizeof(b2ChainShape));
+ b2ChainShape* clone = new (mem) b2ChainShape;
+ clone->CreateChain(m_vertices, m_count, m_prevVertex, m_nextVertex);
+ return clone;
+}
+
+int32 b2ChainShape::GetChildCount() const
+{
+ // edge count = vertex count - 1
+ return m_count - 1;
+}
+
+void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
+{
+ b2Assert(0 <= index && index < m_count - 1);
+ edge->m_type = b2Shape::e_edge;
+ edge->m_radius = m_radius;
+
+ edge->m_vertex1 = m_vertices[index + 0];
+ edge->m_vertex2 = m_vertices[index + 1];
+ edge->m_oneSided = true;
+
+ if (index > 0)
+ {
+ edge->m_vertex0 = m_vertices[index - 1];
+ }
+ else
+ {
+ edge->m_vertex0 = m_prevVertex;
+ }
+
+ if (index < m_count - 2)
+ {
+ edge->m_vertex3 = m_vertices[index + 2];
+ }
+ else
+ {
+ edge->m_vertex3 = m_nextVertex;
+ }
+}
+
+bool b2ChainShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
+{
+ B2_NOT_USED(xf);
+ B2_NOT_USED(p);
+ return false;
+}
+
+bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& xf, int32 childIndex) const
+{
+ b2Assert(childIndex < m_count);
+
+ b2EdgeShape edgeShape;
+
+ int32 i1 = childIndex;
+ int32 i2 = childIndex + 1;
+ if (i2 == m_count)
+ {
+ i2 = 0;
+ }
+
+ edgeShape.m_vertex1 = m_vertices[i1];
+ edgeShape.m_vertex2 = m_vertices[i2];
+
+ return edgeShape.RayCast(output, input, xf, 0);
+}
+
+void b2ChainShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
+{
+ b2Assert(childIndex < m_count);
+
+ int32 i1 = childIndex;
+ int32 i2 = childIndex + 1;
+ if (i2 == m_count)
+ {
+ i2 = 0;
+ }
+
+ b2Vec2 v1 = b2Mul(xf, m_vertices[i1]);
+ b2Vec2 v2 = b2Mul(xf, m_vertices[i2]);
+
+ b2Vec2 lower = b2Min(v1, v2);
+ b2Vec2 upper = b2Max(v1, v2);
+
+ b2Vec2 r(m_radius, m_radius);
+ aabb->lowerBound = lower - r;
+ aabb->upperBound = upper + r;
+}
+
+void b2ChainShape::ComputeMass(b2MassData* massData, float density) const
+{
+ B2_NOT_USED(density);
+
+ massData->mass = 0.0f;
+ massData->center.SetZero();
+ massData->I = 0.0f;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_circle_shape.cpp b/Client/ThirdParty/Box2D/src/collision/b2_circle_shape.cpp
new file mode 100644
index 0000000..ecc6929
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_circle_shape.cpp
@@ -0,0 +1,105 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_block_allocator.h"
+
+#include <new>
+
+b2Shape* b2CircleShape::Clone(b2BlockAllocator* allocator) const
+{
+ void* mem = allocator->Allocate(sizeof(b2CircleShape));
+ b2CircleShape* clone = new (mem) b2CircleShape;
+ *clone = *this;
+ return clone;
+}
+
+int32 b2CircleShape::GetChildCount() const
+{
+ return 1;
+}
+
+bool b2CircleShape::TestPoint(const b2Transform& transform, const b2Vec2& p) const
+{
+ b2Vec2 center = transform.p + b2Mul(transform.q, m_p);
+ b2Vec2 d = p - center;
+ return b2Dot(d, d) <= m_radius * m_radius;
+}
+
+// Collision Detection in Interactive 3D Environments by Gino van den Bergen
+// From Section 3.1.2
+// x = s + a * r
+// norm(x) = radius
+bool b2CircleShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& transform, int32 childIndex) const
+{
+ B2_NOT_USED(childIndex);
+
+ b2Vec2 position = transform.p + b2Mul(transform.q, m_p);
+ b2Vec2 s = input.p1 - position;
+ float b = b2Dot(s, s) - m_radius * m_radius;
+
+ // Solve quadratic equation.
+ b2Vec2 r = input.p2 - input.p1;
+ float c = b2Dot(s, r);
+ float rr = b2Dot(r, r);
+ float sigma = c * c - rr * b;
+
+ // Check for negative discriminant and short segment.
+ if (sigma < 0.0f || rr < b2_epsilon)
+ {
+ return false;
+ }
+
+ // Find the point of intersection of the line with the circle.
+ float a = -(c + b2Sqrt(sigma));
+
+ // Is the intersection point on the segment?
+ if (0.0f <= a && a <= input.maxFraction * rr)
+ {
+ a /= rr;
+ output->fraction = a;
+ output->normal = s + a * r;
+ output->normal.Normalize();
+ return true;
+ }
+
+ return false;
+}
+
+void b2CircleShape::ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const
+{
+ B2_NOT_USED(childIndex);
+
+ b2Vec2 p = transform.p + b2Mul(transform.q, m_p);
+ aabb->lowerBound.Set(p.x - m_radius, p.y - m_radius);
+ aabb->upperBound.Set(p.x + m_radius, p.y + m_radius);
+}
+
+void b2CircleShape::ComputeMass(b2MassData* massData, float density) const
+{
+ massData->mass = density * b2_pi * m_radius * m_radius;
+ massData->center = m_p;
+
+ // inertia about the local origin
+ massData->I = massData->mass * (0.5f * m_radius * m_radius + b2Dot(m_p, m_p));
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_collide_circle.cpp b/Client/ThirdParty/Box2D/src/collision/b2_collide_circle.cpp
new file mode 100644
index 0000000..469da55
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_collide_circle.cpp
@@ -0,0 +1,158 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_collision.h"
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_polygon_shape.h"
+
+void b2CollideCircles(
+ b2Manifold* manifold,
+ const b2CircleShape* circleA, const b2Transform& xfA,
+ const b2CircleShape* circleB, const b2Transform& xfB)
+{
+ manifold->pointCount = 0;
+
+ b2Vec2 pA = b2Mul(xfA, circleA->m_p);
+ b2Vec2 pB = b2Mul(xfB, circleB->m_p);
+
+ b2Vec2 d = pB - pA;
+ float distSqr = b2Dot(d, d);
+ float rA = circleA->m_radius, rB = circleB->m_radius;
+ float radius = rA + rB;
+ if (distSqr > radius * radius)
+ {
+ return;
+ }
+
+ manifold->type = b2Manifold::e_circles;
+ manifold->localPoint = circleA->m_p;
+ manifold->localNormal.SetZero();
+ manifold->pointCount = 1;
+
+ manifold->points[0].localPoint = circleB->m_p;
+ manifold->points[0].id.key = 0;
+}
+
+void b2CollidePolygonAndCircle(
+ b2Manifold* manifold,
+ const b2PolygonShape* polygonA, const b2Transform& xfA,
+ const b2CircleShape* circleB, const b2Transform& xfB)
+{
+ manifold->pointCount = 0;
+
+ // Compute circle position in the frame of the polygon.
+ b2Vec2 c = b2Mul(xfB, circleB->m_p);
+ b2Vec2 cLocal = b2MulT(xfA, c);
+
+ // Find the min separating edge.
+ int32 normalIndex = 0;
+ float separation = -b2_maxFloat;
+ float radius = polygonA->m_radius + circleB->m_radius;
+ int32 vertexCount = polygonA->m_count;
+ const b2Vec2* vertices = polygonA->m_vertices;
+ const b2Vec2* normals = polygonA->m_normals;
+
+ for (int32 i = 0; i < vertexCount; ++i)
+ {
+ float s = b2Dot(normals[i], cLocal - vertices[i]);
+
+ if (s > radius)
+ {
+ // Early out.
+ return;
+ }
+
+ if (s > separation)
+ {
+ separation = s;
+ normalIndex = i;
+ }
+ }
+
+ // Vertices that subtend the incident face.
+ int32 vertIndex1 = normalIndex;
+ int32 vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;
+ b2Vec2 v1 = vertices[vertIndex1];
+ b2Vec2 v2 = vertices[vertIndex2];
+
+ // If the center is inside the polygon ...
+ if (separation < b2_epsilon)
+ {
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_faceA;
+ manifold->localNormal = normals[normalIndex];
+ manifold->localPoint = 0.5f * (v1 + v2);
+ manifold->points[0].localPoint = circleB->m_p;
+ manifold->points[0].id.key = 0;
+ return;
+ }
+
+ // Compute barycentric coordinates
+ float u1 = b2Dot(cLocal - v1, v2 - v1);
+ float u2 = b2Dot(cLocal - v2, v1 - v2);
+ if (u1 <= 0.0f)
+ {
+ if (b2DistanceSquared(cLocal, v1) > radius * radius)
+ {
+ return;
+ }
+
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_faceA;
+ manifold->localNormal = cLocal - v1;
+ manifold->localNormal.Normalize();
+ manifold->localPoint = v1;
+ manifold->points[0].localPoint = circleB->m_p;
+ manifold->points[0].id.key = 0;
+ }
+ else if (u2 <= 0.0f)
+ {
+ if (b2DistanceSquared(cLocal, v2) > radius * radius)
+ {
+ return;
+ }
+
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_faceA;
+ manifold->localNormal = cLocal - v2;
+ manifold->localNormal.Normalize();
+ manifold->localPoint = v2;
+ manifold->points[0].localPoint = circleB->m_p;
+ manifold->points[0].id.key = 0;
+ }
+ else
+ {
+ b2Vec2 faceCenter = 0.5f * (v1 + v2);
+ float s = b2Dot(cLocal - faceCenter, normals[vertIndex1]);
+ if (s > radius)
+ {
+ return;
+ }
+
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_faceA;
+ manifold->localNormal = normals[vertIndex1];
+ manifold->localPoint = faceCenter;
+ manifold->points[0].localPoint = circleB->m_p;
+ manifold->points[0].id.key = 0;
+ }
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_collide_edge.cpp b/Client/ThirdParty/Box2D/src/collision/b2_collide_edge.cpp
new file mode 100644
index 0000000..e06b900
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_collide_edge.cpp
@@ -0,0 +1,524 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_collision.h"
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_edge_shape.h"
+#include "box2d/b2_polygon_shape.h"
+
+
+// Compute contact points for edge versus circle.
+// This accounts for edge connectivity.
+void b2CollideEdgeAndCircle(b2Manifold* manifold,
+ const b2EdgeShape* edgeA, const b2Transform& xfA,
+ const b2CircleShape* circleB, const b2Transform& xfB)
+{
+ manifold->pointCount = 0;
+
+ // Compute circle in frame of edge
+ b2Vec2 Q = b2MulT(xfA, b2Mul(xfB, circleB->m_p));
+
+ b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_vertex2;
+ b2Vec2 e = B - A;
+
+ // Normal points to the right for a CCW winding
+ b2Vec2 n(e.y, -e.x);
+ float offset = b2Dot(n, Q - A);
+
+ bool oneSided = edgeA->m_oneSided;
+ if (oneSided && offset < 0.0f)
+ {
+ return;
+ }
+
+ // Barycentric coordinates
+ float u = b2Dot(e, B - Q);
+ float v = b2Dot(e, Q - A);
+
+ float radius = edgeA->m_radius + circleB->m_radius;
+
+ b2ContactFeature cf;
+ cf.indexB = 0;
+ cf.typeB = b2ContactFeature::e_vertex;
+
+ // Region A
+ if (v <= 0.0f)
+ {
+ b2Vec2 P = A;
+ b2Vec2 d = Q - P;
+ float dd = b2Dot(d, d);
+ if (dd > radius * radius)
+ {
+ return;
+ }
+
+ // Is there an edge connected to A?
+ if (edgeA->m_oneSided)
+ {
+ b2Vec2 A1 = edgeA->m_vertex0;
+ b2Vec2 B1 = A;
+ b2Vec2 e1 = B1 - A1;
+ float u1 = b2Dot(e1, B1 - Q);
+
+ // Is the circle in Region AB of the previous edge?
+ if (u1 > 0.0f)
+ {
+ return;
+ }
+ }
+
+ cf.indexA = 0;
+ cf.typeA = b2ContactFeature::e_vertex;
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_circles;
+ manifold->localNormal.SetZero();
+ manifold->localPoint = P;
+ manifold->points[0].id.key = 0;
+ manifold->points[0].id.cf = cf;
+ manifold->points[0].localPoint = circleB->m_p;
+ return;
+ }
+
+ // Region B
+ if (u <= 0.0f)
+ {
+ b2Vec2 P = B;
+ b2Vec2 d = Q - P;
+ float dd = b2Dot(d, d);
+ if (dd > radius * radius)
+ {
+ return;
+ }
+
+ // Is there an edge connected to B?
+ if (edgeA->m_oneSided)
+ {
+ b2Vec2 B2 = edgeA->m_vertex3;
+ b2Vec2 A2 = B;
+ b2Vec2 e2 = B2 - A2;
+ float v2 = b2Dot(e2, Q - A2);
+
+ // Is the circle in Region AB of the next edge?
+ if (v2 > 0.0f)
+ {
+ return;
+ }
+ }
+
+ cf.indexA = 1;
+ cf.typeA = b2ContactFeature::e_vertex;
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_circles;
+ manifold->localNormal.SetZero();
+ manifold->localPoint = P;
+ manifold->points[0].id.key = 0;
+ manifold->points[0].id.cf = cf;
+ manifold->points[0].localPoint = circleB->m_p;
+ return;
+ }
+
+ // Region AB
+ float den = b2Dot(e, e);
+ b2Assert(den > 0.0f);
+ b2Vec2 P = (1.0f / den) * (u * A + v * B);
+ b2Vec2 d = Q - P;
+ float dd = b2Dot(d, d);
+ if (dd > radius * radius)
+ {
+ return;
+ }
+
+ if (offset < 0.0f)
+ {
+ n.Set(-n.x, -n.y);
+ }
+ n.Normalize();
+
+ cf.indexA = 0;
+ cf.typeA = b2ContactFeature::e_face;
+ manifold->pointCount = 1;
+ manifold->type = b2Manifold::e_faceA;
+ manifold->localNormal = n;
+ manifold->localPoint = A;
+ manifold->points[0].id.key = 0;
+ manifold->points[0].id.cf = cf;
+ manifold->points[0].localPoint = circleB->m_p;
+}
+
+// This structure is used to keep track of the best separating axis.
+struct b2EPAxis
+{
+ enum Type
+ {
+ e_unknown,
+ e_edgeA,
+ e_edgeB
+ };
+
+ b2Vec2 normal;
+ Type type;
+ int32 index;
+ float separation;
+};
+
+// This holds polygon B expressed in frame A.
+struct b2TempPolygon
+{
+ b2Vec2 vertices[b2_maxPolygonVertices];
+ b2Vec2 normals[b2_maxPolygonVertices];
+ int32 count;
+};
+
+// Reference face used for clipping
+struct b2ReferenceFace
+{
+ int32 i1, i2;
+ b2Vec2 v1, v2;
+ b2Vec2 normal;
+
+ b2Vec2 sideNormal1;
+ float sideOffset1;
+
+ b2Vec2 sideNormal2;
+ float sideOffset2;
+};
+
+static b2EPAxis b2ComputeEdgeSeparation(const b2TempPolygon& polygonB, const b2Vec2& v1, const b2Vec2& normal1)
+{
+ b2EPAxis axis;
+ axis.type = b2EPAxis::e_edgeA;
+ axis.index = -1;
+ axis.separation = -FLT_MAX;
+ axis.normal.SetZero();
+
+ b2Vec2 axes[2] = { normal1, -normal1 };
+
+ // Find axis with least overlap (min-max problem)
+ for (int32 j = 0; j < 2; ++j)
+ {
+ float sj = FLT_MAX;
+
+ // Find deepest polygon vertex along axis j
+ for (int32 i = 0; i < polygonB.count; ++i)
+ {
+ float si = b2Dot(axes[j], polygonB.vertices[i] - v1);
+ if (si < sj)
+ {
+ sj = si;
+ }
+ }
+
+ if (sj > axis.separation)
+ {
+ axis.index = j;
+ axis.separation = sj;
+ axis.normal = axes[j];
+ }
+ }
+
+ return axis;
+}
+
+static b2EPAxis b2ComputePolygonSeparation(const b2TempPolygon& polygonB, const b2Vec2& v1, const b2Vec2& v2)
+{
+ b2EPAxis axis;
+ axis.type = b2EPAxis::e_unknown;
+ axis.index = -1;
+ axis.separation = -FLT_MAX;
+ axis.normal.SetZero();
+
+ for (int32 i = 0; i < polygonB.count; ++i)
+ {
+ b2Vec2 n = -polygonB.normals[i];
+
+ float s1 = b2Dot(n, polygonB.vertices[i] - v1);
+ float s2 = b2Dot(n, polygonB.vertices[i] - v2);
+ float s = b2Min(s1, s2);
+
+ if (s > axis.separation)
+ {
+ axis.type = b2EPAxis::e_edgeB;
+ axis.index = i;
+ axis.separation = s;
+ axis.normal = n;
+ }
+ }
+
+ return axis;
+}
+
+void b2CollideEdgeAndPolygon(b2Manifold* manifold,
+ const b2EdgeShape* edgeA, const b2Transform& xfA,
+ const b2PolygonShape* polygonB, const b2Transform& xfB)
+{
+ manifold->pointCount = 0;
+
+ b2Transform xf = b2MulT(xfA, xfB);
+
+ b2Vec2 centroidB = b2Mul(xf, polygonB->m_centroid);
+
+ b2Vec2 v1 = edgeA->m_vertex1;
+ b2Vec2 v2 = edgeA->m_vertex2;
+
+ b2Vec2 edge1 = v2 - v1;
+ edge1.Normalize();
+
+ // Normal points to the right for a CCW winding
+ b2Vec2 normal1(edge1.y, -edge1.x);
+ float offset1 = b2Dot(normal1, centroidB - v1);
+
+ bool oneSided = edgeA->m_oneSided;
+ if (oneSided && offset1 < 0.0f)
+ {
+ return;
+ }
+
+ // Get polygonB in frameA
+ b2TempPolygon tempPolygonB;
+ tempPolygonB.count = polygonB->m_count;
+ for (int32 i = 0; i < polygonB->m_count; ++i)
+ {
+ tempPolygonB.vertices[i] = b2Mul(xf, polygonB->m_vertices[i]);
+ tempPolygonB.normals[i] = b2Mul(xf.q, polygonB->m_normals[i]);
+ }
+
+ float radius = polygonB->m_radius + edgeA->m_radius;
+
+ b2EPAxis edgeAxis = b2ComputeEdgeSeparation(tempPolygonB, v1, normal1);
+ if (edgeAxis.separation > radius)
+ {
+ return;
+ }
+
+ b2EPAxis polygonAxis = b2ComputePolygonSeparation(tempPolygonB, v1, v2);
+ if (polygonAxis.separation > radius)
+ {
+ return;
+ }
+
+ // Use hysteresis for jitter reduction.
+ const float k_relativeTol = 0.98f;
+ const float k_absoluteTol = 0.001f;
+
+ b2EPAxis primaryAxis;
+ if (polygonAxis.separation - radius > k_relativeTol * (edgeAxis.separation - radius) + k_absoluteTol)
+ {
+ primaryAxis = polygonAxis;
+ }
+ else
+ {
+ primaryAxis = edgeAxis;
+ }
+
+ if (oneSided)
+ {
+ // Smooth collision
+ // See https://box2d.org/posts/2020/06/ghost-collisions/
+
+ b2Vec2 edge0 = v1 - edgeA->m_vertex0;
+ edge0.Normalize();
+ b2Vec2 normal0(edge0.y, -edge0.x);
+ bool convex1 = b2Cross(edge0, edge1) >= 0.0f;
+
+ b2Vec2 edge2 = edgeA->m_vertex3 - v2;
+ edge2.Normalize();
+ b2Vec2 normal2(edge2.y, -edge2.x);
+ bool convex2 = b2Cross(edge1, edge2) >= 0.0f;
+
+ const float sinTol = 0.1f;
+ bool side1 = b2Dot(primaryAxis.normal, edge1) <= 0.0f;
+
+ // Check Gauss Map
+ if (side1)
+ {
+ if (convex1)
+ {
+ if (b2Cross(primaryAxis.normal, normal0) > sinTol)
+ {
+ // Skip region
+ return;
+ }
+
+ // Admit region
+ }
+ else
+ {
+ // Snap region
+ primaryAxis = edgeAxis;
+ }
+ }
+ else
+ {
+ if (convex2)
+ {
+ if (b2Cross(normal2, primaryAxis.normal) > sinTol)
+ {
+ // Skip region
+ return;
+ }
+
+ // Admit region
+ }
+ else
+ {
+ // Snap region
+ primaryAxis = edgeAxis;
+ }
+ }
+ }
+
+ b2ClipVertex clipPoints[2];
+ b2ReferenceFace ref;
+ if (primaryAxis.type == b2EPAxis::e_edgeA)
+ {
+ manifold->type = b2Manifold::e_faceA;
+
+ // Search for the polygon normal that is most anti-parallel to the edge normal.
+ int32 bestIndex = 0;
+ float bestValue = b2Dot(primaryAxis.normal, tempPolygonB.normals[0]);
+ for (int32 i = 1; i < tempPolygonB.count; ++i)
+ {
+ float value = b2Dot(primaryAxis.normal, tempPolygonB.normals[i]);
+ if (value < bestValue)
+ {
+ bestValue = value;
+ bestIndex = i;
+ }
+ }
+
+ int32 i1 = bestIndex;
+ int32 i2 = i1 + 1 < tempPolygonB.count ? i1 + 1 : 0;
+
+ clipPoints[0].v = tempPolygonB.vertices[i1];
+ clipPoints[0].id.cf.indexA = 0;
+ clipPoints[0].id.cf.indexB = static_cast<uint8>(i1);
+ clipPoints[0].id.cf.typeA = b2ContactFeature::e_face;
+ clipPoints[0].id.cf.typeB = b2ContactFeature::e_vertex;
+
+ clipPoints[1].v = tempPolygonB.vertices[i2];
+ clipPoints[1].id.cf.indexA = 0;
+ clipPoints[1].id.cf.indexB = static_cast<uint8>(i2);
+ clipPoints[1].id.cf.typeA = b2ContactFeature::e_face;
+ clipPoints[1].id.cf.typeB = b2ContactFeature::e_vertex;
+
+ ref.i1 = 0;
+ ref.i2 = 1;
+ ref.v1 = v1;
+ ref.v2 = v2;
+ ref.normal = primaryAxis.normal;
+ ref.sideNormal1 = -edge1;
+ ref.sideNormal2 = edge1;
+ }
+ else
+ {
+ manifold->type = b2Manifold::e_faceB;
+
+ clipPoints[0].v = v2;
+ clipPoints[0].id.cf.indexA = 1;
+ clipPoints[0].id.cf.indexB = static_cast<uint8>(primaryAxis.index);
+ clipPoints[0].id.cf.typeA = b2ContactFeature::e_vertex;
+ clipPoints[0].id.cf.typeB = b2ContactFeature::e_face;
+
+ clipPoints[1].v = v1;
+ clipPoints[1].id.cf.indexA = 0;
+ clipPoints[1].id.cf.indexB = static_cast<uint8>(primaryAxis.index);
+ clipPoints[1].id.cf.typeA = b2ContactFeature::e_vertex;
+ clipPoints[1].id.cf.typeB = b2ContactFeature::e_face;
+
+ ref.i1 = primaryAxis.index;
+ ref.i2 = ref.i1 + 1 < tempPolygonB.count ? ref.i1 + 1 : 0;
+ ref.v1 = tempPolygonB.vertices[ref.i1];
+ ref.v2 = tempPolygonB.vertices[ref.i2];
+ ref.normal = tempPolygonB.normals[ref.i1];
+
+ // CCW winding
+ ref.sideNormal1.Set(ref.normal.y, -ref.normal.x);
+ ref.sideNormal2 = -ref.sideNormal1;
+ }
+
+ ref.sideOffset1 = b2Dot(ref.sideNormal1, ref.v1);
+ ref.sideOffset2 = b2Dot(ref.sideNormal2, ref.v2);
+
+ // Clip incident edge against reference face side planes
+ b2ClipVertex clipPoints1[2];
+ b2ClipVertex clipPoints2[2];
+ int32 np;
+
+ // Clip to side 1
+ np = b2ClipSegmentToLine(clipPoints1, clipPoints, ref.sideNormal1, ref.sideOffset1, ref.i1);
+
+ if (np < b2_maxManifoldPoints)
+ {
+ return;
+ }
+
+ // Clip to side 2
+ np = b2ClipSegmentToLine(clipPoints2, clipPoints1, ref.sideNormal2, ref.sideOffset2, ref.i2);
+
+ if (np < b2_maxManifoldPoints)
+ {
+ return;
+ }
+
+ // Now clipPoints2 contains the clipped points.
+ if (primaryAxis.type == b2EPAxis::e_edgeA)
+ {
+ manifold->localNormal = ref.normal;
+ manifold->localPoint = ref.v1;
+ }
+ else
+ {
+ manifold->localNormal = polygonB->m_normals[ref.i1];
+ manifold->localPoint = polygonB->m_vertices[ref.i1];
+ }
+
+ int32 pointCount = 0;
+ for (int32 i = 0; i < b2_maxManifoldPoints; ++i)
+ {
+ float separation;
+
+ separation = b2Dot(ref.normal, clipPoints2[i].v - ref.v1);
+
+ if (separation <= radius)
+ {
+ b2ManifoldPoint* cp = manifold->points + pointCount;
+
+ if (primaryAxis.type == b2EPAxis::e_edgeA)
+ {
+ cp->localPoint = b2MulT(xf, clipPoints2[i].v);
+ cp->id = clipPoints2[i].id;
+ }
+ else
+ {
+ cp->localPoint = clipPoints2[i].v;
+ cp->id.cf.typeA = clipPoints2[i].id.cf.typeB;
+ cp->id.cf.typeB = clipPoints2[i].id.cf.typeA;
+ cp->id.cf.indexA = clipPoints2[i].id.cf.indexB;
+ cp->id.cf.indexB = clipPoints2[i].id.cf.indexA;
+ }
+
+ ++pointCount;
+ }
+ }
+
+ manifold->pointCount = pointCount;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_collide_polygon.cpp b/Client/ThirdParty/Box2D/src/collision/b2_collide_polygon.cpp
new file mode 100644
index 0000000..f3fa850
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_collide_polygon.cpp
@@ -0,0 +1,243 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_collision.h"
+#include "box2d/b2_polygon_shape.h"
+
+// Find the max separation between poly1 and poly2 using edge normals from poly1.
+static float b2FindMaxSeparation(int32* edgeIndex,
+ const b2PolygonShape* poly1, const b2Transform& xf1,
+ const b2PolygonShape* poly2, const b2Transform& xf2)
+{
+ int32 count1 = poly1->m_count;
+ int32 count2 = poly2->m_count;
+ const b2Vec2* n1s = poly1->m_normals;
+ const b2Vec2* v1s = poly1->m_vertices;
+ const b2Vec2* v2s = poly2->m_vertices;
+ b2Transform xf = b2MulT(xf2, xf1);
+
+ int32 bestIndex = 0;
+ float maxSeparation = -b2_maxFloat;
+ for (int32 i = 0; i < count1; ++i)
+ {
+ // Get poly1 normal in frame2.
+ b2Vec2 n = b2Mul(xf.q, n1s[i]);
+ b2Vec2 v1 = b2Mul(xf, v1s[i]);
+
+ // Find deepest point for normal i.
+ float si = b2_maxFloat;
+ for (int32 j = 0; j < count2; ++j)
+ {
+ float sij = b2Dot(n, v2s[j] - v1);
+ if (sij < si)
+ {
+ si = sij;
+ }
+ }
+
+ if (si > maxSeparation)
+ {
+ maxSeparation = si;
+ bestIndex = i;
+ }
+ }
+
+ *edgeIndex = bestIndex;
+ return maxSeparation;
+}
+
+static void b2FindIncidentEdge(b2ClipVertex c[2],
+ const b2PolygonShape* poly1, const b2Transform& xf1, int32 edge1,
+ const b2PolygonShape* poly2, const b2Transform& xf2)
+{
+ const b2Vec2* normals1 = poly1->m_normals;
+
+ int32 count2 = poly2->m_count;
+ const b2Vec2* vertices2 = poly2->m_vertices;
+ const b2Vec2* normals2 = poly2->m_normals;
+
+ b2Assert(0 <= edge1 && edge1 < poly1->m_count);
+
+ // Get the normal of the reference edge in poly2's frame.
+ b2Vec2 normal1 = b2MulT(xf2.q, b2Mul(xf1.q, normals1[edge1]));
+
+ // Find the incident edge on poly2.
+ int32 index = 0;
+ float minDot = b2_maxFloat;
+ for (int32 i = 0; i < count2; ++i)
+ {
+ float dot = b2Dot(normal1, normals2[i]);
+ if (dot < minDot)
+ {
+ minDot = dot;
+ index = i;
+ }
+ }
+
+ // Build the clip vertices for the incident edge.
+ int32 i1 = index;
+ int32 i2 = i1 + 1 < count2 ? i1 + 1 : 0;
+
+ c[0].v = b2Mul(xf2, vertices2[i1]);
+ c[0].id.cf.indexA = (uint8)edge1;
+ c[0].id.cf.indexB = (uint8)i1;
+ c[0].id.cf.typeA = b2ContactFeature::e_face;
+ c[0].id.cf.typeB = b2ContactFeature::e_vertex;
+
+ c[1].v = b2Mul(xf2, vertices2[i2]);
+ c[1].id.cf.indexA = (uint8)edge1;
+ c[1].id.cf.indexB = (uint8)i2;
+ c[1].id.cf.typeA = b2ContactFeature::e_face;
+ c[1].id.cf.typeB = b2ContactFeature::e_vertex;
+}
+
+// Find edge normal of max separation on A - return if separating axis is found
+// Find edge normal of max separation on B - return if separation axis is found
+// Choose reference edge as min(minA, minB)
+// Find incident edge
+// Clip
+
+// The normal points from 1 to 2
+void b2CollidePolygons(b2Manifold* manifold,
+ const b2PolygonShape* polyA, const b2Transform& xfA,
+ const b2PolygonShape* polyB, const b2Transform& xfB)
+{
+ manifold->pointCount = 0;
+ float totalRadius = polyA->m_radius + polyB->m_radius;
+
+ int32 edgeA = 0;
+ float separationA = b2FindMaxSeparation(&edgeA, polyA, xfA, polyB, xfB);
+ if (separationA > totalRadius)
+ return;
+
+ int32 edgeB = 0;
+ float separationB = b2FindMaxSeparation(&edgeB, polyB, xfB, polyA, xfA);
+ if (separationB > totalRadius)
+ return;
+
+ const b2PolygonShape* poly1; // reference polygon
+ const b2PolygonShape* poly2; // incident polygon
+ b2Transform xf1, xf2;
+ int32 edge1; // reference edge
+ uint8 flip;
+ const float k_tol = 0.1f * b2_linearSlop;
+
+ if (separationB > separationA + k_tol)
+ {
+ poly1 = polyB;
+ poly2 = polyA;
+ xf1 = xfB;
+ xf2 = xfA;
+ edge1 = edgeB;
+ manifold->type = b2Manifold::e_faceB;
+ flip = 1;
+ }
+ else
+ {
+ poly1 = polyA;
+ poly2 = polyB;
+ xf1 = xfA;
+ xf2 = xfB;
+ edge1 = edgeA;
+ manifold->type = b2Manifold::e_faceA;
+ flip = 0;
+ }
+
+ b2ClipVertex incidentEdge[2];
+ b2FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);
+
+ int32 count1 = poly1->m_count;
+ const b2Vec2* vertices1 = poly1->m_vertices;
+
+ int32 iv1 = edge1;
+ int32 iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;
+
+ b2Vec2 v11 = vertices1[iv1];
+ b2Vec2 v12 = vertices1[iv2];
+
+ b2Vec2 localTangent = v12 - v11;
+ localTangent.Normalize();
+
+ b2Vec2 localNormal = b2Cross(localTangent, 1.0f);
+ b2Vec2 planePoint = 0.5f * (v11 + v12);
+
+ b2Vec2 tangent = b2Mul(xf1.q, localTangent);
+ b2Vec2 normal = b2Cross(tangent, 1.0f);
+
+ v11 = b2Mul(xf1, v11);
+ v12 = b2Mul(xf1, v12);
+
+ // Face offset.
+ float frontOffset = b2Dot(normal, v11);
+
+ // Side offsets, extended by polytope skin thickness.
+ float sideOffset1 = -b2Dot(tangent, v11) + totalRadius;
+ float sideOffset2 = b2Dot(tangent, v12) + totalRadius;
+
+ // Clip incident edge against extruded edge1 side edges.
+ b2ClipVertex clipPoints1[2];
+ b2ClipVertex clipPoints2[2];
+ int np;
+
+ // Clip to box side 1
+ np = b2ClipSegmentToLine(clipPoints1, incidentEdge, -tangent, sideOffset1, iv1);
+
+ if (np < 2)
+ return;
+
+ // Clip to negative box side 1
+ np = b2ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2, iv2);
+
+ if (np < 2)
+ {
+ return;
+ }
+
+ // Now clipPoints2 contains the clipped points.
+ manifold->localNormal = localNormal;
+ manifold->localPoint = planePoint;
+
+ int32 pointCount = 0;
+ for (int32 i = 0; i < b2_maxManifoldPoints; ++i)
+ {
+ float separation = b2Dot(normal, clipPoints2[i].v) - frontOffset;
+
+ if (separation <= totalRadius)
+ {
+ b2ManifoldPoint* cp = manifold->points + pointCount;
+ cp->localPoint = b2MulT(xf2, clipPoints2[i].v);
+ cp->id = clipPoints2[i].id;
+ if (flip)
+ {
+ // Swap features
+ b2ContactFeature cf = cp->id.cf;
+ cp->id.cf.indexA = cf.indexB;
+ cp->id.cf.indexB = cf.indexA;
+ cp->id.cf.typeA = cf.typeB;
+ cp->id.cf.typeB = cf.typeA;
+ }
+ ++pointCount;
+ }
+ }
+
+ manifold->pointCount = pointCount;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_collision.cpp b/Client/ThirdParty/Box2D/src/collision/b2_collision.cpp
new file mode 100644
index 0000000..8a0501b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_collision.cpp
@@ -0,0 +1,258 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_collision.h"
+#include "box2d/b2_distance.h"
+
+void b2WorldManifold::Initialize(const b2Manifold* manifold,
+ const b2Transform& xfA, float radiusA,
+ const b2Transform& xfB, float radiusB)
+{
+ if (manifold->pointCount == 0)
+ {
+ return;
+ }
+
+ switch (manifold->type)
+ {
+ case b2Manifold::e_circles:
+ {
+ normal.Set(1.0f, 0.0f);
+ b2Vec2 pointA = b2Mul(xfA, manifold->localPoint);
+ b2Vec2 pointB = b2Mul(xfB, manifold->points[0].localPoint);
+ if (b2DistanceSquared(pointA, pointB) > b2_epsilon * b2_epsilon)
+ {
+ normal = pointB - pointA;
+ normal.Normalize();
+ }
+
+ b2Vec2 cA = pointA + radiusA * normal;
+ b2Vec2 cB = pointB - radiusB * normal;
+ points[0] = 0.5f * (cA + cB);
+ separations[0] = b2Dot(cB - cA, normal);
+ }
+ break;
+
+ case b2Manifold::e_faceA:
+ {
+ normal = b2Mul(xfA.q, manifold->localNormal);
+ b2Vec2 planePoint = b2Mul(xfA, manifold->localPoint);
+
+ for (int32 i = 0; i < manifold->pointCount; ++i)
+ {
+ b2Vec2 clipPoint = b2Mul(xfB, manifold->points[i].localPoint);
+ b2Vec2 cA = clipPoint + (radiusA - b2Dot(clipPoint - planePoint, normal)) * normal;
+ b2Vec2 cB = clipPoint - radiusB * normal;
+ points[i] = 0.5f * (cA + cB);
+ separations[i] = b2Dot(cB - cA, normal);
+ }
+ }
+ break;
+
+ case b2Manifold::e_faceB:
+ {
+ normal = b2Mul(xfB.q, manifold->localNormal);
+ b2Vec2 planePoint = b2Mul(xfB, manifold->localPoint);
+
+ for (int32 i = 0; i < manifold->pointCount; ++i)
+ {
+ b2Vec2 clipPoint = b2Mul(xfA, manifold->points[i].localPoint);
+ b2Vec2 cB = clipPoint + (radiusB - b2Dot(clipPoint - planePoint, normal)) * normal;
+ b2Vec2 cA = clipPoint - radiusA * normal;
+ points[i] = 0.5f * (cA + cB);
+ separations[i] = b2Dot(cA - cB, normal);
+ }
+
+ // Ensure normal points from A to B.
+ normal = -normal;
+ }
+ break;
+ }
+}
+
+void b2GetPointStates(b2PointState state1[b2_maxManifoldPoints], b2PointState state2[b2_maxManifoldPoints],
+ const b2Manifold* manifold1, const b2Manifold* manifold2)
+{
+ for (int32 i = 0; i < b2_maxManifoldPoints; ++i)
+ {
+ state1[i] = b2_nullState;
+ state2[i] = b2_nullState;
+ }
+
+ // Detect persists and removes.
+ for (int32 i = 0; i < manifold1->pointCount; ++i)
+ {
+ b2ContactID id = manifold1->points[i].id;
+
+ state1[i] = b2_removeState;
+
+ for (int32 j = 0; j < manifold2->pointCount; ++j)
+ {
+ if (manifold2->points[j].id.key == id.key)
+ {
+ state1[i] = b2_persistState;
+ break;
+ }
+ }
+ }
+
+ // Detect persists and adds.
+ for (int32 i = 0; i < manifold2->pointCount; ++i)
+ {
+ b2ContactID id = manifold2->points[i].id;
+
+ state2[i] = b2_addState;
+
+ for (int32 j = 0; j < manifold1->pointCount; ++j)
+ {
+ if (manifold1->points[j].id.key == id.key)
+ {
+ state2[i] = b2_persistState;
+ break;
+ }
+ }
+ }
+}
+
+// From Real-time Collision Detection, p179.
+bool b2AABB::RayCast(b2RayCastOutput* output, const b2RayCastInput& input) const
+{
+ float tmin = -b2_maxFloat;
+ float tmax = b2_maxFloat;
+
+ b2Vec2 p = input.p1;
+ b2Vec2 d = input.p2 - input.p1;
+ b2Vec2 absD = b2Abs(d);
+
+ b2Vec2 normal;
+
+ for (int32 i = 0; i < 2; ++i)
+ {
+ if (absD(i) < b2_epsilon)
+ {
+ // Parallel.
+ if (p(i) < lowerBound(i) || upperBound(i) < p(i))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ float inv_d = 1.0f / d(i);
+ float t1 = (lowerBound(i) - p(i)) * inv_d;
+ float t2 = (upperBound(i) - p(i)) * inv_d;
+
+ // Sign of the normal vector.
+ float s = -1.0f;
+
+ if (t1 > t2)
+ {
+ b2Swap(t1, t2);
+ s = 1.0f;
+ }
+
+ // Push the min up
+ if (t1 > tmin)
+ {
+ normal.SetZero();
+ normal(i) = s;
+ tmin = t1;
+ }
+
+ // Pull the max down
+ tmax = b2Min(tmax, t2);
+
+ if (tmin > tmax)
+ {
+ return false;
+ }
+ }
+ }
+
+ // Does the ray start inside the box?
+ // Does the ray intersect beyond the max fraction?
+ if (tmin < 0.0f || input.maxFraction < tmin)
+ {
+ return false;
+ }
+
+ // Intersection.
+ output->fraction = tmin;
+ output->normal = normal;
+ return true;
+}
+
+// Sutherland-Hodgman clipping.
+int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2],
+ const b2Vec2& normal, float offset, int32 vertexIndexA)
+{
+ // Start with no output points
+ int32 count = 0;
+
+ // Calculate the distance of end points to the line
+ float distance0 = b2Dot(normal, vIn[0].v) - offset;
+ float distance1 = b2Dot(normal, vIn[1].v) - offset;
+
+ // If the points are behind the plane
+ if (distance0 <= 0.0f) vOut[count++] = vIn[0];
+ if (distance1 <= 0.0f) vOut[count++] = vIn[1];
+
+ // If the points are on different sides of the plane
+ if (distance0 * distance1 < 0.0f)
+ {
+ // Find intersection point of edge and plane
+ float interp = distance0 / (distance0 - distance1);
+ vOut[count].v = vIn[0].v + interp * (vIn[1].v - vIn[0].v);
+
+ // VertexA is hitting edgeB.
+ vOut[count].id.cf.indexA = static_cast<uint8>(vertexIndexA);
+ vOut[count].id.cf.indexB = vIn[0].id.cf.indexB;
+ vOut[count].id.cf.typeA = b2ContactFeature::e_vertex;
+ vOut[count].id.cf.typeB = b2ContactFeature::e_face;
+ ++count;
+
+ b2Assert(count == 2);
+ }
+
+ return count;
+}
+
+bool b2TestOverlap( const b2Shape* shapeA, int32 indexA,
+ const b2Shape* shapeB, int32 indexB,
+ const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2DistanceInput input;
+ input.proxyA.Set(shapeA, indexA);
+ input.proxyB.Set(shapeB, indexB);
+ input.transformA = xfA;
+ input.transformB = xfB;
+ input.useRadii = true;
+
+ b2SimplexCache cache;
+ cache.count = 0;
+
+ b2DistanceOutput output;
+
+ b2Distance(&output, &cache, &input);
+
+ return output.distance < 10.0f * b2_epsilon;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_distance.cpp b/Client/ThirdParty/Box2D/src/collision/b2_distance.cpp
new file mode 100644
index 0000000..2441324
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_distance.cpp
@@ -0,0 +1,746 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_distance.h"
+#include "box2d/b2_edge_shape.h"
+#include "box2d/b2_chain_shape.h"
+#include "box2d/b2_polygon_shape.h"
+
+// GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.
+B2_API int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
+
+void b2DistanceProxy::Set(const b2Shape* shape, int32 index)
+{
+ switch (shape->GetType())
+ {
+ case b2Shape::e_circle:
+ {
+ const b2CircleShape* circle = static_cast<const b2CircleShape*>(shape);
+ m_vertices = &circle->m_p;
+ m_count = 1;
+ m_radius = circle->m_radius;
+ }
+ break;
+
+ case b2Shape::e_polygon:
+ {
+ const b2PolygonShape* polygon = static_cast<const b2PolygonShape*>(shape);
+ m_vertices = polygon->m_vertices;
+ m_count = polygon->m_count;
+ m_radius = polygon->m_radius;
+ }
+ break;
+
+ case b2Shape::e_chain:
+ {
+ const b2ChainShape* chain = static_cast<const b2ChainShape*>(shape);
+ b2Assert(0 <= index && index < chain->m_count);
+
+ m_buffer[0] = chain->m_vertices[index];
+ if (index + 1 < chain->m_count)
+ {
+ m_buffer[1] = chain->m_vertices[index + 1];
+ }
+ else
+ {
+ m_buffer[1] = chain->m_vertices[0];
+ }
+
+ m_vertices = m_buffer;
+ m_count = 2;
+ m_radius = chain->m_radius;
+ }
+ break;
+
+ case b2Shape::e_edge:
+ {
+ const b2EdgeShape* edge = static_cast<const b2EdgeShape*>(shape);
+ m_vertices = &edge->m_vertex1;
+ m_count = 2;
+ m_radius = edge->m_radius;
+ }
+ break;
+
+ default:
+ b2Assert(false);
+ }
+}
+
+void b2DistanceProxy::Set(const b2Vec2* vertices, int32 count, float radius)
+{
+ m_vertices = vertices;
+ m_count = count;
+ m_radius = radius;
+}
+
+struct b2SimplexVertex
+{
+ b2Vec2 wA; // support point in proxyA
+ b2Vec2 wB; // support point in proxyB
+ b2Vec2 w; // wB - wA
+ float a; // barycentric coordinate for closest point
+ int32 indexA; // wA index
+ int32 indexB; // wB index
+};
+
+struct b2Simplex
+{
+ void ReadCache( const b2SimplexCache* cache,
+ const b2DistanceProxy* proxyA, const b2Transform& transformA,
+ const b2DistanceProxy* proxyB, const b2Transform& transformB)
+ {
+ b2Assert(cache->count <= 3);
+
+ // Copy data from cache.
+ m_count = cache->count;
+ b2SimplexVertex* vertices = &m_v1;
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2SimplexVertex* v = vertices + i;
+ v->indexA = cache->indexA[i];
+ v->indexB = cache->indexB[i];
+ b2Vec2 wALocal = proxyA->GetVertex(v->indexA);
+ b2Vec2 wBLocal = proxyB->GetVertex(v->indexB);
+ v->wA = b2Mul(transformA, wALocal);
+ v->wB = b2Mul(transformB, wBLocal);
+ v->w = v->wB - v->wA;
+ v->a = 0.0f;
+ }
+
+ // Compute the new simplex metric, if it is substantially different than
+ // old metric then flush the simplex.
+ if (m_count > 1)
+ {
+ float metric1 = cache->metric;
+ float metric2 = GetMetric();
+ if (metric2 < 0.5f * metric1 || 2.0f * metric1 < metric2 || metric2 < b2_epsilon)
+ {
+ // Reset the simplex.
+ m_count = 0;
+ }
+ }
+
+ // If the cache is empty or invalid ...
+ if (m_count == 0)
+ {
+ b2SimplexVertex* v = vertices + 0;
+ v->indexA = 0;
+ v->indexB = 0;
+ b2Vec2 wALocal = proxyA->GetVertex(0);
+ b2Vec2 wBLocal = proxyB->GetVertex(0);
+ v->wA = b2Mul(transformA, wALocal);
+ v->wB = b2Mul(transformB, wBLocal);
+ v->w = v->wB - v->wA;
+ v->a = 1.0f;
+ m_count = 1;
+ }
+ }
+
+ void WriteCache(b2SimplexCache* cache) const
+ {
+ cache->metric = GetMetric();
+ cache->count = uint16(m_count);
+ const b2SimplexVertex* vertices = &m_v1;
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ cache->indexA[i] = uint8(vertices[i].indexA);
+ cache->indexB[i] = uint8(vertices[i].indexB);
+ }
+ }
+
+ b2Vec2 GetSearchDirection() const
+ {
+ switch (m_count)
+ {
+ case 1:
+ return -m_v1.w;
+
+ case 2:
+ {
+ b2Vec2 e12 = m_v2.w - m_v1.w;
+ float sgn = b2Cross(e12, -m_v1.w);
+ if (sgn > 0.0f)
+ {
+ // Origin is left of e12.
+ return b2Cross(1.0f, e12);
+ }
+ else
+ {
+ // Origin is right of e12.
+ return b2Cross(e12, 1.0f);
+ }
+ }
+
+ default:
+ b2Assert(false);
+ return b2Vec2_zero;
+ }
+ }
+
+ b2Vec2 GetClosestPoint() const
+ {
+ switch (m_count)
+ {
+ case 0:
+ b2Assert(false);
+ return b2Vec2_zero;
+
+ case 1:
+ return m_v1.w;
+
+ case 2:
+ return m_v1.a * m_v1.w + m_v2.a * m_v2.w;
+
+ case 3:
+ return b2Vec2_zero;
+
+ default:
+ b2Assert(false);
+ return b2Vec2_zero;
+ }
+ }
+
+ void GetWitnessPoints(b2Vec2* pA, b2Vec2* pB) const
+ {
+ switch (m_count)
+ {
+ case 0:
+ b2Assert(false);
+ break;
+
+ case 1:
+ *pA = m_v1.wA;
+ *pB = m_v1.wB;
+ break;
+
+ case 2:
+ *pA = m_v1.a * m_v1.wA + m_v2.a * m_v2.wA;
+ *pB = m_v1.a * m_v1.wB + m_v2.a * m_v2.wB;
+ break;
+
+ case 3:
+ *pA = m_v1.a * m_v1.wA + m_v2.a * m_v2.wA + m_v3.a * m_v3.wA;
+ *pB = *pA;
+ break;
+
+ default:
+ b2Assert(false);
+ break;
+ }
+ }
+
+ float GetMetric() const
+ {
+ switch (m_count)
+ {
+ case 0:
+ b2Assert(false);
+ return 0.0f;
+
+ case 1:
+ return 0.0f;
+
+ case 2:
+ return b2Distance(m_v1.w, m_v2.w);
+
+ case 3:
+ return b2Cross(m_v2.w - m_v1.w, m_v3.w - m_v1.w);
+
+ default:
+ b2Assert(false);
+ return 0.0f;
+ }
+ }
+
+ void Solve2();
+ void Solve3();
+
+ b2SimplexVertex m_v1, m_v2, m_v3;
+ int32 m_count;
+};
+
+
+// Solve a line segment using barycentric coordinates.
+//
+// p = a1 * w1 + a2 * w2
+// a1 + a2 = 1
+//
+// The vector from the origin to the closest point on the line is
+// perpendicular to the line.
+// e12 = w2 - w1
+// dot(p, e) = 0
+// a1 * dot(w1, e) + a2 * dot(w2, e) = 0
+//
+// 2-by-2 linear system
+// [1 1 ][a1] = [1]
+// [w1.e12 w2.e12][a2] = [0]
+//
+// Define
+// d12_1 = dot(w2, e12)
+// d12_2 = -dot(w1, e12)
+// d12 = d12_1 + d12_2
+//
+// Solution
+// a1 = d12_1 / d12
+// a2 = d12_2 / d12
+void b2Simplex::Solve2()
+{
+ b2Vec2 w1 = m_v1.w;
+ b2Vec2 w2 = m_v2.w;
+ b2Vec2 e12 = w2 - w1;
+
+ // w1 region
+ float d12_2 = -b2Dot(w1, e12);
+ if (d12_2 <= 0.0f)
+ {
+ // a2 <= 0, so we clamp it to 0
+ m_v1.a = 1.0f;
+ m_count = 1;
+ return;
+ }
+
+ // w2 region
+ float d12_1 = b2Dot(w2, e12);
+ if (d12_1 <= 0.0f)
+ {
+ // a1 <= 0, so we clamp it to 0
+ m_v2.a = 1.0f;
+ m_count = 1;
+ m_v1 = m_v2;
+ return;
+ }
+
+ // Must be in e12 region.
+ float inv_d12 = 1.0f / (d12_1 + d12_2);
+ m_v1.a = d12_1 * inv_d12;
+ m_v2.a = d12_2 * inv_d12;
+ m_count = 2;
+}
+
+// Possible regions:
+// - points[2]
+// - edge points[0]-points[2]
+// - edge points[1]-points[2]
+// - inside the triangle
+void b2Simplex::Solve3()
+{
+ b2Vec2 w1 = m_v1.w;
+ b2Vec2 w2 = m_v2.w;
+ b2Vec2 w3 = m_v3.w;
+
+ // Edge12
+ // [1 1 ][a1] = [1]
+ // [w1.e12 w2.e12][a2] = [0]
+ // a3 = 0
+ b2Vec2 e12 = w2 - w1;
+ float w1e12 = b2Dot(w1, e12);
+ float w2e12 = b2Dot(w2, e12);
+ float d12_1 = w2e12;
+ float d12_2 = -w1e12;
+
+ // Edge13
+ // [1 1 ][a1] = [1]
+ // [w1.e13 w3.e13][a3] = [0]
+ // a2 = 0
+ b2Vec2 e13 = w3 - w1;
+ float w1e13 = b2Dot(w1, e13);
+ float w3e13 = b2Dot(w3, e13);
+ float d13_1 = w3e13;
+ float d13_2 = -w1e13;
+
+ // Edge23
+ // [1 1 ][a2] = [1]
+ // [w2.e23 w3.e23][a3] = [0]
+ // a1 = 0
+ b2Vec2 e23 = w3 - w2;
+ float w2e23 = b2Dot(w2, e23);
+ float w3e23 = b2Dot(w3, e23);
+ float d23_1 = w3e23;
+ float d23_2 = -w2e23;
+
+ // Triangle123
+ float n123 = b2Cross(e12, e13);
+
+ float d123_1 = n123 * b2Cross(w2, w3);
+ float d123_2 = n123 * b2Cross(w3, w1);
+ float d123_3 = n123 * b2Cross(w1, w2);
+
+ // w1 region
+ if (d12_2 <= 0.0f && d13_2 <= 0.0f)
+ {
+ m_v1.a = 1.0f;
+ m_count = 1;
+ return;
+ }
+
+ // e12
+ if (d12_1 > 0.0f && d12_2 > 0.0f && d123_3 <= 0.0f)
+ {
+ float inv_d12 = 1.0f / (d12_1 + d12_2);
+ m_v1.a = d12_1 * inv_d12;
+ m_v2.a = d12_2 * inv_d12;
+ m_count = 2;
+ return;
+ }
+
+ // e13
+ if (d13_1 > 0.0f && d13_2 > 0.0f && d123_2 <= 0.0f)
+ {
+ float inv_d13 = 1.0f / (d13_1 + d13_2);
+ m_v1.a = d13_1 * inv_d13;
+ m_v3.a = d13_2 * inv_d13;
+ m_count = 2;
+ m_v2 = m_v3;
+ return;
+ }
+
+ // w2 region
+ if (d12_1 <= 0.0f && d23_2 <= 0.0f)
+ {
+ m_v2.a = 1.0f;
+ m_count = 1;
+ m_v1 = m_v2;
+ return;
+ }
+
+ // w3 region
+ if (d13_1 <= 0.0f && d23_1 <= 0.0f)
+ {
+ m_v3.a = 1.0f;
+ m_count = 1;
+ m_v1 = m_v3;
+ return;
+ }
+
+ // e23
+ if (d23_1 > 0.0f && d23_2 > 0.0f && d123_1 <= 0.0f)
+ {
+ float inv_d23 = 1.0f / (d23_1 + d23_2);
+ m_v2.a = d23_1 * inv_d23;
+ m_v3.a = d23_2 * inv_d23;
+ m_count = 2;
+ m_v1 = m_v3;
+ return;
+ }
+
+ // Must be in triangle123
+ float inv_d123 = 1.0f / (d123_1 + d123_2 + d123_3);
+ m_v1.a = d123_1 * inv_d123;
+ m_v2.a = d123_2 * inv_d123;
+ m_v3.a = d123_3 * inv_d123;
+ m_count = 3;
+}
+
+void b2Distance(b2DistanceOutput* output,
+ b2SimplexCache* cache,
+ const b2DistanceInput* input)
+{
+ ++b2_gjkCalls;
+
+ const b2DistanceProxy* proxyA = &input->proxyA;
+ const b2DistanceProxy* proxyB = &input->proxyB;
+
+ b2Transform transformA = input->transformA;
+ b2Transform transformB = input->transformB;
+
+ // Initialize the simplex.
+ b2Simplex simplex;
+ simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB);
+
+ // Get simplex vertices as an array.
+ b2SimplexVertex* vertices = &simplex.m_v1;
+ const int32 k_maxIters = 20;
+
+ // These store the vertices of the last simplex so that we
+ // can check for duplicates and prevent cycling.
+ int32 saveA[3], saveB[3];
+ int32 saveCount = 0;
+
+ // Main iteration loop.
+ int32 iter = 0;
+ while (iter < k_maxIters)
+ {
+ // Copy simplex so we can identify duplicates.
+ saveCount = simplex.m_count;
+ for (int32 i = 0; i < saveCount; ++i)
+ {
+ saveA[i] = vertices[i].indexA;
+ saveB[i] = vertices[i].indexB;
+ }
+
+ switch (simplex.m_count)
+ {
+ case 1:
+ break;
+
+ case 2:
+ simplex.Solve2();
+ break;
+
+ case 3:
+ simplex.Solve3();
+ break;
+
+ default:
+ b2Assert(false);
+ }
+
+ // If we have 3 points, then the origin is in the corresponding triangle.
+ if (simplex.m_count == 3)
+ {
+ break;
+ }
+
+ // Get search direction.
+ b2Vec2 d = simplex.GetSearchDirection();
+
+ // Ensure the search direction is numerically fit.
+ if (d.LengthSquared() < b2_epsilon * b2_epsilon)
+ {
+ // The origin is probably contained by a line segment
+ // or triangle. Thus the shapes are overlapped.
+
+ // We can't return zero here even though there may be overlap.
+ // In case the simplex is a point, segment, or triangle it is difficult
+ // to determine if the origin is contained in the CSO or very close to it.
+ break;
+ }
+
+ // Compute a tentative new simplex vertex using support points.
+ b2SimplexVertex* vertex = vertices + simplex.m_count;
+ vertex->indexA = proxyA->GetSupport(b2MulT(transformA.q, -d));
+ vertex->wA = b2Mul(transformA, proxyA->GetVertex(vertex->indexA));
+ vertex->indexB = proxyB->GetSupport(b2MulT(transformB.q, d));
+ vertex->wB = b2Mul(transformB, proxyB->GetVertex(vertex->indexB));
+ vertex->w = vertex->wB - vertex->wA;
+
+ // Iteration count is equated to the number of support point calls.
+ ++iter;
+ ++b2_gjkIters;
+
+ // Check for duplicate support points. This is the main termination criteria.
+ bool duplicate = false;
+ for (int32 i = 0; i < saveCount; ++i)
+ {
+ if (vertex->indexA == saveA[i] && vertex->indexB == saveB[i])
+ {
+ duplicate = true;
+ break;
+ }
+ }
+
+ // If we found a duplicate support point we must exit to avoid cycling.
+ if (duplicate)
+ {
+ break;
+ }
+
+ // New vertex is ok and needed.
+ ++simplex.m_count;
+ }
+
+ b2_gjkMaxIters = b2Max(b2_gjkMaxIters, iter);
+
+ // Prepare output.
+ simplex.GetWitnessPoints(&output->pointA, &output->pointB);
+ output->distance = b2Distance(output->pointA, output->pointB);
+ output->iterations = iter;
+
+ // Cache the simplex.
+ simplex.WriteCache(cache);
+
+ // Apply radii if requested.
+ if (input->useRadii)
+ {
+ float rA = proxyA->m_radius;
+ float rB = proxyB->m_radius;
+
+ if (output->distance > rA + rB && output->distance > b2_epsilon)
+ {
+ // Shapes are still no overlapped.
+ // Move the witness points to the outer surface.
+ output->distance -= rA + rB;
+ b2Vec2 normal = output->pointB - output->pointA;
+ normal.Normalize();
+ output->pointA += rA * normal;
+ output->pointB -= rB * normal;
+ }
+ else
+ {
+ // Shapes are overlapped when radii are considered.
+ // Move the witness points to the middle.
+ b2Vec2 p = 0.5f * (output->pointA + output->pointB);
+ output->pointA = p;
+ output->pointB = p;
+ output->distance = 0.0f;
+ }
+ }
+}
+
+// GJK-raycast
+// Algorithm by Gino van den Bergen.
+// "Smooth Mesh Contacts with GJK" in Game Physics Pearls. 2010
+bool b2ShapeCast(b2ShapeCastOutput * output, const b2ShapeCastInput * input)
+{
+ output->iterations = 0;
+ output->lambda = 1.0f;
+ output->normal.SetZero();
+ output->point.SetZero();
+
+ const b2DistanceProxy* proxyA = &input->proxyA;
+ const b2DistanceProxy* proxyB = &input->proxyB;
+
+ float radiusA = b2Max(proxyA->m_radius, b2_polygonRadius);
+ float radiusB = b2Max(proxyB->m_radius, b2_polygonRadius);
+ float radius = radiusA + radiusB;
+
+ b2Transform xfA = input->transformA;
+ b2Transform xfB = input->transformB;
+
+ b2Vec2 r = input->translationB;
+ b2Vec2 n(0.0f, 0.0f);
+ float lambda = 0.0f;
+
+ // Initial simplex
+ b2Simplex simplex;
+ simplex.m_count = 0;
+
+ // Get simplex vertices as an array.
+ b2SimplexVertex* vertices = &simplex.m_v1;
+
+ // Get support point in -r direction
+ int32 indexA = proxyA->GetSupport(b2MulT(xfA.q, -r));
+ b2Vec2 wA = b2Mul(xfA, proxyA->GetVertex(indexA));
+ int32 indexB = proxyB->GetSupport(b2MulT(xfB.q, r));
+ b2Vec2 wB = b2Mul(xfB, proxyB->GetVertex(indexB));
+ b2Vec2 v = wA - wB;
+
+ // Sigma is the target distance between polygons
+ float sigma = b2Max(b2_polygonRadius, radius - b2_polygonRadius);
+ const float tolerance = 0.5f * b2_linearSlop;
+
+ // Main iteration loop.
+ const int32 k_maxIters = 20;
+ int32 iter = 0;
+ while (iter < k_maxIters && v.Length() - sigma > tolerance)
+ {
+ b2Assert(simplex.m_count < 3);
+
+ output->iterations += 1;
+
+ // Support in direction -v (A - B)
+ indexA = proxyA->GetSupport(b2MulT(xfA.q, -v));
+ wA = b2Mul(xfA, proxyA->GetVertex(indexA));
+ indexB = proxyB->GetSupport(b2MulT(xfB.q, v));
+ wB = b2Mul(xfB, proxyB->GetVertex(indexB));
+ b2Vec2 p = wA - wB;
+
+ // -v is a normal at p
+ v.Normalize();
+
+ // Intersect ray with plane
+ float vp = b2Dot(v, p);
+ float vr = b2Dot(v, r);
+ if (vp - sigma > lambda * vr)
+ {
+ if (vr <= 0.0f)
+ {
+ return false;
+ }
+
+ lambda = (vp - sigma) / vr;
+ if (lambda > 1.0f)
+ {
+ return false;
+ }
+
+ n = -v;
+ simplex.m_count = 0;
+ }
+
+ // Reverse simplex since it works with B - A.
+ // Shift by lambda * r because we want the closest point to the current clip point.
+ // Note that the support point p is not shifted because we want the plane equation
+ // to be formed in unshifted space.
+ b2SimplexVertex* vertex = vertices + simplex.m_count;
+ vertex->indexA = indexB;
+ vertex->wA = wB + lambda * r;
+ vertex->indexB = indexA;
+ vertex->wB = wA;
+ vertex->w = vertex->wB - vertex->wA;
+ vertex->a = 1.0f;
+ simplex.m_count += 1;
+
+ switch (simplex.m_count)
+ {
+ case 1:
+ break;
+
+ case 2:
+ simplex.Solve2();
+ break;
+
+ case 3:
+ simplex.Solve3();
+ break;
+
+ default:
+ b2Assert(false);
+ }
+
+ // If we have 3 points, then the origin is in the corresponding triangle.
+ if (simplex.m_count == 3)
+ {
+ // Overlap
+ return false;
+ }
+
+ // Get search direction.
+ v = simplex.GetClosestPoint();
+
+ // Iteration count is equated to the number of support point calls.
+ ++iter;
+ }
+
+ if (iter == 0)
+ {
+ // Initial overlap
+ return false;
+ }
+
+ // Prepare output.
+ b2Vec2 pointA, pointB;
+ simplex.GetWitnessPoints(&pointB, &pointA);
+
+ if (v.LengthSquared() > 0.0f)
+ {
+ n = -v;
+ n.Normalize();
+ }
+
+ output->point = pointA + radiusA * n;
+ output->normal = n;
+ output->lambda = lambda;
+ output->iterations = iter;
+ return true;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_dynamic_tree.cpp b/Client/ThirdParty/Box2D/src/collision/b2_dynamic_tree.cpp
new file mode 100644
index 0000000..55a9d32
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_dynamic_tree.cpp
@@ -0,0 +1,801 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+#include "box2d/b2_dynamic_tree.h"
+#include <string.h>
+
+b2DynamicTree::b2DynamicTree()
+{
+ m_root = b2_nullNode;
+
+ m_nodeCapacity = 16;
+ m_nodeCount = 0;
+ m_nodes = (b2TreeNode*)b2Alloc(m_nodeCapacity * sizeof(b2TreeNode));
+ memset(m_nodes, 0, m_nodeCapacity * sizeof(b2TreeNode));
+
+ // Build a linked list for the free list.
+ for (int32 i = 0; i < m_nodeCapacity - 1; ++i)
+ {
+ m_nodes[i].next = i + 1;
+ m_nodes[i].height = -1;
+ }
+ m_nodes[m_nodeCapacity-1].next = b2_nullNode;
+ m_nodes[m_nodeCapacity-1].height = -1;
+ m_freeList = 0;
+
+ m_insertionCount = 0;
+}
+
+b2DynamicTree::~b2DynamicTree()
+{
+ // This frees the entire tree in one shot.
+ b2Free(m_nodes);
+}
+
+// Allocate a node from the pool. Grow the pool if necessary.
+int32 b2DynamicTree::AllocateNode()
+{
+ // Expand the node pool as needed.
+ if (m_freeList == b2_nullNode)
+ {
+ b2Assert(m_nodeCount == m_nodeCapacity);
+
+ // The free list is empty. Rebuild a bigger pool.
+ b2TreeNode* oldNodes = m_nodes;
+ m_nodeCapacity *= 2;
+ m_nodes = (b2TreeNode*)b2Alloc(m_nodeCapacity * sizeof(b2TreeNode));
+ memcpy(m_nodes, oldNodes, m_nodeCount * sizeof(b2TreeNode));
+ b2Free(oldNodes);
+
+ // Build a linked list for the free list. The parent
+ // pointer becomes the "next" pointer.
+ for (int32 i = m_nodeCount; i < m_nodeCapacity - 1; ++i)
+ {
+ m_nodes[i].next = i + 1;
+ m_nodes[i].height = -1;
+ }
+ m_nodes[m_nodeCapacity-1].next = b2_nullNode;
+ m_nodes[m_nodeCapacity-1].height = -1;
+ m_freeList = m_nodeCount;
+ }
+
+ // Peel a node off the free list.
+ int32 nodeId = m_freeList;
+ m_freeList = m_nodes[nodeId].next;
+ m_nodes[nodeId].parent = b2_nullNode;
+ m_nodes[nodeId].child1 = b2_nullNode;
+ m_nodes[nodeId].child2 = b2_nullNode;
+ m_nodes[nodeId].height = 0;
+ m_nodes[nodeId].userData = nullptr;
+ m_nodes[nodeId].moved = false;
+ ++m_nodeCount;
+ return nodeId;
+}
+
+// Return a node to the pool.
+void b2DynamicTree::FreeNode(int32 nodeId)
+{
+ b2Assert(0 <= nodeId && nodeId < m_nodeCapacity);
+ b2Assert(0 < m_nodeCount);
+ m_nodes[nodeId].next = m_freeList;
+ m_nodes[nodeId].height = -1;
+ m_freeList = nodeId;
+ --m_nodeCount;
+}
+
+// Create a proxy in the tree as a leaf node. We return the index
+// of the node instead of a pointer so that we can grow
+// the node pool.
+int32 b2DynamicTree::CreateProxy(const b2AABB& aabb, void* userData)
+{
+ int32 proxyId = AllocateNode();
+
+ // Fatten the aabb.
+ b2Vec2 r(b2_aabbExtension, b2_aabbExtension);
+ m_nodes[proxyId].aabb.lowerBound = aabb.lowerBound - r;
+ m_nodes[proxyId].aabb.upperBound = aabb.upperBound + r;
+ m_nodes[proxyId].userData = userData;
+ m_nodes[proxyId].height = 0;
+ m_nodes[proxyId].moved = true;
+
+ InsertLeaf(proxyId);
+
+ return proxyId;
+}
+
+void b2DynamicTree::DestroyProxy(int32 proxyId)
+{
+ b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
+ b2Assert(m_nodes[proxyId].IsLeaf());
+
+ RemoveLeaf(proxyId);
+ FreeNode(proxyId);
+}
+
+bool b2DynamicTree::MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement)
+{
+ b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
+
+ b2Assert(m_nodes[proxyId].IsLeaf());
+
+ // Extend AABB
+ b2AABB fatAABB;
+ b2Vec2 r(b2_aabbExtension, b2_aabbExtension);
+ fatAABB.lowerBound = aabb.lowerBound - r;
+ fatAABB.upperBound = aabb.upperBound + r;
+
+ // Predict AABB movement
+ b2Vec2 d = b2_aabbMultiplier * displacement;
+
+ if (d.x < 0.0f)
+ {
+ fatAABB.lowerBound.x += d.x;
+ }
+ else
+ {
+ fatAABB.upperBound.x += d.x;
+ }
+
+ if (d.y < 0.0f)
+ {
+ fatAABB.lowerBound.y += d.y;
+ }
+ else
+ {
+ fatAABB.upperBound.y += d.y;
+ }
+
+ const b2AABB& treeAABB = m_nodes[proxyId].aabb;
+ if (treeAABB.Contains(aabb))
+ {
+ // The tree AABB still contains the object, but it might be too large.
+ // Perhaps the object was moving fast but has since gone to sleep.
+ // The huge AABB is larger than the new fat AABB.
+ b2AABB hugeAABB;
+ hugeAABB.lowerBound = fatAABB.lowerBound - 4.0f * r;
+ hugeAABB.upperBound = fatAABB.upperBound + 4.0f * r;
+
+ if (hugeAABB.Contains(treeAABB))
+ {
+ // The tree AABB contains the object AABB and the tree AABB is
+ // not too large. No tree update needed.
+ return false;
+ }
+
+ // Otherwise the tree AABB is huge and needs to be shrunk
+ }
+
+ RemoveLeaf(proxyId);
+
+ m_nodes[proxyId].aabb = fatAABB;
+
+ InsertLeaf(proxyId);
+
+ m_nodes[proxyId].moved = true;
+
+ return true;
+}
+
+void b2DynamicTree::InsertLeaf(int32 leaf)
+{
+ ++m_insertionCount;
+
+ if (m_root == b2_nullNode)
+ {
+ m_root = leaf;
+ m_nodes[m_root].parent = b2_nullNode;
+ return;
+ }
+
+ // Find the best sibling for this node
+ b2AABB leafAABB = m_nodes[leaf].aabb;
+ int32 index = m_root;
+ while (m_nodes[index].IsLeaf() == false)
+ {
+ int32 child1 = m_nodes[index].child1;
+ int32 child2 = m_nodes[index].child2;
+
+ float area = m_nodes[index].aabb.GetPerimeter();
+
+ b2AABB combinedAABB;
+ combinedAABB.Combine(m_nodes[index].aabb, leafAABB);
+ float combinedArea = combinedAABB.GetPerimeter();
+
+ // Cost of creating a new parent for this node and the new leaf
+ float cost = 2.0f * combinedArea;
+
+ // Minimum cost of pushing the leaf further down the tree
+ float inheritanceCost = 2.0f * (combinedArea - area);
+
+ // Cost of descending into child1
+ float cost1;
+ if (m_nodes[child1].IsLeaf())
+ {
+ b2AABB aabb;
+ aabb.Combine(leafAABB, m_nodes[child1].aabb);
+ cost1 = aabb.GetPerimeter() + inheritanceCost;
+ }
+ else
+ {
+ b2AABB aabb;
+ aabb.Combine(leafAABB, m_nodes[child1].aabb);
+ float oldArea = m_nodes[child1].aabb.GetPerimeter();
+ float newArea = aabb.GetPerimeter();
+ cost1 = (newArea - oldArea) + inheritanceCost;
+ }
+
+ // Cost of descending into child2
+ float cost2;
+ if (m_nodes[child2].IsLeaf())
+ {
+ b2AABB aabb;
+ aabb.Combine(leafAABB, m_nodes[child2].aabb);
+ cost2 = aabb.GetPerimeter() + inheritanceCost;
+ }
+ else
+ {
+ b2AABB aabb;
+ aabb.Combine(leafAABB, m_nodes[child2].aabb);
+ float oldArea = m_nodes[child2].aabb.GetPerimeter();
+ float newArea = aabb.GetPerimeter();
+ cost2 = newArea - oldArea + inheritanceCost;
+ }
+
+ // Descend according to the minimum cost.
+ if (cost < cost1 && cost < cost2)
+ {
+ break;
+ }
+
+ // Descend
+ if (cost1 < cost2)
+ {
+ index = child1;
+ }
+ else
+ {
+ index = child2;
+ }
+ }
+
+ int32 sibling = index;
+
+ // Create a new parent.
+ int32 oldParent = m_nodes[sibling].parent;
+ int32 newParent = AllocateNode();
+ m_nodes[newParent].parent = oldParent;
+ m_nodes[newParent].userData = nullptr;
+ m_nodes[newParent].aabb.Combine(leafAABB, m_nodes[sibling].aabb);
+ m_nodes[newParent].height = m_nodes[sibling].height + 1;
+
+ if (oldParent != b2_nullNode)
+ {
+ // The sibling was not the root.
+ if (m_nodes[oldParent].child1 == sibling)
+ {
+ m_nodes[oldParent].child1 = newParent;
+ }
+ else
+ {
+ m_nodes[oldParent].child2 = newParent;
+ }
+
+ m_nodes[newParent].child1 = sibling;
+ m_nodes[newParent].child2 = leaf;
+ m_nodes[sibling].parent = newParent;
+ m_nodes[leaf].parent = newParent;
+ }
+ else
+ {
+ // The sibling was the root.
+ m_nodes[newParent].child1 = sibling;
+ m_nodes[newParent].child2 = leaf;
+ m_nodes[sibling].parent = newParent;
+ m_nodes[leaf].parent = newParent;
+ m_root = newParent;
+ }
+
+ // Walk back up the tree fixing heights and AABBs
+ index = m_nodes[leaf].parent;
+ while (index != b2_nullNode)
+ {
+ index = Balance(index);
+
+ int32 child1 = m_nodes[index].child1;
+ int32 child2 = m_nodes[index].child2;
+
+ b2Assert(child1 != b2_nullNode);
+ b2Assert(child2 != b2_nullNode);
+
+ m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height);
+ m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb);
+
+ index = m_nodes[index].parent;
+ }
+
+ //Validate();
+}
+
+void b2DynamicTree::RemoveLeaf(int32 leaf)
+{
+ if (leaf == m_root)
+ {
+ m_root = b2_nullNode;
+ return;
+ }
+
+ int32 parent = m_nodes[leaf].parent;
+ int32 grandParent = m_nodes[parent].parent;
+ int32 sibling;
+ if (m_nodes[parent].child1 == leaf)
+ {
+ sibling = m_nodes[parent].child2;
+ }
+ else
+ {
+ sibling = m_nodes[parent].child1;
+ }
+
+ if (grandParent != b2_nullNode)
+ {
+ // Destroy parent and connect sibling to grandParent.
+ if (m_nodes[grandParent].child1 == parent)
+ {
+ m_nodes[grandParent].child1 = sibling;
+ }
+ else
+ {
+ m_nodes[grandParent].child2 = sibling;
+ }
+ m_nodes[sibling].parent = grandParent;
+ FreeNode(parent);
+
+ // Adjust ancestor bounds.
+ int32 index = grandParent;
+ while (index != b2_nullNode)
+ {
+ index = Balance(index);
+
+ int32 child1 = m_nodes[index].child1;
+ int32 child2 = m_nodes[index].child2;
+
+ m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb);
+ m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height);
+
+ index = m_nodes[index].parent;
+ }
+ }
+ else
+ {
+ m_root = sibling;
+ m_nodes[sibling].parent = b2_nullNode;
+ FreeNode(parent);
+ }
+
+ //Validate();
+}
+
+// Perform a left or right rotation if node A is imbalanced.
+// Returns the new root index.
+int32 b2DynamicTree::Balance(int32 iA)
+{
+ b2Assert(iA != b2_nullNode);
+
+ b2TreeNode* A = m_nodes + iA;
+ if (A->IsLeaf() || A->height < 2)
+ {
+ return iA;
+ }
+
+ int32 iB = A->child1;
+ int32 iC = A->child2;
+ b2Assert(0 <= iB && iB < m_nodeCapacity);
+ b2Assert(0 <= iC && iC < m_nodeCapacity);
+
+ b2TreeNode* B = m_nodes + iB;
+ b2TreeNode* C = m_nodes + iC;
+
+ int32 balance = C->height - B->height;
+
+ // Rotate C up
+ if (balance > 1)
+ {
+ int32 iF = C->child1;
+ int32 iG = C->child2;
+ b2TreeNode* F = m_nodes + iF;
+ b2TreeNode* G = m_nodes + iG;
+ b2Assert(0 <= iF && iF < m_nodeCapacity);
+ b2Assert(0 <= iG && iG < m_nodeCapacity);
+
+ // Swap A and C
+ C->child1 = iA;
+ C->parent = A->parent;
+ A->parent = iC;
+
+ // A's old parent should point to C
+ if (C->parent != b2_nullNode)
+ {
+ if (m_nodes[C->parent].child1 == iA)
+ {
+ m_nodes[C->parent].child1 = iC;
+ }
+ else
+ {
+ b2Assert(m_nodes[C->parent].child2 == iA);
+ m_nodes[C->parent].child2 = iC;
+ }
+ }
+ else
+ {
+ m_root = iC;
+ }
+
+ // Rotate
+ if (F->height > G->height)
+ {
+ C->child2 = iF;
+ A->child2 = iG;
+ G->parent = iA;
+ A->aabb.Combine(B->aabb, G->aabb);
+ C->aabb.Combine(A->aabb, F->aabb);
+
+ A->height = 1 + b2Max(B->height, G->height);
+ C->height = 1 + b2Max(A->height, F->height);
+ }
+ else
+ {
+ C->child2 = iG;
+ A->child2 = iF;
+ F->parent = iA;
+ A->aabb.Combine(B->aabb, F->aabb);
+ C->aabb.Combine(A->aabb, G->aabb);
+
+ A->height = 1 + b2Max(B->height, F->height);
+ C->height = 1 + b2Max(A->height, G->height);
+ }
+
+ return iC;
+ }
+
+ // Rotate B up
+ if (balance < -1)
+ {
+ int32 iD = B->child1;
+ int32 iE = B->child2;
+ b2TreeNode* D = m_nodes + iD;
+ b2TreeNode* E = m_nodes + iE;
+ b2Assert(0 <= iD && iD < m_nodeCapacity);
+ b2Assert(0 <= iE && iE < m_nodeCapacity);
+
+ // Swap A and B
+ B->child1 = iA;
+ B->parent = A->parent;
+ A->parent = iB;
+
+ // A's old parent should point to B
+ if (B->parent != b2_nullNode)
+ {
+ if (m_nodes[B->parent].child1 == iA)
+ {
+ m_nodes[B->parent].child1 = iB;
+ }
+ else
+ {
+ b2Assert(m_nodes[B->parent].child2 == iA);
+ m_nodes[B->parent].child2 = iB;
+ }
+ }
+ else
+ {
+ m_root = iB;
+ }
+
+ // Rotate
+ if (D->height > E->height)
+ {
+ B->child2 = iD;
+ A->child1 = iE;
+ E->parent = iA;
+ A->aabb.Combine(C->aabb, E->aabb);
+ B->aabb.Combine(A->aabb, D->aabb);
+
+ A->height = 1 + b2Max(C->height, E->height);
+ B->height = 1 + b2Max(A->height, D->height);
+ }
+ else
+ {
+ B->child2 = iE;
+ A->child1 = iD;
+ D->parent = iA;
+ A->aabb.Combine(C->aabb, D->aabb);
+ B->aabb.Combine(A->aabb, E->aabb);
+
+ A->height = 1 + b2Max(C->height, D->height);
+ B->height = 1 + b2Max(A->height, E->height);
+ }
+
+ return iB;
+ }
+
+ return iA;
+}
+
+int32 b2DynamicTree::GetHeight() const
+{
+ if (m_root == b2_nullNode)
+ {
+ return 0;
+ }
+
+ return m_nodes[m_root].height;
+}
+
+//
+float b2DynamicTree::GetAreaRatio() const
+{
+ if (m_root == b2_nullNode)
+ {
+ return 0.0f;
+ }
+
+ const b2TreeNode* root = m_nodes + m_root;
+ float rootArea = root->aabb.GetPerimeter();
+
+ float totalArea = 0.0f;
+ for (int32 i = 0; i < m_nodeCapacity; ++i)
+ {
+ const b2TreeNode* node = m_nodes + i;
+ if (node->height < 0)
+ {
+ // Free node in pool
+ continue;
+ }
+
+ totalArea += node->aabb.GetPerimeter();
+ }
+
+ return totalArea / rootArea;
+}
+
+// Compute the height of a sub-tree.
+int32 b2DynamicTree::ComputeHeight(int32 nodeId) const
+{
+ b2Assert(0 <= nodeId && nodeId < m_nodeCapacity);
+ b2TreeNode* node = m_nodes + nodeId;
+
+ if (node->IsLeaf())
+ {
+ return 0;
+ }
+
+ int32 height1 = ComputeHeight(node->child1);
+ int32 height2 = ComputeHeight(node->child2);
+ return 1 + b2Max(height1, height2);
+}
+
+int32 b2DynamicTree::ComputeHeight() const
+{
+ int32 height = ComputeHeight(m_root);
+ return height;
+}
+
+void b2DynamicTree::ValidateStructure(int32 index) const
+{
+ if (index == b2_nullNode)
+ {
+ return;
+ }
+
+ if (index == m_root)
+ {
+ b2Assert(m_nodes[index].parent == b2_nullNode);
+ }
+
+ const b2TreeNode* node = m_nodes + index;
+
+ int32 child1 = node->child1;
+ int32 child2 = node->child2;
+
+ if (node->IsLeaf())
+ {
+ b2Assert(child1 == b2_nullNode);
+ b2Assert(child2 == b2_nullNode);
+ b2Assert(node->height == 0);
+ return;
+ }
+
+ b2Assert(0 <= child1 && child1 < m_nodeCapacity);
+ b2Assert(0 <= child2 && child2 < m_nodeCapacity);
+
+ b2Assert(m_nodes[child1].parent == index);
+ b2Assert(m_nodes[child2].parent == index);
+
+ ValidateStructure(child1);
+ ValidateStructure(child2);
+}
+
+void b2DynamicTree::ValidateMetrics(int32 index) const
+{
+ if (index == b2_nullNode)
+ {
+ return;
+ }
+
+ const b2TreeNode* node = m_nodes + index;
+
+ int32 child1 = node->child1;
+ int32 child2 = node->child2;
+
+ if (node->IsLeaf())
+ {
+ b2Assert(child1 == b2_nullNode);
+ b2Assert(child2 == b2_nullNode);
+ b2Assert(node->height == 0);
+ return;
+ }
+
+ b2Assert(0 <= child1 && child1 < m_nodeCapacity);
+ b2Assert(0 <= child2 && child2 < m_nodeCapacity);
+
+ int32 height1 = m_nodes[child1].height;
+ int32 height2 = m_nodes[child2].height;
+ int32 height;
+ height = 1 + b2Max(height1, height2);
+ b2Assert(node->height == height);
+
+ b2AABB aabb;
+ aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb);
+
+ b2Assert(aabb.lowerBound == node->aabb.lowerBound);
+ b2Assert(aabb.upperBound == node->aabb.upperBound);
+
+ ValidateMetrics(child1);
+ ValidateMetrics(child2);
+}
+
+void b2DynamicTree::Validate() const
+{
+#if defined(b2DEBUG)
+ ValidateStructure(m_root);
+ ValidateMetrics(m_root);
+
+ int32 freeCount = 0;
+ int32 freeIndex = m_freeList;
+ while (freeIndex != b2_nullNode)
+ {
+ b2Assert(0 <= freeIndex && freeIndex < m_nodeCapacity);
+ freeIndex = m_nodes[freeIndex].next;
+ ++freeCount;
+ }
+
+ b2Assert(GetHeight() == ComputeHeight());
+
+ b2Assert(m_nodeCount + freeCount == m_nodeCapacity);
+#endif
+}
+
+int32 b2DynamicTree::GetMaxBalance() const
+{
+ int32 maxBalance = 0;
+ for (int32 i = 0; i < m_nodeCapacity; ++i)
+ {
+ const b2TreeNode* node = m_nodes + i;
+ if (node->height <= 1)
+ {
+ continue;
+ }
+
+ b2Assert(node->IsLeaf() == false);
+
+ int32 child1 = node->child1;
+ int32 child2 = node->child2;
+ int32 balance = b2Abs(m_nodes[child2].height - m_nodes[child1].height);
+ maxBalance = b2Max(maxBalance, balance);
+ }
+
+ return maxBalance;
+}
+
+void b2DynamicTree::RebuildBottomUp()
+{
+ int32* nodes = (int32*)b2Alloc(m_nodeCount * sizeof(int32));
+ int32 count = 0;
+
+ // Build array of leaves. Free the rest.
+ for (int32 i = 0; i < m_nodeCapacity; ++i)
+ {
+ if (m_nodes[i].height < 0)
+ {
+ // free node in pool
+ continue;
+ }
+
+ if (m_nodes[i].IsLeaf())
+ {
+ m_nodes[i].parent = b2_nullNode;
+ nodes[count] = i;
+ ++count;
+ }
+ else
+ {
+ FreeNode(i);
+ }
+ }
+
+ while (count > 1)
+ {
+ float minCost = b2_maxFloat;
+ int32 iMin = -1, jMin = -1;
+ for (int32 i = 0; i < count; ++i)
+ {
+ b2AABB aabbi = m_nodes[nodes[i]].aabb;
+
+ for (int32 j = i + 1; j < count; ++j)
+ {
+ b2AABB aabbj = m_nodes[nodes[j]].aabb;
+ b2AABB b;
+ b.Combine(aabbi, aabbj);
+ float cost = b.GetPerimeter();
+ if (cost < minCost)
+ {
+ iMin = i;
+ jMin = j;
+ minCost = cost;
+ }
+ }
+ }
+
+ int32 index1 = nodes[iMin];
+ int32 index2 = nodes[jMin];
+ b2TreeNode* child1 = m_nodes + index1;
+ b2TreeNode* child2 = m_nodes + index2;
+
+ int32 parentIndex = AllocateNode();
+ b2TreeNode* parent = m_nodes + parentIndex;
+ parent->child1 = index1;
+ parent->child2 = index2;
+ parent->height = 1 + b2Max(child1->height, child2->height);
+ parent->aabb.Combine(child1->aabb, child2->aabb);
+ parent->parent = b2_nullNode;
+
+ child1->parent = parentIndex;
+ child2->parent = parentIndex;
+
+ nodes[jMin] = nodes[count-1];
+ nodes[iMin] = parentIndex;
+ --count;
+ }
+
+ m_root = nodes[0];
+ b2Free(nodes);
+
+ Validate();
+}
+
+void b2DynamicTree::ShiftOrigin(const b2Vec2& newOrigin)
+{
+ // Build array of leaves. Free the rest.
+ for (int32 i = 0; i < m_nodeCapacity; ++i)
+ {
+ m_nodes[i].aabb.lowerBound -= newOrigin;
+ m_nodes[i].aabb.upperBound -= newOrigin;
+ }
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_edge_shape.cpp b/Client/ThirdParty/Box2D/src/collision/b2_edge_shape.cpp
new file mode 100644
index 0000000..65f0606
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_edge_shape.cpp
@@ -0,0 +1,158 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_edge_shape.h"
+#include "box2d/b2_block_allocator.h"
+#include <new>
+
+void b2EdgeShape::SetOneSided(const b2Vec2& v0, const b2Vec2& v1, const b2Vec2& v2, const b2Vec2& v3)
+{
+ m_vertex0 = v0;
+ m_vertex1 = v1;
+ m_vertex2 = v2;
+ m_vertex3 = v3;
+ m_oneSided = true;
+}
+
+void b2EdgeShape::SetTwoSided(const b2Vec2& v1, const b2Vec2& v2)
+{
+ m_vertex1 = v1;
+ m_vertex2 = v2;
+ m_oneSided = false;
+}
+
+b2Shape* b2EdgeShape::Clone(b2BlockAllocator* allocator) const
+{
+ void* mem = allocator->Allocate(sizeof(b2EdgeShape));
+ b2EdgeShape* clone = new (mem) b2EdgeShape;
+ *clone = *this;
+ return clone;
+}
+
+int32 b2EdgeShape::GetChildCount() const
+{
+ return 1;
+}
+
+bool b2EdgeShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
+{
+ B2_NOT_USED(xf);
+ B2_NOT_USED(p);
+ return false;
+}
+
+// p = p1 + t * d
+// v = v1 + s * e
+// p1 + t * d = v1 + s * e
+// s * e - t * d = p1 - v1
+bool b2EdgeShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& xf, int32 childIndex) const
+{
+ B2_NOT_USED(childIndex);
+
+ // Put the ray into the edge's frame of reference.
+ b2Vec2 p1 = b2MulT(xf.q, input.p1 - xf.p);
+ b2Vec2 p2 = b2MulT(xf.q, input.p2 - xf.p);
+ b2Vec2 d = p2 - p1;
+
+ b2Vec2 v1 = m_vertex1;
+ b2Vec2 v2 = m_vertex2;
+ b2Vec2 e = v2 - v1;
+
+ // Normal points to the right, looking from v1 at v2
+ b2Vec2 normal(e.y, -e.x);
+ normal.Normalize();
+
+ // q = p1 + t * d
+ // dot(normal, q - v1) = 0
+ // dot(normal, p1 - v1) + t * dot(normal, d) = 0
+ float numerator = b2Dot(normal, v1 - p1);
+ if (m_oneSided && numerator > 0.0f)
+ {
+ return false;
+ }
+
+ float denominator = b2Dot(normal, d);
+
+ if (denominator == 0.0f)
+ {
+ return false;
+ }
+
+ float t = numerator / denominator;
+ if (t < 0.0f || input.maxFraction < t)
+ {
+ return false;
+ }
+
+ b2Vec2 q = p1 + t * d;
+
+ // q = v1 + s * r
+ // s = dot(q - v1, r) / dot(r, r)
+ b2Vec2 r = v2 - v1;
+ float rr = b2Dot(r, r);
+ if (rr == 0.0f)
+ {
+ return false;
+ }
+
+ float s = b2Dot(q - v1, r) / rr;
+ if (s < 0.0f || 1.0f < s)
+ {
+ return false;
+ }
+
+ output->fraction = t;
+ if (numerator > 0.0f)
+ {
+ output->normal = -b2Mul(xf.q, normal);
+ }
+ else
+ {
+ output->normal = b2Mul(xf.q, normal);
+ }
+ return true;
+}
+
+void b2EdgeShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
+{
+ B2_NOT_USED(childIndex);
+
+ b2Vec2 v1 = b2Mul(xf, m_vertex1);
+ b2Vec2 v2 = b2Mul(xf, m_vertex2);
+
+ b2Vec2 lower = b2Min(v1, v2);
+ b2Vec2 upper = b2Max(v1, v2);
+
+ b2Vec2 r(m_radius, m_radius);
+ aabb->lowerBound = lower - r;
+ aabb->upperBound = upper + r;
+}
+
+void b2EdgeShape::ComputeMass(b2MassData* massData, float density) const
+{
+ B2_NOT_USED(density);
+
+ massData->mass = 0.0f;
+ massData->center = 0.5f * (m_vertex1 + m_vertex2);
+ massData->I = 0.0f;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_polygon_shape.cpp b/Client/ThirdParty/Box2D/src/collision/b2_polygon_shape.cpp
new file mode 100644
index 0000000..368fb80
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_polygon_shape.cpp
@@ -0,0 +1,459 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_polygon_shape.h"
+#include "box2d/b2_block_allocator.h"
+
+#include <new>
+
+b2Shape* b2PolygonShape::Clone(b2BlockAllocator* allocator) const
+{
+ void* mem = allocator->Allocate(sizeof(b2PolygonShape));
+ b2PolygonShape* clone = new (mem) b2PolygonShape;
+ *clone = *this;
+ return clone;
+}
+
+void b2PolygonShape::SetAsBox(float hx, float hy)
+{
+ m_count = 4;
+ m_vertices[0].Set(-hx, -hy);
+ m_vertices[1].Set( hx, -hy);
+ m_vertices[2].Set( hx, hy);
+ m_vertices[3].Set(-hx, hy);
+ m_normals[0].Set(0.0f, -1.0f);
+ m_normals[1].Set(1.0f, 0.0f);
+ m_normals[2].Set(0.0f, 1.0f);
+ m_normals[3].Set(-1.0f, 0.0f);
+ m_centroid.SetZero();
+}
+
+void b2PolygonShape::SetAsBox(float hx, float hy, const b2Vec2& center, float angle)
+{
+ m_count = 4;
+ m_vertices[0].Set(-hx, -hy);
+ m_vertices[1].Set( hx, -hy);
+ m_vertices[2].Set( hx, hy);
+ m_vertices[3].Set(-hx, hy);
+ m_normals[0].Set(0.0f, -1.0f);
+ m_normals[1].Set(1.0f, 0.0f);
+ m_normals[2].Set(0.0f, 1.0f);
+ m_normals[3].Set(-1.0f, 0.0f);
+ m_centroid = center;
+
+ b2Transform xf;
+ xf.p = center;
+ xf.q.Set(angle);
+
+ // Transform vertices and normals.
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ m_vertices[i] = b2Mul(xf, m_vertices[i]);
+ m_normals[i] = b2Mul(xf.q, m_normals[i]);
+ }
+}
+
+int32 b2PolygonShape::GetChildCount() const
+{
+ return 1;
+}
+
+static b2Vec2 ComputeCentroid(const b2Vec2* vs, int32 count)
+{
+ b2Assert(count >= 3);
+
+ b2Vec2 c(0.0f, 0.0f);
+ float area = 0.0f;
+
+ // Get a reference point for forming triangles.
+ // Use the first vertex to reduce round-off errors.
+ b2Vec2 s = vs[0];
+
+ const float inv3 = 1.0f / 3.0f;
+
+ for (int32 i = 0; i < count; ++i)
+ {
+ // Triangle vertices.
+ b2Vec2 p1 = vs[0] - s;
+ b2Vec2 p2 = vs[i] - s;
+ b2Vec2 p3 = i + 1 < count ? vs[i+1] - s : vs[0] - s;
+
+ b2Vec2 e1 = p2 - p1;
+ b2Vec2 e2 = p3 - p1;
+
+ float D = b2Cross(e1, e2);
+
+ float triangleArea = 0.5f * D;
+ area += triangleArea;
+
+ // Area weighted centroid
+ c += triangleArea * inv3 * (p1 + p2 + p3);
+ }
+
+ // Centroid
+ b2Assert(area > b2_epsilon);
+ c = (1.0f / area) * c + s;
+ return c;
+}
+
+void b2PolygonShape::Set(const b2Vec2* vertices, int32 count)
+{
+ b2Assert(3 <= count && count <= b2_maxPolygonVertices);
+ if (count < 3)
+ {
+ SetAsBox(1.0f, 1.0f);
+ return;
+ }
+
+ int32 n = b2Min(count, b2_maxPolygonVertices);
+
+ // Perform welding and copy vertices into local buffer.
+ b2Vec2 ps[b2_maxPolygonVertices];
+ int32 tempCount = 0;
+ for (int32 i = 0; i < n; ++i)
+ {
+ b2Vec2 v = vertices[i];
+
+ bool unique = true;
+ for (int32 j = 0; j < tempCount; ++j)
+ {
+ if (b2DistanceSquared(v, ps[j]) < ((0.5f * b2_linearSlop) * (0.5f * b2_linearSlop)))
+ {
+ unique = false;
+ break;
+ }
+ }
+
+ if (unique)
+ {
+ ps[tempCount++] = v;
+ }
+ }
+
+ n = tempCount;
+ if (n < 3)
+ {
+ // Polygon is degenerate.
+ b2Assert(false);
+ SetAsBox(1.0f, 1.0f);
+ return;
+ }
+
+ // Create the convex hull using the Gift wrapping algorithm
+ // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
+
+ // Find the right most point on the hull
+ int32 i0 = 0;
+ float x0 = ps[0].x;
+ for (int32 i = 1; i < n; ++i)
+ {
+ float x = ps[i].x;
+ if (x > x0 || (x == x0 && ps[i].y < ps[i0].y))
+ {
+ i0 = i;
+ x0 = x;
+ }
+ }
+
+ int32 hull[b2_maxPolygonVertices];
+ int32 m = 0;
+ int32 ih = i0;
+
+ for (;;)
+ {
+ b2Assert(m < b2_maxPolygonVertices);
+ hull[m] = ih;
+
+ int32 ie = 0;
+ for (int32 j = 1; j < n; ++j)
+ {
+ if (ie == ih)
+ {
+ ie = j;
+ continue;
+ }
+
+ b2Vec2 r = ps[ie] - ps[hull[m]];
+ b2Vec2 v = ps[j] - ps[hull[m]];
+ float c = b2Cross(r, v);
+ if (c < 0.0f)
+ {
+ ie = j;
+ }
+
+ // Collinearity check
+ if (c == 0.0f && v.LengthSquared() > r.LengthSquared())
+ {
+ ie = j;
+ }
+ }
+
+ ++m;
+ ih = ie;
+
+ if (ie == i0)
+ {
+ break;
+ }
+ }
+
+ if (m < 3)
+ {
+ // Polygon is degenerate.
+ b2Assert(false);
+ SetAsBox(1.0f, 1.0f);
+ return;
+ }
+
+ m_count = m;
+
+ // Copy vertices.
+ for (int32 i = 0; i < m; ++i)
+ {
+ m_vertices[i] = ps[hull[i]];
+ }
+
+ // Compute normals. Ensure the edges have non-zero length.
+ for (int32 i = 0; i < m; ++i)
+ {
+ int32 i1 = i;
+ int32 i2 = i + 1 < m ? i + 1 : 0;
+ b2Vec2 edge = m_vertices[i2] - m_vertices[i1];
+ b2Assert(edge.LengthSquared() > b2_epsilon * b2_epsilon);
+ m_normals[i] = b2Cross(edge, 1.0f);
+ m_normals[i].Normalize();
+ }
+
+ // Compute the polygon centroid.
+ m_centroid = ComputeCentroid(m_vertices, m);
+}
+
+bool b2PolygonShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
+{
+ b2Vec2 pLocal = b2MulT(xf.q, p - xf.p);
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ float dot = b2Dot(m_normals[i], pLocal - m_vertices[i]);
+ if (dot > 0.0f)
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool b2PolygonShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
+ const b2Transform& xf, int32 childIndex) const
+{
+ B2_NOT_USED(childIndex);
+
+ // Put the ray into the polygon's frame of reference.
+ b2Vec2 p1 = b2MulT(xf.q, input.p1 - xf.p);
+ b2Vec2 p2 = b2MulT(xf.q, input.p2 - xf.p);
+ b2Vec2 d = p2 - p1;
+
+ float lower = 0.0f, upper = input.maxFraction;
+
+ int32 index = -1;
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ // p = p1 + a * d
+ // dot(normal, p - v) = 0
+ // dot(normal, p1 - v) + a * dot(normal, d) = 0
+ float numerator = b2Dot(m_normals[i], m_vertices[i] - p1);
+ float denominator = b2Dot(m_normals[i], d);
+
+ if (denominator == 0.0f)
+ {
+ if (numerator < 0.0f)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ // Note: we want this predicate without division:
+ // lower < numerator / denominator, where denominator < 0
+ // Since denominator < 0, we have to flip the inequality:
+ // lower < numerator / denominator <==> denominator * lower > numerator.
+ if (denominator < 0.0f && numerator < lower * denominator)
+ {
+ // Increase lower.
+ // The segment enters this half-space.
+ lower = numerator / denominator;
+ index = i;
+ }
+ else if (denominator > 0.0f && numerator < upper * denominator)
+ {
+ // Decrease upper.
+ // The segment exits this half-space.
+ upper = numerator / denominator;
+ }
+ }
+
+ // The use of epsilon here causes the assert on lower to trip
+ // in some cases. Apparently the use of epsilon was to make edge
+ // shapes work, but now those are handled separately.
+ //if (upper < lower - b2_epsilon)
+ if (upper < lower)
+ {
+ return false;
+ }
+ }
+
+ b2Assert(0.0f <= lower && lower <= input.maxFraction);
+
+ if (index >= 0)
+ {
+ output->fraction = lower;
+ output->normal = b2Mul(xf.q, m_normals[index]);
+ return true;
+ }
+
+ return false;
+}
+
+void b2PolygonShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
+{
+ B2_NOT_USED(childIndex);
+
+ b2Vec2 lower = b2Mul(xf, m_vertices[0]);
+ b2Vec2 upper = lower;
+
+ for (int32 i = 1; i < m_count; ++i)
+ {
+ b2Vec2 v = b2Mul(xf, m_vertices[i]);
+ lower = b2Min(lower, v);
+ upper = b2Max(upper, v);
+ }
+
+ b2Vec2 r(m_radius, m_radius);
+ aabb->lowerBound = lower - r;
+ aabb->upperBound = upper + r;
+}
+
+void b2PolygonShape::ComputeMass(b2MassData* massData, float density) const
+{
+ // Polygon mass, centroid, and inertia.
+ // Let rho be the polygon density in mass per unit area.
+ // Then:
+ // mass = rho * int(dA)
+ // centroid.x = (1/mass) * rho * int(x * dA)
+ // centroid.y = (1/mass) * rho * int(y * dA)
+ // I = rho * int((x*x + y*y) * dA)
+ //
+ // We can compute these integrals by summing all the integrals
+ // for each triangle of the polygon. To evaluate the integral
+ // for a single triangle, we make a change of variables to
+ // the (u,v) coordinates of the triangle:
+ // x = x0 + e1x * u + e2x * v
+ // y = y0 + e1y * u + e2y * v
+ // where 0 <= u && 0 <= v && u + v <= 1.
+ //
+ // We integrate u from [0,1-v] and then v from [0,1].
+ // We also need to use the Jacobian of the transformation:
+ // D = cross(e1, e2)
+ //
+ // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)
+ //
+ // The rest of the derivation is handled by computer algebra.
+
+ b2Assert(m_count >= 3);
+
+ b2Vec2 center(0.0f, 0.0f);
+ float area = 0.0f;
+ float I = 0.0f;
+
+ // Get a reference point for forming triangles.
+ // Use the first vertex to reduce round-off errors.
+ b2Vec2 s = m_vertices[0];
+
+ const float k_inv3 = 1.0f / 3.0f;
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ // Triangle vertices.
+ b2Vec2 e1 = m_vertices[i] - s;
+ b2Vec2 e2 = i + 1 < m_count ? m_vertices[i+1] - s : m_vertices[0] - s;
+
+ float D = b2Cross(e1, e2);
+
+ float triangleArea = 0.5f * D;
+ area += triangleArea;
+
+ // Area weighted centroid
+ center += triangleArea * k_inv3 * (e1 + e2);
+
+ float ex1 = e1.x, ey1 = e1.y;
+ float ex2 = e2.x, ey2 = e2.y;
+
+ float intx2 = ex1*ex1 + ex2*ex1 + ex2*ex2;
+ float inty2 = ey1*ey1 + ey2*ey1 + ey2*ey2;
+
+ I += (0.25f * k_inv3 * D) * (intx2 + inty2);
+ }
+
+ // Total mass
+ massData->mass = density * area;
+
+ // Center of mass
+ b2Assert(area > b2_epsilon);
+ center *= 1.0f / area;
+ massData->center = center + s;
+
+ // Inertia tensor relative to the local origin (point s).
+ massData->I = density * I;
+
+ // Shift to center of mass then to original body origin.
+ massData->I += massData->mass * (b2Dot(massData->center, massData->center) - b2Dot(center, center));
+}
+
+bool b2PolygonShape::Validate() const
+{
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ int32 i1 = i;
+ int32 i2 = i < m_count - 1 ? i1 + 1 : 0;
+ b2Vec2 p = m_vertices[i1];
+ b2Vec2 e = m_vertices[i2] - p;
+
+ for (int32 j = 0; j < m_count; ++j)
+ {
+ if (j == i1 || j == i2)
+ {
+ continue;
+ }
+
+ b2Vec2 v = m_vertices[j] - p;
+ float c = b2Cross(e, v);
+ if (c < 0.0f)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
diff --git a/Client/ThirdParty/Box2D/src/collision/b2_time_of_impact.cpp b/Client/ThirdParty/Box2D/src/collision/b2_time_of_impact.cpp
new file mode 100644
index 0000000..7a1011b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/collision/b2_time_of_impact.cpp
@@ -0,0 +1,490 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_collision.h"
+#include "box2d/b2_distance.h"
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_polygon_shape.h"
+#include "box2d/b2_time_of_impact.h"
+#include "box2d/b2_timer.h"
+
+#include <stdio.h>
+
+B2_API float b2_toiTime, b2_toiMaxTime;
+B2_API int32 b2_toiCalls, b2_toiIters, b2_toiMaxIters;
+B2_API int32 b2_toiRootIters, b2_toiMaxRootIters;
+
+//
+struct b2SeparationFunction
+{
+ enum Type
+ {
+ e_points,
+ e_faceA,
+ e_faceB
+ };
+
+ // TODO_ERIN might not need to return the separation
+
+ float Initialize(const b2SimplexCache* cache,
+ const b2DistanceProxy* proxyA, const b2Sweep& sweepA,
+ const b2DistanceProxy* proxyB, const b2Sweep& sweepB,
+ float t1)
+ {
+ m_proxyA = proxyA;
+ m_proxyB = proxyB;
+ int32 count = cache->count;
+ b2Assert(0 < count && count < 3);
+
+ m_sweepA = sweepA;
+ m_sweepB = sweepB;
+
+ b2Transform xfA, xfB;
+ m_sweepA.GetTransform(&xfA, t1);
+ m_sweepB.GetTransform(&xfB, t1);
+
+ if (count == 1)
+ {
+ m_type = e_points;
+ b2Vec2 localPointA = m_proxyA->GetVertex(cache->indexA[0]);
+ b2Vec2 localPointB = m_proxyB->GetVertex(cache->indexB[0]);
+ b2Vec2 pointA = b2Mul(xfA, localPointA);
+ b2Vec2 pointB = b2Mul(xfB, localPointB);
+ m_axis = pointB - pointA;
+ float s = m_axis.Normalize();
+ return s;
+ }
+ else if (cache->indexA[0] == cache->indexA[1])
+ {
+ // Two points on B and one on A.
+ m_type = e_faceB;
+ b2Vec2 localPointB1 = proxyB->GetVertex(cache->indexB[0]);
+ b2Vec2 localPointB2 = proxyB->GetVertex(cache->indexB[1]);
+
+ m_axis = b2Cross(localPointB2 - localPointB1, 1.0f);
+ m_axis.Normalize();
+ b2Vec2 normal = b2Mul(xfB.q, m_axis);
+
+ m_localPoint = 0.5f * (localPointB1 + localPointB2);
+ b2Vec2 pointB = b2Mul(xfB, m_localPoint);
+
+ b2Vec2 localPointA = proxyA->GetVertex(cache->indexA[0]);
+ b2Vec2 pointA = b2Mul(xfA, localPointA);
+
+ float s = b2Dot(pointA - pointB, normal);
+ if (s < 0.0f)
+ {
+ m_axis = -m_axis;
+ s = -s;
+ }
+ return s;
+ }
+ else
+ {
+ // Two points on A and one or two points on B.
+ m_type = e_faceA;
+ b2Vec2 localPointA1 = m_proxyA->GetVertex(cache->indexA[0]);
+ b2Vec2 localPointA2 = m_proxyA->GetVertex(cache->indexA[1]);
+
+ m_axis = b2Cross(localPointA2 - localPointA1, 1.0f);
+ m_axis.Normalize();
+ b2Vec2 normal = b2Mul(xfA.q, m_axis);
+
+ m_localPoint = 0.5f * (localPointA1 + localPointA2);
+ b2Vec2 pointA = b2Mul(xfA, m_localPoint);
+
+ b2Vec2 localPointB = m_proxyB->GetVertex(cache->indexB[0]);
+ b2Vec2 pointB = b2Mul(xfB, localPointB);
+
+ float s = b2Dot(pointB - pointA, normal);
+ if (s < 0.0f)
+ {
+ m_axis = -m_axis;
+ s = -s;
+ }
+ return s;
+ }
+ }
+
+ //
+ float FindMinSeparation(int32* indexA, int32* indexB, float t) const
+ {
+ b2Transform xfA, xfB;
+ m_sweepA.GetTransform(&xfA, t);
+ m_sweepB.GetTransform(&xfB, t);
+
+ switch (m_type)
+ {
+ case e_points:
+ {
+ b2Vec2 axisA = b2MulT(xfA.q, m_axis);
+ b2Vec2 axisB = b2MulT(xfB.q, -m_axis);
+
+ *indexA = m_proxyA->GetSupport(axisA);
+ *indexB = m_proxyB->GetSupport(axisB);
+
+ b2Vec2 localPointA = m_proxyA->GetVertex(*indexA);
+ b2Vec2 localPointB = m_proxyB->GetVertex(*indexB);
+
+ b2Vec2 pointA = b2Mul(xfA, localPointA);
+ b2Vec2 pointB = b2Mul(xfB, localPointB);
+
+ float separation = b2Dot(pointB - pointA, m_axis);
+ return separation;
+ }
+
+ case e_faceA:
+ {
+ b2Vec2 normal = b2Mul(xfA.q, m_axis);
+ b2Vec2 pointA = b2Mul(xfA, m_localPoint);
+
+ b2Vec2 axisB = b2MulT(xfB.q, -normal);
+
+ *indexA = -1;
+ *indexB = m_proxyB->GetSupport(axisB);
+
+ b2Vec2 localPointB = m_proxyB->GetVertex(*indexB);
+ b2Vec2 pointB = b2Mul(xfB, localPointB);
+
+ float separation = b2Dot(pointB - pointA, normal);
+ return separation;
+ }
+
+ case e_faceB:
+ {
+ b2Vec2 normal = b2Mul(xfB.q, m_axis);
+ b2Vec2 pointB = b2Mul(xfB, m_localPoint);
+
+ b2Vec2 axisA = b2MulT(xfA.q, -normal);
+
+ *indexB = -1;
+ *indexA = m_proxyA->GetSupport(axisA);
+
+ b2Vec2 localPointA = m_proxyA->GetVertex(*indexA);
+ b2Vec2 pointA = b2Mul(xfA, localPointA);
+
+ float separation = b2Dot(pointA - pointB, normal);
+ return separation;
+ }
+
+ default:
+ b2Assert(false);
+ *indexA = -1;
+ *indexB = -1;
+ return 0.0f;
+ }
+ }
+
+ //
+ float Evaluate(int32 indexA, int32 indexB, float t) const
+ {
+ b2Transform xfA, xfB;
+ m_sweepA.GetTransform(&xfA, t);
+ m_sweepB.GetTransform(&xfB, t);
+
+ switch (m_type)
+ {
+ case e_points:
+ {
+ b2Vec2 localPointA = m_proxyA->GetVertex(indexA);
+ b2Vec2 localPointB = m_proxyB->GetVertex(indexB);
+
+ b2Vec2 pointA = b2Mul(xfA, localPointA);
+ b2Vec2 pointB = b2Mul(xfB, localPointB);
+ float separation = b2Dot(pointB - pointA, m_axis);
+
+ return separation;
+ }
+
+ case e_faceA:
+ {
+ b2Vec2 normal = b2Mul(xfA.q, m_axis);
+ b2Vec2 pointA = b2Mul(xfA, m_localPoint);
+
+ b2Vec2 localPointB = m_proxyB->GetVertex(indexB);
+ b2Vec2 pointB = b2Mul(xfB, localPointB);
+
+ float separation = b2Dot(pointB - pointA, normal);
+ return separation;
+ }
+
+ case e_faceB:
+ {
+ b2Vec2 normal = b2Mul(xfB.q, m_axis);
+ b2Vec2 pointB = b2Mul(xfB, m_localPoint);
+
+ b2Vec2 localPointA = m_proxyA->GetVertex(indexA);
+ b2Vec2 pointA = b2Mul(xfA, localPointA);
+
+ float separation = b2Dot(pointA - pointB, normal);
+ return separation;
+ }
+
+ default:
+ b2Assert(false);
+ return 0.0f;
+ }
+ }
+
+ const b2DistanceProxy* m_proxyA;
+ const b2DistanceProxy* m_proxyB;
+ b2Sweep m_sweepA, m_sweepB;
+ Type m_type;
+ b2Vec2 m_localPoint;
+ b2Vec2 m_axis;
+};
+
+// CCD via the local separating axis method. This seeks progression
+// by computing the largest time at which separation is maintained.
+void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input)
+{
+ b2Timer timer;
+
+ ++b2_toiCalls;
+
+ output->state = b2TOIOutput::e_unknown;
+ output->t = input->tMax;
+
+ const b2DistanceProxy* proxyA = &input->proxyA;
+ const b2DistanceProxy* proxyB = &input->proxyB;
+
+ b2Sweep sweepA = input->sweepA;
+ b2Sweep sweepB = input->sweepB;
+
+ // Large rotations can make the root finder fail, so we normalize the
+ // sweep angles.
+ sweepA.Normalize();
+ sweepB.Normalize();
+
+ float tMax = input->tMax;
+
+ float totalRadius = proxyA->m_radius + proxyB->m_radius;
+ float target = b2Max(b2_linearSlop, totalRadius - 3.0f * b2_linearSlop);
+ float tolerance = 0.25f * b2_linearSlop;
+ b2Assert(target > tolerance);
+
+ float t1 = 0.0f;
+ const int32 k_maxIterations = 20; // TODO_ERIN b2Settings
+ int32 iter = 0;
+
+ // Prepare input for distance query.
+ b2SimplexCache cache;
+ cache.count = 0;
+ b2DistanceInput distanceInput;
+ distanceInput.proxyA = input->proxyA;
+ distanceInput.proxyB = input->proxyB;
+ distanceInput.useRadii = false;
+
+ // The outer loop progressively attempts to compute new separating axes.
+ // This loop terminates when an axis is repeated (no progress is made).
+ for(;;)
+ {
+ b2Transform xfA, xfB;
+ sweepA.GetTransform(&xfA, t1);
+ sweepB.GetTransform(&xfB, t1);
+
+ // Get the distance between shapes. We can also use the results
+ // to get a separating axis.
+ distanceInput.transformA = xfA;
+ distanceInput.transformB = xfB;
+ b2DistanceOutput distanceOutput;
+ b2Distance(&distanceOutput, &cache, &distanceInput);
+
+ // If the shapes are overlapped, we give up on continuous collision.
+ if (distanceOutput.distance <= 0.0f)
+ {
+ // Failure!
+ output->state = b2TOIOutput::e_overlapped;
+ output->t = 0.0f;
+ break;
+ }
+
+ if (distanceOutput.distance < target + tolerance)
+ {
+ // Victory!
+ output->state = b2TOIOutput::e_touching;
+ output->t = t1;
+ break;
+ }
+
+ // Initialize the separating axis.
+ b2SeparationFunction fcn;
+ fcn.Initialize(&cache, proxyA, sweepA, proxyB, sweepB, t1);
+#if 0
+ // Dump the curve seen by the root finder
+ {
+ const int32 N = 100;
+ float dx = 1.0f / N;
+ float xs[N+1];
+ float fs[N+1];
+
+ float x = 0.0f;
+
+ for (int32 i = 0; i <= N; ++i)
+ {
+ sweepA.GetTransform(&xfA, x);
+ sweepB.GetTransform(&xfB, x);
+ float f = fcn.Evaluate(xfA, xfB) - target;
+
+ printf("%g %g\n", x, f);
+
+ xs[i] = x;
+ fs[i] = f;
+
+ x += dx;
+ }
+ }
+#endif
+
+ // Compute the TOI on the separating axis. We do this by successively
+ // resolving the deepest point. This loop is bounded by the number of vertices.
+ bool done = false;
+ float t2 = tMax;
+ int32 pushBackIter = 0;
+ for (;;)
+ {
+ // Find the deepest point at t2. Store the witness point indices.
+ int32 indexA, indexB;
+ float s2 = fcn.FindMinSeparation(&indexA, &indexB, t2);
+
+ // Is the final configuration separated?
+ if (s2 > target + tolerance)
+ {
+ // Victory!
+ output->state = b2TOIOutput::e_separated;
+ output->t = tMax;
+ done = true;
+ break;
+ }
+
+ // Has the separation reached tolerance?
+ if (s2 > target - tolerance)
+ {
+ // Advance the sweeps
+ t1 = t2;
+ break;
+ }
+
+ // Compute the initial separation of the witness points.
+ float s1 = fcn.Evaluate(indexA, indexB, t1);
+
+ // Check for initial overlap. This might happen if the root finder
+ // runs out of iterations.
+ if (s1 < target - tolerance)
+ {
+ output->state = b2TOIOutput::e_failed;
+ output->t = t1;
+ done = true;
+ break;
+ }
+
+ // Check for touching
+ if (s1 <= target + tolerance)
+ {
+ // Victory! t1 should hold the TOI (could be 0.0).
+ output->state = b2TOIOutput::e_touching;
+ output->t = t1;
+ done = true;
+ break;
+ }
+
+ // Compute 1D root of: f(x) - target = 0
+ int32 rootIterCount = 0;
+ float a1 = t1, a2 = t2;
+ for (;;)
+ {
+ // Use a mix of the secant rule and bisection.
+ float t;
+ if (rootIterCount & 1)
+ {
+ // Secant rule to improve convergence.
+ t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);
+ }
+ else
+ {
+ // Bisection to guarantee progress.
+ t = 0.5f * (a1 + a2);
+ }
+
+ ++rootIterCount;
+ ++b2_toiRootIters;
+
+ float s = fcn.Evaluate(indexA, indexB, t);
+
+ if (b2Abs(s - target) < tolerance)
+ {
+ // t2 holds a tentative value for t1
+ t2 = t;
+ break;
+ }
+
+ // Ensure we continue to bracket the root.
+ if (s > target)
+ {
+ a1 = t;
+ s1 = s;
+ }
+ else
+ {
+ a2 = t;
+ s2 = s;
+ }
+
+ if (rootIterCount == 50)
+ {
+ break;
+ }
+ }
+
+ b2_toiMaxRootIters = b2Max(b2_toiMaxRootIters, rootIterCount);
+
+ ++pushBackIter;
+
+ if (pushBackIter == b2_maxPolygonVertices)
+ {
+ break;
+ }
+ }
+
+ ++iter;
+ ++b2_toiIters;
+
+ if (done)
+ {
+ break;
+ }
+
+ if (iter == k_maxIterations)
+ {
+ // Root finder got stuck. Semi-victory.
+ output->state = b2TOIOutput::e_failed;
+ output->t = t1;
+ break;
+ }
+ }
+
+ b2_toiMaxIters = b2Max(b2_toiMaxIters, iter);
+
+ float time = timer.GetMilliseconds();
+ b2_toiMaxTime = b2Max(b2_toiMaxTime, time);
+ b2_toiTime += time;
+}
diff --git a/Client/ThirdParty/Box2D/src/common/b2_block_allocator.cpp b/Client/ThirdParty/Box2D/src/common/b2_block_allocator.cpp
new file mode 100644
index 0000000..595f2ad
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/common/b2_block_allocator.cpp
@@ -0,0 +1,230 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_block_allocator.h"
+#include <limits.h>
+#include <string.h>
+#include <stddef.h>
+
+static const int32 b2_chunkSize = 16 * 1024;
+static const int32 b2_maxBlockSize = 640;
+static const int32 b2_chunkArrayIncrement = 128;
+
+// These are the supported object sizes. Actual allocations are rounded up the next size.
+static const int32 b2_blockSizes[b2_blockSizeCount] =
+{
+ 16, // 0
+ 32, // 1
+ 64, // 2
+ 96, // 3
+ 128, // 4
+ 160, // 5
+ 192, // 6
+ 224, // 7
+ 256, // 8
+ 320, // 9
+ 384, // 10
+ 448, // 11
+ 512, // 12
+ 640, // 13
+};
+
+// This maps an arbitrary allocation size to a suitable slot in b2_blockSizes.
+struct b2SizeMap
+{
+ b2SizeMap()
+ {
+ int32 j = 0;
+ values[0] = 0;
+ for (int32 i = 1; i <= b2_maxBlockSize; ++i)
+ {
+ b2Assert(j < b2_blockSizeCount);
+ if (i <= b2_blockSizes[j])
+ {
+ values[i] = (uint8)j;
+ }
+ else
+ {
+ ++j;
+ values[i] = (uint8)j;
+ }
+ }
+ }
+
+ uint8 values[b2_maxBlockSize + 1];
+};
+
+static const b2SizeMap b2_sizeMap;
+
+struct b2Chunk
+{
+ int32 blockSize;
+ b2Block* blocks;
+};
+
+struct b2Block
+{
+ b2Block* next;
+};
+
+b2BlockAllocator::b2BlockAllocator()
+{
+ b2Assert(b2_blockSizeCount < UCHAR_MAX);
+
+ m_chunkSpace = b2_chunkArrayIncrement;
+ m_chunkCount = 0;
+ m_chunks = (b2Chunk*)b2Alloc(m_chunkSpace * sizeof(b2Chunk));
+
+ memset(m_chunks, 0, m_chunkSpace * sizeof(b2Chunk));
+ memset(m_freeLists, 0, sizeof(m_freeLists));
+}
+
+b2BlockAllocator::~b2BlockAllocator()
+{
+ for (int32 i = 0; i < m_chunkCount; ++i)
+ {
+ b2Free(m_chunks[i].blocks);
+ }
+
+ b2Free(m_chunks);
+}
+
+void* b2BlockAllocator::Allocate(int32 size)
+{
+ if (size == 0)
+ {
+ return nullptr;
+ }
+
+ b2Assert(0 < size);
+
+ if (size > b2_maxBlockSize)
+ {
+ return b2Alloc(size);
+ }
+
+ int32 index = b2_sizeMap.values[size];
+ b2Assert(0 <= index && index < b2_blockSizeCount);
+
+ if (m_freeLists[index])
+ {
+ b2Block* block = m_freeLists[index];
+ m_freeLists[index] = block->next;
+ return block;
+ }
+ else
+ {
+ if (m_chunkCount == m_chunkSpace)
+ {
+ b2Chunk* oldChunks = m_chunks;
+ m_chunkSpace += b2_chunkArrayIncrement;
+ m_chunks = (b2Chunk*)b2Alloc(m_chunkSpace * sizeof(b2Chunk));
+ memcpy(m_chunks, oldChunks, m_chunkCount * sizeof(b2Chunk));
+ memset(m_chunks + m_chunkCount, 0, b2_chunkArrayIncrement * sizeof(b2Chunk));
+ b2Free(oldChunks);
+ }
+
+ b2Chunk* chunk = m_chunks + m_chunkCount;
+ chunk->blocks = (b2Block*)b2Alloc(b2_chunkSize);
+#if defined(_DEBUG)
+ memset(chunk->blocks, 0xcd, b2_chunkSize);
+#endif
+ int32 blockSize = b2_blockSizes[index];
+ chunk->blockSize = blockSize;
+ int32 blockCount = b2_chunkSize / blockSize;
+ b2Assert(blockCount * blockSize <= b2_chunkSize);
+ for (int32 i = 0; i < blockCount - 1; ++i)
+ {
+ b2Block* block = (b2Block*)((int8*)chunk->blocks + blockSize * i);
+ b2Block* next = (b2Block*)((int8*)chunk->blocks + blockSize * (i + 1));
+ block->next = next;
+ }
+ b2Block* last = (b2Block*)((int8*)chunk->blocks + blockSize * (blockCount - 1));
+ last->next = nullptr;
+
+ m_freeLists[index] = chunk->blocks->next;
+ ++m_chunkCount;
+
+ return chunk->blocks;
+ }
+}
+
+void b2BlockAllocator::Free(void* p, int32 size)
+{
+ if (size == 0)
+ {
+ return;
+ }
+
+ b2Assert(0 < size);
+
+ if (size > b2_maxBlockSize)
+ {
+ b2Free(p);
+ return;
+ }
+
+ int32 index = b2_sizeMap.values[size];
+ b2Assert(0 <= index && index < b2_blockSizeCount);
+
+#if defined(_DEBUG)
+ // Verify the memory address and size is valid.
+ int32 blockSize = b2_blockSizes[index];
+ bool found = false;
+ for (int32 i = 0; i < m_chunkCount; ++i)
+ {
+ b2Chunk* chunk = m_chunks + i;
+ if (chunk->blockSize != blockSize)
+ {
+ b2Assert( (int8*)p + blockSize <= (int8*)chunk->blocks ||
+ (int8*)chunk->blocks + b2_chunkSize <= (int8*)p);
+ }
+ else
+ {
+ if ((int8*)chunk->blocks <= (int8*)p && (int8*)p + blockSize <= (int8*)chunk->blocks + b2_chunkSize)
+ {
+ found = true;
+ }
+ }
+ }
+
+ b2Assert(found);
+
+ memset(p, 0xfd, blockSize);
+#endif
+
+ b2Block* block = (b2Block*)p;
+ block->next = m_freeLists[index];
+ m_freeLists[index] = block;
+}
+
+void b2BlockAllocator::Clear()
+{
+ for (int32 i = 0; i < m_chunkCount; ++i)
+ {
+ b2Free(m_chunks[i].blocks);
+ }
+
+ m_chunkCount = 0;
+ memset(m_chunks, 0, m_chunkSpace * sizeof(b2Chunk));
+ memset(m_freeLists, 0, sizeof(m_freeLists));
+}
diff --git a/Client/ThirdParty/Box2D/src/common/b2_draw.cpp b/Client/ThirdParty/Box2D/src/common/b2_draw.cpp
new file mode 100644
index 0000000..1ec11e5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/common/b2_draw.cpp
@@ -0,0 +1,47 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+#include "box2d/b2_draw.h"
+
+b2Draw::b2Draw()
+{
+ m_drawFlags = 0;
+}
+
+void b2Draw::SetFlags(uint32 flags)
+{
+ m_drawFlags = flags;
+}
+
+uint32 b2Draw::GetFlags() const
+{
+ return m_drawFlags;
+}
+
+void b2Draw::AppendFlags(uint32 flags)
+{
+ m_drawFlags |= flags;
+}
+
+void b2Draw::ClearFlags(uint32 flags)
+{
+ m_drawFlags &= ~flags;
+}
diff --git a/Client/ThirdParty/Box2D/src/common/b2_math.cpp b/Client/ThirdParty/Box2D/src/common/b2_math.cpp
new file mode 100644
index 0000000..a14460c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/common/b2_math.cpp
@@ -0,0 +1,98 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_math.h"
+
+const b2Vec2 b2Vec2_zero(0.0f, 0.0f);
+
+/// Solve A * x = b, where b is a column vector. This is more efficient
+/// than computing the inverse in one-shot cases.
+b2Vec3 b2Mat33::Solve33(const b2Vec3& b) const
+{
+ float det = b2Dot(ex, b2Cross(ey, ez));
+ if (det != 0.0f)
+ {
+ det = 1.0f / det;
+ }
+ b2Vec3 x;
+ x.x = det * b2Dot(b, b2Cross(ey, ez));
+ x.y = det * b2Dot(ex, b2Cross(b, ez));
+ x.z = det * b2Dot(ex, b2Cross(ey, b));
+ return x;
+}
+
+/// Solve A * x = b, where b is a column vector. This is more efficient
+/// than computing the inverse in one-shot cases.
+b2Vec2 b2Mat33::Solve22(const b2Vec2& b) const
+{
+ float a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
+ float det = a11 * a22 - a12 * a21;
+ if (det != 0.0f)
+ {
+ det = 1.0f / det;
+ }
+ b2Vec2 x;
+ x.x = det * (a22 * b.x - a12 * b.y);
+ x.y = det * (a11 * b.y - a21 * b.x);
+ return x;
+}
+
+///
+void b2Mat33::GetInverse22(b2Mat33* M) const
+{
+ float a = ex.x, b = ey.x, c = ex.y, d = ey.y;
+ float det = a * d - b * c;
+ if (det != 0.0f)
+ {
+ det = 1.0f / det;
+ }
+
+ M->ex.x = det * d; M->ey.x = -det * b; M->ex.z = 0.0f;
+ M->ex.y = -det * c; M->ey.y = det * a; M->ey.z = 0.0f;
+ M->ez.x = 0.0f; M->ez.y = 0.0f; M->ez.z = 0.0f;
+}
+
+/// Returns the zero matrix if singular.
+void b2Mat33::GetSymInverse33(b2Mat33* M) const
+{
+ float det = b2Dot(ex, b2Cross(ey, ez));
+ if (det != 0.0f)
+ {
+ det = 1.0f / det;
+ }
+
+ float a11 = ex.x, a12 = ey.x, a13 = ez.x;
+ float a22 = ey.y, a23 = ez.y;
+ float a33 = ez.z;
+
+ M->ex.x = det * (a22 * a33 - a23 * a23);
+ M->ex.y = det * (a13 * a23 - a12 * a33);
+ M->ex.z = det * (a12 * a23 - a13 * a22);
+
+ M->ey.x = M->ex.y;
+ M->ey.y = det * (a11 * a33 - a13 * a13);
+ M->ey.z = det * (a13 * a12 - a11 * a23);
+
+ M->ez.x = M->ex.z;
+ M->ez.y = M->ey.z;
+ M->ez.z = det * (a11 * a22 - a12 * a12);
+}
diff --git a/Client/ThirdParty/Box2D/src/common/b2_settings.cpp b/Client/ThirdParty/Box2D/src/common/b2_settings.cpp
new file mode 100644
index 0000000..9b66769
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/common/b2_settings.cpp
@@ -0,0 +1,74 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#include "box2d/b2_settings.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+b2Version b2_version = {2, 4, 0};
+
+// Memory allocators. Modify these to use your own allocator.
+void* b2Alloc_Default(int32 size)
+{
+ return malloc(size);
+}
+
+void b2Free_Default(void* mem)
+{
+ free(mem);
+}
+
+// You can modify this to use your logging facility.
+void b2Log_Default(const char* string, va_list args)
+{
+ vprintf(string, args);
+}
+
+FILE* b2_dumpFile = nullptr;
+
+void b2OpenDump(const char* fileName)
+{
+ b2Assert(b2_dumpFile == nullptr);
+ b2_dumpFile = fopen(fileName, "w");
+}
+
+void b2Dump(const char* string, ...)
+{
+ if (b2_dumpFile == nullptr)
+ {
+ return;
+ }
+
+ va_list args;
+ va_start(args, string);
+ vfprintf(b2_dumpFile, string, args);
+ va_end(args);
+}
+
+void b2CloseDump()
+{
+ fclose(b2_dumpFile);
+ b2_dumpFile = nullptr;
+}
diff --git a/Client/ThirdParty/Box2D/src/common/b2_stack_allocator.cpp b/Client/ThirdParty/Box2D/src/common/b2_stack_allocator.cpp
new file mode 100644
index 0000000..602db1a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/common/b2_stack_allocator.cpp
@@ -0,0 +1,87 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_stack_allocator.h"
+#include "box2d/b2_math.h"
+
+b2StackAllocator::b2StackAllocator()
+{
+ m_index = 0;
+ m_allocation = 0;
+ m_maxAllocation = 0;
+ m_entryCount = 0;
+}
+
+b2StackAllocator::~b2StackAllocator()
+{
+ b2Assert(m_index == 0);
+ b2Assert(m_entryCount == 0);
+}
+
+void* b2StackAllocator::Allocate(int32 size)
+{
+ b2Assert(m_entryCount < b2_maxStackEntries);
+
+ b2StackEntry* entry = m_entries + m_entryCount;
+ entry->size = size;
+ if (m_index + size > b2_stackSize)
+ {
+ entry->data = (char*)b2Alloc(size);
+ entry->usedMalloc = true;
+ }
+ else
+ {
+ entry->data = m_data + m_index;
+ entry->usedMalloc = false;
+ m_index += size;
+ }
+
+ m_allocation += size;
+ m_maxAllocation = b2Max(m_maxAllocation, m_allocation);
+ ++m_entryCount;
+
+ return entry->data;
+}
+
+void b2StackAllocator::Free(void* p)
+{
+ b2Assert(m_entryCount > 0);
+ b2StackEntry* entry = m_entries + m_entryCount - 1;
+ b2Assert(p == entry->data);
+ if (entry->usedMalloc)
+ {
+ b2Free(p);
+ }
+ else
+ {
+ m_index -= entry->size;
+ }
+ m_allocation -= entry->size;
+ --m_entryCount;
+
+ p = nullptr;
+}
+
+int32 b2StackAllocator::GetMaxAllocation() const
+{
+ return m_maxAllocation;
+}
diff --git a/Client/ThirdParty/Box2D/src/common/b2_timer.cpp b/Client/ThirdParty/Box2D/src/common/b2_timer.cpp
new file mode 100644
index 0000000..dd7cde7
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/common/b2_timer.cpp
@@ -0,0 +1,125 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_timer.h"
+
+#if defined(_WIN32)
+
+double b2Timer::s_invFrequency = 0.0;
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include <windows.h>
+
+b2Timer::b2Timer()
+{
+ LARGE_INTEGER largeInteger;
+
+ if (s_invFrequency == 0.0)
+ {
+ QueryPerformanceFrequency(&largeInteger);
+ s_invFrequency = double(largeInteger.QuadPart);
+ if (s_invFrequency > 0.0)
+ {
+ s_invFrequency = 1000.0 / s_invFrequency;
+ }
+ }
+
+ QueryPerformanceCounter(&largeInteger);
+ m_start = double(largeInteger.QuadPart);
+}
+
+void b2Timer::Reset()
+{
+ LARGE_INTEGER largeInteger;
+ QueryPerformanceCounter(&largeInteger);
+ m_start = double(largeInteger.QuadPart);
+}
+
+float b2Timer::GetMilliseconds() const
+{
+ LARGE_INTEGER largeInteger;
+ QueryPerformanceCounter(&largeInteger);
+ double count = double(largeInteger.QuadPart);
+ float ms = float(s_invFrequency * (count - m_start));
+ return ms;
+}
+
+#elif defined(__linux__) || defined (__APPLE__)
+
+#include <sys/time.h>
+
+b2Timer::b2Timer()
+{
+ Reset();
+}
+
+void b2Timer::Reset()
+{
+ timeval t;
+ gettimeofday(&t, 0);
+ m_start_sec = t.tv_sec;
+ m_start_usec = t.tv_usec;
+}
+
+float b2Timer::GetMilliseconds() const
+{
+ timeval t;
+ gettimeofday(&t, 0);
+ time_t start_sec = m_start_sec;
+ suseconds_t start_usec = m_start_usec;
+
+ // http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html
+ if (t.tv_usec < start_usec)
+ {
+ int nsec = (start_usec - t.tv_usec) / 1000000 + 1;
+ start_usec -= 1000000 * nsec;
+ start_sec += nsec;
+ }
+
+ if (t.tv_usec - start_usec > 1000000)
+ {
+ int nsec = (t.tv_usec - start_usec) / 1000000;
+ start_usec += 1000000 * nsec;
+ start_sec -= nsec;
+ }
+ return 1000.0f * (t.tv_sec - start_sec) + 0.001f * (t.tv_usec - start_usec);
+}
+
+#else
+
+b2Timer::b2Timer()
+{
+}
+
+void b2Timer::Reset()
+{
+}
+
+float b2Timer::GetMilliseconds() const
+{
+ return 0.0f;
+}
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_body.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_body.cpp
new file mode 100644
index 0000000..5746664
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_body.cpp
@@ -0,0 +1,565 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_contact.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_joint.h"
+#include "box2d/b2_world.h"
+
+#include <new>
+
+b2Body::b2Body(const b2BodyDef* bd, b2World* world)
+{
+ b2Assert(bd->position.IsValid());
+ b2Assert(bd->linearVelocity.IsValid());
+ b2Assert(b2IsValid(bd->angle));
+ b2Assert(b2IsValid(bd->angularVelocity));
+ b2Assert(b2IsValid(bd->angularDamping) && bd->angularDamping >= 0.0f);
+ b2Assert(b2IsValid(bd->linearDamping) && bd->linearDamping >= 0.0f);
+
+ m_flags = 0;
+
+ if (bd->bullet)
+ {
+ m_flags |= e_bulletFlag;
+ }
+ if (bd->fixedRotation)
+ {
+ m_flags |= e_fixedRotationFlag;
+ }
+ if (bd->allowSleep)
+ {
+ m_flags |= e_autoSleepFlag;
+ }
+ if (bd->awake && bd->type != b2_staticBody)
+ {
+ m_flags |= e_awakeFlag;
+ }
+ if (bd->enabled)
+ {
+ m_flags |= e_enabledFlag;
+ }
+
+ m_world = world;
+
+ m_xf.p = bd->position;
+ m_xf.q.Set(bd->angle);
+
+ m_sweep.localCenter.SetZero();
+ m_sweep.c0 = m_xf.p;
+ m_sweep.c = m_xf.p;
+ m_sweep.a0 = bd->angle;
+ m_sweep.a = bd->angle;
+ m_sweep.alpha0 = 0.0f;
+
+ m_jointList = nullptr;
+ m_contactList = nullptr;
+ m_prev = nullptr;
+ m_next = nullptr;
+
+ m_linearVelocity = bd->linearVelocity;
+ m_angularVelocity = bd->angularVelocity;
+
+ m_linearDamping = bd->linearDamping;
+ m_angularDamping = bd->angularDamping;
+ m_gravityScale = bd->gravityScale;
+
+ m_force.SetZero();
+ m_torque = 0.0f;
+
+ m_sleepTime = 0.0f;
+
+ m_type = bd->type;
+
+ m_mass = 0.0f;
+ m_invMass = 0.0f;
+
+ m_I = 0.0f;
+ m_invI = 0.0f;
+
+ m_userData = bd->userData;
+
+ m_fixtureList = nullptr;
+ m_fixtureCount = 0;
+}
+
+b2Body::~b2Body()
+{
+ // shapes and joints are destroyed in b2World::Destroy
+}
+
+void b2Body::SetType(b2BodyType type)
+{
+ b2Assert(m_world->IsLocked() == false);
+ if (m_world->IsLocked() == true)
+ {
+ return;
+ }
+
+ if (m_type == type)
+ {
+ return;
+ }
+
+ m_type = type;
+
+ ResetMassData();
+
+ if (m_type == b2_staticBody)
+ {
+ m_linearVelocity.SetZero();
+ m_angularVelocity = 0.0f;
+ m_sweep.a0 = m_sweep.a;
+ m_sweep.c0 = m_sweep.c;
+ m_flags &= ~e_awakeFlag;
+ SynchronizeFixtures();
+ }
+
+ SetAwake(true);
+
+ m_force.SetZero();
+ m_torque = 0.0f;
+
+ // Delete the attached contacts.
+ b2ContactEdge* ce = m_contactList;
+ while (ce)
+ {
+ b2ContactEdge* ce0 = ce;
+ ce = ce->next;
+ m_world->m_contactManager.Destroy(ce0->contact);
+ }
+ m_contactList = nullptr;
+
+ // Touch the proxies so that new contacts will be created (when appropriate)
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ int32 proxyCount = f->m_proxyCount;
+ for (int32 i = 0; i < proxyCount; ++i)
+ {
+ broadPhase->TouchProxy(f->m_proxies[i].proxyId);
+ }
+ }
+}
+
+b2Fixture* b2Body::CreateFixture(const b2FixtureDef* def)
+{
+ b2Assert(m_world->IsLocked() == false);
+ if (m_world->IsLocked() == true)
+ {
+ return nullptr;
+ }
+
+ b2BlockAllocator* allocator = &m_world->m_blockAllocator;
+
+ void* memory = allocator->Allocate(sizeof(b2Fixture));
+ b2Fixture* fixture = new (memory) b2Fixture;
+ fixture->Create(allocator, this, def);
+
+ if (m_flags & e_enabledFlag)
+ {
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+ fixture->CreateProxies(broadPhase, m_xf);
+ }
+
+ fixture->m_next = m_fixtureList;
+ m_fixtureList = fixture;
+ ++m_fixtureCount;
+
+ fixture->m_body = this;
+
+ // Adjust mass properties if needed.
+ if (fixture->m_density > 0.0f)
+ {
+ ResetMassData();
+ }
+
+ // Let the world know we have a new fixture. This will cause new contacts
+ // to be created at the beginning of the next time step.
+ m_world->m_newContacts = true;
+
+ return fixture;
+}
+
+b2Fixture* b2Body::CreateFixture(const b2Shape* shape, float density)
+{
+ b2FixtureDef def;
+ def.shape = shape;
+ def.density = density;
+
+ return CreateFixture(&def);
+}
+
+void b2Body::DestroyFixture(b2Fixture* fixture)
+{
+ if (fixture == NULL)
+ {
+ return;
+ }
+
+ b2Assert(m_world->IsLocked() == false);
+ if (m_world->IsLocked() == true)
+ {
+ return;
+ }
+
+ b2Assert(fixture->m_body == this);
+
+ // Remove the fixture from this body's singly linked list.
+ b2Assert(m_fixtureCount > 0);
+ b2Fixture** node = &m_fixtureList;
+ bool found = false;
+ while (*node != nullptr)
+ {
+ if (*node == fixture)
+ {
+ *node = fixture->m_next;
+ found = true;
+ break;
+ }
+
+ node = &(*node)->m_next;
+ }
+
+ // You tried to remove a shape that is not attached to this body.
+ b2Assert(found);
+
+ // Destroy any contacts associated with the fixture.
+ b2ContactEdge* edge = m_contactList;
+ while (edge)
+ {
+ b2Contact* c = edge->contact;
+ edge = edge->next;
+
+ b2Fixture* fixtureA = c->GetFixtureA();
+ b2Fixture* fixtureB = c->GetFixtureB();
+
+ if (fixture == fixtureA || fixture == fixtureB)
+ {
+ // This destroys the contact and removes it from
+ // this body's contact list.
+ m_world->m_contactManager.Destroy(c);
+ }
+ }
+
+ b2BlockAllocator* allocator = &m_world->m_blockAllocator;
+
+ if (m_flags & e_enabledFlag)
+ {
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+ fixture->DestroyProxies(broadPhase);
+ }
+
+ fixture->m_body = nullptr;
+ fixture->m_next = nullptr;
+ fixture->Destroy(allocator);
+ fixture->~b2Fixture();
+ allocator->Free(fixture, sizeof(b2Fixture));
+
+ --m_fixtureCount;
+
+ // Reset the mass data.
+ ResetMassData();
+}
+
+void b2Body::ResetMassData()
+{
+ // Compute mass data from shapes. Each shape has its own density.
+ m_mass = 0.0f;
+ m_invMass = 0.0f;
+ m_I = 0.0f;
+ m_invI = 0.0f;
+ m_sweep.localCenter.SetZero();
+
+ // Static and kinematic bodies have zero mass.
+ if (m_type == b2_staticBody || m_type == b2_kinematicBody)
+ {
+ m_sweep.c0 = m_xf.p;
+ m_sweep.c = m_xf.p;
+ m_sweep.a0 = m_sweep.a;
+ return;
+ }
+
+ b2Assert(m_type == b2_dynamicBody);
+
+ // Accumulate mass over all fixtures.
+ b2Vec2 localCenter = b2Vec2_zero;
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ if (f->m_density == 0.0f)
+ {
+ continue;
+ }
+
+ b2MassData massData;
+ f->GetMassData(&massData);
+ m_mass += massData.mass;
+ localCenter += massData.mass * massData.center;
+ m_I += massData.I;
+ }
+
+ // Compute center of mass.
+ if (m_mass > 0.0f)
+ {
+ m_invMass = 1.0f / m_mass;
+ localCenter *= m_invMass;
+ }
+
+ if (m_I > 0.0f && (m_flags & e_fixedRotationFlag) == 0)
+ {
+ // Center the inertia about the center of mass.
+ m_I -= m_mass * b2Dot(localCenter, localCenter);
+ b2Assert(m_I > 0.0f);
+ m_invI = 1.0f / m_I;
+
+ }
+ else
+ {
+ m_I = 0.0f;
+ m_invI = 0.0f;
+ }
+
+ // Move center of mass.
+ b2Vec2 oldCenter = m_sweep.c;
+ m_sweep.localCenter = localCenter;
+ m_sweep.c0 = m_sweep.c = b2Mul(m_xf, m_sweep.localCenter);
+
+ // Update center of mass velocity.
+ m_linearVelocity += b2Cross(m_angularVelocity, m_sweep.c - oldCenter);
+}
+
+void b2Body::SetMassData(const b2MassData* massData)
+{
+ b2Assert(m_world->IsLocked() == false);
+ if (m_world->IsLocked() == true)
+ {
+ return;
+ }
+
+ if (m_type != b2_dynamicBody)
+ {
+ return;
+ }
+
+ m_invMass = 0.0f;
+ m_I = 0.0f;
+ m_invI = 0.0f;
+
+ m_mass = massData->mass;
+ if (m_mass <= 0.0f)
+ {
+ m_mass = 1.0f;
+ }
+
+ m_invMass = 1.0f / m_mass;
+
+ if (massData->I > 0.0f && (m_flags & b2Body::e_fixedRotationFlag) == 0)
+ {
+ m_I = massData->I - m_mass * b2Dot(massData->center, massData->center);
+ b2Assert(m_I > 0.0f);
+ m_invI = 1.0f / m_I;
+ }
+
+ // Move center of mass.
+ b2Vec2 oldCenter = m_sweep.c;
+ m_sweep.localCenter = massData->center;
+ m_sweep.c0 = m_sweep.c = b2Mul(m_xf, m_sweep.localCenter);
+
+ // Update center of mass velocity.
+ m_linearVelocity += b2Cross(m_angularVelocity, m_sweep.c - oldCenter);
+}
+
+bool b2Body::ShouldCollide(const b2Body* other) const
+{
+ // At least one body should be dynamic.
+ if (m_type != b2_dynamicBody && other->m_type != b2_dynamicBody)
+ {
+ return false;
+ }
+
+ // Does a joint prevent collision?
+ for (b2JointEdge* jn = m_jointList; jn; jn = jn->next)
+ {
+ if (jn->other == other)
+ {
+ if (jn->joint->m_collideConnected == false)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+void b2Body::SetTransform(const b2Vec2& position, float angle)
+{
+ b2Assert(m_world->IsLocked() == false);
+ if (m_world->IsLocked() == true)
+ {
+ return;
+ }
+
+ m_xf.q.Set(angle);
+ m_xf.p = position;
+
+ m_sweep.c = b2Mul(m_xf, m_sweep.localCenter);
+ m_sweep.a = angle;
+
+ m_sweep.c0 = m_sweep.c;
+ m_sweep.a0 = angle;
+
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ f->Synchronize(broadPhase, m_xf, m_xf);
+ }
+
+ // Check for new contacts the next step
+ m_world->m_newContacts = true;
+}
+
+void b2Body::SynchronizeFixtures()
+{
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+
+ if (m_flags & b2Body::e_awakeFlag)
+ {
+ b2Transform xf1;
+ xf1.q.Set(m_sweep.a0);
+ xf1.p = m_sweep.c0 - b2Mul(xf1.q, m_sweep.localCenter);
+
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ f->Synchronize(broadPhase, xf1, m_xf);
+ }
+ }
+ else
+ {
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ f->Synchronize(broadPhase, m_xf, m_xf);
+ }
+ }
+}
+
+void b2Body::SetEnabled(bool flag)
+{
+ b2Assert(m_world->IsLocked() == false);
+
+ if (flag == IsEnabled())
+ {
+ return;
+ }
+
+ if (flag)
+ {
+ m_flags |= e_enabledFlag;
+
+ // Create all proxies.
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ f->CreateProxies(broadPhase, m_xf);
+ }
+
+ // Contacts are created at the beginning of the next
+ m_world->m_newContacts = true;
+ }
+ else
+ {
+ m_flags &= ~e_enabledFlag;
+
+ // Destroy all proxies.
+ b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ f->DestroyProxies(broadPhase);
+ }
+
+ // Destroy the attached contacts.
+ b2ContactEdge* ce = m_contactList;
+ while (ce)
+ {
+ b2ContactEdge* ce0 = ce;
+ ce = ce->next;
+ m_world->m_contactManager.Destroy(ce0->contact);
+ }
+ m_contactList = nullptr;
+ }
+}
+
+void b2Body::SetFixedRotation(bool flag)
+{
+ bool status = (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag;
+ if (status == flag)
+ {
+ return;
+ }
+
+ if (flag)
+ {
+ m_flags |= e_fixedRotationFlag;
+ }
+ else
+ {
+ m_flags &= ~e_fixedRotationFlag;
+ }
+
+ m_angularVelocity = 0.0f;
+
+ ResetMassData();
+}
+
+void b2Body::Dump()
+{
+ int32 bodyIndex = m_islandIndex;
+
+ // %.9g is sufficient to save and load the same value using text
+ // FLT_DECIMAL_DIG == 9
+
+ b2Dump("{\n");
+ b2Dump(" b2BodyDef bd;\n");
+ b2Dump(" bd.type = b2BodyType(%d);\n", m_type);
+ b2Dump(" bd.position.Set(%.9g, %.9g);\n", m_xf.p.x, m_xf.p.y);
+ b2Dump(" bd.angle = %.9g;\n", m_sweep.a);
+ b2Dump(" bd.linearVelocity.Set(%.9g, %.9g);\n", m_linearVelocity.x, m_linearVelocity.y);
+ b2Dump(" bd.angularVelocity = %.9g;\n", m_angularVelocity);
+ b2Dump(" bd.linearDamping = %.9g;\n", m_linearDamping);
+ b2Dump(" bd.angularDamping = %.9g;\n", m_angularDamping);
+ b2Dump(" bd.allowSleep = bool(%d);\n", m_flags & e_autoSleepFlag);
+ b2Dump(" bd.awake = bool(%d);\n", m_flags & e_awakeFlag);
+ b2Dump(" bd.fixedRotation = bool(%d);\n", m_flags & e_fixedRotationFlag);
+ b2Dump(" bd.bullet = bool(%d);\n", m_flags & e_bulletFlag);
+ b2Dump(" bd.enabled = bool(%d);\n", m_flags & e_enabledFlag);
+ b2Dump(" bd.gravityScale = %.9g;\n", m_gravityScale);
+ b2Dump(" bodies[%d] = m_world->CreateBody(&bd);\n", m_islandIndex);
+ b2Dump("\n");
+ for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
+ {
+ b2Dump(" {\n");
+ f->Dump(bodyIndex);
+ b2Dump(" }\n");
+ }
+ b2Dump("}\n");
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.cpp
new file mode 100644
index 0000000..8464fe8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.cpp
@@ -0,0 +1,57 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_chain_circle_contact.h"
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_chain_shape.h"
+#include "box2d/b2_edge_shape.h"
+
+#include <new>
+
+b2Contact* b2ChainAndCircleContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2ChainAndCircleContact));
+ return new (mem) b2ChainAndCircleContact(fixtureA, indexA, fixtureB, indexB);
+}
+
+void b2ChainAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2ChainAndCircleContact*)contact)->~b2ChainAndCircleContact();
+ allocator->Free(contact, sizeof(b2ChainAndCircleContact));
+}
+
+b2ChainAndCircleContact::b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB)
+: b2Contact(fixtureA, indexA, fixtureB, indexB)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_chain);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_circle);
+}
+
+void b2ChainAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape();
+ b2EdgeShape edge;
+ chain->GetChildEdge(&edge, m_indexA);
+ b2CollideEdgeAndCircle( manifold, &edge, xfA,
+ (b2CircleShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.h
new file mode 100644
index 0000000..33ced64
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_circle_contact.h
@@ -0,0 +1,43 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CHAIN_AND_CIRCLE_CONTACT_H
+#define B2_CHAIN_AND_CIRCLE_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2ChainAndCircleContact : public b2Contact
+{
+public:
+ static b2Contact* Create( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB);
+ ~b2ChainAndCircleContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.cpp
new file mode 100644
index 0000000..b8257aa
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.cpp
@@ -0,0 +1,57 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_chain_polygon_contact.h"
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_chain_shape.h"
+#include "box2d/b2_edge_shape.h"
+
+#include <new>
+
+b2Contact* b2ChainAndPolygonContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2ChainAndPolygonContact));
+ return new (mem) b2ChainAndPolygonContact(fixtureA, indexA, fixtureB, indexB);
+}
+
+void b2ChainAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2ChainAndPolygonContact*)contact)->~b2ChainAndPolygonContact();
+ allocator->Free(contact, sizeof(b2ChainAndPolygonContact));
+}
+
+b2ChainAndPolygonContact::b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB)
+: b2Contact(fixtureA, indexA, fixtureB, indexB)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_chain);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon);
+}
+
+void b2ChainAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape();
+ b2EdgeShape edge;
+ chain->GetChildEdge(&edge, m_indexA);
+ b2CollideEdgeAndPolygon( manifold, &edge, xfA,
+ (b2PolygonShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.h
new file mode 100644
index 0000000..058154f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_chain_polygon_contact.h
@@ -0,0 +1,43 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CHAIN_AND_POLYGON_CONTACT_H
+#define B2_CHAIN_AND_POLYGON_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2ChainAndPolygonContact : public b2Contact
+{
+public:
+ static b2Contact* Create( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB);
+ ~b2ChainAndPolygonContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.cpp
new file mode 100644
index 0000000..738aa84
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.cpp
@@ -0,0 +1,56 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_circle_contact.h"
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_body.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_time_of_impact.h"
+#include "box2d/b2_world_callbacks.h"
+
+#include <new>
+
+b2Contact* b2CircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2CircleContact));
+ return new (mem) b2CircleContact(fixtureA, fixtureB);
+}
+
+void b2CircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2CircleContact*)contact)->~b2CircleContact();
+ allocator->Free(contact, sizeof(b2CircleContact));
+}
+
+b2CircleContact::b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB)
+ : b2Contact(fixtureA, 0, fixtureB, 0)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_circle);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_circle);
+}
+
+void b2CircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2CollideCircles(manifold,
+ (b2CircleShape*)m_fixtureA->GetShape(), xfA,
+ (b2CircleShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.h
new file mode 100644
index 0000000..98e09ea
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_circle_contact.h
@@ -0,0 +1,43 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CIRCLE_CONTACT_H
+#define B2_CIRCLE_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2CircleContact : public b2Contact
+{
+public:
+ static b2Contact* Create( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB);
+ ~b2CircleContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_contact.cpp
new file mode 100644
index 0000000..1c65bc8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_contact.cpp
@@ -0,0 +1,252 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_chain_circle_contact.h"
+#include "b2_chain_polygon_contact.h"
+#include "b2_circle_contact.h"
+#include "b2_contact_solver.h"
+#include "b2_edge_circle_contact.h"
+#include "b2_edge_polygon_contact.h"
+#include "b2_polygon_circle_contact.h"
+#include "b2_polygon_contact.h"
+
+#include "box2d/b2_contact.h"
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_body.h"
+#include "box2d/b2_collision.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_shape.h"
+#include "box2d/b2_time_of_impact.h"
+#include "box2d/b2_world.h"
+
+b2ContactRegister b2Contact::s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount];
+bool b2Contact::s_initialized = false;
+
+void b2Contact::InitializeRegisters()
+{
+ AddType(b2CircleContact::Create, b2CircleContact::Destroy, b2Shape::e_circle, b2Shape::e_circle);
+ AddType(b2PolygonAndCircleContact::Create, b2PolygonAndCircleContact::Destroy, b2Shape::e_polygon, b2Shape::e_circle);
+ AddType(b2PolygonContact::Create, b2PolygonContact::Destroy, b2Shape::e_polygon, b2Shape::e_polygon);
+ AddType(b2EdgeAndCircleContact::Create, b2EdgeAndCircleContact::Destroy, b2Shape::e_edge, b2Shape::e_circle);
+ AddType(b2EdgeAndPolygonContact::Create, b2EdgeAndPolygonContact::Destroy, b2Shape::e_edge, b2Shape::e_polygon);
+ AddType(b2ChainAndCircleContact::Create, b2ChainAndCircleContact::Destroy, b2Shape::e_chain, b2Shape::e_circle);
+ AddType(b2ChainAndPolygonContact::Create, b2ChainAndPolygonContact::Destroy, b2Shape::e_chain, b2Shape::e_polygon);
+}
+
+void b2Contact::AddType(b2ContactCreateFcn* createFcn, b2ContactDestroyFcn* destoryFcn,
+ b2Shape::Type type1, b2Shape::Type type2)
+{
+ b2Assert(0 <= type1 && type1 < b2Shape::e_typeCount);
+ b2Assert(0 <= type2 && type2 < b2Shape::e_typeCount);
+
+ s_registers[type1][type2].createFcn = createFcn;
+ s_registers[type1][type2].destroyFcn = destoryFcn;
+ s_registers[type1][type2].primary = true;
+
+ if (type1 != type2)
+ {
+ s_registers[type2][type1].createFcn = createFcn;
+ s_registers[type2][type1].destroyFcn = destoryFcn;
+ s_registers[type2][type1].primary = false;
+ }
+}
+
+b2Contact* b2Contact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator)
+{
+ if (s_initialized == false)
+ {
+ InitializeRegisters();
+ s_initialized = true;
+ }
+
+ b2Shape::Type type1 = fixtureA->GetType();
+ b2Shape::Type type2 = fixtureB->GetType();
+
+ b2Assert(0 <= type1 && type1 < b2Shape::e_typeCount);
+ b2Assert(0 <= type2 && type2 < b2Shape::e_typeCount);
+
+ b2ContactCreateFcn* createFcn = s_registers[type1][type2].createFcn;
+ if (createFcn)
+ {
+ if (s_registers[type1][type2].primary)
+ {
+ return createFcn(fixtureA, indexA, fixtureB, indexB, allocator);
+ }
+ else
+ {
+ return createFcn(fixtureB, indexB, fixtureA, indexA, allocator);
+ }
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+void b2Contact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ b2Assert(s_initialized == true);
+
+ b2Fixture* fixtureA = contact->m_fixtureA;
+ b2Fixture* fixtureB = contact->m_fixtureB;
+
+ if (contact->m_manifold.pointCount > 0 &&
+ fixtureA->IsSensor() == false &&
+ fixtureB->IsSensor() == false)
+ {
+ fixtureA->GetBody()->SetAwake(true);
+ fixtureB->GetBody()->SetAwake(true);
+ }
+
+ b2Shape::Type typeA = fixtureA->GetType();
+ b2Shape::Type typeB = fixtureB->GetType();
+
+ b2Assert(0 <= typeA && typeA < b2Shape::e_typeCount);
+ b2Assert(0 <= typeB && typeB < b2Shape::e_typeCount);
+
+ b2ContactDestroyFcn* destroyFcn = s_registers[typeA][typeB].destroyFcn;
+ destroyFcn(contact, allocator);
+}
+
+b2Contact::b2Contact(b2Fixture* fA, int32 indexA, b2Fixture* fB, int32 indexB)
+{
+ m_flags = e_enabledFlag;
+
+ m_fixtureA = fA;
+ m_fixtureB = fB;
+
+ m_indexA = indexA;
+ m_indexB = indexB;
+
+ m_manifold.pointCount = 0;
+
+ m_prev = nullptr;
+ m_next = nullptr;
+
+ m_nodeA.contact = nullptr;
+ m_nodeA.prev = nullptr;
+ m_nodeA.next = nullptr;
+ m_nodeA.other = nullptr;
+
+ m_nodeB.contact = nullptr;
+ m_nodeB.prev = nullptr;
+ m_nodeB.next = nullptr;
+ m_nodeB.other = nullptr;
+
+ m_toiCount = 0;
+
+ m_friction = b2MixFriction(m_fixtureA->m_friction, m_fixtureB->m_friction);
+ m_restitution = b2MixRestitution(m_fixtureA->m_restitution, m_fixtureB->m_restitution);
+ m_restitutionThreshold = b2MixRestitutionThreshold(m_fixtureA->m_restitutionThreshold, m_fixtureB->m_restitutionThreshold);
+
+ m_tangentSpeed = 0.0f;
+}
+
+// Update the contact manifold and touching status.
+// Note: do not assume the fixture AABBs are overlapping or are valid.
+void b2Contact::Update(b2ContactListener* listener)
+{
+ b2Manifold oldManifold = m_manifold;
+
+ // Re-enable this contact.
+ m_flags |= e_enabledFlag;
+
+ bool touching = false;
+ bool wasTouching = (m_flags & e_touchingFlag) == e_touchingFlag;
+
+ bool sensorA = m_fixtureA->IsSensor();
+ bool sensorB = m_fixtureB->IsSensor();
+ bool sensor = sensorA || sensorB;
+
+ b2Body* bodyA = m_fixtureA->GetBody();
+ b2Body* bodyB = m_fixtureB->GetBody();
+ const b2Transform& xfA = bodyA->GetTransform();
+ const b2Transform& xfB = bodyB->GetTransform();
+
+ // Is this contact a sensor?
+ if (sensor)
+ {
+ const b2Shape* shapeA = m_fixtureA->GetShape();
+ const b2Shape* shapeB = m_fixtureB->GetShape();
+ touching = b2TestOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB);
+
+ // Sensors don't generate manifolds.
+ m_manifold.pointCount = 0;
+ }
+ else
+ {
+ Evaluate(&m_manifold, xfA, xfB);
+ touching = m_manifold.pointCount > 0;
+
+ // Match old contact ids to new contact ids and copy the
+ // stored impulses to warm start the solver.
+ for (int32 i = 0; i < m_manifold.pointCount; ++i)
+ {
+ b2ManifoldPoint* mp2 = m_manifold.points + i;
+ mp2->normalImpulse = 0.0f;
+ mp2->tangentImpulse = 0.0f;
+ b2ContactID id2 = mp2->id;
+
+ for (int32 j = 0; j < oldManifold.pointCount; ++j)
+ {
+ b2ManifoldPoint* mp1 = oldManifold.points + j;
+
+ if (mp1->id.key == id2.key)
+ {
+ mp2->normalImpulse = mp1->normalImpulse;
+ mp2->tangentImpulse = mp1->tangentImpulse;
+ break;
+ }
+ }
+ }
+
+ if (touching != wasTouching)
+ {
+ bodyA->SetAwake(true);
+ bodyB->SetAwake(true);
+ }
+ }
+
+ if (touching)
+ {
+ m_flags |= e_touchingFlag;
+ }
+ else
+ {
+ m_flags &= ~e_touchingFlag;
+ }
+
+ if (wasTouching == false && touching == true && listener)
+ {
+ listener->BeginContact(this);
+ }
+
+ if (wasTouching == true && touching == false && listener)
+ {
+ listener->EndContact(this);
+ }
+
+ if (sensor == false && touching && listener)
+ {
+ listener->PreSolve(this, &oldManifold);
+ }
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_contact_manager.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_contact_manager.cpp
new file mode 100644
index 0000000..5666608
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_contact_manager.cpp
@@ -0,0 +1,293 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_contact.h"
+#include "box2d/b2_contact_manager.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_world_callbacks.h"
+
+b2ContactFilter b2_defaultFilter;
+b2ContactListener b2_defaultListener;
+
+b2ContactManager::b2ContactManager()
+{
+ m_contactList = nullptr;
+ m_contactCount = 0;
+ m_contactFilter = &b2_defaultFilter;
+ m_contactListener = &b2_defaultListener;
+ m_allocator = nullptr;
+}
+
+void b2ContactManager::Destroy(b2Contact* c)
+{
+ b2Fixture* fixtureA = c->GetFixtureA();
+ b2Fixture* fixtureB = c->GetFixtureB();
+ b2Body* bodyA = fixtureA->GetBody();
+ b2Body* bodyB = fixtureB->GetBody();
+
+ if (m_contactListener && c->IsTouching())
+ {
+ m_contactListener->EndContact(c);
+ }
+
+ // Remove from the world.
+ if (c->m_prev)
+ {
+ c->m_prev->m_next = c->m_next;
+ }
+
+ if (c->m_next)
+ {
+ c->m_next->m_prev = c->m_prev;
+ }
+
+ if (c == m_contactList)
+ {
+ m_contactList = c->m_next;
+ }
+
+ // Remove from body 1
+ if (c->m_nodeA.prev)
+ {
+ c->m_nodeA.prev->next = c->m_nodeA.next;
+ }
+
+ if (c->m_nodeA.next)
+ {
+ c->m_nodeA.next->prev = c->m_nodeA.prev;
+ }
+
+ if (&c->m_nodeA == bodyA->m_contactList)
+ {
+ bodyA->m_contactList = c->m_nodeA.next;
+ }
+
+ // Remove from body 2
+ if (c->m_nodeB.prev)
+ {
+ c->m_nodeB.prev->next = c->m_nodeB.next;
+ }
+
+ if (c->m_nodeB.next)
+ {
+ c->m_nodeB.next->prev = c->m_nodeB.prev;
+ }
+
+ if (&c->m_nodeB == bodyB->m_contactList)
+ {
+ bodyB->m_contactList = c->m_nodeB.next;
+ }
+
+ // Call the factory.
+ b2Contact::Destroy(c, m_allocator);
+ --m_contactCount;
+}
+
+// This is the top level collision call for the time step. Here
+// all the narrow phase collision is processed for the world
+// contact list.
+void b2ContactManager::Collide()
+{
+ // Update awake contacts.
+ b2Contact* c = m_contactList;
+ while (c)
+ {
+ b2Fixture* fixtureA = c->GetFixtureA();
+ b2Fixture* fixtureB = c->GetFixtureB();
+ int32 indexA = c->GetChildIndexA();
+ int32 indexB = c->GetChildIndexB();
+ b2Body* bodyA = fixtureA->GetBody();
+ b2Body* bodyB = fixtureB->GetBody();
+
+ // Is this contact flagged for filtering?
+ if (c->m_flags & b2Contact::e_filterFlag)
+ {
+ // Should these bodies collide?
+ if (bodyB->ShouldCollide(bodyA) == false)
+ {
+ b2Contact* cNuke = c;
+ c = cNuke->GetNext();
+ Destroy(cNuke);
+ continue;
+ }
+
+ // Check user filtering.
+ if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false)
+ {
+ b2Contact* cNuke = c;
+ c = cNuke->GetNext();
+ Destroy(cNuke);
+ continue;
+ }
+
+ // Clear the filtering flag.
+ c->m_flags &= ~b2Contact::e_filterFlag;
+ }
+
+ bool activeA = bodyA->IsAwake() && bodyA->m_type != b2_staticBody;
+ bool activeB = bodyB->IsAwake() && bodyB->m_type != b2_staticBody;
+
+ // At least one body must be awake and it must be dynamic or kinematic.
+ if (activeA == false && activeB == false)
+ {
+ c = c->GetNext();
+ continue;
+ }
+
+ int32 proxyIdA = fixtureA->m_proxies[indexA].proxyId;
+ int32 proxyIdB = fixtureB->m_proxies[indexB].proxyId;
+ bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB);
+
+ // Here we destroy contacts that cease to overlap in the broad-phase.
+ if (overlap == false)
+ {
+ b2Contact* cNuke = c;
+ c = cNuke->GetNext();
+ Destroy(cNuke);
+ continue;
+ }
+
+ // The contact persists.
+ c->Update(m_contactListener);
+ c = c->GetNext();
+ }
+}
+
+void b2ContactManager::FindNewContacts()
+{
+ m_broadPhase.UpdatePairs(this);
+}
+
+void b2ContactManager::AddPair(void* proxyUserDataA, void* proxyUserDataB)
+{
+ b2FixtureProxy* proxyA = (b2FixtureProxy*)proxyUserDataA;
+ b2FixtureProxy* proxyB = (b2FixtureProxy*)proxyUserDataB;
+
+ b2Fixture* fixtureA = proxyA->fixture;
+ b2Fixture* fixtureB = proxyB->fixture;
+
+ int32 indexA = proxyA->childIndex;
+ int32 indexB = proxyB->childIndex;
+
+ b2Body* bodyA = fixtureA->GetBody();
+ b2Body* bodyB = fixtureB->GetBody();
+
+ // Are the fixtures on the same body?
+ if (bodyA == bodyB)
+ {
+ return;
+ }
+
+ // TODO_ERIN use a hash table to remove a potential bottleneck when both
+ // bodies have a lot of contacts.
+ // Does a contact already exist?
+ b2ContactEdge* edge = bodyB->GetContactList();
+ while (edge)
+ {
+ if (edge->other == bodyA)
+ {
+ b2Fixture* fA = edge->contact->GetFixtureA();
+ b2Fixture* fB = edge->contact->GetFixtureB();
+ int32 iA = edge->contact->GetChildIndexA();
+ int32 iB = edge->contact->GetChildIndexB();
+
+ if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB)
+ {
+ // A contact already exists.
+ return;
+ }
+
+ if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA)
+ {
+ // A contact already exists.
+ return;
+ }
+ }
+
+ edge = edge->next;
+ }
+
+ // Does a joint override collision? Is at least one body dynamic?
+ if (bodyB->ShouldCollide(bodyA) == false)
+ {
+ return;
+ }
+
+ // Check user filtering.
+ if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false)
+ {
+ return;
+ }
+
+ // Call the factory.
+ b2Contact* c = b2Contact::Create(fixtureA, indexA, fixtureB, indexB, m_allocator);
+ if (c == nullptr)
+ {
+ return;
+ }
+
+ // Contact creation may swap fixtures.
+ fixtureA = c->GetFixtureA();
+ fixtureB = c->GetFixtureB();
+ indexA = c->GetChildIndexA();
+ indexB = c->GetChildIndexB();
+ bodyA = fixtureA->GetBody();
+ bodyB = fixtureB->GetBody();
+
+ // Insert into the world.
+ c->m_prev = nullptr;
+ c->m_next = m_contactList;
+ if (m_contactList != nullptr)
+ {
+ m_contactList->m_prev = c;
+ }
+ m_contactList = c;
+
+ // Connect to island graph.
+
+ // Connect to body A
+ c->m_nodeA.contact = c;
+ c->m_nodeA.other = bodyB;
+
+ c->m_nodeA.prev = nullptr;
+ c->m_nodeA.next = bodyA->m_contactList;
+ if (bodyA->m_contactList != nullptr)
+ {
+ bodyA->m_contactList->prev = &c->m_nodeA;
+ }
+ bodyA->m_contactList = &c->m_nodeA;
+
+ // Connect to body B
+ c->m_nodeB.contact = c;
+ c->m_nodeB.other = bodyA;
+
+ c->m_nodeB.prev = nullptr;
+ c->m_nodeB.next = bodyB->m_contactList;
+ if (bodyB->m_contactList != nullptr)
+ {
+ bodyB->m_contactList->prev = &c->m_nodeB;
+ }
+ bodyB->m_contactList = &c->m_nodeB;
+
+ ++m_contactCount;
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.cpp
new file mode 100644
index 0000000..e6f432a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.cpp
@@ -0,0 +1,843 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_contact_solver.h"
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_contact.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_stack_allocator.h"
+#include "box2d/b2_world.h"
+
+// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.
+#define B2_DEBUG_SOLVER 0
+
+B2_API bool g_blockSolve = true;
+
+struct b2ContactPositionConstraint
+{
+ b2Vec2 localPoints[b2_maxManifoldPoints];
+ b2Vec2 localNormal;
+ b2Vec2 localPoint;
+ int32 indexA;
+ int32 indexB;
+ float invMassA, invMassB;
+ b2Vec2 localCenterA, localCenterB;
+ float invIA, invIB;
+ b2Manifold::Type type;
+ float radiusA, radiusB;
+ int32 pointCount;
+};
+
+b2ContactSolver::b2ContactSolver(b2ContactSolverDef* def)
+{
+ m_step = def->step;
+ m_allocator = def->allocator;
+ m_count = def->count;
+ m_positionConstraints = (b2ContactPositionConstraint*)m_allocator->Allocate(m_count * sizeof(b2ContactPositionConstraint));
+ m_velocityConstraints = (b2ContactVelocityConstraint*)m_allocator->Allocate(m_count * sizeof(b2ContactVelocityConstraint));
+ m_positions = def->positions;
+ m_velocities = def->velocities;
+ m_contacts = def->contacts;
+
+ // Initialize position independent portions of the constraints.
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2Contact* contact = m_contacts[i];
+
+ b2Fixture* fixtureA = contact->m_fixtureA;
+ b2Fixture* fixtureB = contact->m_fixtureB;
+ b2Shape* shapeA = fixtureA->GetShape();
+ b2Shape* shapeB = fixtureB->GetShape();
+ float radiusA = shapeA->m_radius;
+ float radiusB = shapeB->m_radius;
+ b2Body* bodyA = fixtureA->GetBody();
+ b2Body* bodyB = fixtureB->GetBody();
+ b2Manifold* manifold = contact->GetManifold();
+
+ int32 pointCount = manifold->pointCount;
+ b2Assert(pointCount > 0);
+
+ b2ContactVelocityConstraint* vc = m_velocityConstraints + i;
+ vc->friction = contact->m_friction;
+ vc->restitution = contact->m_restitution;
+ vc->threshold = contact->m_restitutionThreshold;
+ vc->tangentSpeed = contact->m_tangentSpeed;
+ vc->indexA = bodyA->m_islandIndex;
+ vc->indexB = bodyB->m_islandIndex;
+ vc->invMassA = bodyA->m_invMass;
+ vc->invMassB = bodyB->m_invMass;
+ vc->invIA = bodyA->m_invI;
+ vc->invIB = bodyB->m_invI;
+ vc->contactIndex = i;
+ vc->pointCount = pointCount;
+ vc->K.SetZero();
+ vc->normalMass.SetZero();
+
+ b2ContactPositionConstraint* pc = m_positionConstraints + i;
+ pc->indexA = bodyA->m_islandIndex;
+ pc->indexB = bodyB->m_islandIndex;
+ pc->invMassA = bodyA->m_invMass;
+ pc->invMassB = bodyB->m_invMass;
+ pc->localCenterA = bodyA->m_sweep.localCenter;
+ pc->localCenterB = bodyB->m_sweep.localCenter;
+ pc->invIA = bodyA->m_invI;
+ pc->invIB = bodyB->m_invI;
+ pc->localNormal = manifold->localNormal;
+ pc->localPoint = manifold->localPoint;
+ pc->pointCount = pointCount;
+ pc->radiusA = radiusA;
+ pc->radiusB = radiusB;
+ pc->type = manifold->type;
+
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2ManifoldPoint* cp = manifold->points + j;
+ b2VelocityConstraintPoint* vcp = vc->points + j;
+
+ if (m_step.warmStarting)
+ {
+ vcp->normalImpulse = m_step.dtRatio * cp->normalImpulse;
+ vcp->tangentImpulse = m_step.dtRatio * cp->tangentImpulse;
+ }
+ else
+ {
+ vcp->normalImpulse = 0.0f;
+ vcp->tangentImpulse = 0.0f;
+ }
+
+ vcp->rA.SetZero();
+ vcp->rB.SetZero();
+ vcp->normalMass = 0.0f;
+ vcp->tangentMass = 0.0f;
+ vcp->velocityBias = 0.0f;
+
+ pc->localPoints[j] = cp->localPoint;
+ }
+ }
+}
+
+b2ContactSolver::~b2ContactSolver()
+{
+ m_allocator->Free(m_velocityConstraints);
+ m_allocator->Free(m_positionConstraints);
+}
+
+// Initialize position dependent portions of the velocity constraints.
+void b2ContactSolver::InitializeVelocityConstraints()
+{
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2ContactVelocityConstraint* vc = m_velocityConstraints + i;
+ b2ContactPositionConstraint* pc = m_positionConstraints + i;
+
+ float radiusA = pc->radiusA;
+ float radiusB = pc->radiusB;
+ b2Manifold* manifold = m_contacts[vc->contactIndex]->GetManifold();
+
+ int32 indexA = vc->indexA;
+ int32 indexB = vc->indexB;
+
+ float mA = vc->invMassA;
+ float mB = vc->invMassB;
+ float iA = vc->invIA;
+ float iB = vc->invIB;
+ b2Vec2 localCenterA = pc->localCenterA;
+ b2Vec2 localCenterB = pc->localCenterB;
+
+ b2Vec2 cA = m_positions[indexA].c;
+ float aA = m_positions[indexA].a;
+ b2Vec2 vA = m_velocities[indexA].v;
+ float wA = m_velocities[indexA].w;
+
+ b2Vec2 cB = m_positions[indexB].c;
+ float aB = m_positions[indexB].a;
+ b2Vec2 vB = m_velocities[indexB].v;
+ float wB = m_velocities[indexB].w;
+
+ b2Assert(manifold->pointCount > 0);
+
+ b2Transform xfA, xfB;
+ xfA.q.Set(aA);
+ xfB.q.Set(aB);
+ xfA.p = cA - b2Mul(xfA.q, localCenterA);
+ xfB.p = cB - b2Mul(xfB.q, localCenterB);
+
+ b2WorldManifold worldManifold;
+ worldManifold.Initialize(manifold, xfA, radiusA, xfB, radiusB);
+
+ vc->normal = worldManifold.normal;
+
+ int32 pointCount = vc->pointCount;
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2VelocityConstraintPoint* vcp = vc->points + j;
+
+ vcp->rA = worldManifold.points[j] - cA;
+ vcp->rB = worldManifold.points[j] - cB;
+
+ float rnA = b2Cross(vcp->rA, vc->normal);
+ float rnB = b2Cross(vcp->rB, vc->normal);
+
+ float kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;
+
+ vcp->normalMass = kNormal > 0.0f ? 1.0f / kNormal : 0.0f;
+
+ b2Vec2 tangent = b2Cross(vc->normal, 1.0f);
+
+ float rtA = b2Cross(vcp->rA, tangent);
+ float rtB = b2Cross(vcp->rB, tangent);
+
+ float kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;
+
+ vcp->tangentMass = kTangent > 0.0f ? 1.0f / kTangent : 0.0f;
+
+ // Setup a velocity bias for restitution.
+ vcp->velocityBias = 0.0f;
+ float vRel = b2Dot(vc->normal, vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA));
+ if (vRel < -vc->threshold)
+ {
+ vcp->velocityBias = -vc->restitution * vRel;
+ }
+ }
+
+ // If we have two points, then prepare the block solver.
+ if (vc->pointCount == 2 && g_blockSolve)
+ {
+ b2VelocityConstraintPoint* vcp1 = vc->points + 0;
+ b2VelocityConstraintPoint* vcp2 = vc->points + 1;
+
+ float rn1A = b2Cross(vcp1->rA, vc->normal);
+ float rn1B = b2Cross(vcp1->rB, vc->normal);
+ float rn2A = b2Cross(vcp2->rA, vc->normal);
+ float rn2B = b2Cross(vcp2->rB, vc->normal);
+
+ float k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;
+ float k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;
+ float k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;
+
+ // Ensure a reasonable condition number.
+ const float k_maxConditionNumber = 1000.0f;
+ if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12))
+ {
+ // K is safe to invert.
+ vc->K.ex.Set(k11, k12);
+ vc->K.ey.Set(k12, k22);
+ vc->normalMass = vc->K.GetInverse();
+ }
+ else
+ {
+ // The constraints are redundant, just use one.
+ // TODO_ERIN use deepest?
+ vc->pointCount = 1;
+ }
+ }
+ }
+}
+
+void b2ContactSolver::WarmStart()
+{
+ // Warm start.
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2ContactVelocityConstraint* vc = m_velocityConstraints + i;
+
+ int32 indexA = vc->indexA;
+ int32 indexB = vc->indexB;
+ float mA = vc->invMassA;
+ float iA = vc->invIA;
+ float mB = vc->invMassB;
+ float iB = vc->invIB;
+ int32 pointCount = vc->pointCount;
+
+ b2Vec2 vA = m_velocities[indexA].v;
+ float wA = m_velocities[indexA].w;
+ b2Vec2 vB = m_velocities[indexB].v;
+ float wB = m_velocities[indexB].w;
+
+ b2Vec2 normal = vc->normal;
+ b2Vec2 tangent = b2Cross(normal, 1.0f);
+
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2VelocityConstraintPoint* vcp = vc->points + j;
+ b2Vec2 P = vcp->normalImpulse * normal + vcp->tangentImpulse * tangent;
+ wA -= iA * b2Cross(vcp->rA, P);
+ vA -= mA * P;
+ wB += iB * b2Cross(vcp->rB, P);
+ vB += mB * P;
+ }
+
+ m_velocities[indexA].v = vA;
+ m_velocities[indexA].w = wA;
+ m_velocities[indexB].v = vB;
+ m_velocities[indexB].w = wB;
+ }
+}
+
+void b2ContactSolver::SolveVelocityConstraints()
+{
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2ContactVelocityConstraint* vc = m_velocityConstraints + i;
+
+ int32 indexA = vc->indexA;
+ int32 indexB = vc->indexB;
+ float mA = vc->invMassA;
+ float iA = vc->invIA;
+ float mB = vc->invMassB;
+ float iB = vc->invIB;
+ int32 pointCount = vc->pointCount;
+
+ b2Vec2 vA = m_velocities[indexA].v;
+ float wA = m_velocities[indexA].w;
+ b2Vec2 vB = m_velocities[indexB].v;
+ float wB = m_velocities[indexB].w;
+
+ b2Vec2 normal = vc->normal;
+ b2Vec2 tangent = b2Cross(normal, 1.0f);
+ float friction = vc->friction;
+
+ b2Assert(pointCount == 1 || pointCount == 2);
+
+ // Solve tangent constraints first because non-penetration is more important
+ // than friction.
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2VelocityConstraintPoint* vcp = vc->points + j;
+
+ // Relative velocity at contact
+ b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA);
+
+ // Compute tangent force
+ float vt = b2Dot(dv, tangent) - vc->tangentSpeed;
+ float lambda = vcp->tangentMass * (-vt);
+
+ // b2Clamp the accumulated force
+ float maxFriction = friction * vcp->normalImpulse;
+ float newImpulse = b2Clamp(vcp->tangentImpulse + lambda, -maxFriction, maxFriction);
+ lambda = newImpulse - vcp->tangentImpulse;
+ vcp->tangentImpulse = newImpulse;
+
+ // Apply contact impulse
+ b2Vec2 P = lambda * tangent;
+
+ vA -= mA * P;
+ wA -= iA * b2Cross(vcp->rA, P);
+
+ vB += mB * P;
+ wB += iB * b2Cross(vcp->rB, P);
+ }
+
+ // Solve normal constraints
+ if (pointCount == 1 || g_blockSolve == false)
+ {
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2VelocityConstraintPoint* vcp = vc->points + j;
+
+ // Relative velocity at contact
+ b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA);
+
+ // Compute normal impulse
+ float vn = b2Dot(dv, normal);
+ float lambda = -vcp->normalMass * (vn - vcp->velocityBias);
+
+ // b2Clamp the accumulated impulse
+ float newImpulse = b2Max(vcp->normalImpulse + lambda, 0.0f);
+ lambda = newImpulse - vcp->normalImpulse;
+ vcp->normalImpulse = newImpulse;
+
+ // Apply contact impulse
+ b2Vec2 P = lambda * normal;
+ vA -= mA * P;
+ wA -= iA * b2Cross(vcp->rA, P);
+
+ vB += mB * P;
+ wB += iB * b2Cross(vcp->rB, P);
+ }
+ }
+ else
+ {
+ // Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on Box2D_Lite).
+ // Build the mini LCP for this contact patch
+ //
+ // vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
+ //
+ // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
+ // b = vn0 - velocityBias
+ //
+ // The system is solved using the "Total enumeration method" (s. Murty). The complementary constraint vn_i * x_i
+ // implies that we must have in any solution either vn_i = 0 or x_i = 0. So for the 2D contact problem the cases
+ // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and vn1 = 0 need to be tested. The first valid
+ // solution that satisfies the problem is chosen.
+ //
+ // In order to account of the accumulated impulse 'a' (because of the iterative nature of the solver which only requires
+ // that the accumulated impulse is clamped and not the incremental impulse) we change the impulse variable (x_i).
+ //
+ // Substitute:
+ //
+ // x = a + d
+ //
+ // a := old total impulse
+ // x := new total impulse
+ // d := incremental impulse
+ //
+ // For the current iteration we extend the formula for the incremental impulse
+ // to compute the new total impulse:
+ //
+ // vn = A * d + b
+ // = A * (x - a) + b
+ // = A * x + b - A * a
+ // = A * x + b'
+ // b' = b - A * a;
+
+ b2VelocityConstraintPoint* cp1 = vc->points + 0;
+ b2VelocityConstraintPoint* cp2 = vc->points + 1;
+
+ b2Vec2 a(cp1->normalImpulse, cp2->normalImpulse);
+ b2Assert(a.x >= 0.0f && a.y >= 0.0f);
+
+ // Relative velocity at contact
+ b2Vec2 dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA);
+ b2Vec2 dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA);
+
+ // Compute normal velocity
+ float vn1 = b2Dot(dv1, normal);
+ float vn2 = b2Dot(dv2, normal);
+
+ b2Vec2 b;
+ b.x = vn1 - cp1->velocityBias;
+ b.y = vn2 - cp2->velocityBias;
+
+ // Compute b'
+ b -= b2Mul(vc->K, a);
+
+ const float k_errorTol = 1e-3f;
+ B2_NOT_USED(k_errorTol);
+
+ for (;;)
+ {
+ //
+ // Case 1: vn = 0
+ //
+ // 0 = A * x + b'
+ //
+ // Solve for x:
+ //
+ // x = - inv(A) * b'
+ //
+ b2Vec2 x = - b2Mul(vc->normalMass, b);
+
+ if (x.x >= 0.0f && x.y >= 0.0f)
+ {
+ // Get the incremental impulse
+ b2Vec2 d = x - a;
+
+ // Apply incremental impulse
+ b2Vec2 P1 = d.x * normal;
+ b2Vec2 P2 = d.y * normal;
+ vA -= mA * (P1 + P2);
+ wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
+
+ vB += mB * (P1 + P2);
+ wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
+
+ // Accumulate
+ cp1->normalImpulse = x.x;
+ cp2->normalImpulse = x.y;
+
+#if B2_DEBUG_SOLVER == 1
+ // Postconditions
+ dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA);
+ dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA);
+
+ // Compute normal velocity
+ vn1 = b2Dot(dv1, normal);
+ vn2 = b2Dot(dv2, normal);
+
+ b2Assert(b2Abs(vn1 - cp1->velocityBias) < k_errorTol);
+ b2Assert(b2Abs(vn2 - cp2->velocityBias) < k_errorTol);
+#endif
+ break;
+ }
+
+ //
+ // Case 2: vn1 = 0 and x2 = 0
+ //
+ // 0 = a11 * x1 + a12 * 0 + b1'
+ // vn2 = a21 * x1 + a22 * 0 + b2'
+ //
+ x.x = - cp1->normalMass * b.x;
+ x.y = 0.0f;
+ vn1 = 0.0f;
+ vn2 = vc->K.ex.y * x.x + b.y;
+ if (x.x >= 0.0f && vn2 >= 0.0f)
+ {
+ // Get the incremental impulse
+ b2Vec2 d = x - a;
+
+ // Apply incremental impulse
+ b2Vec2 P1 = d.x * normal;
+ b2Vec2 P2 = d.y * normal;
+ vA -= mA * (P1 + P2);
+ wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
+
+ vB += mB * (P1 + P2);
+ wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
+
+ // Accumulate
+ cp1->normalImpulse = x.x;
+ cp2->normalImpulse = x.y;
+
+#if B2_DEBUG_SOLVER == 1
+ // Postconditions
+ dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA);
+
+ // Compute normal velocity
+ vn1 = b2Dot(dv1, normal);
+
+ b2Assert(b2Abs(vn1 - cp1->velocityBias) < k_errorTol);
+#endif
+ break;
+ }
+
+
+ //
+ // Case 3: vn2 = 0 and x1 = 0
+ //
+ // vn1 = a11 * 0 + a12 * x2 + b1'
+ // 0 = a21 * 0 + a22 * x2 + b2'
+ //
+ x.x = 0.0f;
+ x.y = - cp2->normalMass * b.y;
+ vn1 = vc->K.ey.x * x.y + b.x;
+ vn2 = 0.0f;
+
+ if (x.y >= 0.0f && vn1 >= 0.0f)
+ {
+ // Resubstitute for the incremental impulse
+ b2Vec2 d = x - a;
+
+ // Apply incremental impulse
+ b2Vec2 P1 = d.x * normal;
+ b2Vec2 P2 = d.y * normal;
+ vA -= mA * (P1 + P2);
+ wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
+
+ vB += mB * (P1 + P2);
+ wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
+
+ // Accumulate
+ cp1->normalImpulse = x.x;
+ cp2->normalImpulse = x.y;
+
+#if B2_DEBUG_SOLVER == 1
+ // Postconditions
+ dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA);
+
+ // Compute normal velocity
+ vn2 = b2Dot(dv2, normal);
+
+ b2Assert(b2Abs(vn2 - cp2->velocityBias) < k_errorTol);
+#endif
+ break;
+ }
+
+ //
+ // Case 4: x1 = 0 and x2 = 0
+ //
+ // vn1 = b1
+ // vn2 = b2;
+ x.x = 0.0f;
+ x.y = 0.0f;
+ vn1 = b.x;
+ vn2 = b.y;
+
+ if (vn1 >= 0.0f && vn2 >= 0.0f )
+ {
+ // Resubstitute for the incremental impulse
+ b2Vec2 d = x - a;
+
+ // Apply incremental impulse
+ b2Vec2 P1 = d.x * normal;
+ b2Vec2 P2 = d.y * normal;
+ vA -= mA * (P1 + P2);
+ wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2));
+
+ vB += mB * (P1 + P2);
+ wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2));
+
+ // Accumulate
+ cp1->normalImpulse = x.x;
+ cp2->normalImpulse = x.y;
+
+ break;
+ }
+
+ // No solution, give up. This is hit sometimes, but it doesn't seem to matter.
+ break;
+ }
+ }
+
+ m_velocities[indexA].v = vA;
+ m_velocities[indexA].w = wA;
+ m_velocities[indexB].v = vB;
+ m_velocities[indexB].w = wB;
+ }
+}
+
+void b2ContactSolver::StoreImpulses()
+{
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2ContactVelocityConstraint* vc = m_velocityConstraints + i;
+ b2Manifold* manifold = m_contacts[vc->contactIndex]->GetManifold();
+
+ for (int32 j = 0; j < vc->pointCount; ++j)
+ {
+ manifold->points[j].normalImpulse = vc->points[j].normalImpulse;
+ manifold->points[j].tangentImpulse = vc->points[j].tangentImpulse;
+ }
+ }
+}
+
+struct b2PositionSolverManifold
+{
+ void Initialize(b2ContactPositionConstraint* pc, const b2Transform& xfA, const b2Transform& xfB, int32 index)
+ {
+ b2Assert(pc->pointCount > 0);
+
+ switch (pc->type)
+ {
+ case b2Manifold::e_circles:
+ {
+ b2Vec2 pointA = b2Mul(xfA, pc->localPoint);
+ b2Vec2 pointB = b2Mul(xfB, pc->localPoints[0]);
+ normal = pointB - pointA;
+ normal.Normalize();
+ point = 0.5f * (pointA + pointB);
+ separation = b2Dot(pointB - pointA, normal) - pc->radiusA - pc->radiusB;
+ }
+ break;
+
+ case b2Manifold::e_faceA:
+ {
+ normal = b2Mul(xfA.q, pc->localNormal);
+ b2Vec2 planePoint = b2Mul(xfA, pc->localPoint);
+
+ b2Vec2 clipPoint = b2Mul(xfB, pc->localPoints[index]);
+ separation = b2Dot(clipPoint - planePoint, normal) - pc->radiusA - pc->radiusB;
+ point = clipPoint;
+ }
+ break;
+
+ case b2Manifold::e_faceB:
+ {
+ normal = b2Mul(xfB.q, pc->localNormal);
+ b2Vec2 planePoint = b2Mul(xfB, pc->localPoint);
+
+ b2Vec2 clipPoint = b2Mul(xfA, pc->localPoints[index]);
+ separation = b2Dot(clipPoint - planePoint, normal) - pc->radiusA - pc->radiusB;
+ point = clipPoint;
+
+ // Ensure normal points from A to B
+ normal = -normal;
+ }
+ break;
+ }
+ }
+
+ b2Vec2 normal;
+ b2Vec2 point;
+ float separation;
+};
+
+// Sequential solver.
+bool b2ContactSolver::SolvePositionConstraints()
+{
+ float minSeparation = 0.0f;
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2ContactPositionConstraint* pc = m_positionConstraints + i;
+
+ int32 indexA = pc->indexA;
+ int32 indexB = pc->indexB;
+ b2Vec2 localCenterA = pc->localCenterA;
+ float mA = pc->invMassA;
+ float iA = pc->invIA;
+ b2Vec2 localCenterB = pc->localCenterB;
+ float mB = pc->invMassB;
+ float iB = pc->invIB;
+ int32 pointCount = pc->pointCount;
+
+ b2Vec2 cA = m_positions[indexA].c;
+ float aA = m_positions[indexA].a;
+
+ b2Vec2 cB = m_positions[indexB].c;
+ float aB = m_positions[indexB].a;
+
+ // Solve normal constraints
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2Transform xfA, xfB;
+ xfA.q.Set(aA);
+ xfB.q.Set(aB);
+ xfA.p = cA - b2Mul(xfA.q, localCenterA);
+ xfB.p = cB - b2Mul(xfB.q, localCenterB);
+
+ b2PositionSolverManifold psm;
+ psm.Initialize(pc, xfA, xfB, j);
+ b2Vec2 normal = psm.normal;
+
+ b2Vec2 point = psm.point;
+ float separation = psm.separation;
+
+ b2Vec2 rA = point - cA;
+ b2Vec2 rB = point - cB;
+
+ // Track max constraint error.
+ minSeparation = b2Min(minSeparation, separation);
+
+ // Prevent large corrections and allow slop.
+ float C = b2Clamp(b2_baumgarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0.0f);
+
+ // Compute the effective mass.
+ float rnA = b2Cross(rA, normal);
+ float rnB = b2Cross(rB, normal);
+ float K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;
+
+ // Compute normal impulse
+ float impulse = K > 0.0f ? - C / K : 0.0f;
+
+ b2Vec2 P = impulse * normal;
+
+ cA -= mA * P;
+ aA -= iA * b2Cross(rA, P);
+
+ cB += mB * P;
+ aB += iB * b2Cross(rB, P);
+ }
+
+ m_positions[indexA].c = cA;
+ m_positions[indexA].a = aA;
+
+ m_positions[indexB].c = cB;
+ m_positions[indexB].a = aB;
+ }
+
+ // We can't expect minSpeparation >= -b2_linearSlop because we don't
+ // push the separation above -b2_linearSlop.
+ return minSeparation >= -3.0f * b2_linearSlop;
+}
+
+// Sequential position solver for position constraints.
+bool b2ContactSolver::SolveTOIPositionConstraints(int32 toiIndexA, int32 toiIndexB)
+{
+ float minSeparation = 0.0f;
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ b2ContactPositionConstraint* pc = m_positionConstraints + i;
+
+ int32 indexA = pc->indexA;
+ int32 indexB = pc->indexB;
+ b2Vec2 localCenterA = pc->localCenterA;
+ b2Vec2 localCenterB = pc->localCenterB;
+ int32 pointCount = pc->pointCount;
+
+ float mA = 0.0f;
+ float iA = 0.0f;
+ if (indexA == toiIndexA || indexA == toiIndexB)
+ {
+ mA = pc->invMassA;
+ iA = pc->invIA;
+ }
+
+ float mB = 0.0f;
+ float iB = 0.;
+ if (indexB == toiIndexA || indexB == toiIndexB)
+ {
+ mB = pc->invMassB;
+ iB = pc->invIB;
+ }
+
+ b2Vec2 cA = m_positions[indexA].c;
+ float aA = m_positions[indexA].a;
+
+ b2Vec2 cB = m_positions[indexB].c;
+ float aB = m_positions[indexB].a;
+
+ // Solve normal constraints
+ for (int32 j = 0; j < pointCount; ++j)
+ {
+ b2Transform xfA, xfB;
+ xfA.q.Set(aA);
+ xfB.q.Set(aB);
+ xfA.p = cA - b2Mul(xfA.q, localCenterA);
+ xfB.p = cB - b2Mul(xfB.q, localCenterB);
+
+ b2PositionSolverManifold psm;
+ psm.Initialize(pc, xfA, xfB, j);
+ b2Vec2 normal = psm.normal;
+
+ b2Vec2 point = psm.point;
+ float separation = psm.separation;
+
+ b2Vec2 rA = point - cA;
+ b2Vec2 rB = point - cB;
+
+ // Track max constraint error.
+ minSeparation = b2Min(minSeparation, separation);
+
+ // Prevent large corrections and allow slop.
+ float C = b2Clamp(b2_toiBaumgarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0.0f);
+
+ // Compute the effective mass.
+ float rnA = b2Cross(rA, normal);
+ float rnB = b2Cross(rB, normal);
+ float K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;
+
+ // Compute normal impulse
+ float impulse = K > 0.0f ? - C / K : 0.0f;
+
+ b2Vec2 P = impulse * normal;
+
+ cA -= mA * P;
+ aA -= iA * b2Cross(rA, P);
+
+ cB += mB * P;
+ aB += iB * b2Cross(rB, P);
+ }
+
+ m_positions[indexA].c = cA;
+ m_positions[indexA].a = aA;
+
+ m_positions[indexB].c = cB;
+ m_positions[indexB].a = aB;
+ }
+
+ // We can't expect minSpeparation >= -b2_linearSlop because we don't
+ // push the separation above -b2_linearSlop.
+ return minSeparation >= -1.5f * b2_linearSlop;
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.h b/Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.h
new file mode 100644
index 0000000..1064738
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_contact_solver.h
@@ -0,0 +1,100 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_CONTACT_SOLVER_H
+#define B2_CONTACT_SOLVER_H
+
+#include "box2d/b2_collision.h"
+#include "box2d/b2_math.h"
+#include "box2d/b2_time_step.h"
+
+class b2Contact;
+class b2Body;
+class b2StackAllocator;
+struct b2ContactPositionConstraint;
+
+struct b2VelocityConstraintPoint
+{
+ b2Vec2 rA;
+ b2Vec2 rB;
+ float normalImpulse;
+ float tangentImpulse;
+ float normalMass;
+ float tangentMass;
+ float velocityBias;
+};
+
+struct b2ContactVelocityConstraint
+{
+ b2VelocityConstraintPoint points[b2_maxManifoldPoints];
+ b2Vec2 normal;
+ b2Mat22 normalMass;
+ b2Mat22 K;
+ int32 indexA;
+ int32 indexB;
+ float invMassA, invMassB;
+ float invIA, invIB;
+ float friction;
+ float restitution;
+ float threshold;
+ float tangentSpeed;
+ int32 pointCount;
+ int32 contactIndex;
+};
+
+struct b2ContactSolverDef
+{
+ b2TimeStep step;
+ b2Contact** contacts;
+ int32 count;
+ b2Position* positions;
+ b2Velocity* velocities;
+ b2StackAllocator* allocator;
+};
+
+class b2ContactSolver
+{
+public:
+ b2ContactSolver(b2ContactSolverDef* def);
+ ~b2ContactSolver();
+
+ void InitializeVelocityConstraints();
+
+ void WarmStart();
+ void SolveVelocityConstraints();
+ void StoreImpulses();
+
+ bool SolvePositionConstraints();
+ bool SolveTOIPositionConstraints(int32 toiIndexA, int32 toiIndexB);
+
+ b2TimeStep m_step;
+ b2Position* m_positions;
+ b2Velocity* m_velocities;
+ b2StackAllocator* m_allocator;
+ b2ContactPositionConstraint* m_positionConstraints;
+ b2ContactVelocityConstraint* m_velocityConstraints;
+ b2Contact** m_contacts;
+ int m_count;
+};
+
+#endif
+
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_distance_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_distance_joint.cpp
new file mode 100644
index 0000000..e54dbaf
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_distance_joint.cpp
@@ -0,0 +1,421 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_draw.h"
+#include "box2d/b2_distance_joint.h"
+#include "box2d/b2_time_step.h"
+
+// 1-D constrained system
+// m (v2 - v1) = lambda
+// v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
+// x2 = x1 + h * v2
+
+// 1-D mass-damper-spring system
+// m (v2 - v1) + h * d * v2 + h * k *
+
+// C = norm(p2 - p1) - L
+// u = (p2 - p1) / norm(p2 - p1)
+// Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
+// J = [-u -cross(r1, u) u cross(r2, u)]
+// K = J * invM * JT
+// = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
+
+
+void b2DistanceJointDef::Initialize(b2Body* b1, b2Body* b2,
+ const b2Vec2& anchor1, const b2Vec2& anchor2)
+{
+ bodyA = b1;
+ bodyB = b2;
+ localAnchorA = bodyA->GetLocalPoint(anchor1);
+ localAnchorB = bodyB->GetLocalPoint(anchor2);
+ b2Vec2 d = anchor2 - anchor1;
+ length = b2Max(d.Length(), b2_linearSlop);
+ minLength = length;
+ maxLength = length;
+}
+
+b2DistanceJoint::b2DistanceJoint(const b2DistanceJointDef* def)
+: b2Joint(def)
+{
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+ m_length = b2Max(def->length, b2_linearSlop);
+ m_minLength = b2Max(def->minLength, b2_linearSlop);
+ m_maxLength = b2Max(def->maxLength, m_minLength);
+ m_stiffness = def->stiffness;
+ m_damping = def->damping;
+
+ m_gamma = 0.0f;
+ m_bias = 0.0f;
+ m_impulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ m_currentLength = 0.0f;
+}
+
+void b2DistanceJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ m_u = cB + m_rB - cA - m_rA;
+
+ // Handle singularity.
+ m_currentLength = m_u.Length();
+ if (m_currentLength > b2_linearSlop)
+ {
+ m_u *= 1.0f / m_currentLength;
+ }
+ else
+ {
+ m_u.Set(0.0f, 0.0f);
+ m_mass = 0.0f;
+ m_impulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ float crAu = b2Cross(m_rA, m_u);
+ float crBu = b2Cross(m_rB, m_u);
+ float invMass = m_invMassA + m_invIA * crAu * crAu + m_invMassB + m_invIB * crBu * crBu;
+ m_mass = invMass != 0.0f ? 1.0f / invMass : 0.0f;
+
+ if (m_stiffness > 0.0f && m_minLength < m_maxLength)
+ {
+ // soft
+ float C = m_currentLength - m_length;
+
+ float d = m_damping;
+ float k = m_stiffness;
+
+ // magic formulas
+ float h = data.step.dt;
+
+ // gamma = 1 / (h * (d + h * k))
+ // the extra factor of h in the denominator is since the lambda is an impulse, not a force
+ m_gamma = h * (d + h * k);
+ m_gamma = m_gamma != 0.0f ? 1.0f / m_gamma : 0.0f;
+ m_bias = C * h * k * m_gamma;
+
+ invMass += m_gamma;
+ m_softMass = invMass != 0.0f ? 1.0f / invMass : 0.0f;
+ }
+ else
+ {
+ // rigid
+ m_gamma = 0.0f;
+ m_bias = 0.0f;
+ m_softMass = m_mass;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Scale the impulse to support a variable time step.
+ m_impulse *= data.step.dtRatio;
+ m_lowerImpulse *= data.step.dtRatio;
+ m_upperImpulse *= data.step.dtRatio;
+
+ b2Vec2 P = (m_impulse + m_lowerImpulse - m_upperImpulse) * m_u;
+ vA -= m_invMassA * P;
+ wA -= m_invIA * b2Cross(m_rA, P);
+ vB += m_invMassB * P;
+ wB += m_invIB * b2Cross(m_rB, P);
+ }
+ else
+ {
+ m_impulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2DistanceJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ if (m_minLength < m_maxLength)
+ {
+ if (m_stiffness > 0.0f)
+ {
+ // Cdot = dot(u, v + cross(w, r))
+ b2Vec2 vpA = vA + b2Cross(wA, m_rA);
+ b2Vec2 vpB = vB + b2Cross(wB, m_rB);
+ float Cdot = b2Dot(m_u, vpB - vpA);
+
+ float impulse = -m_softMass * (Cdot + m_bias + m_gamma * m_impulse);
+ m_impulse += impulse;
+
+ b2Vec2 P = impulse * m_u;
+ vA -= m_invMassA * P;
+ wA -= m_invIA * b2Cross(m_rA, P);
+ vB += m_invMassB * P;
+ wB += m_invIB * b2Cross(m_rB, P);
+ }
+
+ // lower
+ {
+ float C = m_currentLength - m_minLength;
+ float bias = b2Max(0.0f, C) * data.step.inv_dt;
+
+ b2Vec2 vpA = vA + b2Cross(wA, m_rA);
+ b2Vec2 vpB = vB + b2Cross(wB, m_rB);
+ float Cdot = b2Dot(m_u, vpB - vpA);
+
+ float impulse = -m_mass * (Cdot + bias);
+ float oldImpulse = m_lowerImpulse;
+ m_lowerImpulse = b2Max(0.0f, m_lowerImpulse + impulse);
+ impulse = m_lowerImpulse - oldImpulse;
+ b2Vec2 P = impulse * m_u;
+
+ vA -= m_invMassA * P;
+ wA -= m_invIA * b2Cross(m_rA, P);
+ vB += m_invMassB * P;
+ wB += m_invIB * b2Cross(m_rB, P);
+ }
+
+ // upper
+ {
+ float C = m_maxLength - m_currentLength;
+ float bias = b2Max(0.0f, C) * data.step.inv_dt;
+
+ b2Vec2 vpA = vA + b2Cross(wA, m_rA);
+ b2Vec2 vpB = vB + b2Cross(wB, m_rB);
+ float Cdot = b2Dot(m_u, vpA - vpB);
+
+ float impulse = -m_mass * (Cdot + bias);
+ float oldImpulse = m_upperImpulse;
+ m_upperImpulse = b2Max(0.0f, m_upperImpulse + impulse);
+ impulse = m_upperImpulse - oldImpulse;
+ b2Vec2 P = -impulse * m_u;
+
+ vA -= m_invMassA * P;
+ wA -= m_invIA * b2Cross(m_rA, P);
+ vB += m_invMassB * P;
+ wB += m_invIB * b2Cross(m_rB, P);
+ }
+ }
+ else
+ {
+ // Equal limits
+
+ // Cdot = dot(u, v + cross(w, r))
+ b2Vec2 vpA = vA + b2Cross(wA, m_rA);
+ b2Vec2 vpB = vB + b2Cross(wB, m_rB);
+ float Cdot = b2Dot(m_u, vpB - vpA);
+
+ float impulse = -m_mass * Cdot;
+ m_impulse += impulse;
+
+ b2Vec2 P = impulse * m_u;
+ vA -= m_invMassA * P;
+ wA -= m_invIA * b2Cross(m_rA, P);
+ vB += m_invMassB * P;
+ wB += m_invIB * b2Cross(m_rB, P);
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2DistanceJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+
+ b2Rot qA(aA), qB(aB);
+
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ b2Vec2 u = cB + rB - cA - rA;
+
+ float length = u.Normalize();
+ float C;
+ if (m_minLength == m_maxLength)
+ {
+ C = length - m_minLength;
+ }
+ else if (length < m_minLength)
+ {
+ C = length - m_minLength;
+ }
+ else if (m_maxLength < length)
+ {
+ C = length - m_maxLength;
+ }
+ else
+ {
+ return true;
+ }
+
+ float impulse = -m_mass * C;
+ b2Vec2 P = impulse * u;
+
+ cA -= m_invMassA * P;
+ aA -= m_invIA * b2Cross(rA, P);
+ cB += m_invMassB * P;
+ aB += m_invIB * b2Cross(rB, P);
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+
+ return b2Abs(C) < b2_linearSlop;
+}
+
+b2Vec2 b2DistanceJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2DistanceJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2DistanceJoint::GetReactionForce(float inv_dt) const
+{
+ b2Vec2 F = inv_dt * (m_impulse + m_lowerImpulse - m_upperImpulse) * m_u;
+ return F;
+}
+
+float b2DistanceJoint::GetReactionTorque(float inv_dt) const
+{
+ B2_NOT_USED(inv_dt);
+ return 0.0f;
+}
+
+float b2DistanceJoint::SetLength(float length)
+{
+ m_impulse = 0.0f;
+ m_length = b2Max(b2_linearSlop, length);
+ return m_length;
+}
+
+float b2DistanceJoint::SetMinLength(float minLength)
+{
+ m_lowerImpulse = 0.0f;
+ m_minLength = b2Clamp(minLength, b2_linearSlop, m_maxLength);
+ return m_minLength;
+}
+
+float b2DistanceJoint::SetMaxLength(float maxLength)
+{
+ m_upperImpulse = 0.0f;
+ m_maxLength = b2Max(maxLength, m_minLength);
+ return m_maxLength;
+}
+
+float b2DistanceJoint::GetCurrentLength() const
+{
+ b2Vec2 pA = m_bodyA->GetWorldPoint(m_localAnchorA);
+ b2Vec2 pB = m_bodyB->GetWorldPoint(m_localAnchorB);
+ b2Vec2 d = pB - pA;
+ float length = d.Length();
+ return length;
+}
+
+void b2DistanceJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2DistanceJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.length = %.9g;\n", m_length);
+ b2Dump(" jd.minLength = %.9g;\n", m_minLength);
+ b2Dump(" jd.maxLength = %.9g;\n", m_maxLength);
+ b2Dump(" jd.stiffness = %.9g;\n", m_stiffness);
+ b2Dump(" jd.damping = %.9g;\n", m_damping);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
+
+void b2DistanceJoint::Draw(b2Draw* draw) const
+{
+ const b2Transform& xfA = m_bodyA->GetTransform();
+ const b2Transform& xfB = m_bodyB->GetTransform();
+ b2Vec2 pA = b2Mul(xfA, m_localAnchorA);
+ b2Vec2 pB = b2Mul(xfB, m_localAnchorB);
+
+ b2Vec2 axis = pB - pA;
+ float length = axis.Normalize();
+
+ b2Color c1(0.7f, 0.7f, 0.7f);
+ b2Color c2(0.3f, 0.9f, 0.3f);
+ b2Color c3(0.9f, 0.3f, 0.3f);
+ b2Color c4(0.4f, 0.4f, 0.4f);
+
+ draw->DrawSegment(pA, pB, c4);
+
+ b2Vec2 pRest = pA + m_length * axis;
+ draw->DrawPoint(pRest, 8.0f, c1);
+
+ if (m_minLength != m_maxLength)
+ {
+ if (m_minLength > b2_linearSlop)
+ {
+ b2Vec2 pMin = pA + m_minLength * axis;
+ draw->DrawPoint(pMin, 4.0f, c2);
+ }
+
+ if (m_maxLength < FLT_MAX)
+ {
+ b2Vec2 pMax = pA + m_maxLength * axis;
+ draw->DrawPoint(pMax, 4.0f, c3);
+ }
+ }
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.cpp
new file mode 100644
index 0000000..8a126de
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.cpp
@@ -0,0 +1,54 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_edge_circle_contact.h"
+
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_fixture.h"
+
+#include <new>
+
+b2Contact* b2EdgeAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2EdgeAndCircleContact));
+ return new (mem) b2EdgeAndCircleContact(fixtureA, fixtureB);
+}
+
+void b2EdgeAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2EdgeAndCircleContact*)contact)->~b2EdgeAndCircleContact();
+ allocator->Free(contact, sizeof(b2EdgeAndCircleContact));
+}
+
+b2EdgeAndCircleContact::b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB)
+: b2Contact(fixtureA, 0, fixtureB, 0)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_edge);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_circle);
+}
+
+void b2EdgeAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2CollideEdgeAndCircle( manifold,
+ (b2EdgeShape*)m_fixtureA->GetShape(), xfA,
+ (b2CircleShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.h
new file mode 100644
index 0000000..3efc88e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_circle_contact.h
@@ -0,0 +1,43 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_EDGE_AND_CIRCLE_CONTACT_H
+#define B2_EDGE_AND_CIRCLE_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2EdgeAndCircleContact : public b2Contact
+{
+public:
+ static b2Contact* Create( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB);
+ ~b2EdgeAndCircleContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.cpp
new file mode 100644
index 0000000..e617e35
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.cpp
@@ -0,0 +1,54 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_edge_polygon_contact.h"
+
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_fixture.h"
+
+#include <new>
+
+b2Contact* b2EdgeAndPolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2EdgeAndPolygonContact));
+ return new (mem) b2EdgeAndPolygonContact(fixtureA, fixtureB);
+}
+
+void b2EdgeAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2EdgeAndPolygonContact*)contact)->~b2EdgeAndPolygonContact();
+ allocator->Free(contact, sizeof(b2EdgeAndPolygonContact));
+}
+
+b2EdgeAndPolygonContact::b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB)
+: b2Contact(fixtureA, 0, fixtureB, 0)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_edge);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon);
+}
+
+void b2EdgeAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2CollideEdgeAndPolygon( manifold,
+ (b2EdgeShape*)m_fixtureA->GetShape(), xfA,
+ (b2PolygonShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.h
new file mode 100644
index 0000000..e6616b5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_edge_polygon_contact.h
@@ -0,0 +1,43 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_EDGE_AND_POLYGON_CONTACT_H
+#define B2_EDGE_AND_POLYGON_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2EdgeAndPolygonContact : public b2Contact
+{
+public:
+ static b2Contact* Create( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB);
+ ~b2EdgeAndPolygonContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_fixture.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_fixture.cpp
new file mode 100644
index 0000000..9fd700a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_fixture.cpp
@@ -0,0 +1,305 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_broad_phase.h"
+#include "box2d/b2_chain_shape.h"
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_collision.h"
+#include "box2d/b2_contact.h"
+#include "box2d/b2_edge_shape.h"
+#include "box2d/b2_polygon_shape.h"
+#include "box2d/b2_world.h"
+
+b2Fixture::b2Fixture()
+{
+ m_body = nullptr;
+ m_next = nullptr;
+ m_proxies = nullptr;
+ m_proxyCount = 0;
+ m_shape = nullptr;
+ m_density = 0.0f;
+}
+
+void b2Fixture::Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def)
+{
+ m_userData = def->userData;
+ m_friction = def->friction;
+ m_restitution = def->restitution;
+ m_restitutionThreshold = def->restitutionThreshold;
+
+ m_body = body;
+ m_next = nullptr;
+
+ m_filter = def->filter;
+
+ m_isSensor = def->isSensor;
+
+ m_shape = def->shape->Clone(allocator);
+
+ // Reserve proxy space
+ int32 childCount = m_shape->GetChildCount();
+ m_proxies = (b2FixtureProxy*)allocator->Allocate(childCount * sizeof(b2FixtureProxy));
+ for (int32 i = 0; i < childCount; ++i)
+ {
+ m_proxies[i].fixture = nullptr;
+ m_proxies[i].proxyId = b2BroadPhase::e_nullProxy;
+ }
+ m_proxyCount = 0;
+
+ m_density = def->density;
+}
+
+void b2Fixture::Destroy(b2BlockAllocator* allocator)
+{
+ // The proxies must be destroyed before calling this.
+ b2Assert(m_proxyCount == 0);
+
+ // Free the proxy array.
+ int32 childCount = m_shape->GetChildCount();
+ allocator->Free(m_proxies, childCount * sizeof(b2FixtureProxy));
+ m_proxies = nullptr;
+
+ // Free the child shape.
+ switch (m_shape->m_type)
+ {
+ case b2Shape::e_circle:
+ {
+ b2CircleShape* s = (b2CircleShape*)m_shape;
+ s->~b2CircleShape();
+ allocator->Free(s, sizeof(b2CircleShape));
+ }
+ break;
+
+ case b2Shape::e_edge:
+ {
+ b2EdgeShape* s = (b2EdgeShape*)m_shape;
+ s->~b2EdgeShape();
+ allocator->Free(s, sizeof(b2EdgeShape));
+ }
+ break;
+
+ case b2Shape::e_polygon:
+ {
+ b2PolygonShape* s = (b2PolygonShape*)m_shape;
+ s->~b2PolygonShape();
+ allocator->Free(s, sizeof(b2PolygonShape));
+ }
+ break;
+
+ case b2Shape::e_chain:
+ {
+ b2ChainShape* s = (b2ChainShape*)m_shape;
+ s->~b2ChainShape();
+ allocator->Free(s, sizeof(b2ChainShape));
+ }
+ break;
+
+ default:
+ b2Assert(false);
+ break;
+ }
+
+ m_shape = nullptr;
+}
+
+void b2Fixture::CreateProxies(b2BroadPhase* broadPhase, const b2Transform& xf)
+{
+ b2Assert(m_proxyCount == 0);
+
+ // Create proxies in the broad-phase.
+ m_proxyCount = m_shape->GetChildCount();
+
+ for (int32 i = 0; i < m_proxyCount; ++i)
+ {
+ b2FixtureProxy* proxy = m_proxies + i;
+ m_shape->ComputeAABB(&proxy->aabb, xf, i);
+ proxy->proxyId = broadPhase->CreateProxy(proxy->aabb, proxy);
+ proxy->fixture = this;
+ proxy->childIndex = i;
+ }
+}
+
+void b2Fixture::DestroyProxies(b2BroadPhase* broadPhase)
+{
+ // Destroy proxies in the broad-phase.
+ for (int32 i = 0; i < m_proxyCount; ++i)
+ {
+ b2FixtureProxy* proxy = m_proxies + i;
+ broadPhase->DestroyProxy(proxy->proxyId);
+ proxy->proxyId = b2BroadPhase::e_nullProxy;
+ }
+
+ m_proxyCount = 0;
+}
+
+void b2Fixture::Synchronize(b2BroadPhase* broadPhase, const b2Transform& transform1, const b2Transform& transform2)
+{
+ if (m_proxyCount == 0)
+ {
+ return;
+ }
+
+ for (int32 i = 0; i < m_proxyCount; ++i)
+ {
+ b2FixtureProxy* proxy = m_proxies + i;
+
+ // Compute an AABB that covers the swept shape (may miss some rotation effect).
+ b2AABB aabb1, aabb2;
+ m_shape->ComputeAABB(&aabb1, transform1, proxy->childIndex);
+ m_shape->ComputeAABB(&aabb2, transform2, proxy->childIndex);
+
+ proxy->aabb.Combine(aabb1, aabb2);
+
+ b2Vec2 displacement = aabb2.GetCenter() - aabb1.GetCenter();
+
+ broadPhase->MoveProxy(proxy->proxyId, proxy->aabb, displacement);
+ }
+}
+
+void b2Fixture::SetFilterData(const b2Filter& filter)
+{
+ m_filter = filter;
+
+ Refilter();
+}
+
+void b2Fixture::Refilter()
+{
+ if (m_body == nullptr)
+ {
+ return;
+ }
+
+ // Flag associated contacts for filtering.
+ b2ContactEdge* edge = m_body->GetContactList();
+ while (edge)
+ {
+ b2Contact* contact = edge->contact;
+ b2Fixture* fixtureA = contact->GetFixtureA();
+ b2Fixture* fixtureB = contact->GetFixtureB();
+ if (fixtureA == this || fixtureB == this)
+ {
+ contact->FlagForFiltering();
+ }
+
+ edge = edge->next;
+ }
+
+ b2World* world = m_body->GetWorld();
+
+ if (world == nullptr)
+ {
+ return;
+ }
+
+ // Touch each proxy so that new pairs may be created
+ b2BroadPhase* broadPhase = &world->m_contactManager.m_broadPhase;
+ for (int32 i = 0; i < m_proxyCount; ++i)
+ {
+ broadPhase->TouchProxy(m_proxies[i].proxyId);
+ }
+}
+
+void b2Fixture::SetSensor(bool sensor)
+{
+ if (sensor != m_isSensor)
+ {
+ m_body->SetAwake(true);
+ m_isSensor = sensor;
+ }
+}
+
+void b2Fixture::Dump(int32 bodyIndex)
+{
+ b2Dump(" b2FixtureDef fd;\n");
+ b2Dump(" fd.friction = %.9g;\n", m_friction);
+ b2Dump(" fd.restitution = %.9g;\n", m_restitution);
+ b2Dump(" fd.restitutionThreshold = %.9g;\n", m_restitutionThreshold);
+ b2Dump(" fd.density = %.9g;\n", m_density);
+ b2Dump(" fd.isSensor = bool(%d);\n", m_isSensor);
+ b2Dump(" fd.filter.categoryBits = uint16(%d);\n", m_filter.categoryBits);
+ b2Dump(" fd.filter.maskBits = uint16(%d);\n", m_filter.maskBits);
+ b2Dump(" fd.filter.groupIndex = int16(%d);\n", m_filter.groupIndex);
+
+ switch (m_shape->m_type)
+ {
+ case b2Shape::e_circle:
+ {
+ b2CircleShape* s = (b2CircleShape*)m_shape;
+ b2Dump(" b2CircleShape shape;\n");
+ b2Dump(" shape.m_radius = %.9g;\n", s->m_radius);
+ b2Dump(" shape.m_p.Set(%.9g, %.9g);\n", s->m_p.x, s->m_p.y);
+ }
+ break;
+
+ case b2Shape::e_edge:
+ {
+ b2EdgeShape* s = (b2EdgeShape*)m_shape;
+ b2Dump(" b2EdgeShape shape;\n");
+ b2Dump(" shape.m_radius = %.9g;\n", s->m_radius);
+ b2Dump(" shape.m_vertex0.Set(%.9g, %.9g);\n", s->m_vertex0.x, s->m_vertex0.y);
+ b2Dump(" shape.m_vertex1.Set(%.9g, %.9g);\n", s->m_vertex1.x, s->m_vertex1.y);
+ b2Dump(" shape.m_vertex2.Set(%.9g, %.9g);\n", s->m_vertex2.x, s->m_vertex2.y);
+ b2Dump(" shape.m_vertex3.Set(%.9g, %.9g);\n", s->m_vertex3.x, s->m_vertex3.y);
+ b2Dump(" shape.m_oneSided = bool(%d);\n", s->m_oneSided);
+ }
+ break;
+
+ case b2Shape::e_polygon:
+ {
+ b2PolygonShape* s = (b2PolygonShape*)m_shape;
+ b2Dump(" b2PolygonShape shape;\n");
+ b2Dump(" b2Vec2 vs[%d];\n", b2_maxPolygonVertices);
+ for (int32 i = 0; i < s->m_count; ++i)
+ {
+ b2Dump(" vs[%d].Set(%.9g, %.9g);\n", i, s->m_vertices[i].x, s->m_vertices[i].y);
+ }
+ b2Dump(" shape.Set(vs, %d);\n", s->m_count);
+ }
+ break;
+
+ case b2Shape::e_chain:
+ {
+ b2ChainShape* s = (b2ChainShape*)m_shape;
+ b2Dump(" b2ChainShape shape;\n");
+ b2Dump(" b2Vec2 vs[%d];\n", s->m_count);
+ for (int32 i = 0; i < s->m_count; ++i)
+ {
+ b2Dump(" vs[%d].Set(%.9g, %.9g);\n", i, s->m_vertices[i].x, s->m_vertices[i].y);
+ }
+ b2Dump(" shape.CreateChain(vs, %d);\n", s->m_count);
+ b2Dump(" shape.m_prevVertex.Set(%.9g, %.9g);\n", s->m_prevVertex.x, s->m_prevVertex.y);
+ b2Dump(" shape.m_nextVertex.Set(%.9g, %.9g);\n", s->m_nextVertex.x, s->m_nextVertex.y);
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ b2Dump("\n");
+ b2Dump(" fd.shape = &shape;\n");
+ b2Dump("\n");
+ b2Dump(" bodies[%d]->CreateFixture(&fd);\n", bodyIndex);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_friction_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_friction_joint.cpp
new file mode 100644
index 0000000..d9d893a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_friction_joint.cpp
@@ -0,0 +1,255 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_friction_joint.h"
+#include "box2d/b2_body.h"
+#include "box2d/b2_time_step.h"
+
+// Point-to-point constraint
+// Cdot = v2 - v1
+// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
+// J = [-I -r1_skew I r2_skew ]
+// Identity used:
+// w k % (rx i + ry j) = w * (-ry i + rx j)
+
+// Angle constraint
+// Cdot = w2 - w1
+// J = [0 0 -1 0 0 1]
+// K = invI1 + invI2
+
+void b2FrictionJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor)
+{
+ bodyA = bA;
+ bodyB = bB;
+ localAnchorA = bodyA->GetLocalPoint(anchor);
+ localAnchorB = bodyB->GetLocalPoint(anchor);
+}
+
+b2FrictionJoint::b2FrictionJoint(const b2FrictionJointDef* def)
+: b2Joint(def)
+{
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+
+ m_linearImpulse.SetZero();
+ m_angularImpulse = 0.0f;
+
+ m_maxForce = def->maxForce;
+ m_maxTorque = def->maxTorque;
+}
+
+void b2FrictionJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ // Compute the effective mass matrix.
+ m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ // J = [-I -r1_skew I r2_skew]
+ // [ 0 -1 0 1]
+ // r_skew = [-ry; rx]
+
+ // Matlab
+ // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]
+ // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]
+ // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ b2Mat22 K;
+ K.ex.x = mA + mB + iA * m_rA.y * m_rA.y + iB * m_rB.y * m_rB.y;
+ K.ex.y = -iA * m_rA.x * m_rA.y - iB * m_rB.x * m_rB.y;
+ K.ey.x = K.ex.y;
+ K.ey.y = mA + mB + iA * m_rA.x * m_rA.x + iB * m_rB.x * m_rB.x;
+
+ m_linearMass = K.GetInverse();
+
+ m_angularMass = iA + iB;
+ if (m_angularMass > 0.0f)
+ {
+ m_angularMass = 1.0f / m_angularMass;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Scale impulses to support a variable time step.
+ m_linearImpulse *= data.step.dtRatio;
+ m_angularImpulse *= data.step.dtRatio;
+
+ b2Vec2 P(m_linearImpulse.x, m_linearImpulse.y);
+ vA -= mA * P;
+ wA -= iA * (b2Cross(m_rA, P) + m_angularImpulse);
+ vB += mB * P;
+ wB += iB * (b2Cross(m_rB, P) + m_angularImpulse);
+ }
+ else
+ {
+ m_linearImpulse.SetZero();
+ m_angularImpulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2FrictionJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ float h = data.step.dt;
+
+ // Solve angular friction
+ {
+ float Cdot = wB - wA;
+ float impulse = -m_angularMass * Cdot;
+
+ float oldImpulse = m_angularImpulse;
+ float maxImpulse = h * m_maxTorque;
+ m_angularImpulse = b2Clamp(m_angularImpulse + impulse, -maxImpulse, maxImpulse);
+ impulse = m_angularImpulse - oldImpulse;
+
+ wA -= iA * impulse;
+ wB += iB * impulse;
+ }
+
+ // Solve linear friction
+ {
+ b2Vec2 Cdot = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA);
+
+ b2Vec2 impulse = -b2Mul(m_linearMass, Cdot);
+ b2Vec2 oldImpulse = m_linearImpulse;
+ m_linearImpulse += impulse;
+
+ float maxImpulse = h * m_maxForce;
+
+ if (m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse)
+ {
+ m_linearImpulse.Normalize();
+ m_linearImpulse *= maxImpulse;
+ }
+
+ impulse = m_linearImpulse - oldImpulse;
+
+ vA -= mA * impulse;
+ wA -= iA * b2Cross(m_rA, impulse);
+
+ vB += mB * impulse;
+ wB += iB * b2Cross(m_rB, impulse);
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2FrictionJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ B2_NOT_USED(data);
+
+ return true;
+}
+
+b2Vec2 b2FrictionJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2FrictionJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2FrictionJoint::GetReactionForce(float inv_dt) const
+{
+ return inv_dt * m_linearImpulse;
+}
+
+float b2FrictionJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * m_angularImpulse;
+}
+
+void b2FrictionJoint::SetMaxForce(float force)
+{
+ b2Assert(b2IsValid(force) && force >= 0.0f);
+ m_maxForce = force;
+}
+
+float b2FrictionJoint::GetMaxForce() const
+{
+ return m_maxForce;
+}
+
+void b2FrictionJoint::SetMaxTorque(float torque)
+{
+ b2Assert(b2IsValid(torque) && torque >= 0.0f);
+ m_maxTorque = torque;
+}
+
+float b2FrictionJoint::GetMaxTorque() const
+{
+ return m_maxTorque;
+}
+
+void b2FrictionJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2FrictionJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.maxForce = %.9g;\n", m_maxForce);
+ b2Dump(" jd.maxTorque = %.9g;\n", m_maxTorque);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_gear_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_gear_joint.cpp
new file mode 100644
index 0000000..ff36d3e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_gear_joint.cpp
@@ -0,0 +1,429 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_gear_joint.h"
+#include "box2d/b2_revolute_joint.h"
+#include "box2d/b2_prismatic_joint.h"
+#include "box2d/b2_body.h"
+#include "box2d/b2_time_step.h"
+
+// Gear Joint:
+// C0 = (coordinate1 + ratio * coordinate2)_initial
+// C = (coordinate1 + ratio * coordinate2) - C0 = 0
+// J = [J1 ratio * J2]
+// K = J * invM * JT
+// = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T
+//
+// Revolute:
+// coordinate = rotation
+// Cdot = angularVelocity
+// J = [0 0 1]
+// K = J * invM * JT = invI
+//
+// Prismatic:
+// coordinate = dot(p - pg, ug)
+// Cdot = dot(v + cross(w, r), ug)
+// J = [ug cross(r, ug)]
+// K = J * invM * JT = invMass + invI * cross(r, ug)^2
+
+b2GearJoint::b2GearJoint(const b2GearJointDef* def)
+: b2Joint(def)
+{
+ m_joint1 = def->joint1;
+ m_joint2 = def->joint2;
+
+ m_typeA = m_joint1->GetType();
+ m_typeB = m_joint2->GetType();
+
+ b2Assert(m_typeA == e_revoluteJoint || m_typeA == e_prismaticJoint);
+ b2Assert(m_typeB == e_revoluteJoint || m_typeB == e_prismaticJoint);
+
+ float coordinateA, coordinateB;
+
+ // TODO_ERIN there might be some problem with the joint edges in b2Joint.
+
+ m_bodyC = m_joint1->GetBodyA();
+ m_bodyA = m_joint1->GetBodyB();
+
+ // Body B on joint1 must be dynamic
+ b2Assert(m_bodyA->m_type == b2_dynamicBody);
+
+ // Get geometry of joint1
+ b2Transform xfA = m_bodyA->m_xf;
+ float aA = m_bodyA->m_sweep.a;
+ b2Transform xfC = m_bodyC->m_xf;
+ float aC = m_bodyC->m_sweep.a;
+
+ if (m_typeA == e_revoluteJoint)
+ {
+ b2RevoluteJoint* revolute = (b2RevoluteJoint*)def->joint1;
+ m_localAnchorC = revolute->m_localAnchorA;
+ m_localAnchorA = revolute->m_localAnchorB;
+ m_referenceAngleA = revolute->m_referenceAngle;
+ m_localAxisC.SetZero();
+
+ coordinateA = aA - aC - m_referenceAngleA;
+ }
+ else
+ {
+ b2PrismaticJoint* prismatic = (b2PrismaticJoint*)def->joint1;
+ m_localAnchorC = prismatic->m_localAnchorA;
+ m_localAnchorA = prismatic->m_localAnchorB;
+ m_referenceAngleA = prismatic->m_referenceAngle;
+ m_localAxisC = prismatic->m_localXAxisA;
+
+ b2Vec2 pC = m_localAnchorC;
+ b2Vec2 pA = b2MulT(xfC.q, b2Mul(xfA.q, m_localAnchorA) + (xfA.p - xfC.p));
+ coordinateA = b2Dot(pA - pC, m_localAxisC);
+ }
+
+ m_bodyD = m_joint2->GetBodyA();
+ m_bodyB = m_joint2->GetBodyB();
+
+ // Body B on joint2 must be dynamic
+ b2Assert(m_bodyB->m_type == b2_dynamicBody);
+
+ // Get geometry of joint2
+ b2Transform xfB = m_bodyB->m_xf;
+ float aB = m_bodyB->m_sweep.a;
+ b2Transform xfD = m_bodyD->m_xf;
+ float aD = m_bodyD->m_sweep.a;
+
+ if (m_typeB == e_revoluteJoint)
+ {
+ b2RevoluteJoint* revolute = (b2RevoluteJoint*)def->joint2;
+ m_localAnchorD = revolute->m_localAnchorA;
+ m_localAnchorB = revolute->m_localAnchorB;
+ m_referenceAngleB = revolute->m_referenceAngle;
+ m_localAxisD.SetZero();
+
+ coordinateB = aB - aD - m_referenceAngleB;
+ }
+ else
+ {
+ b2PrismaticJoint* prismatic = (b2PrismaticJoint*)def->joint2;
+ m_localAnchorD = prismatic->m_localAnchorA;
+ m_localAnchorB = prismatic->m_localAnchorB;
+ m_referenceAngleB = prismatic->m_referenceAngle;
+ m_localAxisD = prismatic->m_localXAxisA;
+
+ b2Vec2 pD = m_localAnchorD;
+ b2Vec2 pB = b2MulT(xfD.q, b2Mul(xfB.q, m_localAnchorB) + (xfB.p - xfD.p));
+ coordinateB = b2Dot(pB - pD, m_localAxisD);
+ }
+
+ m_ratio = def->ratio;
+
+ m_constant = coordinateA + m_ratio * coordinateB;
+
+ m_impulse = 0.0f;
+}
+
+void b2GearJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_indexC = m_bodyC->m_islandIndex;
+ m_indexD = m_bodyD->m_islandIndex;
+ m_lcA = m_bodyA->m_sweep.localCenter;
+ m_lcB = m_bodyB->m_sweep.localCenter;
+ m_lcC = m_bodyC->m_sweep.localCenter;
+ m_lcD = m_bodyD->m_sweep.localCenter;
+ m_mA = m_bodyA->m_invMass;
+ m_mB = m_bodyB->m_invMass;
+ m_mC = m_bodyC->m_invMass;
+ m_mD = m_bodyD->m_invMass;
+ m_iA = m_bodyA->m_invI;
+ m_iB = m_bodyB->m_invI;
+ m_iC = m_bodyC->m_invI;
+ m_iD = m_bodyD->m_invI;
+
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ float aC = data.positions[m_indexC].a;
+ b2Vec2 vC = data.velocities[m_indexC].v;
+ float wC = data.velocities[m_indexC].w;
+
+ float aD = data.positions[m_indexD].a;
+ b2Vec2 vD = data.velocities[m_indexD].v;
+ float wD = data.velocities[m_indexD].w;
+
+ b2Rot qA(aA), qB(aB), qC(aC), qD(aD);
+
+ m_mass = 0.0f;
+
+ if (m_typeA == e_revoluteJoint)
+ {
+ m_JvAC.SetZero();
+ m_JwA = 1.0f;
+ m_JwC = 1.0f;
+ m_mass += m_iA + m_iC;
+ }
+ else
+ {
+ b2Vec2 u = b2Mul(qC, m_localAxisC);
+ b2Vec2 rC = b2Mul(qC, m_localAnchorC - m_lcC);
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_lcA);
+ m_JvAC = u;
+ m_JwC = b2Cross(rC, u);
+ m_JwA = b2Cross(rA, u);
+ m_mass += m_mC + m_mA + m_iC * m_JwC * m_JwC + m_iA * m_JwA * m_JwA;
+ }
+
+ if (m_typeB == e_revoluteJoint)
+ {
+ m_JvBD.SetZero();
+ m_JwB = m_ratio;
+ m_JwD = m_ratio;
+ m_mass += m_ratio * m_ratio * (m_iB + m_iD);
+ }
+ else
+ {
+ b2Vec2 u = b2Mul(qD, m_localAxisD);
+ b2Vec2 rD = b2Mul(qD, m_localAnchorD - m_lcD);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_lcB);
+ m_JvBD = m_ratio * u;
+ m_JwD = m_ratio * b2Cross(rD, u);
+ m_JwB = m_ratio * b2Cross(rB, u);
+ m_mass += m_ratio * m_ratio * (m_mD + m_mB) + m_iD * m_JwD * m_JwD + m_iB * m_JwB * m_JwB;
+ }
+
+ // Compute effective mass.
+ m_mass = m_mass > 0.0f ? 1.0f / m_mass : 0.0f;
+
+ if (data.step.warmStarting)
+ {
+ vA += (m_mA * m_impulse) * m_JvAC;
+ wA += m_iA * m_impulse * m_JwA;
+ vB += (m_mB * m_impulse) * m_JvBD;
+ wB += m_iB * m_impulse * m_JwB;
+ vC -= (m_mC * m_impulse) * m_JvAC;
+ wC -= m_iC * m_impulse * m_JwC;
+ vD -= (m_mD * m_impulse) * m_JvBD;
+ wD -= m_iD * m_impulse * m_JwD;
+ }
+ else
+ {
+ m_impulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+ data.velocities[m_indexC].v = vC;
+ data.velocities[m_indexC].w = wC;
+ data.velocities[m_indexD].v = vD;
+ data.velocities[m_indexD].w = wD;
+}
+
+void b2GearJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+ b2Vec2 vC = data.velocities[m_indexC].v;
+ float wC = data.velocities[m_indexC].w;
+ b2Vec2 vD = data.velocities[m_indexD].v;
+ float wD = data.velocities[m_indexD].w;
+
+ float Cdot = b2Dot(m_JvAC, vA - vC) + b2Dot(m_JvBD, vB - vD);
+ Cdot += (m_JwA * wA - m_JwC * wC) + (m_JwB * wB - m_JwD * wD);
+
+ float impulse = -m_mass * Cdot;
+ m_impulse += impulse;
+
+ vA += (m_mA * impulse) * m_JvAC;
+ wA += m_iA * impulse * m_JwA;
+ vB += (m_mB * impulse) * m_JvBD;
+ wB += m_iB * impulse * m_JwB;
+ vC -= (m_mC * impulse) * m_JvAC;
+ wC -= m_iC * impulse * m_JwC;
+ vD -= (m_mD * impulse) * m_JvBD;
+ wD -= m_iD * impulse * m_JwD;
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+ data.velocities[m_indexC].v = vC;
+ data.velocities[m_indexC].w = wC;
+ data.velocities[m_indexD].v = vD;
+ data.velocities[m_indexD].w = wD;
+}
+
+bool b2GearJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 cC = data.positions[m_indexC].c;
+ float aC = data.positions[m_indexC].a;
+ b2Vec2 cD = data.positions[m_indexD].c;
+ float aD = data.positions[m_indexD].a;
+
+ b2Rot qA(aA), qB(aB), qC(aC), qD(aD);
+
+ float linearError = 0.0f;
+
+ float coordinateA, coordinateB;
+
+ b2Vec2 JvAC, JvBD;
+ float JwA, JwB, JwC, JwD;
+ float mass = 0.0f;
+
+ if (m_typeA == e_revoluteJoint)
+ {
+ JvAC.SetZero();
+ JwA = 1.0f;
+ JwC = 1.0f;
+ mass += m_iA + m_iC;
+
+ coordinateA = aA - aC - m_referenceAngleA;
+ }
+ else
+ {
+ b2Vec2 u = b2Mul(qC, m_localAxisC);
+ b2Vec2 rC = b2Mul(qC, m_localAnchorC - m_lcC);
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_lcA);
+ JvAC = u;
+ JwC = b2Cross(rC, u);
+ JwA = b2Cross(rA, u);
+ mass += m_mC + m_mA + m_iC * JwC * JwC + m_iA * JwA * JwA;
+
+ b2Vec2 pC = m_localAnchorC - m_lcC;
+ b2Vec2 pA = b2MulT(qC, rA + (cA - cC));
+ coordinateA = b2Dot(pA - pC, m_localAxisC);
+ }
+
+ if (m_typeB == e_revoluteJoint)
+ {
+ JvBD.SetZero();
+ JwB = m_ratio;
+ JwD = m_ratio;
+ mass += m_ratio * m_ratio * (m_iB + m_iD);
+
+ coordinateB = aB - aD - m_referenceAngleB;
+ }
+ else
+ {
+ b2Vec2 u = b2Mul(qD, m_localAxisD);
+ b2Vec2 rD = b2Mul(qD, m_localAnchorD - m_lcD);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_lcB);
+ JvBD = m_ratio * u;
+ JwD = m_ratio * b2Cross(rD, u);
+ JwB = m_ratio * b2Cross(rB, u);
+ mass += m_ratio * m_ratio * (m_mD + m_mB) + m_iD * JwD * JwD + m_iB * JwB * JwB;
+
+ b2Vec2 pD = m_localAnchorD - m_lcD;
+ b2Vec2 pB = b2MulT(qD, rB + (cB - cD));
+ coordinateB = b2Dot(pB - pD, m_localAxisD);
+ }
+
+ float C = (coordinateA + m_ratio * coordinateB) - m_constant;
+
+ float impulse = 0.0f;
+ if (mass > 0.0f)
+ {
+ impulse = -C / mass;
+ }
+
+ cA += m_mA * impulse * JvAC;
+ aA += m_iA * impulse * JwA;
+ cB += m_mB * impulse * JvBD;
+ aB += m_iB * impulse * JwB;
+ cC -= m_mC * impulse * JvAC;
+ aC -= m_iC * impulse * JwC;
+ cD -= m_mD * impulse * JvBD;
+ aD -= m_iD * impulse * JwD;
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+ data.positions[m_indexC].c = cC;
+ data.positions[m_indexC].a = aC;
+ data.positions[m_indexD].c = cD;
+ data.positions[m_indexD].a = aD;
+
+ // TODO_ERIN not implemented
+ return linearError < b2_linearSlop;
+}
+
+b2Vec2 b2GearJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2GearJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2GearJoint::GetReactionForce(float inv_dt) const
+{
+ b2Vec2 P = m_impulse * m_JvAC;
+ return inv_dt * P;
+}
+
+float b2GearJoint::GetReactionTorque(float inv_dt) const
+{
+ float L = m_impulse * m_JwA;
+ return inv_dt * L;
+}
+
+void b2GearJoint::SetRatio(float ratio)
+{
+ b2Assert(b2IsValid(ratio));
+ m_ratio = ratio;
+}
+
+float b2GearJoint::GetRatio() const
+{
+ return m_ratio;
+}
+
+void b2GearJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ int32 index1 = m_joint1->m_index;
+ int32 index2 = m_joint2->m_index;
+
+ b2Dump(" b2GearJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.joint1 = joints[%d];\n", index1);
+ b2Dump(" jd.joint2 = joints[%d];\n", index2);
+ b2Dump(" jd.ratio = %.9g;\n", m_ratio);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_island.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_island.cpp
new file mode 100644
index 0000000..48d89a8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_island.cpp
@@ -0,0 +1,544 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_contact.h"
+#include "box2d/b2_distance.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_joint.h"
+#include "box2d/b2_stack_allocator.h"
+#include "box2d/b2_timer.h"
+#include "box2d/b2_world.h"
+
+#include "b2_island.h"
+#include "dynamics/b2_contact_solver.h"
+
+/*
+Position Correction Notes
+=========================
+I tried the several algorithms for position correction of the 2D revolute joint.
+I looked at these systems:
+- simple pendulum (1m diameter sphere on massless 5m stick) with initial angular velocity of 100 rad/s.
+- suspension bridge with 30 1m long planks of length 1m.
+- multi-link chain with 30 1m long links.
+
+Here are the algorithms:
+
+Baumgarte - A fraction of the position error is added to the velocity error. There is no
+separate position solver.
+
+Pseudo Velocities - After the velocity solver and position integration,
+the position error, Jacobian, and effective mass are recomputed. Then
+the velocity constraints are solved with pseudo velocities and a fraction
+of the position error is added to the pseudo velocity error. The pseudo
+velocities are initialized to zero and there is no warm-starting. After
+the position solver, the pseudo velocities are added to the positions.
+This is also called the First Order World method or the Position LCP method.
+
+Modified Nonlinear Gauss-Seidel (NGS) - Like Pseudo Velocities except the
+position error is re-computed for each constraint and the positions are updated
+after the constraint is solved. The radius vectors (aka Jacobians) are
+re-computed too (otherwise the algorithm has horrible instability). The pseudo
+velocity states are not needed because they are effectively zero at the beginning
+of each iteration. Since we have the current position error, we allow the
+iterations to terminate early if the error becomes smaller than b2_linearSlop.
+
+Full NGS or just NGS - Like Modified NGS except the effective mass are re-computed
+each time a constraint is solved.
+
+Here are the results:
+Baumgarte - this is the cheapest algorithm but it has some stability problems,
+especially with the bridge. The chain links separate easily close to the root
+and they jitter as they struggle to pull together. This is one of the most common
+methods in the field. The big drawback is that the position correction artificially
+affects the momentum, thus leading to instabilities and false bounce. I used a
+bias factor of 0.2. A larger bias factor makes the bridge less stable, a smaller
+factor makes joints and contacts more spongy.
+
+Pseudo Velocities - the is more stable than the Baumgarte method. The bridge is
+stable. However, joints still separate with large angular velocities. Drag the
+simple pendulum in a circle quickly and the joint will separate. The chain separates
+easily and does not recover. I used a bias factor of 0.2. A larger value lead to
+the bridge collapsing when a heavy cube drops on it.
+
+Modified NGS - this algorithm is better in some ways than Baumgarte and Pseudo
+Velocities, but in other ways it is worse. The bridge and chain are much more
+stable, but the simple pendulum goes unstable at high angular velocities.
+
+Full NGS - stable in all tests. The joints display good stiffness. The bridge
+still sags, but this is better than infinite forces.
+
+Recommendations
+Pseudo Velocities are not really worthwhile because the bridge and chain cannot
+recover from joint separation. In other cases the benefit over Baumgarte is small.
+
+Modified NGS is not a robust method for the revolute joint due to the violent
+instability seen in the simple pendulum. Perhaps it is viable with other constraint
+types, especially scalar constraints where the effective mass is a scalar.
+
+This leaves Baumgarte and Full NGS. Baumgarte has small, but manageable instabilities
+and is very fast. I don't think we can escape Baumgarte, especially in highly
+demanding cases where high constraint fidelity is not needed.
+
+Full NGS is robust and easy on the eyes. I recommend this as an option for
+higher fidelity simulation and certainly for suspension bridges and long chains.
+Full NGS might be a good choice for ragdolls, especially motorized ragdolls where
+joint separation can be problematic. The number of NGS iterations can be reduced
+for better performance without harming robustness much.
+
+Each joint in a can be handled differently in the position solver. So I recommend
+a system where the user can select the algorithm on a per joint basis. I would
+probably default to the slower Full NGS and let the user select the faster
+Baumgarte method in performance critical scenarios.
+*/
+
+/*
+Cache Performance
+
+The Box2D solvers are dominated by cache misses. Data structures are designed
+to increase the number of cache hits. Much of misses are due to random access
+to body data. The constraint structures are iterated over linearly, which leads
+to few cache misses.
+
+The bodies are not accessed during iteration. Instead read only data, such as
+the mass values are stored with the constraints. The mutable data are the constraint
+impulses and the bodies velocities/positions. The impulses are held inside the
+constraint structures. The body velocities/positions are held in compact, temporary
+arrays to increase the number of cache hits. Linear and angular velocity are
+stored in a single array since multiple arrays lead to multiple misses.
+*/
+
+/*
+2D Rotation
+
+R = [cos(theta) -sin(theta)]
+ [sin(theta) cos(theta) ]
+
+thetaDot = omega
+
+Let q1 = cos(theta), q2 = sin(theta).
+R = [q1 -q2]
+ [q2 q1]
+
+q1Dot = -thetaDot * q2
+q2Dot = thetaDot * q1
+
+q1_new = q1_old - dt * w * q2
+q2_new = q2_old + dt * w * q1
+then normalize.
+
+This might be faster than computing sin+cos.
+However, we can compute sin+cos of the same angle fast.
+*/
+
+b2Island::b2Island(
+ int32 bodyCapacity,
+ int32 contactCapacity,
+ int32 jointCapacity,
+ b2StackAllocator* allocator,
+ b2ContactListener* listener)
+{
+ m_bodyCapacity = bodyCapacity;
+ m_contactCapacity = contactCapacity;
+ m_jointCapacity = jointCapacity;
+ m_bodyCount = 0;
+ m_contactCount = 0;
+ m_jointCount = 0;
+
+ m_allocator = allocator;
+ m_listener = listener;
+
+ m_bodies = (b2Body**)m_allocator->Allocate(bodyCapacity * sizeof(b2Body*));
+ m_contacts = (b2Contact**)m_allocator->Allocate(contactCapacity * sizeof(b2Contact*));
+ m_joints = (b2Joint**)m_allocator->Allocate(jointCapacity * sizeof(b2Joint*));
+
+ m_velocities = (b2Velocity*)m_allocator->Allocate(m_bodyCapacity * sizeof(b2Velocity));
+ m_positions = (b2Position*)m_allocator->Allocate(m_bodyCapacity * sizeof(b2Position));
+}
+
+b2Island::~b2Island()
+{
+ // Warning: the order should reverse the constructor order.
+ m_allocator->Free(m_positions);
+ m_allocator->Free(m_velocities);
+ m_allocator->Free(m_joints);
+ m_allocator->Free(m_contacts);
+ m_allocator->Free(m_bodies);
+}
+
+void b2Island::Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep)
+{
+ b2Timer timer;
+
+ float h = step.dt;
+
+ // Integrate velocities and apply damping. Initialize the body state.
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Body* b = m_bodies[i];
+
+ b2Vec2 c = b->m_sweep.c;
+ float a = b->m_sweep.a;
+ b2Vec2 v = b->m_linearVelocity;
+ float w = b->m_angularVelocity;
+
+ // Store positions for continuous collision.
+ b->m_sweep.c0 = b->m_sweep.c;
+ b->m_sweep.a0 = b->m_sweep.a;
+
+ if (b->m_type == b2_dynamicBody)
+ {
+ // Integrate velocities.
+ v += h * b->m_invMass * (b->m_gravityScale * b->m_mass * gravity + b->m_force);
+ w += h * b->m_invI * b->m_torque;
+
+ // Apply damping.
+ // ODE: dv/dt + c * v = 0
+ // Solution: v(t) = v0 * exp(-c * t)
+ // Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt)
+ // v2 = exp(-c * dt) * v1
+ // Pade approximation:
+ // v2 = v1 * 1 / (1 + c * dt)
+ v *= 1.0f / (1.0f + h * b->m_linearDamping);
+ w *= 1.0f / (1.0f + h * b->m_angularDamping);
+ }
+
+ m_positions[i].c = c;
+ m_positions[i].a = a;
+ m_velocities[i].v = v;
+ m_velocities[i].w = w;
+ }
+
+ timer.Reset();
+
+ // Solver data
+ b2SolverData solverData;
+ solverData.step = step;
+ solverData.positions = m_positions;
+ solverData.velocities = m_velocities;
+
+ // Initialize velocity constraints.
+ b2ContactSolverDef contactSolverDef;
+ contactSolverDef.step = step;
+ contactSolverDef.contacts = m_contacts;
+ contactSolverDef.count = m_contactCount;
+ contactSolverDef.positions = m_positions;
+ contactSolverDef.velocities = m_velocities;
+ contactSolverDef.allocator = m_allocator;
+
+ b2ContactSolver contactSolver(&contactSolverDef);
+ contactSolver.InitializeVelocityConstraints();
+
+ if (step.warmStarting)
+ {
+ contactSolver.WarmStart();
+ }
+
+ for (int32 i = 0; i < m_jointCount; ++i)
+ {
+ m_joints[i]->InitVelocityConstraints(solverData);
+ }
+
+ profile->solveInit = timer.GetMilliseconds();
+
+ // Solve velocity constraints
+ timer.Reset();
+ for (int32 i = 0; i < step.velocityIterations; ++i)
+ {
+ for (int32 j = 0; j < m_jointCount; ++j)
+ {
+ m_joints[j]->SolveVelocityConstraints(solverData);
+ }
+
+ contactSolver.SolveVelocityConstraints();
+ }
+
+ // Store impulses for warm starting
+ contactSolver.StoreImpulses();
+ profile->solveVelocity = timer.GetMilliseconds();
+
+ // Integrate positions
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Vec2 c = m_positions[i].c;
+ float a = m_positions[i].a;
+ b2Vec2 v = m_velocities[i].v;
+ float w = m_velocities[i].w;
+
+ // Check for large velocities
+ b2Vec2 translation = h * v;
+ if (b2Dot(translation, translation) > b2_maxTranslationSquared)
+ {
+ float ratio = b2_maxTranslation / translation.Length();
+ v *= ratio;
+ }
+
+ float rotation = h * w;
+ if (rotation * rotation > b2_maxRotationSquared)
+ {
+ float ratio = b2_maxRotation / b2Abs(rotation);
+ w *= ratio;
+ }
+
+ // Integrate
+ c += h * v;
+ a += h * w;
+
+ m_positions[i].c = c;
+ m_positions[i].a = a;
+ m_velocities[i].v = v;
+ m_velocities[i].w = w;
+ }
+
+ // Solve position constraints
+ timer.Reset();
+ bool positionSolved = false;
+ for (int32 i = 0; i < step.positionIterations; ++i)
+ {
+ bool contactsOkay = contactSolver.SolvePositionConstraints();
+
+ bool jointsOkay = true;
+ for (int32 j = 0; j < m_jointCount; ++j)
+ {
+ bool jointOkay = m_joints[j]->SolvePositionConstraints(solverData);
+ jointsOkay = jointsOkay && jointOkay;
+ }
+
+ if (contactsOkay && jointsOkay)
+ {
+ // Exit early if the position errors are small.
+ positionSolved = true;
+ break;
+ }
+ }
+
+ // Copy state buffers back to the bodies
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Body* body = m_bodies[i];
+ body->m_sweep.c = m_positions[i].c;
+ body->m_sweep.a = m_positions[i].a;
+ body->m_linearVelocity = m_velocities[i].v;
+ body->m_angularVelocity = m_velocities[i].w;
+ body->SynchronizeTransform();
+ }
+
+ profile->solvePosition = timer.GetMilliseconds();
+
+ Report(contactSolver.m_velocityConstraints);
+
+ if (allowSleep)
+ {
+ float minSleepTime = b2_maxFloat;
+
+ const float linTolSqr = b2_linearSleepTolerance * b2_linearSleepTolerance;
+ const float angTolSqr = b2_angularSleepTolerance * b2_angularSleepTolerance;
+
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Body* b = m_bodies[i];
+ if (b->GetType() == b2_staticBody)
+ {
+ continue;
+ }
+
+ if ((b->m_flags & b2Body::e_autoSleepFlag) == 0 ||
+ b->m_angularVelocity * b->m_angularVelocity > angTolSqr ||
+ b2Dot(b->m_linearVelocity, b->m_linearVelocity) > linTolSqr)
+ {
+ b->m_sleepTime = 0.0f;
+ minSleepTime = 0.0f;
+ }
+ else
+ {
+ b->m_sleepTime += h;
+ minSleepTime = b2Min(minSleepTime, b->m_sleepTime);
+ }
+ }
+
+ if (minSleepTime >= b2_timeToSleep && positionSolved)
+ {
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Body* b = m_bodies[i];
+ b->SetAwake(false);
+ }
+ }
+ }
+}
+
+void b2Island::SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB)
+{
+ b2Assert(toiIndexA < m_bodyCount);
+ b2Assert(toiIndexB < m_bodyCount);
+
+ // Initialize the body state.
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Body* b = m_bodies[i];
+ m_positions[i].c = b->m_sweep.c;
+ m_positions[i].a = b->m_sweep.a;
+ m_velocities[i].v = b->m_linearVelocity;
+ m_velocities[i].w = b->m_angularVelocity;
+ }
+
+ b2ContactSolverDef contactSolverDef;
+ contactSolverDef.contacts = m_contacts;
+ contactSolverDef.count = m_contactCount;
+ contactSolverDef.allocator = m_allocator;
+ contactSolverDef.step = subStep;
+ contactSolverDef.positions = m_positions;
+ contactSolverDef.velocities = m_velocities;
+ b2ContactSolver contactSolver(&contactSolverDef);
+
+ // Solve position constraints.
+ for (int32 i = 0; i < subStep.positionIterations; ++i)
+ {
+ bool contactsOkay = contactSolver.SolveTOIPositionConstraints(toiIndexA, toiIndexB);
+ if (contactsOkay)
+ {
+ break;
+ }
+ }
+
+#if 0
+ // Is the new position really safe?
+ for (int32 i = 0; i < m_contactCount; ++i)
+ {
+ b2Contact* c = m_contacts[i];
+ b2Fixture* fA = c->GetFixtureA();
+ b2Fixture* fB = c->GetFixtureB();
+
+ b2Body* bA = fA->GetBody();
+ b2Body* bB = fB->GetBody();
+
+ int32 indexA = c->GetChildIndexA();
+ int32 indexB = c->GetChildIndexB();
+
+ b2DistanceInput input;
+ input.proxyA.Set(fA->GetShape(), indexA);
+ input.proxyB.Set(fB->GetShape(), indexB);
+ input.transformA = bA->GetTransform();
+ input.transformB = bB->GetTransform();
+ input.useRadii = false;
+
+ b2DistanceOutput output;
+ b2SimplexCache cache;
+ cache.count = 0;
+ b2Distance(&output, &cache, &input);
+
+ if (output.distance == 0 || cache.count == 3)
+ {
+ cache.count += 0;
+ }
+ }
+#endif
+
+ // Leap of faith to new safe state.
+ m_bodies[toiIndexA]->m_sweep.c0 = m_positions[toiIndexA].c;
+ m_bodies[toiIndexA]->m_sweep.a0 = m_positions[toiIndexA].a;
+ m_bodies[toiIndexB]->m_sweep.c0 = m_positions[toiIndexB].c;
+ m_bodies[toiIndexB]->m_sweep.a0 = m_positions[toiIndexB].a;
+
+ // No warm starting is needed for TOI events because warm
+ // starting impulses were applied in the discrete solver.
+ contactSolver.InitializeVelocityConstraints();
+
+ // Solve velocity constraints.
+ for (int32 i = 0; i < subStep.velocityIterations; ++i)
+ {
+ contactSolver.SolveVelocityConstraints();
+ }
+
+ // Don't store the TOI contact forces for warm starting
+ // because they can be quite large.
+
+ float h = subStep.dt;
+
+ // Integrate positions
+ for (int32 i = 0; i < m_bodyCount; ++i)
+ {
+ b2Vec2 c = m_positions[i].c;
+ float a = m_positions[i].a;
+ b2Vec2 v = m_velocities[i].v;
+ float w = m_velocities[i].w;
+
+ // Check for large velocities
+ b2Vec2 translation = h * v;
+ if (b2Dot(translation, translation) > b2_maxTranslationSquared)
+ {
+ float ratio = b2_maxTranslation / translation.Length();
+ v *= ratio;
+ }
+
+ float rotation = h * w;
+ if (rotation * rotation > b2_maxRotationSquared)
+ {
+ float ratio = b2_maxRotation / b2Abs(rotation);
+ w *= ratio;
+ }
+
+ // Integrate
+ c += h * v;
+ a += h * w;
+
+ m_positions[i].c = c;
+ m_positions[i].a = a;
+ m_velocities[i].v = v;
+ m_velocities[i].w = w;
+
+ // Sync bodies
+ b2Body* body = m_bodies[i];
+ body->m_sweep.c = c;
+ body->m_sweep.a = a;
+ body->m_linearVelocity = v;
+ body->m_angularVelocity = w;
+ body->SynchronizeTransform();
+ }
+
+ Report(contactSolver.m_velocityConstraints);
+}
+
+void b2Island::Report(const b2ContactVelocityConstraint* constraints)
+{
+ if (m_listener == nullptr)
+ {
+ return;
+ }
+
+ for (int32 i = 0; i < m_contactCount; ++i)
+ {
+ b2Contact* c = m_contacts[i];
+
+ const b2ContactVelocityConstraint* vc = constraints + i;
+
+ b2ContactImpulse impulse;
+ impulse.count = vc->pointCount;
+ for (int32 j = 0; j < vc->pointCount; ++j)
+ {
+ impulse.normalImpulses[j] = vc->points[j].normalImpulse;
+ impulse.tangentImpulses[j] = vc->points[j].tangentImpulse;
+ }
+
+ m_listener->PostSolve(c, &impulse);
+ }
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_island.h b/Client/ThirdParty/Box2D/src/dynamics/b2_island.h
new file mode 100644
index 0000000..2e28a35
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_island.h
@@ -0,0 +1,97 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_ISLAND_H
+#define B2_ISLAND_H
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_math.h"
+#include "box2d/b2_time_step.h"
+
+class b2Contact;
+class b2Joint;
+class b2StackAllocator;
+class b2ContactListener;
+struct b2ContactVelocityConstraint;
+struct b2Profile;
+
+/// This is an internal class.
+class b2Island
+{
+public:
+ b2Island(int32 bodyCapacity, int32 contactCapacity, int32 jointCapacity,
+ b2StackAllocator* allocator, b2ContactListener* listener);
+ ~b2Island();
+
+ void Clear()
+ {
+ m_bodyCount = 0;
+ m_contactCount = 0;
+ m_jointCount = 0;
+ }
+
+ void Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep);
+
+ void SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB);
+
+ void Add(b2Body* body)
+ {
+ b2Assert(m_bodyCount < m_bodyCapacity);
+ body->m_islandIndex = m_bodyCount;
+ m_bodies[m_bodyCount] = body;
+ ++m_bodyCount;
+ }
+
+ void Add(b2Contact* contact)
+ {
+ b2Assert(m_contactCount < m_contactCapacity);
+ m_contacts[m_contactCount++] = contact;
+ }
+
+ void Add(b2Joint* joint)
+ {
+ b2Assert(m_jointCount < m_jointCapacity);
+ m_joints[m_jointCount++] = joint;
+ }
+
+ void Report(const b2ContactVelocityConstraint* constraints);
+
+ b2StackAllocator* m_allocator;
+ b2ContactListener* m_listener;
+
+ b2Body** m_bodies;
+ b2Contact** m_contacts;
+ b2Joint** m_joints;
+
+ b2Position* m_positions;
+ b2Velocity* m_velocities;
+
+ int32 m_bodyCount;
+ int32 m_jointCount;
+ int32 m_contactCount;
+
+ int32 m_bodyCapacity;
+ int32 m_contactCapacity;
+ int32 m_jointCapacity;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_joint.cpp
new file mode 100644
index 0000000..41addbb
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_joint.cpp
@@ -0,0 +1,301 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_body.h"
+#include "box2d/b2_distance_joint.h"
+#include "box2d/b2_draw.h"
+#include "box2d/b2_friction_joint.h"
+#include "box2d/b2_gear_joint.h"
+#include "box2d/b2_motor_joint.h"
+#include "box2d/b2_mouse_joint.h"
+#include "box2d/b2_prismatic_joint.h"
+#include "box2d/b2_pulley_joint.h"
+#include "box2d/b2_revolute_joint.h"
+#include "box2d/b2_weld_joint.h"
+#include "box2d/b2_wheel_joint.h"
+#include "box2d/b2_world.h"
+
+#include <new>
+
+void b2LinearStiffness(float& stiffness, float& damping,
+ float frequencyHertz, float dampingRatio,
+ const b2Body* bodyA, const b2Body* bodyB)
+{
+ float massA = bodyA->GetMass();
+ float massB = bodyB->GetMass();
+ float mass;
+ if (massA > 0.0f && massB > 0.0f)
+ {
+ mass = massA * massB / (massA + massB);
+ }
+ else if (massA > 0.0f)
+ {
+ mass = massA;
+ }
+ else
+ {
+ mass = massB;
+ }
+
+ float omega = 2.0f * b2_pi * frequencyHertz;
+ stiffness = mass * omega * omega;
+ damping = 2.0f * mass * dampingRatio * omega;
+}
+
+void b2AngularStiffness(float& stiffness, float& damping,
+ float frequencyHertz, float dampingRatio,
+ const b2Body* bodyA, const b2Body* bodyB)
+{
+ float IA = bodyA->GetInertia();
+ float IB = bodyB->GetInertia();
+ float I;
+ if (IA > 0.0f && IB > 0.0f)
+ {
+ I = IA * IB / (IA + IB);
+ }
+ else if (IA > 0.0f)
+ {
+ I = IA;
+ }
+ else
+ {
+ I = IB;
+ }
+
+ float omega = 2.0f * b2_pi * frequencyHertz;
+ stiffness = I * omega * omega;
+ damping = 2.0f * I * dampingRatio * omega;
+}
+
+b2Joint* b2Joint::Create(const b2JointDef* def, b2BlockAllocator* allocator)
+{
+ b2Joint* joint = nullptr;
+
+ switch (def->type)
+ {
+ case e_distanceJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2DistanceJoint));
+ joint = new (mem) b2DistanceJoint(static_cast<const b2DistanceJointDef*>(def));
+ }
+ break;
+
+ case e_mouseJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2MouseJoint));
+ joint = new (mem) b2MouseJoint(static_cast<const b2MouseJointDef*>(def));
+ }
+ break;
+
+ case e_prismaticJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2PrismaticJoint));
+ joint = new (mem) b2PrismaticJoint(static_cast<const b2PrismaticJointDef*>(def));
+ }
+ break;
+
+ case e_revoluteJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2RevoluteJoint));
+ joint = new (mem) b2RevoluteJoint(static_cast<const b2RevoluteJointDef*>(def));
+ }
+ break;
+
+ case e_pulleyJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2PulleyJoint));
+ joint = new (mem) b2PulleyJoint(static_cast<const b2PulleyJointDef*>(def));
+ }
+ break;
+
+ case e_gearJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2GearJoint));
+ joint = new (mem) b2GearJoint(static_cast<const b2GearJointDef*>(def));
+ }
+ break;
+
+ case e_wheelJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2WheelJoint));
+ joint = new (mem) b2WheelJoint(static_cast<const b2WheelJointDef*>(def));
+ }
+ break;
+
+ case e_weldJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2WeldJoint));
+ joint = new (mem) b2WeldJoint(static_cast<const b2WeldJointDef*>(def));
+ }
+ break;
+
+ case e_frictionJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2FrictionJoint));
+ joint = new (mem) b2FrictionJoint(static_cast<const b2FrictionJointDef*>(def));
+ }
+ break;
+
+ case e_motorJoint:
+ {
+ void* mem = allocator->Allocate(sizeof(b2MotorJoint));
+ joint = new (mem) b2MotorJoint(static_cast<const b2MotorJointDef*>(def));
+ }
+ break;
+
+ default:
+ b2Assert(false);
+ break;
+ }
+
+ return joint;
+}
+
+void b2Joint::Destroy(b2Joint* joint, b2BlockAllocator* allocator)
+{
+ joint->~b2Joint();
+ switch (joint->m_type)
+ {
+ case e_distanceJoint:
+ allocator->Free(joint, sizeof(b2DistanceJoint));
+ break;
+
+ case e_mouseJoint:
+ allocator->Free(joint, sizeof(b2MouseJoint));
+ break;
+
+ case e_prismaticJoint:
+ allocator->Free(joint, sizeof(b2PrismaticJoint));
+ break;
+
+ case e_revoluteJoint:
+ allocator->Free(joint, sizeof(b2RevoluteJoint));
+ break;
+
+ case e_pulleyJoint:
+ allocator->Free(joint, sizeof(b2PulleyJoint));
+ break;
+
+ case e_gearJoint:
+ allocator->Free(joint, sizeof(b2GearJoint));
+ break;
+
+ case e_wheelJoint:
+ allocator->Free(joint, sizeof(b2WheelJoint));
+ break;
+
+ case e_weldJoint:
+ allocator->Free(joint, sizeof(b2WeldJoint));
+ break;
+
+ case e_frictionJoint:
+ allocator->Free(joint, sizeof(b2FrictionJoint));
+ break;
+
+ case e_motorJoint:
+ allocator->Free(joint, sizeof(b2MotorJoint));
+ break;
+
+ default:
+ b2Assert(false);
+ break;
+ }
+}
+
+b2Joint::b2Joint(const b2JointDef* def)
+{
+ b2Assert(def->bodyA != def->bodyB);
+
+ m_type = def->type;
+ m_prev = nullptr;
+ m_next = nullptr;
+ m_bodyA = def->bodyA;
+ m_bodyB = def->bodyB;
+ m_index = 0;
+ m_collideConnected = def->collideConnected;
+ m_islandFlag = false;
+ m_userData = def->userData;
+
+ m_edgeA.joint = nullptr;
+ m_edgeA.other = nullptr;
+ m_edgeA.prev = nullptr;
+ m_edgeA.next = nullptr;
+
+ m_edgeB.joint = nullptr;
+ m_edgeB.other = nullptr;
+ m_edgeB.prev = nullptr;
+ m_edgeB.next = nullptr;
+}
+
+bool b2Joint::IsEnabled() const
+{
+ return m_bodyA->IsEnabled() && m_bodyB->IsEnabled();
+}
+
+void b2Joint::Draw(b2Draw* draw) const
+{
+ const b2Transform& xf1 = m_bodyA->GetTransform();
+ const b2Transform& xf2 = m_bodyB->GetTransform();
+ b2Vec2 x1 = xf1.p;
+ b2Vec2 x2 = xf2.p;
+ b2Vec2 p1 = GetAnchorA();
+ b2Vec2 p2 = GetAnchorB();
+
+ b2Color color(0.5f, 0.8f, 0.8f);
+
+ switch (m_type)
+ {
+ case e_distanceJoint:
+ draw->DrawSegment(p1, p2, color);
+ break;
+
+ case e_pulleyJoint:
+ {
+ b2PulleyJoint* pulley = (b2PulleyJoint*)this;
+ b2Vec2 s1 = pulley->GetGroundAnchorA();
+ b2Vec2 s2 = pulley->GetGroundAnchorB();
+ draw->DrawSegment(s1, p1, color);
+ draw->DrawSegment(s2, p2, color);
+ draw->DrawSegment(s1, s2, color);
+ }
+ break;
+
+ case e_mouseJoint:
+ {
+ b2Color c;
+ c.Set(0.0f, 1.0f, 0.0f);
+ draw->DrawPoint(p1, 4.0f, c);
+ draw->DrawPoint(p2, 4.0f, c);
+
+ c.Set(0.8f, 0.8f, 0.8f);
+ draw->DrawSegment(p1, p2, c);
+
+ }
+ break;
+
+ default:
+ draw->DrawSegment(x1, p1, color);
+ draw->DrawSegment(p1, p2, color);
+ draw->DrawSegment(x2, p2, color);
+ }
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_motor_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_motor_joint.cpp
new file mode 100644
index 0000000..6e0b075
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_motor_joint.cpp
@@ -0,0 +1,311 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_motor_joint.h"
+#include "box2d/b2_time_step.h"
+
+// Point-to-point constraint
+// Cdot = v2 - v1
+// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
+// J = [-I -r1_skew I r2_skew ]
+// Identity used:
+// w k % (rx i + ry j) = w * (-ry i + rx j)
+//
+// r1 = offset - c1
+// r2 = -c2
+
+// Angle constraint
+// Cdot = w2 - w1
+// J = [0 0 -1 0 0 1]
+// K = invI1 + invI2
+
+void b2MotorJointDef::Initialize(b2Body* bA, b2Body* bB)
+{
+ bodyA = bA;
+ bodyB = bB;
+ b2Vec2 xB = bodyB->GetPosition();
+ linearOffset = bodyA->GetLocalPoint(xB);
+
+ float angleA = bodyA->GetAngle();
+ float angleB = bodyB->GetAngle();
+ angularOffset = angleB - angleA;
+}
+
+b2MotorJoint::b2MotorJoint(const b2MotorJointDef* def)
+: b2Joint(def)
+{
+ m_linearOffset = def->linearOffset;
+ m_angularOffset = def->angularOffset;
+
+ m_linearImpulse.SetZero();
+ m_angularImpulse = 0.0f;
+
+ m_maxForce = def->maxForce;
+ m_maxTorque = def->maxTorque;
+ m_correctionFactor = def->correctionFactor;
+}
+
+void b2MotorJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ // Compute the effective mass matrix.
+ m_rA = b2Mul(qA, m_linearOffset - m_localCenterA);
+ m_rB = b2Mul(qB, -m_localCenterB);
+
+ // J = [-I -r1_skew I r2_skew]
+ // r_skew = [-ry; rx]
+
+ // Matlab
+ // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]
+ // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]
+ // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ // Upper 2 by 2 of K for point to point
+ b2Mat22 K;
+ K.ex.x = mA + mB + iA * m_rA.y * m_rA.y + iB * m_rB.y * m_rB.y;
+ K.ex.y = -iA * m_rA.x * m_rA.y - iB * m_rB.x * m_rB.y;
+ K.ey.x = K.ex.y;
+ K.ey.y = mA + mB + iA * m_rA.x * m_rA.x + iB * m_rB.x * m_rB.x;
+
+ m_linearMass = K.GetInverse();
+
+ m_angularMass = iA + iB;
+ if (m_angularMass > 0.0f)
+ {
+ m_angularMass = 1.0f / m_angularMass;
+ }
+
+ m_linearError = cB + m_rB - cA - m_rA;
+ m_angularError = aB - aA - m_angularOffset;
+
+ if (data.step.warmStarting)
+ {
+ // Scale impulses to support a variable time step.
+ m_linearImpulse *= data.step.dtRatio;
+ m_angularImpulse *= data.step.dtRatio;
+
+ b2Vec2 P(m_linearImpulse.x, m_linearImpulse.y);
+ vA -= mA * P;
+ wA -= iA * (b2Cross(m_rA, P) + m_angularImpulse);
+ vB += mB * P;
+ wB += iB * (b2Cross(m_rB, P) + m_angularImpulse);
+ }
+ else
+ {
+ m_linearImpulse.SetZero();
+ m_angularImpulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2MotorJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ float h = data.step.dt;
+ float inv_h = data.step.inv_dt;
+
+ // Solve angular friction
+ {
+ float Cdot = wB - wA + inv_h * m_correctionFactor * m_angularError;
+ float impulse = -m_angularMass * Cdot;
+
+ float oldImpulse = m_angularImpulse;
+ float maxImpulse = h * m_maxTorque;
+ m_angularImpulse = b2Clamp(m_angularImpulse + impulse, -maxImpulse, maxImpulse);
+ impulse = m_angularImpulse - oldImpulse;
+
+ wA -= iA * impulse;
+ wB += iB * impulse;
+ }
+
+ // Solve linear friction
+ {
+ b2Vec2 Cdot = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA) + inv_h * m_correctionFactor * m_linearError;
+
+ b2Vec2 impulse = -b2Mul(m_linearMass, Cdot);
+ b2Vec2 oldImpulse = m_linearImpulse;
+ m_linearImpulse += impulse;
+
+ float maxImpulse = h * m_maxForce;
+
+ if (m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse)
+ {
+ m_linearImpulse.Normalize();
+ m_linearImpulse *= maxImpulse;
+ }
+
+ impulse = m_linearImpulse - oldImpulse;
+
+ vA -= mA * impulse;
+ wA -= iA * b2Cross(m_rA, impulse);
+
+ vB += mB * impulse;
+ wB += iB * b2Cross(m_rB, impulse);
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2MotorJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ B2_NOT_USED(data);
+
+ return true;
+}
+
+b2Vec2 b2MotorJoint::GetAnchorA() const
+{
+ return m_bodyA->GetPosition();
+}
+
+b2Vec2 b2MotorJoint::GetAnchorB() const
+{
+ return m_bodyB->GetPosition();
+}
+
+b2Vec2 b2MotorJoint::GetReactionForce(float inv_dt) const
+{
+ return inv_dt * m_linearImpulse;
+}
+
+float b2MotorJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * m_angularImpulse;
+}
+
+void b2MotorJoint::SetMaxForce(float force)
+{
+ b2Assert(b2IsValid(force) && force >= 0.0f);
+ m_maxForce = force;
+}
+
+float b2MotorJoint::GetMaxForce() const
+{
+ return m_maxForce;
+}
+
+void b2MotorJoint::SetMaxTorque(float torque)
+{
+ b2Assert(b2IsValid(torque) && torque >= 0.0f);
+ m_maxTorque = torque;
+}
+
+float b2MotorJoint::GetMaxTorque() const
+{
+ return m_maxTorque;
+}
+
+void b2MotorJoint::SetCorrectionFactor(float factor)
+{
+ b2Assert(b2IsValid(factor) && 0.0f <= factor && factor <= 1.0f);
+ m_correctionFactor = factor;
+}
+
+float b2MotorJoint::GetCorrectionFactor() const
+{
+ return m_correctionFactor;
+}
+
+void b2MotorJoint::SetLinearOffset(const b2Vec2& linearOffset)
+{
+ if (linearOffset.x != m_linearOffset.x || linearOffset.y != m_linearOffset.y)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_linearOffset = linearOffset;
+ }
+}
+
+const b2Vec2& b2MotorJoint::GetLinearOffset() const
+{
+ return m_linearOffset;
+}
+
+void b2MotorJoint::SetAngularOffset(float angularOffset)
+{
+ if (angularOffset != m_angularOffset)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_angularOffset = angularOffset;
+ }
+}
+
+float b2MotorJoint::GetAngularOffset() const
+{
+ return m_angularOffset;
+}
+
+void b2MotorJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2MotorJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.linearOffset.Set(%.9g, %.9g);\n", m_linearOffset.x, m_linearOffset.y);
+ b2Dump(" jd.angularOffset = %.9g;\n", m_angularOffset);
+ b2Dump(" jd.maxForce = %.9g;\n", m_maxForce);
+ b2Dump(" jd.maxTorque = %.9g;\n", m_maxTorque);
+ b2Dump(" jd.correctionFactor = %.9g;\n", m_correctionFactor);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_mouse_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_mouse_joint.cpp
new file mode 100644
index 0000000..1ea6dd4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_mouse_joint.cpp
@@ -0,0 +1,192 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_mouse_joint.h"
+#include "box2d/b2_time_step.h"
+
+// p = attached point, m = mouse point
+// C = p - m
+// Cdot = v
+// = v + cross(w, r)
+// J = [I r_skew]
+// Identity used:
+// w k % (rx i + ry j) = w * (-ry i + rx j)
+
+b2MouseJoint::b2MouseJoint(const b2MouseJointDef* def)
+: b2Joint(def)
+{
+ m_targetA = def->target;
+ m_localAnchorB = b2MulT(m_bodyB->GetTransform(), m_targetA);
+ m_maxForce = def->maxForce;
+ m_stiffness = def->stiffness;
+ m_damping = def->damping;
+
+ m_impulse.SetZero();
+ m_beta = 0.0f;
+ m_gamma = 0.0f;
+}
+
+void b2MouseJoint::SetTarget(const b2Vec2& target)
+{
+ if (target != m_targetA)
+ {
+ m_bodyB->SetAwake(true);
+ m_targetA = target;
+ }
+}
+
+const b2Vec2& b2MouseJoint::GetTarget() const
+{
+ return m_targetA;
+}
+
+void b2MouseJoint::SetMaxForce(float force)
+{
+ m_maxForce = force;
+}
+
+float b2MouseJoint::GetMaxForce() const
+{
+ return m_maxForce;
+}
+
+void b2MouseJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIB = m_bodyB->m_invI;
+
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qB(aB);
+
+ float mass = m_bodyB->GetMass();
+
+ float d = m_damping;
+ float k = m_stiffness;
+
+ // magic formulas
+ // gamma has units of inverse mass.
+ // beta has units of inverse time.
+ float h = data.step.dt;
+ m_gamma = h * (d + h * k);
+ if (m_gamma != 0.0f)
+ {
+ m_gamma = 1.0f / m_gamma;
+ }
+ m_beta = h * k * m_gamma;
+
+ // Compute the effective mass matrix.
+ m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)]
+ // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y]
+ // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x]
+ b2Mat22 K;
+ K.ex.x = m_invMassB + m_invIB * m_rB.y * m_rB.y + m_gamma;
+ K.ex.y = -m_invIB * m_rB.x * m_rB.y;
+ K.ey.x = K.ex.y;
+ K.ey.y = m_invMassB + m_invIB * m_rB.x * m_rB.x + m_gamma;
+
+ m_mass = K.GetInverse();
+
+ m_C = cB + m_rB - m_targetA;
+ m_C *= m_beta;
+
+ // Cheat with some damping
+ wB *= 0.98f;
+
+ if (data.step.warmStarting)
+ {
+ m_impulse *= data.step.dtRatio;
+ vB += m_invMassB * m_impulse;
+ wB += m_invIB * b2Cross(m_rB, m_impulse);
+ }
+ else
+ {
+ m_impulse.SetZero();
+ }
+
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2MouseJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ // Cdot = v + cross(w, r)
+ b2Vec2 Cdot = vB + b2Cross(wB, m_rB);
+ b2Vec2 impulse = b2Mul(m_mass, -(Cdot + m_C + m_gamma * m_impulse));
+
+ b2Vec2 oldImpulse = m_impulse;
+ m_impulse += impulse;
+ float maxImpulse = data.step.dt * m_maxForce;
+ if (m_impulse.LengthSquared() > maxImpulse * maxImpulse)
+ {
+ m_impulse *= maxImpulse / m_impulse.Length();
+ }
+ impulse = m_impulse - oldImpulse;
+
+ vB += m_invMassB * impulse;
+ wB += m_invIB * b2Cross(m_rB, impulse);
+
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2MouseJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ B2_NOT_USED(data);
+ return true;
+}
+
+b2Vec2 b2MouseJoint::GetAnchorA() const
+{
+ return m_targetA;
+}
+
+b2Vec2 b2MouseJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2MouseJoint::GetReactionForce(float inv_dt) const
+{
+ return inv_dt * m_impulse;
+}
+
+float b2MouseJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * 0.0f;
+}
+
+void b2MouseJoint::ShiftOrigin(const b2Vec2& newOrigin)
+{
+ m_targetA -= newOrigin;
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.cpp
new file mode 100644
index 0000000..e4f34f5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.cpp
@@ -0,0 +1,54 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_polygon_circle_contact.h"
+
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_fixture.h"
+
+#include <new>
+
+b2Contact* b2PolygonAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2PolygonAndCircleContact));
+ return new (mem) b2PolygonAndCircleContact(fixtureA, fixtureB);
+}
+
+void b2PolygonAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2PolygonAndCircleContact*)contact)->~b2PolygonAndCircleContact();
+ allocator->Free(contact, sizeof(b2PolygonAndCircleContact));
+}
+
+b2PolygonAndCircleContact::b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB)
+: b2Contact(fixtureA, 0, fixtureB, 0)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_circle);
+}
+
+void b2PolygonAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2CollidePolygonAndCircle( manifold,
+ (b2PolygonShape*)m_fixtureA->GetShape(), xfA,
+ (b2CircleShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.h
new file mode 100644
index 0000000..6ae5425
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_circle_contact.h
@@ -0,0 +1,42 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H
+#define B2_POLYGON_AND_CIRCLE_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2PolygonAndCircleContact : public b2Contact
+{
+public:
+ static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB);
+ ~b2PolygonAndCircleContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.cpp
new file mode 100644
index 0000000..e92a9e8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.cpp
@@ -0,0 +1,57 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_polygon_contact.h"
+
+#include "box2d/b2_block_allocator.h"
+#include "box2d/b2_body.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_time_of_impact.h"
+#include "box2d/b2_world_callbacks.h"
+
+#include <new>
+
+b2Contact* b2PolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator)
+{
+ void* mem = allocator->Allocate(sizeof(b2PolygonContact));
+ return new (mem) b2PolygonContact(fixtureA, fixtureB);
+}
+
+void b2PolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator)
+{
+ ((b2PolygonContact*)contact)->~b2PolygonContact();
+ allocator->Free(contact, sizeof(b2PolygonContact));
+}
+
+b2PolygonContact::b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB)
+ : b2Contact(fixtureA, 0, fixtureB, 0)
+{
+ b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon);
+ b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon);
+}
+
+void b2PolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB)
+{
+ b2CollidePolygons( manifold,
+ (b2PolygonShape*)m_fixtureA->GetShape(), xfA,
+ (b2PolygonShape*)m_fixtureB->GetShape(), xfB);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.h b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.h
new file mode 100644
index 0000000..0516cb0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_polygon_contact.h
@@ -0,0 +1,43 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef B2_POLYGON_CONTACT_H
+#define B2_POLYGON_CONTACT_H
+
+#include "box2d/b2_contact.h"
+
+class b2BlockAllocator;
+
+class b2PolygonContact : public b2Contact
+{
+public:
+ static b2Contact* Create( b2Fixture* fixtureA, int32 indexA,
+ b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
+ static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);
+
+ b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB);
+ ~b2PolygonContact() {}
+
+ void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) override;
+};
+
+#endif
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_prismatic_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_prismatic_joint.cpp
new file mode 100644
index 0000000..00e7769
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_prismatic_joint.cpp
@@ -0,0 +1,643 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_draw.h"
+#include "box2d/b2_prismatic_joint.h"
+#include "box2d/b2_time_step.h"
+
+// Linear constraint (point-to-line)
+// d = p2 - p1 = x2 + r2 - x1 - r1
+// C = dot(perp, d)
+// Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 - cross(w1, r1))
+// = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) + dot(cross(r2, perp), v2)
+// J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)]
+//
+// Angular constraint
+// C = a2 - a1 + a_initial
+// Cdot = w2 - w1
+// J = [0 0 -1 0 0 1]
+//
+// K = J * invM * JT
+//
+// J = [-a -s1 a s2]
+// [0 -1 0 1]
+// a = perp
+// s1 = cross(d + r1, a) = cross(p2 - x1, a)
+// s2 = cross(r2, a) = cross(p2 - x2, a)
+
+// Motor/Limit linear constraint
+// C = dot(ax1, d)
+// Cdot = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2)
+// J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)]
+
+// Predictive limit is applied even when the limit is not active.
+// Prevents a constraint speed that can lead to a constraint error in one time step.
+// Want C2 = C1 + h * Cdot >= 0
+// Or:
+// Cdot + C1/h >= 0
+// I do not apply a negative constraint error because that is handled in position correction.
+// So:
+// Cdot + max(C1, 0)/h >= 0
+
+// Block Solver
+// We develop a block solver that includes the angular and linear constraints. This makes the limit stiffer.
+//
+// The Jacobian has 2 rows:
+// J = [-uT -s1 uT s2] // linear
+// [0 -1 0 1] // angular
+//
+// u = perp
+// s1 = cross(d + r1, u), s2 = cross(r2, u)
+// a1 = cross(d + r1, v), a2 = cross(r2, v)
+
+void b2PrismaticJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor, const b2Vec2& axis)
+{
+ bodyA = bA;
+ bodyB = bB;
+ localAnchorA = bodyA->GetLocalPoint(anchor);
+ localAnchorB = bodyB->GetLocalPoint(anchor);
+ localAxisA = bodyA->GetLocalVector(axis);
+ referenceAngle = bodyB->GetAngle() - bodyA->GetAngle();
+}
+
+b2PrismaticJoint::b2PrismaticJoint(const b2PrismaticJointDef* def)
+: b2Joint(def)
+{
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+ m_localXAxisA = def->localAxisA;
+ m_localXAxisA.Normalize();
+ m_localYAxisA = b2Cross(1.0f, m_localXAxisA);
+ m_referenceAngle = def->referenceAngle;
+
+ m_impulse.SetZero();
+ m_axialMass = 0.0f;
+ m_motorImpulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+
+ m_lowerTranslation = def->lowerTranslation;
+ m_upperTranslation = def->upperTranslation;
+
+ b2Assert(m_lowerTranslation <= m_upperTranslation);
+
+ m_maxMotorForce = def->maxMotorForce;
+ m_motorSpeed = def->motorSpeed;
+ m_enableLimit = def->enableLimit;
+ m_enableMotor = def->enableMotor;
+
+ m_translation = 0.0f;
+ m_axis.SetZero();
+ m_perp.SetZero();
+}
+
+void b2PrismaticJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ // Compute the effective masses.
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ b2Vec2 d = (cB - cA) + rB - rA;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ // Compute motor Jacobian and effective mass.
+ {
+ m_axis = b2Mul(qA, m_localXAxisA);
+ m_a1 = b2Cross(d + rA, m_axis);
+ m_a2 = b2Cross(rB, m_axis);
+
+ m_axialMass = mA + mB + iA * m_a1 * m_a1 + iB * m_a2 * m_a2;
+ if (m_axialMass > 0.0f)
+ {
+ m_axialMass = 1.0f / m_axialMass;
+ }
+ }
+
+ // Prismatic constraint.
+ {
+ m_perp = b2Mul(qA, m_localYAxisA);
+
+ m_s1 = b2Cross(d + rA, m_perp);
+ m_s2 = b2Cross(rB, m_perp);
+
+ float k11 = mA + mB + iA * m_s1 * m_s1 + iB * m_s2 * m_s2;
+ float k12 = iA * m_s1 + iB * m_s2;
+ float k22 = iA + iB;
+ if (k22 == 0.0f)
+ {
+ // For bodies with fixed rotation.
+ k22 = 1.0f;
+ }
+
+ m_K.ex.Set(k11, k12);
+ m_K.ey.Set(k12, k22);
+ }
+
+ if (m_enableLimit)
+ {
+ m_translation = b2Dot(m_axis, d);
+ }
+ else
+ {
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ if (m_enableMotor == false)
+ {
+ m_motorImpulse = 0.0f;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Account for variable time step.
+ m_impulse *= data.step.dtRatio;
+ m_motorImpulse *= data.step.dtRatio;
+ m_lowerImpulse *= data.step.dtRatio;
+ m_upperImpulse *= data.step.dtRatio;
+
+ float axialImpulse = m_motorImpulse + m_lowerImpulse - m_upperImpulse;
+ b2Vec2 P = m_impulse.x * m_perp + axialImpulse * m_axis;
+ float LA = m_impulse.x * m_s1 + m_impulse.y + axialImpulse * m_a1;
+ float LB = m_impulse.x * m_s2 + m_impulse.y + axialImpulse * m_a2;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+
+ vB += mB * P;
+ wB += iB * LB;
+ }
+ else
+ {
+ m_impulse.SetZero();
+ m_motorImpulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2PrismaticJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ // Solve linear motor constraint
+ if (m_enableMotor)
+ {
+ float Cdot = b2Dot(m_axis, vB - vA) + m_a2 * wB - m_a1 * wA;
+ float impulse = m_axialMass * (m_motorSpeed - Cdot);
+ float oldImpulse = m_motorImpulse;
+ float maxImpulse = data.step.dt * m_maxMotorForce;
+ m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse);
+ impulse = m_motorImpulse - oldImpulse;
+
+ b2Vec2 P = impulse * m_axis;
+ float LA = impulse * m_a1;
+ float LB = impulse * m_a2;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+ vB += mB * P;
+ wB += iB * LB;
+ }
+
+ if (m_enableLimit)
+ {
+ // Lower limit
+ {
+ float C = m_translation - m_lowerTranslation;
+ float Cdot = b2Dot(m_axis, vB - vA) + m_a2 * wB - m_a1 * wA;
+ float impulse = -m_axialMass * (Cdot + b2Max(C, 0.0f) * data.step.inv_dt);
+ float oldImpulse = m_lowerImpulse;
+ m_lowerImpulse = b2Max(m_lowerImpulse + impulse, 0.0f);
+ impulse = m_lowerImpulse - oldImpulse;
+
+ b2Vec2 P = impulse * m_axis;
+ float LA = impulse * m_a1;
+ float LB = impulse * m_a2;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+ vB += mB * P;
+ wB += iB * LB;
+ }
+
+ // Upper limit
+ // Note: signs are flipped to keep C positive when the constraint is satisfied.
+ // This also keeps the impulse positive when the limit is active.
+ {
+ float C = m_upperTranslation - m_translation;
+ float Cdot = b2Dot(m_axis, vA - vB) + m_a1 * wA - m_a2 * wB;
+ float impulse = -m_axialMass * (Cdot + b2Max(C, 0.0f) * data.step.inv_dt);
+ float oldImpulse = m_upperImpulse;
+ m_upperImpulse = b2Max(m_upperImpulse + impulse, 0.0f);
+ impulse = m_upperImpulse - oldImpulse;
+
+ b2Vec2 P = impulse * m_axis;
+ float LA = impulse * m_a1;
+ float LB = impulse * m_a2;
+
+ vA += mA * P;
+ wA += iA * LA;
+ vB -= mB * P;
+ wB -= iB * LB;
+ }
+ }
+
+ // Solve the prismatic constraint in block form.
+ {
+ b2Vec2 Cdot;
+ Cdot.x = b2Dot(m_perp, vB - vA) + m_s2 * wB - m_s1 * wA;
+ Cdot.y = wB - wA;
+
+ b2Vec2 df = m_K.Solve(-Cdot);
+ m_impulse += df;
+
+ b2Vec2 P = df.x * m_perp;
+ float LA = df.x * m_s1 + df.y;
+ float LB = df.x * m_s2 + df.y;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+
+ vB += mB * P;
+ wB += iB * LB;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+// A velocity based solver computes reaction forces(impulses) using the velocity constraint solver.Under this context,
+// the position solver is not there to resolve forces.It is only there to cope with integration error.
+//
+// Therefore, the pseudo impulses in the position solver do not have any physical meaning.Thus it is okay if they suck.
+//
+// We could take the active state from the velocity solver.However, the joint might push past the limit when the velocity
+// solver indicates the limit is inactive.
+bool b2PrismaticJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+
+ b2Rot qA(aA), qB(aB);
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ // Compute fresh Jacobians
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ b2Vec2 d = cB + rB - cA - rA;
+
+ b2Vec2 axis = b2Mul(qA, m_localXAxisA);
+ float a1 = b2Cross(d + rA, axis);
+ float a2 = b2Cross(rB, axis);
+ b2Vec2 perp = b2Mul(qA, m_localYAxisA);
+
+ float s1 = b2Cross(d + rA, perp);
+ float s2 = b2Cross(rB, perp);
+
+ b2Vec3 impulse;
+ b2Vec2 C1;
+ C1.x = b2Dot(perp, d);
+ C1.y = aB - aA - m_referenceAngle;
+
+ float linearError = b2Abs(C1.x);
+ float angularError = b2Abs(C1.y);
+
+ bool active = false;
+ float C2 = 0.0f;
+ if (m_enableLimit)
+ {
+ float translation = b2Dot(axis, d);
+ if (b2Abs(m_upperTranslation - m_lowerTranslation) < 2.0f * b2_linearSlop)
+ {
+ C2 = translation;
+ linearError = b2Max(linearError, b2Abs(translation));
+ active = true;
+ }
+ else if (translation <= m_lowerTranslation)
+ {
+ C2 = b2Min(translation - m_lowerTranslation, 0.0f);
+ linearError = b2Max(linearError, m_lowerTranslation - translation);
+ active = true;
+ }
+ else if (translation >= m_upperTranslation)
+ {
+ C2 = b2Max(translation - m_upperTranslation, 0.0f);
+ linearError = b2Max(linearError, translation - m_upperTranslation);
+ active = true;
+ }
+ }
+
+ if (active)
+ {
+ float k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;
+ float k12 = iA * s1 + iB * s2;
+ float k13 = iA * s1 * a1 + iB * s2 * a2;
+ float k22 = iA + iB;
+ if (k22 == 0.0f)
+ {
+ // For fixed rotation
+ k22 = 1.0f;
+ }
+ float k23 = iA * a1 + iB * a2;
+ float k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;
+
+ b2Mat33 K;
+ K.ex.Set(k11, k12, k13);
+ K.ey.Set(k12, k22, k23);
+ K.ez.Set(k13, k23, k33);
+
+ b2Vec3 C;
+ C.x = C1.x;
+ C.y = C1.y;
+ C.z = C2;
+
+ impulse = K.Solve33(-C);
+ }
+ else
+ {
+ float k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;
+ float k12 = iA * s1 + iB * s2;
+ float k22 = iA + iB;
+ if (k22 == 0.0f)
+ {
+ k22 = 1.0f;
+ }
+
+ b2Mat22 K;
+ K.ex.Set(k11, k12);
+ K.ey.Set(k12, k22);
+
+ b2Vec2 impulse1 = K.Solve(-C1);
+ impulse.x = impulse1.x;
+ impulse.y = impulse1.y;
+ impulse.z = 0.0f;
+ }
+
+ b2Vec2 P = impulse.x * perp + impulse.z * axis;
+ float LA = impulse.x * s1 + impulse.y + impulse.z * a1;
+ float LB = impulse.x * s2 + impulse.y + impulse.z * a2;
+
+ cA -= mA * P;
+ aA -= iA * LA;
+ cB += mB * P;
+ aB += iB * LB;
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+
+ return linearError <= b2_linearSlop && angularError <= b2_angularSlop;
+}
+
+b2Vec2 b2PrismaticJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2PrismaticJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2PrismaticJoint::GetReactionForce(float inv_dt) const
+{
+ return inv_dt * (m_impulse.x * m_perp + (m_motorImpulse + m_lowerImpulse - m_upperImpulse) * m_axis);
+}
+
+float b2PrismaticJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * m_impulse.y;
+}
+
+float b2PrismaticJoint::GetJointTranslation() const
+{
+ b2Vec2 pA = m_bodyA->GetWorldPoint(m_localAnchorA);
+ b2Vec2 pB = m_bodyB->GetWorldPoint(m_localAnchorB);
+ b2Vec2 d = pB - pA;
+ b2Vec2 axis = m_bodyA->GetWorldVector(m_localXAxisA);
+
+ float translation = b2Dot(d, axis);
+ return translation;
+}
+
+float b2PrismaticJoint::GetJointSpeed() const
+{
+ b2Body* bA = m_bodyA;
+ b2Body* bB = m_bodyB;
+
+ b2Vec2 rA = b2Mul(bA->m_xf.q, m_localAnchorA - bA->m_sweep.localCenter);
+ b2Vec2 rB = b2Mul(bB->m_xf.q, m_localAnchorB - bB->m_sweep.localCenter);
+ b2Vec2 p1 = bA->m_sweep.c + rA;
+ b2Vec2 p2 = bB->m_sweep.c + rB;
+ b2Vec2 d = p2 - p1;
+ b2Vec2 axis = b2Mul(bA->m_xf.q, m_localXAxisA);
+
+ b2Vec2 vA = bA->m_linearVelocity;
+ b2Vec2 vB = bB->m_linearVelocity;
+ float wA = bA->m_angularVelocity;
+ float wB = bB->m_angularVelocity;
+
+ float speed = b2Dot(d, b2Cross(wA, axis)) + b2Dot(axis, vB + b2Cross(wB, rB) - vA - b2Cross(wA, rA));
+ return speed;
+}
+
+bool b2PrismaticJoint::IsLimitEnabled() const
+{
+ return m_enableLimit;
+}
+
+void b2PrismaticJoint::EnableLimit(bool flag)
+{
+ if (flag != m_enableLimit)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_enableLimit = flag;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+}
+
+float b2PrismaticJoint::GetLowerLimit() const
+{
+ return m_lowerTranslation;
+}
+
+float b2PrismaticJoint::GetUpperLimit() const
+{
+ return m_upperTranslation;
+}
+
+void b2PrismaticJoint::SetLimits(float lower, float upper)
+{
+ b2Assert(lower <= upper);
+ if (lower != m_lowerTranslation || upper != m_upperTranslation)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_lowerTranslation = lower;
+ m_upperTranslation = upper;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+}
+
+bool b2PrismaticJoint::IsMotorEnabled() const
+{
+ return m_enableMotor;
+}
+
+void b2PrismaticJoint::EnableMotor(bool flag)
+{
+ if (flag != m_enableMotor)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_enableMotor = flag;
+ }
+}
+
+void b2PrismaticJoint::SetMotorSpeed(float speed)
+{
+ if (speed != m_motorSpeed)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_motorSpeed = speed;
+ }
+}
+
+void b2PrismaticJoint::SetMaxMotorForce(float force)
+{
+ if (force != m_maxMotorForce)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_maxMotorForce = force;
+ }
+}
+
+float b2PrismaticJoint::GetMotorForce(float inv_dt) const
+{
+ return inv_dt * m_motorImpulse;
+}
+
+void b2PrismaticJoint::Dump()
+{
+ // FLT_DECIMAL_DIG == 9
+
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2PrismaticJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.localAxisA.Set(%.9g, %.9g);\n", m_localXAxisA.x, m_localXAxisA.y);
+ b2Dump(" jd.referenceAngle = %.9g;\n", m_referenceAngle);
+ b2Dump(" jd.enableLimit = bool(%d);\n", m_enableLimit);
+ b2Dump(" jd.lowerTranslation = %.9g;\n", m_lowerTranslation);
+ b2Dump(" jd.upperTranslation = %.9g;\n", m_upperTranslation);
+ b2Dump(" jd.enableMotor = bool(%d);\n", m_enableMotor);
+ b2Dump(" jd.motorSpeed = %.9g;\n", m_motorSpeed);
+ b2Dump(" jd.maxMotorForce = %.9g;\n", m_maxMotorForce);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
+
+void b2PrismaticJoint::Draw(b2Draw* draw) const
+{
+ const b2Transform& xfA = m_bodyA->GetTransform();
+ const b2Transform& xfB = m_bodyB->GetTransform();
+ b2Vec2 pA = b2Mul(xfA, m_localAnchorA);
+ b2Vec2 pB = b2Mul(xfB, m_localAnchorB);
+
+ b2Vec2 axis = b2Mul(xfA.q, m_localXAxisA);
+
+ b2Color c1(0.7f, 0.7f, 0.7f);
+ b2Color c2(0.3f, 0.9f, 0.3f);
+ b2Color c3(0.9f, 0.3f, 0.3f);
+ b2Color c4(0.3f, 0.3f, 0.9f);
+ b2Color c5(0.4f, 0.4f, 0.4f);
+
+ draw->DrawSegment(pA, pB, c5);
+
+ if (m_enableLimit)
+ {
+ b2Vec2 lower = pA + m_lowerTranslation * axis;
+ b2Vec2 upper = pA + m_upperTranslation * axis;
+ b2Vec2 perp = b2Mul(xfA.q, m_localYAxisA);
+ draw->DrawSegment(lower, upper, c1);
+ draw->DrawSegment(lower - 0.5f * perp, lower + 0.5f * perp, c2);
+ draw->DrawSegment(upper - 0.5f * perp, upper + 0.5f * perp, c3);
+ }
+ else
+ {
+ draw->DrawSegment(pA - 1.0f * axis, pA + 1.0f * axis, c1);
+ }
+
+ draw->DrawPoint(pA, 5.0f, c1);
+ draw->DrawPoint(pB, 5.0f, c4);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_pulley_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_pulley_joint.cpp
new file mode 100644
index 0000000..099e57e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_pulley_joint.cpp
@@ -0,0 +1,352 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_pulley_joint.h"
+#include "box2d/b2_time_step.h"
+
+// Pulley:
+// length1 = norm(p1 - s1)
+// length2 = norm(p2 - s2)
+// C0 = (length1 + ratio * length2)_initial
+// C = C0 - (length1 + ratio * length2)
+// u1 = (p1 - s1) / norm(p1 - s1)
+// u2 = (p2 - s2) / norm(p2 - s2)
+// Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2))
+// J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)]
+// K = J * invM * JT
+// = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 * cross(r2, u2)^2)
+
+void b2PulleyJointDef::Initialize(b2Body* bA, b2Body* bB,
+ const b2Vec2& groundA, const b2Vec2& groundB,
+ const b2Vec2& anchorA, const b2Vec2& anchorB,
+ float r)
+{
+ bodyA = bA;
+ bodyB = bB;
+ groundAnchorA = groundA;
+ groundAnchorB = groundB;
+ localAnchorA = bodyA->GetLocalPoint(anchorA);
+ localAnchorB = bodyB->GetLocalPoint(anchorB);
+ b2Vec2 dA = anchorA - groundA;
+ lengthA = dA.Length();
+ b2Vec2 dB = anchorB - groundB;
+ lengthB = dB.Length();
+ ratio = r;
+ b2Assert(ratio > b2_epsilon);
+}
+
+b2PulleyJoint::b2PulleyJoint(const b2PulleyJointDef* def)
+: b2Joint(def)
+{
+ m_groundAnchorA = def->groundAnchorA;
+ m_groundAnchorB = def->groundAnchorB;
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+
+ m_lengthA = def->lengthA;
+ m_lengthB = def->lengthB;
+
+ b2Assert(def->ratio != 0.0f);
+ m_ratio = def->ratio;
+
+ m_constant = def->lengthA + m_ratio * def->lengthB;
+
+ m_impulse = 0.0f;
+}
+
+void b2PulleyJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ // Get the pulley axes.
+ m_uA = cA + m_rA - m_groundAnchorA;
+ m_uB = cB + m_rB - m_groundAnchorB;
+
+ float lengthA = m_uA.Length();
+ float lengthB = m_uB.Length();
+
+ if (lengthA > 10.0f * b2_linearSlop)
+ {
+ m_uA *= 1.0f / lengthA;
+ }
+ else
+ {
+ m_uA.SetZero();
+ }
+
+ if (lengthB > 10.0f * b2_linearSlop)
+ {
+ m_uB *= 1.0f / lengthB;
+ }
+ else
+ {
+ m_uB.SetZero();
+ }
+
+ // Compute effective mass.
+ float ruA = b2Cross(m_rA, m_uA);
+ float ruB = b2Cross(m_rB, m_uB);
+
+ float mA = m_invMassA + m_invIA * ruA * ruA;
+ float mB = m_invMassB + m_invIB * ruB * ruB;
+
+ m_mass = mA + m_ratio * m_ratio * mB;
+
+ if (m_mass > 0.0f)
+ {
+ m_mass = 1.0f / m_mass;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Scale impulses to support variable time steps.
+ m_impulse *= data.step.dtRatio;
+
+ // Warm starting.
+ b2Vec2 PA = -(m_impulse) * m_uA;
+ b2Vec2 PB = (-m_ratio * m_impulse) * m_uB;
+
+ vA += m_invMassA * PA;
+ wA += m_invIA * b2Cross(m_rA, PA);
+ vB += m_invMassB * PB;
+ wB += m_invIB * b2Cross(m_rB, PB);
+ }
+ else
+ {
+ m_impulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2PulleyJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Vec2 vpA = vA + b2Cross(wA, m_rA);
+ b2Vec2 vpB = vB + b2Cross(wB, m_rB);
+
+ float Cdot = -b2Dot(m_uA, vpA) - m_ratio * b2Dot(m_uB, vpB);
+ float impulse = -m_mass * Cdot;
+ m_impulse += impulse;
+
+ b2Vec2 PA = -impulse * m_uA;
+ b2Vec2 PB = -m_ratio * impulse * m_uB;
+ vA += m_invMassA * PA;
+ wA += m_invIA * b2Cross(m_rA, PA);
+ vB += m_invMassB * PB;
+ wB += m_invIB * b2Cross(m_rB, PB);
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2PulleyJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+
+ b2Rot qA(aA), qB(aB);
+
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ // Get the pulley axes.
+ b2Vec2 uA = cA + rA - m_groundAnchorA;
+ b2Vec2 uB = cB + rB - m_groundAnchorB;
+
+ float lengthA = uA.Length();
+ float lengthB = uB.Length();
+
+ if (lengthA > 10.0f * b2_linearSlop)
+ {
+ uA *= 1.0f / lengthA;
+ }
+ else
+ {
+ uA.SetZero();
+ }
+
+ if (lengthB > 10.0f * b2_linearSlop)
+ {
+ uB *= 1.0f / lengthB;
+ }
+ else
+ {
+ uB.SetZero();
+ }
+
+ // Compute effective mass.
+ float ruA = b2Cross(rA, uA);
+ float ruB = b2Cross(rB, uB);
+
+ float mA = m_invMassA + m_invIA * ruA * ruA;
+ float mB = m_invMassB + m_invIB * ruB * ruB;
+
+ float mass = mA + m_ratio * m_ratio * mB;
+
+ if (mass > 0.0f)
+ {
+ mass = 1.0f / mass;
+ }
+
+ float C = m_constant - lengthA - m_ratio * lengthB;
+ float linearError = b2Abs(C);
+
+ float impulse = -mass * C;
+
+ b2Vec2 PA = -impulse * uA;
+ b2Vec2 PB = -m_ratio * impulse * uB;
+
+ cA += m_invMassA * PA;
+ aA += m_invIA * b2Cross(rA, PA);
+ cB += m_invMassB * PB;
+ aB += m_invIB * b2Cross(rB, PB);
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+
+ return linearError < b2_linearSlop;
+}
+
+b2Vec2 b2PulleyJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2PulleyJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2PulleyJoint::GetReactionForce(float inv_dt) const
+{
+ b2Vec2 P = m_impulse * m_uB;
+ return inv_dt * P;
+}
+
+float b2PulleyJoint::GetReactionTorque(float inv_dt) const
+{
+ B2_NOT_USED(inv_dt);
+ return 0.0f;
+}
+
+b2Vec2 b2PulleyJoint::GetGroundAnchorA() const
+{
+ return m_groundAnchorA;
+}
+
+b2Vec2 b2PulleyJoint::GetGroundAnchorB() const
+{
+ return m_groundAnchorB;
+}
+
+float b2PulleyJoint::GetLengthA() const
+{
+ return m_lengthA;
+}
+
+float b2PulleyJoint::GetLengthB() const
+{
+ return m_lengthB;
+}
+
+float b2PulleyJoint::GetRatio() const
+{
+ return m_ratio;
+}
+
+float b2PulleyJoint::GetCurrentLengthA() const
+{
+ b2Vec2 p = m_bodyA->GetWorldPoint(m_localAnchorA);
+ b2Vec2 s = m_groundAnchorA;
+ b2Vec2 d = p - s;
+ return d.Length();
+}
+
+float b2PulleyJoint::GetCurrentLengthB() const
+{
+ b2Vec2 p = m_bodyB->GetWorldPoint(m_localAnchorB);
+ b2Vec2 s = m_groundAnchorB;
+ b2Vec2 d = p - s;
+ return d.Length();
+}
+
+void b2PulleyJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2PulleyJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.groundAnchorA.Set(%.9g, %.9g);\n", m_groundAnchorA.x, m_groundAnchorA.y);
+ b2Dump(" jd.groundAnchorB.Set(%.9g, %.9g);\n", m_groundAnchorB.x, m_groundAnchorB.y);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.lengthA = %.9g;\n", m_lengthA);
+ b2Dump(" jd.lengthB = %.9g;\n", m_lengthB);
+ b2Dump(" jd.ratio = %.9g;\n", m_ratio);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
+
+void b2PulleyJoint::ShiftOrigin(const b2Vec2& newOrigin)
+{
+ m_groundAnchorA -= newOrigin;
+ m_groundAnchorB -= newOrigin;
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_revolute_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_revolute_joint.cpp
new file mode 100644
index 0000000..f7cc4cc
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_revolute_joint.cpp
@@ -0,0 +1,501 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_draw.h"
+#include "box2d/b2_revolute_joint.h"
+#include "box2d/b2_time_step.h"
+
+// Point-to-point constraint
+// C = p2 - p1
+// Cdot = v2 - v1
+// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
+// J = [-I -r1_skew I r2_skew ]
+// Identity used:
+// w k % (rx i + ry j) = w * (-ry i + rx j)
+
+// Motor constraint
+// Cdot = w2 - w1
+// J = [0 0 -1 0 0 1]
+// K = invI1 + invI2
+
+void b2RevoluteJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor)
+{
+ bodyA = bA;
+ bodyB = bB;
+ localAnchorA = bodyA->GetLocalPoint(anchor);
+ localAnchorB = bodyB->GetLocalPoint(anchor);
+ referenceAngle = bodyB->GetAngle() - bodyA->GetAngle();
+}
+
+b2RevoluteJoint::b2RevoluteJoint(const b2RevoluteJointDef* def)
+: b2Joint(def)
+{
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+ m_referenceAngle = def->referenceAngle;
+
+ m_impulse.SetZero();
+ m_axialMass = 0.0f;
+ m_motorImpulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+
+ m_lowerAngle = def->lowerAngle;
+ m_upperAngle = def->upperAngle;
+ m_maxMotorTorque = def->maxMotorTorque;
+ m_motorSpeed = def->motorSpeed;
+ m_enableLimit = def->enableLimit;
+ m_enableMotor = def->enableMotor;
+
+ m_angle = 0.0f;
+}
+
+void b2RevoluteJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ // J = [-I -r1_skew I r2_skew]
+ // r_skew = [-ry; rx]
+
+ // Matlab
+ // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x]
+ // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB]
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ m_K.ex.x = mA + mB + m_rA.y * m_rA.y * iA + m_rB.y * m_rB.y * iB;
+ m_K.ey.x = -m_rA.y * m_rA.x * iA - m_rB.y * m_rB.x * iB;
+ m_K.ex.y = m_K.ey.x;
+ m_K.ey.y = mA + mB + m_rA.x * m_rA.x * iA + m_rB.x * m_rB.x * iB;
+
+ m_axialMass = iA + iB;
+ bool fixedRotation;
+ if (m_axialMass > 0.0f)
+ {
+ m_axialMass = 1.0f / m_axialMass;
+ fixedRotation = false;
+ }
+ else
+ {
+ fixedRotation = true;
+ }
+
+ m_angle = aB - aA - m_referenceAngle;
+ if (m_enableLimit == false || fixedRotation)
+ {
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ if (m_enableMotor == false || fixedRotation)
+ {
+ m_motorImpulse = 0.0f;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Scale impulses to support a variable time step.
+ m_impulse *= data.step.dtRatio;
+ m_motorImpulse *= data.step.dtRatio;
+ m_lowerImpulse *= data.step.dtRatio;
+ m_upperImpulse *= data.step.dtRatio;
+
+ float axialImpulse = m_motorImpulse + m_lowerImpulse - m_upperImpulse;
+ b2Vec2 P(m_impulse.x, m_impulse.y);
+
+ vA -= mA * P;
+ wA -= iA * (b2Cross(m_rA, P) + axialImpulse);
+
+ vB += mB * P;
+ wB += iB * (b2Cross(m_rB, P) + axialImpulse);
+ }
+ else
+ {
+ m_impulse.SetZero();
+ m_motorImpulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2RevoluteJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ bool fixedRotation = (iA + iB == 0.0f);
+
+ // Solve motor constraint.
+ if (m_enableMotor && fixedRotation == false)
+ {
+ float Cdot = wB - wA - m_motorSpeed;
+ float impulse = -m_axialMass * Cdot;
+ float oldImpulse = m_motorImpulse;
+ float maxImpulse = data.step.dt * m_maxMotorTorque;
+ m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse);
+ impulse = m_motorImpulse - oldImpulse;
+
+ wA -= iA * impulse;
+ wB += iB * impulse;
+ }
+
+ if (m_enableLimit && fixedRotation == false)
+ {
+ // Lower limit
+ {
+ float C = m_angle - m_lowerAngle;
+ float Cdot = wB - wA;
+ float impulse = -m_axialMass * (Cdot + b2Max(C, 0.0f) * data.step.inv_dt);
+ float oldImpulse = m_lowerImpulse;
+ m_lowerImpulse = b2Max(m_lowerImpulse + impulse, 0.0f);
+ impulse = m_lowerImpulse - oldImpulse;
+
+ wA -= iA * impulse;
+ wB += iB * impulse;
+ }
+
+ // Upper limit
+ // Note: signs are flipped to keep C positive when the constraint is satisfied.
+ // This also keeps the impulse positive when the limit is active.
+ {
+ float C = m_upperAngle - m_angle;
+ float Cdot = wA - wB;
+ float impulse = -m_axialMass * (Cdot + b2Max(C, 0.0f) * data.step.inv_dt);
+ float oldImpulse = m_upperImpulse;
+ m_upperImpulse = b2Max(m_upperImpulse + impulse, 0.0f);
+ impulse = m_upperImpulse - oldImpulse;
+
+ wA += iA * impulse;
+ wB -= iB * impulse;
+ }
+ }
+
+ // Solve point-to-point constraint
+ {
+ b2Vec2 Cdot = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA);
+ b2Vec2 impulse = m_K.Solve(-Cdot);
+
+ m_impulse.x += impulse.x;
+ m_impulse.y += impulse.y;
+
+ vA -= mA * impulse;
+ wA -= iA * b2Cross(m_rA, impulse);
+
+ vB += mB * impulse;
+ wB += iB * b2Cross(m_rB, impulse);
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2RevoluteJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+
+ b2Rot qA(aA), qB(aB);
+
+ float angularError = 0.0f;
+ float positionError = 0.0f;
+
+ bool fixedRotation = (m_invIA + m_invIB == 0.0f);
+
+ // Solve angular limit constraint
+ if (m_enableLimit && fixedRotation == false)
+ {
+ float angle = aB - aA - m_referenceAngle;
+ float C = 0.0f;
+
+ if (b2Abs(m_upperAngle - m_lowerAngle) < 2.0f * b2_angularSlop)
+ {
+ // Prevent large angular corrections
+ C = b2Clamp(angle - m_lowerAngle, -b2_maxAngularCorrection, b2_maxAngularCorrection);
+ }
+ else if (angle <= m_lowerAngle)
+ {
+ // Prevent large angular corrections and allow some slop.
+ C = b2Clamp(angle - m_lowerAngle + b2_angularSlop, -b2_maxAngularCorrection, 0.0f);
+ }
+ else if (angle >= m_upperAngle)
+ {
+ // Prevent large angular corrections and allow some slop.
+ C = b2Clamp(angle - m_upperAngle - b2_angularSlop, 0.0f, b2_maxAngularCorrection);
+ }
+
+ float limitImpulse = -m_axialMass * C;
+ aA -= m_invIA * limitImpulse;
+ aB += m_invIB * limitImpulse;
+ angularError = b2Abs(C);
+ }
+
+ // Solve point-to-point constraint.
+ {
+ qA.Set(aA);
+ qB.Set(aB);
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ b2Vec2 C = cB + rB - cA - rA;
+ positionError = C.Length();
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ b2Mat22 K;
+ K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;
+ K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;
+ K.ey.x = K.ex.y;
+ K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;
+
+ b2Vec2 impulse = -K.Solve(C);
+
+ cA -= mA * impulse;
+ aA -= iA * b2Cross(rA, impulse);
+
+ cB += mB * impulse;
+ aB += iB * b2Cross(rB, impulse);
+ }
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+
+ return positionError <= b2_linearSlop && angularError <= b2_angularSlop;
+}
+
+b2Vec2 b2RevoluteJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2RevoluteJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2RevoluteJoint::GetReactionForce(float inv_dt) const
+{
+ b2Vec2 P(m_impulse.x, m_impulse.y);
+ return inv_dt * P;
+}
+
+float b2RevoluteJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * (m_motorImpulse + m_lowerImpulse - m_upperImpulse);
+}
+
+float b2RevoluteJoint::GetJointAngle() const
+{
+ b2Body* bA = m_bodyA;
+ b2Body* bB = m_bodyB;
+ return bB->m_sweep.a - bA->m_sweep.a - m_referenceAngle;
+}
+
+float b2RevoluteJoint::GetJointSpeed() const
+{
+ b2Body* bA = m_bodyA;
+ b2Body* bB = m_bodyB;
+ return bB->m_angularVelocity - bA->m_angularVelocity;
+}
+
+bool b2RevoluteJoint::IsMotorEnabled() const
+{
+ return m_enableMotor;
+}
+
+void b2RevoluteJoint::EnableMotor(bool flag)
+{
+ if (flag != m_enableMotor)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_enableMotor = flag;
+ }
+}
+
+float b2RevoluteJoint::GetMotorTorque(float inv_dt) const
+{
+ return inv_dt * m_motorImpulse;
+}
+
+void b2RevoluteJoint::SetMotorSpeed(float speed)
+{
+ if (speed != m_motorSpeed)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_motorSpeed = speed;
+ }
+}
+
+void b2RevoluteJoint::SetMaxMotorTorque(float torque)
+{
+ if (torque != m_maxMotorTorque)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_maxMotorTorque = torque;
+ }
+}
+
+bool b2RevoluteJoint::IsLimitEnabled() const
+{
+ return m_enableLimit;
+}
+
+void b2RevoluteJoint::EnableLimit(bool flag)
+{
+ if (flag != m_enableLimit)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_enableLimit = flag;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+}
+
+float b2RevoluteJoint::GetLowerLimit() const
+{
+ return m_lowerAngle;
+}
+
+float b2RevoluteJoint::GetUpperLimit() const
+{
+ return m_upperAngle;
+}
+
+void b2RevoluteJoint::SetLimits(float lower, float upper)
+{
+ b2Assert(lower <= upper);
+
+ if (lower != m_lowerAngle || upper != m_upperAngle)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ m_lowerAngle = lower;
+ m_upperAngle = upper;
+ }
+}
+
+void b2RevoluteJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2RevoluteJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.referenceAngle = %.9g;\n", m_referenceAngle);
+ b2Dump(" jd.enableLimit = bool(%d);\n", m_enableLimit);
+ b2Dump(" jd.lowerAngle = %.9g;\n", m_lowerAngle);
+ b2Dump(" jd.upperAngle = %.9g;\n", m_upperAngle);
+ b2Dump(" jd.enableMotor = bool(%d);\n", m_enableMotor);
+ b2Dump(" jd.motorSpeed = %.9g;\n", m_motorSpeed);
+ b2Dump(" jd.maxMotorTorque = %.9g;\n", m_maxMotorTorque);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
+
+///
+void b2RevoluteJoint::Draw(b2Draw* draw) const
+{
+ const b2Transform& xfA = m_bodyA->GetTransform();
+ const b2Transform& xfB = m_bodyB->GetTransform();
+ b2Vec2 pA = b2Mul(xfA, m_localAnchorA);
+ b2Vec2 pB = b2Mul(xfB, m_localAnchorB);
+
+ b2Color c1(0.7f, 0.7f, 0.7f);
+ b2Color c2(0.3f, 0.9f, 0.3f);
+ b2Color c3(0.9f, 0.3f, 0.3f);
+ b2Color c4(0.3f, 0.3f, 0.9f);
+ b2Color c5(0.4f, 0.4f, 0.4f);
+
+ draw->DrawPoint(pA, 5.0f, c4);
+ draw->DrawPoint(pB, 5.0f, c5);
+
+ float aA = m_bodyA->GetAngle();
+ float aB = m_bodyB->GetAngle();
+ float angle = aB - aA - m_referenceAngle;
+
+ const float L = 0.5f;
+
+ b2Vec2 r = L * b2Vec2(cosf(angle), sinf(angle));
+ draw->DrawSegment(pB, pB + r, c1);
+ draw->DrawCircle(pB, L, c1);
+
+ if (m_enableLimit)
+ {
+ b2Vec2 rlo = L * b2Vec2(cosf(m_lowerAngle), sinf(m_lowerAngle));
+ b2Vec2 rhi = L * b2Vec2(cosf(m_upperAngle), sinf(m_upperAngle));
+
+ draw->DrawSegment(pB, pB + rlo, c2);
+ draw->DrawSegment(pB, pB + rhi, c3);
+ }
+
+ b2Color color(0.5f, 0.8f, 0.8f);
+ draw->DrawSegment(xfA.p, pA, color);
+ draw->DrawSegment(pA, pB, color);
+ draw->DrawSegment(xfB.p, pB, color);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_weld_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_weld_joint.cpp
new file mode 100644
index 0000000..df3ee0a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_weld_joint.cpp
@@ -0,0 +1,344 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_time_step.h"
+#include "box2d/b2_weld_joint.h"
+
+// Point-to-point constraint
+// C = p2 - p1
+// Cdot = v2 - v1
+// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
+// J = [-I -r1_skew I r2_skew ]
+// Identity used:
+// w k % (rx i + ry j) = w * (-ry i + rx j)
+
+// Angle constraint
+// C = angle2 - angle1 - referenceAngle
+// Cdot = w2 - w1
+// J = [0 0 -1 0 0 1]
+// K = invI1 + invI2
+
+void b2WeldJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor)
+{
+ bodyA = bA;
+ bodyB = bB;
+ localAnchorA = bodyA->GetLocalPoint(anchor);
+ localAnchorB = bodyB->GetLocalPoint(anchor);
+ referenceAngle = bodyB->GetAngle() - bodyA->GetAngle();
+}
+
+b2WeldJoint::b2WeldJoint(const b2WeldJointDef* def)
+: b2Joint(def)
+{
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+ m_referenceAngle = def->referenceAngle;
+ m_stiffness = def->stiffness;
+ m_damping = def->damping;
+
+ m_impulse.SetZero();
+}
+
+void b2WeldJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ // J = [-I -r1_skew I r2_skew]
+ // [ 0 -1 0 1]
+ // r_skew = [-ry; rx]
+
+ // Matlab
+ // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB]
+ // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB]
+ // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB]
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ b2Mat33 K;
+ K.ex.x = mA + mB + m_rA.y * m_rA.y * iA + m_rB.y * m_rB.y * iB;
+ K.ey.x = -m_rA.y * m_rA.x * iA - m_rB.y * m_rB.x * iB;
+ K.ez.x = -m_rA.y * iA - m_rB.y * iB;
+ K.ex.y = K.ey.x;
+ K.ey.y = mA + mB + m_rA.x * m_rA.x * iA + m_rB.x * m_rB.x * iB;
+ K.ez.y = m_rA.x * iA + m_rB.x * iB;
+ K.ex.z = K.ez.x;
+ K.ey.z = K.ez.y;
+ K.ez.z = iA + iB;
+
+ if (m_stiffness > 0.0f)
+ {
+ K.GetInverse22(&m_mass);
+
+ float invM = iA + iB;
+
+ float C = aB - aA - m_referenceAngle;
+
+ // Damping coefficient
+ float d = m_damping;
+
+ // Spring stiffness
+ float k = m_stiffness;
+
+ // magic formulas
+ float h = data.step.dt;
+ m_gamma = h * (d + h * k);
+ m_gamma = m_gamma != 0.0f ? 1.0f / m_gamma : 0.0f;
+ m_bias = C * h * k * m_gamma;
+
+ invM += m_gamma;
+ m_mass.ez.z = invM != 0.0f ? 1.0f / invM : 0.0f;
+ }
+ else if (K.ez.z == 0.0f)
+ {
+ K.GetInverse22(&m_mass);
+ m_gamma = 0.0f;
+ m_bias = 0.0f;
+ }
+ else
+ {
+ K.GetSymInverse33(&m_mass);
+ m_gamma = 0.0f;
+ m_bias = 0.0f;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Scale impulses to support a variable time step.
+ m_impulse *= data.step.dtRatio;
+
+ b2Vec2 P(m_impulse.x, m_impulse.y);
+
+ vA -= mA * P;
+ wA -= iA * (b2Cross(m_rA, P) + m_impulse.z);
+
+ vB += mB * P;
+ wB += iB * (b2Cross(m_rB, P) + m_impulse.z);
+ }
+ else
+ {
+ m_impulse.SetZero();
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2WeldJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ if (m_stiffness > 0.0f)
+ {
+ float Cdot2 = wB - wA;
+
+ float impulse2 = -m_mass.ez.z * (Cdot2 + m_bias + m_gamma * m_impulse.z);
+ m_impulse.z += impulse2;
+
+ wA -= iA * impulse2;
+ wB += iB * impulse2;
+
+ b2Vec2 Cdot1 = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA);
+
+ b2Vec2 impulse1 = -b2Mul22(m_mass, Cdot1);
+ m_impulse.x += impulse1.x;
+ m_impulse.y += impulse1.y;
+
+ b2Vec2 P = impulse1;
+
+ vA -= mA * P;
+ wA -= iA * b2Cross(m_rA, P);
+
+ vB += mB * P;
+ wB += iB * b2Cross(m_rB, P);
+ }
+ else
+ {
+ b2Vec2 Cdot1 = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA);
+ float Cdot2 = wB - wA;
+ b2Vec3 Cdot(Cdot1.x, Cdot1.y, Cdot2);
+
+ b2Vec3 impulse = -b2Mul(m_mass, Cdot);
+ m_impulse += impulse;
+
+ b2Vec2 P(impulse.x, impulse.y);
+
+ vA -= mA * P;
+ wA -= iA * (b2Cross(m_rA, P) + impulse.z);
+
+ vB += mB * P;
+ wB += iB * (b2Cross(m_rB, P) + impulse.z);
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2WeldJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+
+ b2Rot qA(aA), qB(aB);
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+
+ float positionError, angularError;
+
+ b2Mat33 K;
+ K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;
+ K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;
+ K.ez.x = -rA.y * iA - rB.y * iB;
+ K.ex.y = K.ey.x;
+ K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;
+ K.ez.y = rA.x * iA + rB.x * iB;
+ K.ex.z = K.ez.x;
+ K.ey.z = K.ez.y;
+ K.ez.z = iA + iB;
+
+ if (m_stiffness > 0.0f)
+ {
+ b2Vec2 C1 = cB + rB - cA - rA;
+
+ positionError = C1.Length();
+ angularError = 0.0f;
+
+ b2Vec2 P = -K.Solve22(C1);
+
+ cA -= mA * P;
+ aA -= iA * b2Cross(rA, P);
+
+ cB += mB * P;
+ aB += iB * b2Cross(rB, P);
+ }
+ else
+ {
+ b2Vec2 C1 = cB + rB - cA - rA;
+ float C2 = aB - aA - m_referenceAngle;
+
+ positionError = C1.Length();
+ angularError = b2Abs(C2);
+
+ b2Vec3 C(C1.x, C1.y, C2);
+
+ b2Vec3 impulse;
+ if (K.ez.z > 0.0f)
+ {
+ impulse = -K.Solve33(C);
+ }
+ else
+ {
+ b2Vec2 impulse2 = -K.Solve22(C1);
+ impulse.Set(impulse2.x, impulse2.y, 0.0f);
+ }
+
+ b2Vec2 P(impulse.x, impulse.y);
+
+ cA -= mA * P;
+ aA -= iA * (b2Cross(rA, P) + impulse.z);
+
+ cB += mB * P;
+ aB += iB * (b2Cross(rB, P) + impulse.z);
+ }
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+
+ return positionError <= b2_linearSlop && angularError <= b2_angularSlop;
+}
+
+b2Vec2 b2WeldJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2WeldJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2WeldJoint::GetReactionForce(float inv_dt) const
+{
+ b2Vec2 P(m_impulse.x, m_impulse.y);
+ return inv_dt * P;
+}
+
+float b2WeldJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * m_impulse.z;
+}
+
+void b2WeldJoint::Dump()
+{
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2WeldJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.referenceAngle = %.9g;\n", m_referenceAngle);
+ b2Dump(" jd.stiffness = %.9g;\n", m_stiffness);
+ b2Dump(" jd.damping = %.9g;\n", m_damping);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_wheel_joint.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_wheel_joint.cpp
new file mode 100644
index 0000000..c23b984
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_wheel_joint.cpp
@@ -0,0 +1,672 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_draw.h"
+#include "box2d/b2_wheel_joint.h"
+#include "box2d/b2_time_step.h"
+
+// Linear constraint (point-to-line)
+// d = pB - pA = xB + rB - xA - rA
+// C = dot(ay, d)
+// Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA, rA))
+// = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB, ay), vB)
+// J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)]
+
+// Spring linear constraint
+// C = dot(ax, d)
+// Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) + dot(cross(rB, ax), vB)
+// J = [-ax -cross(d+rA, ax) ax cross(rB, ax)]
+
+// Motor rotational constraint
+// Cdot = wB - wA
+// J = [0 0 -1 0 0 1]
+
+void b2WheelJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor, const b2Vec2& axis)
+{
+ bodyA = bA;
+ bodyB = bB;
+ localAnchorA = bodyA->GetLocalPoint(anchor);
+ localAnchorB = bodyB->GetLocalPoint(anchor);
+ localAxisA = bodyA->GetLocalVector(axis);
+}
+
+b2WheelJoint::b2WheelJoint(const b2WheelJointDef* def)
+: b2Joint(def)
+{
+ m_localAnchorA = def->localAnchorA;
+ m_localAnchorB = def->localAnchorB;
+ m_localXAxisA = def->localAxisA;
+ m_localYAxisA = b2Cross(1.0f, m_localXAxisA);
+
+ m_mass = 0.0f;
+ m_impulse = 0.0f;
+ m_motorMass = 0.0f;
+ m_motorImpulse = 0.0f;
+ m_springMass = 0.0f;
+ m_springImpulse = 0.0f;
+
+ m_axialMass = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ m_lowerTranslation = def->lowerTranslation;
+ m_upperTranslation = def->upperTranslation;
+ m_enableLimit = def->enableLimit;
+
+ m_maxMotorTorque = def->maxMotorTorque;
+ m_motorSpeed = def->motorSpeed;
+ m_enableMotor = def->enableMotor;
+
+ m_bias = 0.0f;
+ m_gamma = 0.0f;
+
+ m_ax.SetZero();
+ m_ay.SetZero();
+
+ m_stiffness = def->stiffness;
+ m_damping = def->damping;
+}
+
+void b2WheelJoint::InitVelocityConstraints(const b2SolverData& data)
+{
+ m_indexA = m_bodyA->m_islandIndex;
+ m_indexB = m_bodyB->m_islandIndex;
+ m_localCenterA = m_bodyA->m_sweep.localCenter;
+ m_localCenterB = m_bodyB->m_sweep.localCenter;
+ m_invMassA = m_bodyA->m_invMass;
+ m_invMassB = m_bodyB->m_invMass;
+ m_invIA = m_bodyA->m_invI;
+ m_invIB = m_bodyB->m_invI;
+
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ b2Rot qA(aA), qB(aB);
+
+ // Compute the effective masses.
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ b2Vec2 d = cB + rB - cA - rA;
+
+ // Point to line constraint
+ {
+ m_ay = b2Mul(qA, m_localYAxisA);
+ m_sAy = b2Cross(d + rA, m_ay);
+ m_sBy = b2Cross(rB, m_ay);
+
+ m_mass = mA + mB + iA * m_sAy * m_sAy + iB * m_sBy * m_sBy;
+
+ if (m_mass > 0.0f)
+ {
+ m_mass = 1.0f / m_mass;
+ }
+ }
+
+ // Spring constraint
+ m_ax = b2Mul(qA, m_localXAxisA);
+ m_sAx = b2Cross(d + rA, m_ax);
+ m_sBx = b2Cross(rB, m_ax);
+
+ const float invMass = mA + mB + iA * m_sAx * m_sAx + iB * m_sBx * m_sBx;
+ if (invMass > 0.0f)
+ {
+ m_axialMass = 1.0f / invMass;
+ }
+ else
+ {
+ m_axialMass = 0.0f;
+ }
+
+ m_springMass = 0.0f;
+ m_bias = 0.0f;
+ m_gamma = 0.0f;
+
+ if (m_stiffness > 0.0f && invMass > 0.0f)
+ {
+ m_springMass = 1.0f / invMass;
+
+ float C = b2Dot(d, m_ax);
+
+ // magic formulas
+ float h = data.step.dt;
+ m_gamma = h * (m_damping + h * m_stiffness);
+ if (m_gamma > 0.0f)
+ {
+ m_gamma = 1.0f / m_gamma;
+ }
+
+ m_bias = C * h * m_stiffness * m_gamma;
+
+ m_springMass = invMass + m_gamma;
+ if (m_springMass > 0.0f)
+ {
+ m_springMass = 1.0f / m_springMass;
+ }
+ }
+ else
+ {
+ m_springImpulse = 0.0f;
+ }
+
+ if (m_enableLimit)
+ {
+ m_translation = b2Dot(m_ax, d);
+ }
+ else
+ {
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ if (m_enableMotor)
+ {
+ m_motorMass = iA + iB;
+ if (m_motorMass > 0.0f)
+ {
+ m_motorMass = 1.0f / m_motorMass;
+ }
+ }
+ else
+ {
+ m_motorMass = 0.0f;
+ m_motorImpulse = 0.0f;
+ }
+
+ if (data.step.warmStarting)
+ {
+ // Account for variable time step.
+ m_impulse *= data.step.dtRatio;
+ m_springImpulse *= data.step.dtRatio;
+ m_motorImpulse *= data.step.dtRatio;
+
+ float axialImpulse = m_springImpulse + m_lowerImpulse - m_upperImpulse;
+ b2Vec2 P = m_impulse * m_ay + axialImpulse * m_ax;
+ float LA = m_impulse * m_sAy + axialImpulse * m_sAx + m_motorImpulse;
+ float LB = m_impulse * m_sBy + axialImpulse * m_sBx + m_motorImpulse;
+
+ vA -= m_invMassA * P;
+ wA -= m_invIA * LA;
+
+ vB += m_invMassB * P;
+ wB += m_invIB * LB;
+ }
+ else
+ {
+ m_impulse = 0.0f;
+ m_springImpulse = 0.0f;
+ m_motorImpulse = 0.0f;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+void b2WheelJoint::SolveVelocityConstraints(const b2SolverData& data)
+{
+ float mA = m_invMassA, mB = m_invMassB;
+ float iA = m_invIA, iB = m_invIB;
+
+ b2Vec2 vA = data.velocities[m_indexA].v;
+ float wA = data.velocities[m_indexA].w;
+ b2Vec2 vB = data.velocities[m_indexB].v;
+ float wB = data.velocities[m_indexB].w;
+
+ // Solve spring constraint
+ {
+ float Cdot = b2Dot(m_ax, vB - vA) + m_sBx * wB - m_sAx * wA;
+ float impulse = -m_springMass * (Cdot + m_bias + m_gamma * m_springImpulse);
+ m_springImpulse += impulse;
+
+ b2Vec2 P = impulse * m_ax;
+ float LA = impulse * m_sAx;
+ float LB = impulse * m_sBx;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+
+ vB += mB * P;
+ wB += iB * LB;
+ }
+
+ // Solve rotational motor constraint
+ {
+ float Cdot = wB - wA - m_motorSpeed;
+ float impulse = -m_motorMass * Cdot;
+
+ float oldImpulse = m_motorImpulse;
+ float maxImpulse = data.step.dt * m_maxMotorTorque;
+ m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse);
+ impulse = m_motorImpulse - oldImpulse;
+
+ wA -= iA * impulse;
+ wB += iB * impulse;
+ }
+
+ if (m_enableLimit)
+ {
+ // Lower limit
+ {
+ float C = m_translation - m_lowerTranslation;
+ float Cdot = b2Dot(m_ax, vB - vA) + m_sBx * wB - m_sAx * wA;
+ float impulse = -m_axialMass * (Cdot + b2Max(C, 0.0f) * data.step.inv_dt);
+ float oldImpulse = m_lowerImpulse;
+ m_lowerImpulse = b2Max(m_lowerImpulse + impulse, 0.0f);
+ impulse = m_lowerImpulse - oldImpulse;
+
+ b2Vec2 P = impulse * m_ax;
+ float LA = impulse * m_sAx;
+ float LB = impulse * m_sBx;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+ vB += mB * P;
+ wB += iB * LB;
+ }
+
+ // Upper limit
+ // Note: signs are flipped to keep C positive when the constraint is satisfied.
+ // This also keeps the impulse positive when the limit is active.
+ {
+ float C = m_upperTranslation - m_translation;
+ float Cdot = b2Dot(m_ax, vA - vB) + m_sAx * wA - m_sBx * wB;
+ float impulse = -m_axialMass * (Cdot + b2Max(C, 0.0f) * data.step.inv_dt);
+ float oldImpulse = m_upperImpulse;
+ m_upperImpulse = b2Max(m_upperImpulse + impulse, 0.0f);
+ impulse = m_upperImpulse - oldImpulse;
+
+ b2Vec2 P = impulse * m_ax;
+ float LA = impulse * m_sAx;
+ float LB = impulse * m_sBx;
+
+ vA += mA * P;
+ wA += iA * LA;
+ vB -= mB * P;
+ wB -= iB * LB;
+ }
+ }
+
+ // Solve point to line constraint
+ {
+ float Cdot = b2Dot(m_ay, vB - vA) + m_sBy * wB - m_sAy * wA;
+ float impulse = -m_mass * Cdot;
+ m_impulse += impulse;
+
+ b2Vec2 P = impulse * m_ay;
+ float LA = impulse * m_sAy;
+ float LB = impulse * m_sBy;
+
+ vA -= mA * P;
+ wA -= iA * LA;
+
+ vB += mB * P;
+ wB += iB * LB;
+ }
+
+ data.velocities[m_indexA].v = vA;
+ data.velocities[m_indexA].w = wA;
+ data.velocities[m_indexB].v = vB;
+ data.velocities[m_indexB].w = wB;
+}
+
+bool b2WheelJoint::SolvePositionConstraints(const b2SolverData& data)
+{
+ b2Vec2 cA = data.positions[m_indexA].c;
+ float aA = data.positions[m_indexA].a;
+ b2Vec2 cB = data.positions[m_indexB].c;
+ float aB = data.positions[m_indexB].a;
+
+ float linearError = 0.0f;
+
+ if (m_enableLimit)
+ {
+ b2Rot qA(aA), qB(aB);
+
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ b2Vec2 d = (cB - cA) + rB - rA;
+
+ b2Vec2 ax = b2Mul(qA, m_localXAxisA);
+ float sAx = b2Cross(d + rA, m_ax);
+ float sBx = b2Cross(rB, m_ax);
+
+ float C = 0.0f;
+ float translation = b2Dot(ax, d);
+ if (b2Abs(m_upperTranslation - m_lowerTranslation) < 2.0f * b2_linearSlop)
+ {
+ C = translation;
+ }
+ else if (translation <= m_lowerTranslation)
+ {
+ C = b2Min(translation - m_lowerTranslation, 0.0f);
+ }
+ else if (translation >= m_upperTranslation)
+ {
+ C = b2Max(translation - m_upperTranslation, 0.0f);
+ }
+
+ if (C != 0.0f)
+ {
+
+ float invMass = m_invMassA + m_invMassB + m_invIA * sAx * sAx + m_invIB * sBx * sBx;
+ float impulse = 0.0f;
+ if (invMass != 0.0f)
+ {
+ impulse = -C / invMass;
+ }
+
+ b2Vec2 P = impulse * ax;
+ float LA = impulse * sAx;
+ float LB = impulse * sBx;
+
+ cA -= m_invMassA * P;
+ aA -= m_invIA * LA;
+ cB += m_invMassB * P;
+ aB += m_invIB * LB;
+
+ linearError = b2Abs(C);
+ }
+ }
+
+ // Solve perpendicular constraint
+ {
+ b2Rot qA(aA), qB(aB);
+
+ b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA);
+ b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB);
+ b2Vec2 d = (cB - cA) + rB - rA;
+
+ b2Vec2 ay = b2Mul(qA, m_localYAxisA);
+
+ float sAy = b2Cross(d + rA, ay);
+ float sBy = b2Cross(rB, ay);
+
+ float C = b2Dot(d, ay);
+
+ float invMass = m_invMassA + m_invMassB + m_invIA * m_sAy * m_sAy + m_invIB * m_sBy * m_sBy;
+
+ float impulse = 0.0f;
+ if (invMass != 0.0f)
+ {
+ impulse = - C / invMass;
+ }
+
+ b2Vec2 P = impulse * ay;
+ float LA = impulse * sAy;
+ float LB = impulse * sBy;
+
+ cA -= m_invMassA * P;
+ aA -= m_invIA * LA;
+ cB += m_invMassB * P;
+ aB += m_invIB * LB;
+
+ linearError = b2Max(linearError, b2Abs(C));
+ }
+
+ data.positions[m_indexA].c = cA;
+ data.positions[m_indexA].a = aA;
+ data.positions[m_indexB].c = cB;
+ data.positions[m_indexB].a = aB;
+
+ return linearError <= b2_linearSlop;
+}
+
+b2Vec2 b2WheelJoint::GetAnchorA() const
+{
+ return m_bodyA->GetWorldPoint(m_localAnchorA);
+}
+
+b2Vec2 b2WheelJoint::GetAnchorB() const
+{
+ return m_bodyB->GetWorldPoint(m_localAnchorB);
+}
+
+b2Vec2 b2WheelJoint::GetReactionForce(float inv_dt) const
+{
+ return inv_dt * (m_impulse * m_ay + (m_springImpulse + m_lowerImpulse - m_upperImpulse) * m_ax);
+}
+
+float b2WheelJoint::GetReactionTorque(float inv_dt) const
+{
+ return inv_dt * m_motorImpulse;
+}
+
+float b2WheelJoint::GetJointTranslation() const
+{
+ b2Body* bA = m_bodyA;
+ b2Body* bB = m_bodyB;
+
+ b2Vec2 pA = bA->GetWorldPoint(m_localAnchorA);
+ b2Vec2 pB = bB->GetWorldPoint(m_localAnchorB);
+ b2Vec2 d = pB - pA;
+ b2Vec2 axis = bA->GetWorldVector(m_localXAxisA);
+
+ float translation = b2Dot(d, axis);
+ return translation;
+}
+
+float b2WheelJoint::GetJointLinearSpeed() const
+{
+ b2Body* bA = m_bodyA;
+ b2Body* bB = m_bodyB;
+
+ b2Vec2 rA = b2Mul(bA->m_xf.q, m_localAnchorA - bA->m_sweep.localCenter);
+ b2Vec2 rB = b2Mul(bB->m_xf.q, m_localAnchorB - bB->m_sweep.localCenter);
+ b2Vec2 p1 = bA->m_sweep.c + rA;
+ b2Vec2 p2 = bB->m_sweep.c + rB;
+ b2Vec2 d = p2 - p1;
+ b2Vec2 axis = b2Mul(bA->m_xf.q, m_localXAxisA);
+
+ b2Vec2 vA = bA->m_linearVelocity;
+ b2Vec2 vB = bB->m_linearVelocity;
+ float wA = bA->m_angularVelocity;
+ float wB = bB->m_angularVelocity;
+
+ float speed = b2Dot(d, b2Cross(wA, axis)) + b2Dot(axis, vB + b2Cross(wB, rB) - vA - b2Cross(wA, rA));
+ return speed;
+}
+
+float b2WheelJoint::GetJointAngle() const
+{
+ b2Body* bA = m_bodyA;
+ b2Body* bB = m_bodyB;
+ return bB->m_sweep.a - bA->m_sweep.a;
+}
+
+float b2WheelJoint::GetJointAngularSpeed() const
+{
+ float wA = m_bodyA->m_angularVelocity;
+ float wB = m_bodyB->m_angularVelocity;
+ return wB - wA;
+}
+
+bool b2WheelJoint::IsLimitEnabled() const
+{
+ return m_enableLimit;
+}
+
+void b2WheelJoint::EnableLimit(bool flag)
+{
+ if (flag != m_enableLimit)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_enableLimit = flag;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+}
+
+float b2WheelJoint::GetLowerLimit() const
+{
+ return m_lowerTranslation;
+}
+
+float b2WheelJoint::GetUpperLimit() const
+{
+ return m_upperTranslation;
+}
+
+void b2WheelJoint::SetLimits(float lower, float upper)
+{
+ b2Assert(lower <= upper);
+ if (lower != m_lowerTranslation || upper != m_upperTranslation)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_lowerTranslation = lower;
+ m_upperTranslation = upper;
+ m_lowerImpulse = 0.0f;
+ m_upperImpulse = 0.0f;
+ }
+}
+
+bool b2WheelJoint::IsMotorEnabled() const
+{
+ return m_enableMotor;
+}
+
+void b2WheelJoint::EnableMotor(bool flag)
+{
+ if (flag != m_enableMotor)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_enableMotor = flag;
+ }
+}
+
+void b2WheelJoint::SetMotorSpeed(float speed)
+{
+ if (speed != m_motorSpeed)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_motorSpeed = speed;
+ }
+}
+
+void b2WheelJoint::SetMaxMotorTorque(float torque)
+{
+ if (torque != m_maxMotorTorque)
+ {
+ m_bodyA->SetAwake(true);
+ m_bodyB->SetAwake(true);
+ m_maxMotorTorque = torque;
+ }
+}
+
+float b2WheelJoint::GetMotorTorque(float inv_dt) const
+{
+ return inv_dt * m_motorImpulse;
+}
+
+void b2WheelJoint::SetStiffness(float stiffness)
+{
+ m_stiffness = stiffness;
+}
+
+float b2WheelJoint::GetStiffness() const
+{
+ return m_stiffness;
+}
+
+void b2WheelJoint::SetDamping(float damping)
+{
+ m_damping = damping;
+}
+
+float b2WheelJoint::GetDamping() const
+{
+ return m_damping;
+}
+
+void b2WheelJoint::Dump()
+{
+ // FLT_DECIMAL_DIG == 9
+
+ int32 indexA = m_bodyA->m_islandIndex;
+ int32 indexB = m_bodyB->m_islandIndex;
+
+ b2Dump(" b2WheelJointDef jd;\n");
+ b2Dump(" jd.bodyA = bodies[%d];\n", indexA);
+ b2Dump(" jd.bodyB = bodies[%d];\n", indexB);
+ b2Dump(" jd.collideConnected = bool(%d);\n", m_collideConnected);
+ b2Dump(" jd.localAnchorA.Set(%.9g, %.9g);\n", m_localAnchorA.x, m_localAnchorA.y);
+ b2Dump(" jd.localAnchorB.Set(%.9g, %.9g);\n", m_localAnchorB.x, m_localAnchorB.y);
+ b2Dump(" jd.localAxisA.Set(%.9g, %.9g);\n", m_localXAxisA.x, m_localXAxisA.y);
+ b2Dump(" jd.enableMotor = bool(%d);\n", m_enableMotor);
+ b2Dump(" jd.motorSpeed = %.9g;\n", m_motorSpeed);
+ b2Dump(" jd.maxMotorTorque = %.9g;\n", m_maxMotorTorque);
+ b2Dump(" jd.stiffness = %.9g;\n", m_stiffness);
+ b2Dump(" jd.damping = %.9g;\n", m_damping);
+ b2Dump(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index);
+}
+
+///
+void b2WheelJoint::Draw(b2Draw* draw) const
+{
+ const b2Transform& xfA = m_bodyA->GetTransform();
+ const b2Transform& xfB = m_bodyB->GetTransform();
+ b2Vec2 pA = b2Mul(xfA, m_localAnchorA);
+ b2Vec2 pB = b2Mul(xfB, m_localAnchorB);
+
+ b2Vec2 axis = b2Mul(xfA.q, m_localXAxisA);
+
+ b2Color c1(0.7f, 0.7f, 0.7f);
+ b2Color c2(0.3f, 0.9f, 0.3f);
+ b2Color c3(0.9f, 0.3f, 0.3f);
+ b2Color c4(0.3f, 0.3f, 0.9f);
+ b2Color c5(0.4f, 0.4f, 0.4f);
+
+ draw->DrawSegment(pA, pB, c5);
+
+ if (m_enableLimit)
+ {
+ b2Vec2 lower = pA + m_lowerTranslation * axis;
+ b2Vec2 upper = pA + m_upperTranslation * axis;
+ b2Vec2 perp = b2Mul(xfA.q, m_localYAxisA);
+ draw->DrawSegment(lower, upper, c1);
+ draw->DrawSegment(lower - 0.5f * perp, lower + 0.5f * perp, c2);
+ draw->DrawSegment(upper - 0.5f * perp, upper + 0.5f * perp, c3);
+ }
+ else
+ {
+ draw->DrawSegment(pA - 1.0f * axis, pA + 1.0f * axis, c1);
+ }
+
+ draw->DrawPoint(pA, 5.0f, c1);
+ draw->DrawPoint(pB, 5.0f, c4);
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_world.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_world.cpp
new file mode 100644
index 0000000..78ec084
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_world.cpp
@@ -0,0 +1,1322 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "b2_contact_solver.h"
+#include "b2_island.h"
+
+#include "box2d/b2_body.h"
+#include "box2d/b2_broad_phase.h"
+#include "box2d/b2_chain_shape.h"
+#include "box2d/b2_circle_shape.h"
+#include "box2d/b2_collision.h"
+#include "box2d/b2_contact.h"
+#include "box2d/b2_draw.h"
+#include "box2d/b2_edge_shape.h"
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_polygon_shape.h"
+#include "box2d/b2_pulley_joint.h"
+#include "box2d/b2_time_of_impact.h"
+#include "box2d/b2_timer.h"
+#include "box2d/b2_world.h"
+
+#include <new>
+
+b2World::b2World(const b2Vec2& gravity)
+{
+ m_destructionListener = nullptr;
+ m_debugDraw = nullptr;
+
+ m_bodyList = nullptr;
+ m_jointList = nullptr;
+
+ m_bodyCount = 0;
+ m_jointCount = 0;
+
+ m_warmStarting = true;
+ m_continuousPhysics = true;
+ m_subStepping = false;
+
+ m_stepComplete = true;
+
+ m_allowSleep = true;
+ m_gravity = gravity;
+
+ m_newContacts = false;
+ m_locked = false;
+ m_clearForces = true;
+
+ m_inv_dt0 = 0.0f;
+
+ m_contactManager.m_allocator = &m_blockAllocator;
+
+ memset(&m_profile, 0, sizeof(b2Profile));
+}
+
+b2World::~b2World()
+{
+ // Some shapes allocate using b2Alloc.
+ b2Body* b = m_bodyList;
+ while (b)
+ {
+ b2Body* bNext = b->m_next;
+
+ b2Fixture* f = b->m_fixtureList;
+ while (f)
+ {
+ b2Fixture* fNext = f->m_next;
+ f->m_proxyCount = 0;
+ f->Destroy(&m_blockAllocator);
+ f = fNext;
+ }
+
+ b = bNext;
+ }
+}
+
+void b2World::SetDestructionListener(b2DestructionListener* listener)
+{
+ m_destructionListener = listener;
+}
+
+void b2World::SetContactFilter(b2ContactFilter* filter)
+{
+ m_contactManager.m_contactFilter = filter;
+}
+
+void b2World::SetContactListener(b2ContactListener* listener)
+{
+ m_contactManager.m_contactListener = listener;
+}
+
+void b2World::SetDebugDraw(b2Draw* debugDraw)
+{
+ m_debugDraw = debugDraw;
+}
+
+b2Body* b2World::CreateBody(const b2BodyDef* def)
+{
+ b2Assert(IsLocked() == false);
+ if (IsLocked())
+ {
+ return nullptr;
+ }
+
+ void* mem = m_blockAllocator.Allocate(sizeof(b2Body));
+ b2Body* b = new (mem) b2Body(def, this);
+
+ // Add to world doubly linked list.
+ b->m_prev = nullptr;
+ b->m_next = m_bodyList;
+ if (m_bodyList)
+ {
+ m_bodyList->m_prev = b;
+ }
+ m_bodyList = b;
+ ++m_bodyCount;
+
+ return b;
+}
+
+void b2World::DestroyBody(b2Body* b)
+{
+ b2Assert(m_bodyCount > 0);
+ b2Assert(IsLocked() == false);
+ if (IsLocked())
+ {
+ return;
+ }
+
+ // Delete the attached joints.
+ b2JointEdge* je = b->m_jointList;
+ while (je)
+ {
+ b2JointEdge* je0 = je;
+ je = je->next;
+
+ if (m_destructionListener)
+ {
+ m_destructionListener->SayGoodbye(je0->joint);
+ }
+
+ DestroyJoint(je0->joint);
+
+ b->m_jointList = je;
+ }
+ b->m_jointList = nullptr;
+
+ // Delete the attached contacts.
+ b2ContactEdge* ce = b->m_contactList;
+ while (ce)
+ {
+ b2ContactEdge* ce0 = ce;
+ ce = ce->next;
+ m_contactManager.Destroy(ce0->contact);
+ }
+ b->m_contactList = nullptr;
+
+ // Delete the attached fixtures. This destroys broad-phase proxies.
+ b2Fixture* f = b->m_fixtureList;
+ while (f)
+ {
+ b2Fixture* f0 = f;
+ f = f->m_next;
+
+ if (m_destructionListener)
+ {
+ m_destructionListener->SayGoodbye(f0);
+ }
+
+ f0->DestroyProxies(&m_contactManager.m_broadPhase);
+ f0->Destroy(&m_blockAllocator);
+ f0->~b2Fixture();
+ m_blockAllocator.Free(f0, sizeof(b2Fixture));
+
+ b->m_fixtureList = f;
+ b->m_fixtureCount -= 1;
+ }
+ b->m_fixtureList = nullptr;
+ b->m_fixtureCount = 0;
+
+ // Remove world body list.
+ if (b->m_prev)
+ {
+ b->m_prev->m_next = b->m_next;
+ }
+
+ if (b->m_next)
+ {
+ b->m_next->m_prev = b->m_prev;
+ }
+
+ if (b == m_bodyList)
+ {
+ m_bodyList = b->m_next;
+ }
+
+ --m_bodyCount;
+ b->~b2Body();
+ m_blockAllocator.Free(b, sizeof(b2Body));
+}
+
+b2Joint* b2World::CreateJoint(const b2JointDef* def)
+{
+ b2Assert(IsLocked() == false);
+ if (IsLocked())
+ {
+ return nullptr;
+ }
+
+ b2Joint* j = b2Joint::Create(def, &m_blockAllocator);
+
+ // Connect to the world list.
+ j->m_prev = nullptr;
+ j->m_next = m_jointList;
+ if (m_jointList)
+ {
+ m_jointList->m_prev = j;
+ }
+ m_jointList = j;
+ ++m_jointCount;
+
+ // Connect to the bodies' doubly linked lists.
+ j->m_edgeA.joint = j;
+ j->m_edgeA.other = j->m_bodyB;
+ j->m_edgeA.prev = nullptr;
+ j->m_edgeA.next = j->m_bodyA->m_jointList;
+ if (j->m_bodyA->m_jointList) j->m_bodyA->m_jointList->prev = &j->m_edgeA;
+ j->m_bodyA->m_jointList = &j->m_edgeA;
+
+ j->m_edgeB.joint = j;
+ j->m_edgeB.other = j->m_bodyA;
+ j->m_edgeB.prev = nullptr;
+ j->m_edgeB.next = j->m_bodyB->m_jointList;
+ if (j->m_bodyB->m_jointList) j->m_bodyB->m_jointList->prev = &j->m_edgeB;
+ j->m_bodyB->m_jointList = &j->m_edgeB;
+
+ b2Body* bodyA = def->bodyA;
+ b2Body* bodyB = def->bodyB;
+
+ // If the joint prevents collisions, then flag any contacts for filtering.
+ if (def->collideConnected == false)
+ {
+ b2ContactEdge* edge = bodyB->GetContactList();
+ while (edge)
+ {
+ if (edge->other == bodyA)
+ {
+ // Flag the contact for filtering at the next time step (where either
+ // body is awake).
+ edge->contact->FlagForFiltering();
+ }
+
+ edge = edge->next;
+ }
+ }
+
+ // Note: creating a joint doesn't wake the bodies.
+
+ return j;
+}
+
+void b2World::DestroyJoint(b2Joint* j)
+{
+ b2Assert(IsLocked() == false);
+ if (IsLocked())
+ {
+ return;
+ }
+
+ bool collideConnected = j->m_collideConnected;
+
+ // Remove from the doubly linked list.
+ if (j->m_prev)
+ {
+ j->m_prev->m_next = j->m_next;
+ }
+
+ if (j->m_next)
+ {
+ j->m_next->m_prev = j->m_prev;
+ }
+
+ if (j == m_jointList)
+ {
+ m_jointList = j->m_next;
+ }
+
+ // Disconnect from island graph.
+ b2Body* bodyA = j->m_bodyA;
+ b2Body* bodyB = j->m_bodyB;
+
+ // Wake up connected bodies.
+ bodyA->SetAwake(true);
+ bodyB->SetAwake(true);
+
+ // Remove from body 1.
+ if (j->m_edgeA.prev)
+ {
+ j->m_edgeA.prev->next = j->m_edgeA.next;
+ }
+
+ if (j->m_edgeA.next)
+ {
+ j->m_edgeA.next->prev = j->m_edgeA.prev;
+ }
+
+ if (&j->m_edgeA == bodyA->m_jointList)
+ {
+ bodyA->m_jointList = j->m_edgeA.next;
+ }
+
+ j->m_edgeA.prev = nullptr;
+ j->m_edgeA.next = nullptr;
+
+ // Remove from body 2
+ if (j->m_edgeB.prev)
+ {
+ j->m_edgeB.prev->next = j->m_edgeB.next;
+ }
+
+ if (j->m_edgeB.next)
+ {
+ j->m_edgeB.next->prev = j->m_edgeB.prev;
+ }
+
+ if (&j->m_edgeB == bodyB->m_jointList)
+ {
+ bodyB->m_jointList = j->m_edgeB.next;
+ }
+
+ j->m_edgeB.prev = nullptr;
+ j->m_edgeB.next = nullptr;
+
+ b2Joint::Destroy(j, &m_blockAllocator);
+
+ b2Assert(m_jointCount > 0);
+ --m_jointCount;
+
+ // If the joint prevents collisions, then flag any contacts for filtering.
+ if (collideConnected == false)
+ {
+ b2ContactEdge* edge = bodyB->GetContactList();
+ while (edge)
+ {
+ if (edge->other == bodyA)
+ {
+ // Flag the contact for filtering at the next time step (where either
+ // body is awake).
+ edge->contact->FlagForFiltering();
+ }
+
+ edge = edge->next;
+ }
+ }
+}
+
+//
+void b2World::SetAllowSleeping(bool flag)
+{
+ if (flag == m_allowSleep)
+ {
+ return;
+ }
+
+ m_allowSleep = flag;
+ if (m_allowSleep == false)
+ {
+ for (b2Body* b = m_bodyList; b; b = b->m_next)
+ {
+ b->SetAwake(true);
+ }
+ }
+}
+
+// Find islands, integrate and solve constraints, solve position constraints
+void b2World::Solve(const b2TimeStep& step)
+{
+ m_profile.solveInit = 0.0f;
+ m_profile.solveVelocity = 0.0f;
+ m_profile.solvePosition = 0.0f;
+
+ // Size the island for the worst case.
+ b2Island island(m_bodyCount,
+ m_contactManager.m_contactCount,
+ m_jointCount,
+ &m_stackAllocator,
+ m_contactManager.m_contactListener);
+
+ // Clear all the island flags.
+ for (b2Body* b = m_bodyList; b; b = b->m_next)
+ {
+ b->m_flags &= ~b2Body::e_islandFlag;
+ }
+ for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next)
+ {
+ c->m_flags &= ~b2Contact::e_islandFlag;
+ }
+ for (b2Joint* j = m_jointList; j; j = j->m_next)
+ {
+ j->m_islandFlag = false;
+ }
+
+ // Build and simulate all awake islands.
+ int32 stackSize = m_bodyCount;
+ b2Body** stack = (b2Body**)m_stackAllocator.Allocate(stackSize * sizeof(b2Body*));
+ for (b2Body* seed = m_bodyList; seed; seed = seed->m_next)
+ {
+ if (seed->m_flags & b2Body::e_islandFlag)
+ {
+ continue;
+ }
+
+ if (seed->IsAwake() == false || seed->IsEnabled() == false)
+ {
+ continue;
+ }
+
+ // The seed can be dynamic or kinematic.
+ if (seed->GetType() == b2_staticBody)
+ {
+ continue;
+ }
+
+ // Reset island and stack.
+ island.Clear();
+ int32 stackCount = 0;
+ stack[stackCount++] = seed;
+ seed->m_flags |= b2Body::e_islandFlag;
+
+ // Perform a depth first search (DFS) on the constraint graph.
+ while (stackCount > 0)
+ {
+ // Grab the next body off the stack and add it to the island.
+ b2Body* b = stack[--stackCount];
+ b2Assert(b->IsEnabled() == true);
+ island.Add(b);
+
+ // To keep islands as small as possible, we don't
+ // propagate islands across static bodies.
+ if (b->GetType() == b2_staticBody)
+ {
+ continue;
+ }
+
+ // Make sure the body is awake (without resetting sleep timer).
+ b->m_flags |= b2Body::e_awakeFlag;
+
+ // Search all contacts connected to this body.
+ for (b2ContactEdge* ce = b->m_contactList; ce; ce = ce->next)
+ {
+ b2Contact* contact = ce->contact;
+
+ // Has this contact already been added to an island?
+ if (contact->m_flags & b2Contact::e_islandFlag)
+ {
+ continue;
+ }
+
+ // Is this contact solid and touching?
+ if (contact->IsEnabled() == false ||
+ contact->IsTouching() == false)
+ {
+ continue;
+ }
+
+ // Skip sensors.
+ bool sensorA = contact->m_fixtureA->m_isSensor;
+ bool sensorB = contact->m_fixtureB->m_isSensor;
+ if (sensorA || sensorB)
+ {
+ continue;
+ }
+
+ island.Add(contact);
+ contact->m_flags |= b2Contact::e_islandFlag;
+
+ b2Body* other = ce->other;
+
+ // Was the other body already added to this island?
+ if (other->m_flags & b2Body::e_islandFlag)
+ {
+ continue;
+ }
+
+ b2Assert(stackCount < stackSize);
+ stack[stackCount++] = other;
+ other->m_flags |= b2Body::e_islandFlag;
+ }
+
+ // Search all joints connect to this body.
+ for (b2JointEdge* je = b->m_jointList; je; je = je->next)
+ {
+ if (je->joint->m_islandFlag == true)
+ {
+ continue;
+ }
+
+ b2Body* other = je->other;
+
+ // Don't simulate joints connected to disabled bodies.
+ if (other->IsEnabled() == false)
+ {
+ continue;
+ }
+
+ island.Add(je->joint);
+ je->joint->m_islandFlag = true;
+
+ if (other->m_flags & b2Body::e_islandFlag)
+ {
+ continue;
+ }
+
+ b2Assert(stackCount < stackSize);
+ stack[stackCount++] = other;
+ other->m_flags |= b2Body::e_islandFlag;
+ }
+ }
+
+ b2Profile profile;
+ island.Solve(&profile, step, m_gravity, m_allowSleep);
+ m_profile.solveInit += profile.solveInit;
+ m_profile.solveVelocity += profile.solveVelocity;
+ m_profile.solvePosition += profile.solvePosition;
+
+ // Post solve cleanup.
+ for (int32 i = 0; i < island.m_bodyCount; ++i)
+ {
+ // Allow static bodies to participate in other islands.
+ b2Body* b = island.m_bodies[i];
+ if (b->GetType() == b2_staticBody)
+ {
+ b->m_flags &= ~b2Body::e_islandFlag;
+ }
+ }
+ }
+
+ m_stackAllocator.Free(stack);
+
+ {
+ b2Timer timer;
+ // Synchronize fixtures, check for out of range bodies.
+ for (b2Body* b = m_bodyList; b; b = b->GetNext())
+ {
+ // If a body was not in an island then it did not move.
+ if ((b->m_flags & b2Body::e_islandFlag) == 0)
+ {
+ continue;
+ }
+
+ if (b->GetType() == b2_staticBody)
+ {
+ continue;
+ }
+
+ // Update fixtures (for broad-phase).
+ b->SynchronizeFixtures();
+ }
+
+ // Look for new contacts.
+ m_contactManager.FindNewContacts();
+ m_profile.broadphase = timer.GetMilliseconds();
+ }
+}
+
+// Find TOI contacts and solve them.
+void b2World::SolveTOI(const b2TimeStep& step)
+{
+ b2Island island(2 * b2_maxTOIContacts, b2_maxTOIContacts, 0, &m_stackAllocator, m_contactManager.m_contactListener);
+
+ if (m_stepComplete)
+ {
+ for (b2Body* b = m_bodyList; b; b = b->m_next)
+ {
+ b->m_flags &= ~b2Body::e_islandFlag;
+ b->m_sweep.alpha0 = 0.0f;
+ }
+
+ for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next)
+ {
+ // Invalidate TOI
+ c->m_flags &= ~(b2Contact::e_toiFlag | b2Contact::e_islandFlag);
+ c->m_toiCount = 0;
+ c->m_toi = 1.0f;
+ }
+ }
+
+ // Find TOI events and solve them.
+ for (;;)
+ {
+ // Find the first TOI.
+ b2Contact* minContact = nullptr;
+ float minAlpha = 1.0f;
+
+ for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next)
+ {
+ // Is this contact disabled?
+ if (c->IsEnabled() == false)
+ {
+ continue;
+ }
+
+ // Prevent excessive sub-stepping.
+ if (c->m_toiCount > b2_maxSubSteps)
+ {
+ continue;
+ }
+
+ float alpha = 1.0f;
+ if (c->m_flags & b2Contact::e_toiFlag)
+ {
+ // This contact has a valid cached TOI.
+ alpha = c->m_toi;
+ }
+ else
+ {
+ b2Fixture* fA = c->GetFixtureA();
+ b2Fixture* fB = c->GetFixtureB();
+
+ // Is there a sensor?
+ if (fA->IsSensor() || fB->IsSensor())
+ {
+ continue;
+ }
+
+ b2Body* bA = fA->GetBody();
+ b2Body* bB = fB->GetBody();
+
+ b2BodyType typeA = bA->m_type;
+ b2BodyType typeB = bB->m_type;
+ b2Assert(typeA == b2_dynamicBody || typeB == b2_dynamicBody);
+
+ bool activeA = bA->IsAwake() && typeA != b2_staticBody;
+ bool activeB = bB->IsAwake() && typeB != b2_staticBody;
+
+ // Is at least one body active (awake and dynamic or kinematic)?
+ if (activeA == false && activeB == false)
+ {
+ continue;
+ }
+
+ bool collideA = bA->IsBullet() || typeA != b2_dynamicBody;
+ bool collideB = bB->IsBullet() || typeB != b2_dynamicBody;
+
+ // Are these two non-bullet dynamic bodies?
+ if (collideA == false && collideB == false)
+ {
+ continue;
+ }
+
+ // Compute the TOI for this contact.
+ // Put the sweeps onto the same time interval.
+ float alpha0 = bA->m_sweep.alpha0;
+
+ if (bA->m_sweep.alpha0 < bB->m_sweep.alpha0)
+ {
+ alpha0 = bB->m_sweep.alpha0;
+ bA->m_sweep.Advance(alpha0);
+ }
+ else if (bB->m_sweep.alpha0 < bA->m_sweep.alpha0)
+ {
+ alpha0 = bA->m_sweep.alpha0;
+ bB->m_sweep.Advance(alpha0);
+ }
+
+ b2Assert(alpha0 < 1.0f);
+
+ int32 indexA = c->GetChildIndexA();
+ int32 indexB = c->GetChildIndexB();
+
+ // Compute the time of impact in interval [0, minTOI]
+ b2TOIInput input;
+ input.proxyA.Set(fA->GetShape(), indexA);
+ input.proxyB.Set(fB->GetShape(), indexB);
+ input.sweepA = bA->m_sweep;
+ input.sweepB = bB->m_sweep;
+ input.tMax = 1.0f;
+
+ b2TOIOutput output;
+ b2TimeOfImpact(&output, &input);
+
+ // Beta is the fraction of the remaining portion of the .
+ float beta = output.t;
+ if (output.state == b2TOIOutput::e_touching)
+ {
+ alpha = b2Min(alpha0 + (1.0f - alpha0) * beta, 1.0f);
+ }
+ else
+ {
+ alpha = 1.0f;
+ }
+
+ c->m_toi = alpha;
+ c->m_flags |= b2Contact::e_toiFlag;
+ }
+
+ if (alpha < minAlpha)
+ {
+ // This is the minimum TOI found so far.
+ minContact = c;
+ minAlpha = alpha;
+ }
+ }
+
+ if (minContact == nullptr || 1.0f - 10.0f * b2_epsilon < minAlpha)
+ {
+ // No more TOI events. Done!
+ m_stepComplete = true;
+ break;
+ }
+
+ // Advance the bodies to the TOI.
+ b2Fixture* fA = minContact->GetFixtureA();
+ b2Fixture* fB = minContact->GetFixtureB();
+ b2Body* bA = fA->GetBody();
+ b2Body* bB = fB->GetBody();
+
+ b2Sweep backup1 = bA->m_sweep;
+ b2Sweep backup2 = bB->m_sweep;
+
+ bA->Advance(minAlpha);
+ bB->Advance(minAlpha);
+
+ // The TOI contact likely has some new contact points.
+ minContact->Update(m_contactManager.m_contactListener);
+ minContact->m_flags &= ~b2Contact::e_toiFlag;
+ ++minContact->m_toiCount;
+
+ // Is the contact solid?
+ if (minContact->IsEnabled() == false || minContact->IsTouching() == false)
+ {
+ // Restore the sweeps.
+ minContact->SetEnabled(false);
+ bA->m_sweep = backup1;
+ bB->m_sweep = backup2;
+ bA->SynchronizeTransform();
+ bB->SynchronizeTransform();
+ continue;
+ }
+
+ bA->SetAwake(true);
+ bB->SetAwake(true);
+
+ // Build the island
+ island.Clear();
+ island.Add(bA);
+ island.Add(bB);
+ island.Add(minContact);
+
+ bA->m_flags |= b2Body::e_islandFlag;
+ bB->m_flags |= b2Body::e_islandFlag;
+ minContact->m_flags |= b2Contact::e_islandFlag;
+
+ // Get contacts on bodyA and bodyB.
+ b2Body* bodies[2] = {bA, bB};
+ for (int32 i = 0; i < 2; ++i)
+ {
+ b2Body* body = bodies[i];
+ if (body->m_type == b2_dynamicBody)
+ {
+ for (b2ContactEdge* ce = body->m_contactList; ce; ce = ce->next)
+ {
+ if (island.m_bodyCount == island.m_bodyCapacity)
+ {
+ break;
+ }
+
+ if (island.m_contactCount == island.m_contactCapacity)
+ {
+ break;
+ }
+
+ b2Contact* contact = ce->contact;
+
+ // Has this contact already been added to the island?
+ if (contact->m_flags & b2Contact::e_islandFlag)
+ {
+ continue;
+ }
+
+ // Only add static, kinematic, or bullet bodies.
+ b2Body* other = ce->other;
+ if (other->m_type == b2_dynamicBody &&
+ body->IsBullet() == false && other->IsBullet() == false)
+ {
+ continue;
+ }
+
+ // Skip sensors.
+ bool sensorA = contact->m_fixtureA->m_isSensor;
+ bool sensorB = contact->m_fixtureB->m_isSensor;
+ if (sensorA || sensorB)
+ {
+ continue;
+ }
+
+ // Tentatively advance the body to the TOI.
+ b2Sweep backup = other->m_sweep;
+ if ((other->m_flags & b2Body::e_islandFlag) == 0)
+ {
+ other->Advance(minAlpha);
+ }
+
+ // Update the contact points
+ contact->Update(m_contactManager.m_contactListener);
+
+ // Was the contact disabled by the user?
+ if (contact->IsEnabled() == false)
+ {
+ other->m_sweep = backup;
+ other->SynchronizeTransform();
+ continue;
+ }
+
+ // Are there contact points?
+ if (contact->IsTouching() == false)
+ {
+ other->m_sweep = backup;
+ other->SynchronizeTransform();
+ continue;
+ }
+
+ // Add the contact to the island
+ contact->m_flags |= b2Contact::e_islandFlag;
+ island.Add(contact);
+
+ // Has the other body already been added to the island?
+ if (other->m_flags & b2Body::e_islandFlag)
+ {
+ continue;
+ }
+
+ // Add the other body to the island.
+ other->m_flags |= b2Body::e_islandFlag;
+
+ if (other->m_type != b2_staticBody)
+ {
+ other->SetAwake(true);
+ }
+
+ island.Add(other);
+ }
+ }
+ }
+
+ b2TimeStep subStep;
+ subStep.dt = (1.0f - minAlpha) * step.dt;
+ subStep.inv_dt = 1.0f / subStep.dt;
+ subStep.dtRatio = 1.0f;
+ subStep.positionIterations = 20;
+ subStep.velocityIterations = step.velocityIterations;
+ subStep.warmStarting = false;
+ island.SolveTOI(subStep, bA->m_islandIndex, bB->m_islandIndex);
+
+ // Reset island flags and synchronize broad-phase proxies.
+ for (int32 i = 0; i < island.m_bodyCount; ++i)
+ {
+ b2Body* body = island.m_bodies[i];
+ body->m_flags &= ~b2Body::e_islandFlag;
+
+ if (body->m_type != b2_dynamicBody)
+ {
+ continue;
+ }
+
+ body->SynchronizeFixtures();
+
+ // Invalidate all contact TOIs on this displaced body.
+ for (b2ContactEdge* ce = body->m_contactList; ce; ce = ce->next)
+ {
+ ce->contact->m_flags &= ~(b2Contact::e_toiFlag | b2Contact::e_islandFlag);
+ }
+ }
+
+ // Commit fixture proxy movements to the broad-phase so that new contacts are created.
+ // Also, some contacts can be destroyed.
+ m_contactManager.FindNewContacts();
+
+ if (m_subStepping)
+ {
+ m_stepComplete = false;
+ break;
+ }
+ }
+}
+
+void b2World::Step(float dt, int32 velocityIterations, int32 positionIterations)
+{
+ b2Timer stepTimer;
+
+ // If new fixtures were added, we need to find the new contacts.
+ if (m_newContacts)
+ {
+ m_contactManager.FindNewContacts();
+ m_newContacts = false;
+ }
+
+ m_locked = true;
+
+ b2TimeStep step;
+ step.dt = dt;
+ step.velocityIterations = velocityIterations;
+ step.positionIterations = positionIterations;
+ if (dt > 0.0f)
+ {
+ step.inv_dt = 1.0f / dt;
+ }
+ else
+ {
+ step.inv_dt = 0.0f;
+ }
+
+ step.dtRatio = m_inv_dt0 * dt;
+
+ step.warmStarting = m_warmStarting;
+
+ // Update contacts. This is where some contacts are destroyed.
+ {
+ b2Timer timer;
+ m_contactManager.Collide();
+ m_profile.collide = timer.GetMilliseconds();
+ }
+
+ // Integrate velocities, solve velocity constraints, and integrate positions.
+ if (m_stepComplete && step.dt > 0.0f)
+ {
+ b2Timer timer;
+ Solve(step);
+ m_profile.solve = timer.GetMilliseconds();
+ }
+
+ // Handle TOI events.
+ if (m_continuousPhysics && step.dt > 0.0f)
+ {
+ b2Timer timer;
+ SolveTOI(step);
+ m_profile.solveTOI = timer.GetMilliseconds();
+ }
+
+ if (step.dt > 0.0f)
+ {
+ m_inv_dt0 = step.inv_dt;
+ }
+
+ if (m_clearForces)
+ {
+ ClearForces();
+ }
+
+ m_locked = false;
+
+ m_profile.step = stepTimer.GetMilliseconds();
+}
+
+void b2World::ClearForces()
+{
+ for (b2Body* body = m_bodyList; body; body = body->GetNext())
+ {
+ body->m_force.SetZero();
+ body->m_torque = 0.0f;
+ }
+}
+
+struct b2WorldQueryWrapper
+{
+ bool QueryCallback(int32 proxyId)
+ {
+ b2FixtureProxy* proxy = (b2FixtureProxy*)broadPhase->GetUserData(proxyId);
+ return callback->ReportFixture(proxy->fixture);
+ }
+
+ const b2BroadPhase* broadPhase;
+ b2QueryCallback* callback;
+};
+
+void b2World::QueryAABB(b2QueryCallback* callback, const b2AABB& aabb) const
+{
+ b2WorldQueryWrapper wrapper;
+ wrapper.broadPhase = &m_contactManager.m_broadPhase;
+ wrapper.callback = callback;
+ m_contactManager.m_broadPhase.Query(&wrapper, aabb);
+}
+
+struct b2WorldRayCastWrapper
+{
+ float RayCastCallback(const b2RayCastInput& input, int32 proxyId)
+ {
+ void* userData = broadPhase->GetUserData(proxyId);
+ b2FixtureProxy* proxy = (b2FixtureProxy*)userData;
+ b2Fixture* fixture = proxy->fixture;
+ int32 index = proxy->childIndex;
+ b2RayCastOutput output;
+ bool hit = fixture->RayCast(&output, input, index);
+
+ if (hit)
+ {
+ float fraction = output.fraction;
+ b2Vec2 point = (1.0f - fraction) * input.p1 + fraction * input.p2;
+ return callback->ReportFixture(fixture, point, output.normal, fraction);
+ }
+
+ return input.maxFraction;
+ }
+
+ const b2BroadPhase* broadPhase;
+ b2RayCastCallback* callback;
+};
+
+void b2World::RayCast(b2RayCastCallback* callback, const b2Vec2& point1, const b2Vec2& point2) const
+{
+ b2WorldRayCastWrapper wrapper;
+ wrapper.broadPhase = &m_contactManager.m_broadPhase;
+ wrapper.callback = callback;
+ b2RayCastInput input;
+ input.maxFraction = 1.0f;
+ input.p1 = point1;
+ input.p2 = point2;
+ m_contactManager.m_broadPhase.RayCast(&wrapper, input);
+}
+
+void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color& color)
+{
+ switch (fixture->GetType())
+ {
+ case b2Shape::e_circle:
+ {
+ b2CircleShape* circle = (b2CircleShape*)fixture->GetShape();
+
+ b2Vec2 center = b2Mul(xf, circle->m_p);
+ float radius = circle->m_radius;
+ b2Vec2 axis = b2Mul(xf.q, b2Vec2(1.0f, 0.0f));
+
+ m_debugDraw->DrawSolidCircle(center, radius, axis, color);
+ }
+ break;
+
+ case b2Shape::e_edge:
+ {
+ b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape();
+ b2Vec2 v1 = b2Mul(xf, edge->m_vertex1);
+ b2Vec2 v2 = b2Mul(xf, edge->m_vertex2);
+ m_debugDraw->DrawSegment(v1, v2, color);
+
+ if (edge->m_oneSided == false)
+ {
+ m_debugDraw->DrawPoint(v1, 4.0f, color);
+ m_debugDraw->DrawPoint(v2, 4.0f, color);
+ }
+ }
+ break;
+
+ case b2Shape::e_chain:
+ {
+ b2ChainShape* chain = (b2ChainShape*)fixture->GetShape();
+ int32 count = chain->m_count;
+ const b2Vec2* vertices = chain->m_vertices;
+
+ b2Vec2 v1 = b2Mul(xf, vertices[0]);
+ for (int32 i = 1; i < count; ++i)
+ {
+ b2Vec2 v2 = b2Mul(xf, vertices[i]);
+ m_debugDraw->DrawSegment(v1, v2, color);
+ v1 = v2;
+ }
+ }
+ break;
+
+ case b2Shape::e_polygon:
+ {
+ b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape();
+ int32 vertexCount = poly->m_count;
+ b2Assert(vertexCount <= b2_maxPolygonVertices);
+ b2Vec2 vertices[b2_maxPolygonVertices];
+
+ for (int32 i = 0; i < vertexCount; ++i)
+ {
+ vertices[i] = b2Mul(xf, poly->m_vertices[i]);
+ }
+
+ m_debugDraw->DrawSolidPolygon(vertices, vertexCount, color);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+void b2World::DebugDraw()
+{
+ if (m_debugDraw == nullptr)
+ {
+ return;
+ }
+
+ uint32 flags = m_debugDraw->GetFlags();
+
+ if (flags & b2Draw::e_shapeBit)
+ {
+ for (b2Body* b = m_bodyList; b; b = b->GetNext())
+ {
+ const b2Transform& xf = b->GetTransform();
+ for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext())
+ {
+ if (b->GetType() == b2_dynamicBody && b->m_mass == 0.0f)
+ {
+ // Bad body
+ DrawShape(f, xf, b2Color(1.0f, 0.0f, 0.0f));
+ }
+ else if (b->IsEnabled() == false)
+ {
+ DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.3f));
+ }
+ else if (b->GetType() == b2_staticBody)
+ {
+ DrawShape(f, xf, b2Color(0.5f, 0.9f, 0.5f));
+ }
+ else if (b->GetType() == b2_kinematicBody)
+ {
+ DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.9f));
+ }
+ else if (b->IsAwake() == false)
+ {
+ DrawShape(f, xf, b2Color(0.6f, 0.6f, 0.6f));
+ }
+ else
+ {
+ DrawShape(f, xf, b2Color(0.9f, 0.7f, 0.7f));
+ }
+ }
+ }
+ }
+
+ if (flags & b2Draw::e_jointBit)
+ {
+ for (b2Joint* j = m_jointList; j; j = j->GetNext())
+ {
+ j->Draw(m_debugDraw);
+ }
+ }
+
+ if (flags & b2Draw::e_pairBit)
+ {
+ b2Color color(0.3f, 0.9f, 0.9f);
+ for (b2Contact* c = m_contactManager.m_contactList; c; c = c->GetNext())
+ {
+ b2Fixture* fixtureA = c->GetFixtureA();
+ b2Fixture* fixtureB = c->GetFixtureB();
+ int32 indexA = c->GetChildIndexA();
+ int32 indexB = c->GetChildIndexB();
+ b2Vec2 cA = fixtureA->GetAABB(indexA).GetCenter();
+ b2Vec2 cB = fixtureB->GetAABB(indexB).GetCenter();
+
+ m_debugDraw->DrawSegment(cA, cB, color);
+ }
+ }
+
+ if (flags & b2Draw::e_aabbBit)
+ {
+ b2Color color(0.9f, 0.3f, 0.9f);
+ b2BroadPhase* bp = &m_contactManager.m_broadPhase;
+
+ for (b2Body* b = m_bodyList; b; b = b->GetNext())
+ {
+ if (b->IsEnabled() == false)
+ {
+ continue;
+ }
+
+ for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext())
+ {
+ for (int32 i = 0; i < f->m_proxyCount; ++i)
+ {
+ b2FixtureProxy* proxy = f->m_proxies + i;
+ b2AABB aabb = bp->GetFatAABB(proxy->proxyId);
+ b2Vec2 vs[4];
+ vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y);
+ vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y);
+ vs[2].Set(aabb.upperBound.x, aabb.upperBound.y);
+ vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y);
+
+ m_debugDraw->DrawPolygon(vs, 4, color);
+ }
+ }
+ }
+ }
+
+ if (flags & b2Draw::e_centerOfMassBit)
+ {
+ for (b2Body* b = m_bodyList; b; b = b->GetNext())
+ {
+ b2Transform xf = b->GetTransform();
+ xf.p = b->GetWorldCenter();
+ m_debugDraw->DrawTransform(xf);
+ }
+ }
+}
+
+int32 b2World::GetProxyCount() const
+{
+ return m_contactManager.m_broadPhase.GetProxyCount();
+}
+
+int32 b2World::GetTreeHeight() const
+{
+ return m_contactManager.m_broadPhase.GetTreeHeight();
+}
+
+int32 b2World::GetTreeBalance() const
+{
+ return m_contactManager.m_broadPhase.GetTreeBalance();
+}
+
+float b2World::GetTreeQuality() const
+{
+ return m_contactManager.m_broadPhase.GetTreeQuality();
+}
+
+void b2World::ShiftOrigin(const b2Vec2& newOrigin)
+{
+ b2Assert(m_locked == false);
+ if (m_locked)
+ {
+ return;
+ }
+
+ for (b2Body* b = m_bodyList; b; b = b->m_next)
+ {
+ b->m_xf.p -= newOrigin;
+ b->m_sweep.c0 -= newOrigin;
+ b->m_sweep.c -= newOrigin;
+ }
+
+ for (b2Joint* j = m_jointList; j; j = j->m_next)
+ {
+ j->ShiftOrigin(newOrigin);
+ }
+
+ m_contactManager.m_broadPhase.ShiftOrigin(newOrigin);
+}
+
+void b2World::Dump()
+{
+ if (m_locked)
+ {
+ return;
+ }
+
+ b2OpenDump("box2d_dump.inl");
+
+ b2Dump("b2Vec2 g(%.9g, %.9g);\n", m_gravity.x, m_gravity.y);
+ b2Dump("m_world->SetGravity(g);\n");
+
+ b2Dump("b2Body** bodies = (b2Body**)b2Alloc(%d * sizeof(b2Body*));\n", m_bodyCount);
+ b2Dump("b2Joint** joints = (b2Joint**)b2Alloc(%d * sizeof(b2Joint*));\n", m_jointCount);
+
+ int32 i = 0;
+ for (b2Body* b = m_bodyList; b; b = b->m_next)
+ {
+ b->m_islandIndex = i;
+ b->Dump();
+ ++i;
+ }
+
+ i = 0;
+ for (b2Joint* j = m_jointList; j; j = j->m_next)
+ {
+ j->m_index = i;
+ ++i;
+ }
+
+ // First pass on joints, skip gear joints.
+ for (b2Joint* j = m_jointList; j; j = j->m_next)
+ {
+ if (j->m_type == e_gearJoint)
+ {
+ continue;
+ }
+
+ b2Dump("{\n");
+ j->Dump();
+ b2Dump("}\n");
+ }
+
+ // Second pass on joints, only gear joints.
+ for (b2Joint* j = m_jointList; j; j = j->m_next)
+ {
+ if (j->m_type != e_gearJoint)
+ {
+ continue;
+ }
+
+ b2Dump("{\n");
+ j->Dump();
+ b2Dump("}\n");
+ }
+
+ b2Dump("b2Free(joints);\n");
+ b2Dump("b2Free(bodies);\n");
+ b2Dump("joints = nullptr;\n");
+ b2Dump("bodies = nullptr;\n");
+
+ b2CloseDump();
+}
diff --git a/Client/ThirdParty/Box2D/src/dynamics/b2_world_callbacks.cpp b/Client/ThirdParty/Box2D/src/dynamics/b2_world_callbacks.cpp
new file mode 100644
index 0000000..e1583e2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/dynamics/b2_world_callbacks.cpp
@@ -0,0 +1,40 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_fixture.h"
+#include "box2d/b2_world_callbacks.h"
+
+// Return true if contact calculations should be performed between these two shapes.
+// If you implement your own collision filter you may want to build from this implementation.
+bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB)
+{
+ const b2Filter& filterA = fixtureA->GetFilterData();
+ const b2Filter& filterB = fixtureB->GetFilterData();
+
+ if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0)
+ {
+ return filterA.groupIndex > 0;
+ }
+
+ bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0;
+ return collide;
+}
diff --git a/Client/ThirdParty/Box2D/src/rope/b2_rope.cpp b/Client/ThirdParty/Box2D/src/rope/b2_rope.cpp
new file mode 100644
index 0000000..d2425a2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/src/rope/b2_rope.cpp
@@ -0,0 +1,809 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/b2_draw.h"
+#include "box2d/b2_rope.h"
+
+#include <stdio.h>
+
+struct b2RopeStretch
+{
+ int32 i1, i2;
+ float invMass1, invMass2;
+ float L;
+ float lambda;
+ float spring;
+ float damper;
+};
+
+struct b2RopeBend
+{
+ int32 i1, i2, i3;
+ float invMass1, invMass2, invMass3;
+ float invEffectiveMass;
+ float lambda;
+ float L1, L2;
+ float alpha1, alpha2;
+ float spring;
+ float damper;
+};
+
+b2Rope::b2Rope()
+{
+ m_position.SetZero();
+ m_count = 0;
+ m_stretchCount = 0;
+ m_bendCount = 0;
+ m_stretchConstraints = nullptr;
+ m_bendConstraints = nullptr;
+ m_bindPositions = nullptr;
+ m_ps = nullptr;
+ m_p0s = nullptr;
+ m_vs = nullptr;
+ m_invMasses = nullptr;
+ m_gravity.SetZero();
+}
+
+b2Rope::~b2Rope()
+{
+ b2Free(m_stretchConstraints);
+ b2Free(m_bendConstraints);
+ b2Free(m_bindPositions);
+ b2Free(m_ps);
+ b2Free(m_p0s);
+ b2Free(m_vs);
+ b2Free(m_invMasses);
+}
+
+void b2Rope::Create(const b2RopeDef& def)
+{
+ b2Assert(def.count >= 3);
+ m_position = def.position;
+ m_count = def.count;
+ m_bindPositions = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2));
+ m_ps = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2));
+ m_p0s = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2));
+ m_vs = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2));
+ m_invMasses = (float*)b2Alloc(m_count * sizeof(float));
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ m_bindPositions[i] = def.vertices[i];
+ m_ps[i] = def.vertices[i] + m_position;
+ m_p0s[i] = def.vertices[i] + m_position;
+ m_vs[i].SetZero();
+
+ float m = def.masses[i];
+ if (m > 0.0f)
+ {
+ m_invMasses[i] = 1.0f / m;
+ }
+ else
+ {
+ m_invMasses[i] = 0.0f;
+ }
+ }
+
+ m_stretchCount = m_count - 1;
+ m_bendCount = m_count - 2;
+
+ m_stretchConstraints = (b2RopeStretch*)b2Alloc(m_stretchCount * sizeof(b2RopeStretch));
+ m_bendConstraints = (b2RopeBend*)b2Alloc(m_bendCount * sizeof(b2RopeBend));
+
+ for (int32 i = 0; i < m_stretchCount; ++i)
+ {
+ b2RopeStretch& c = m_stretchConstraints[i];
+
+ b2Vec2 p1 = m_ps[i];
+ b2Vec2 p2 = m_ps[i+1];
+
+ c.i1 = i;
+ c.i2 = i + 1;
+ c.L = b2Distance(p1, p2);
+ c.invMass1 = m_invMasses[i];
+ c.invMass2 = m_invMasses[i + 1];
+ c.lambda = 0.0f;
+ c.damper = 0.0f;
+ c.spring = 0.0f;
+ }
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ b2RopeBend& c = m_bendConstraints[i];
+
+ b2Vec2 p1 = m_ps[i];
+ b2Vec2 p2 = m_ps[i + 1];
+ b2Vec2 p3 = m_ps[i + 2];
+
+ c.i1 = i;
+ c.i2 = i + 1;
+ c.i3 = i + 2;
+ c.invMass1 = m_invMasses[i];
+ c.invMass2 = m_invMasses[i + 1];
+ c.invMass3 = m_invMasses[i + 2];
+ c.invEffectiveMass = 0.0f;
+ c.L1 = b2Distance(p1, p2);
+ c.L2 = b2Distance(p2, p3);
+ c.lambda = 0.0f;
+
+ // Pre-compute effective mass (TODO use flattened config)
+ b2Vec2 e1 = p2 - p1;
+ b2Vec2 e2 = p3 - p2;
+ float L1sqr = e1.LengthSquared();
+ float L2sqr = e2.LengthSquared();
+
+ if (L1sqr * L2sqr == 0.0f)
+ {
+ continue;
+ }
+
+ b2Vec2 Jd1 = (-1.0f / L1sqr) * e1.Skew();
+ b2Vec2 Jd2 = (1.0f / L2sqr) * e2.Skew();
+
+ b2Vec2 J1 = -Jd1;
+ b2Vec2 J2 = Jd1 - Jd2;
+ b2Vec2 J3 = Jd2;
+
+ c.invEffectiveMass = c.invMass1 * b2Dot(J1, J1) + c.invMass2 * b2Dot(J2, J2) + c.invMass3 * b2Dot(J3, J3);
+
+ b2Vec2 r = p3 - p1;
+
+ float rr = r.LengthSquared();
+ if (rr == 0.0f)
+ {
+ continue;
+ }
+
+ // a1 = h2 / (h1 + h2)
+ // a2 = h1 / (h1 + h2)
+ c.alpha1 = b2Dot(e2, r) / rr;
+ c.alpha2 = b2Dot(e1, r) / rr;
+ }
+
+ m_gravity = def.gravity;
+
+ SetTuning(def.tuning);
+}
+
+void b2Rope::SetTuning(const b2RopeTuning& tuning)
+{
+ m_tuning = tuning;
+
+ // Pre-compute spring and damper values based on tuning
+
+ const float bendOmega = 2.0f * b2_pi * m_tuning.bendHertz;
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ b2RopeBend& c = m_bendConstraints[i];
+
+ float L1sqr = c.L1 * c.L1;
+ float L2sqr = c.L2 * c.L2;
+
+ if (L1sqr * L2sqr == 0.0f)
+ {
+ c.spring = 0.0f;
+ c.damper = 0.0f;
+ continue;
+ }
+
+ // Flatten the triangle formed by the two edges
+ float J2 = 1.0f / c.L1 + 1.0f / c.L2;
+ float sum = c.invMass1 / L1sqr + c.invMass2 * J2 * J2 + c.invMass3 / L2sqr;
+ if (sum == 0.0f)
+ {
+ c.spring = 0.0f;
+ c.damper = 0.0f;
+ continue;
+ }
+
+ float mass = 1.0f / sum;
+
+ c.spring = mass * bendOmega * bendOmega;
+ c.damper = 2.0f * mass * m_tuning.bendDamping * bendOmega;
+ }
+
+ const float stretchOmega = 2.0f * b2_pi * m_tuning.stretchHertz;
+
+ for (int32 i = 0; i < m_stretchCount; ++i)
+ {
+ b2RopeStretch& c = m_stretchConstraints[i];
+
+ float sum = c.invMass1 + c.invMass2;
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ float mass = 1.0f / sum;
+
+ c.spring = mass * stretchOmega * stretchOmega;
+ c.damper = 2.0f * mass * m_tuning.stretchDamping * stretchOmega;
+ }
+}
+
+void b2Rope::Step(float dt, int32 iterations, const b2Vec2& position)
+{
+ if (dt == 0.0)
+ {
+ return;
+ }
+
+ const float inv_dt = 1.0f / dt;
+ float d = expf(- dt * m_tuning.damping);
+
+ // Apply gravity and damping
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ if (m_invMasses[i] > 0.0f)
+ {
+ m_vs[i] *= d;
+ m_vs[i] += dt * m_gravity;
+ }
+ else
+ {
+ m_vs[i] = inv_dt * (m_bindPositions[i] + position - m_p0s[i]);
+ }
+ }
+
+ // Apply bending spring
+ if (m_tuning.bendingModel == b2_springAngleBendingModel)
+ {
+ ApplyBendForces(dt);
+ }
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ m_bendConstraints[i].lambda = 0.0f;
+ }
+
+ for (int32 i = 0; i < m_stretchCount; ++i)
+ {
+ m_stretchConstraints[i].lambda = 0.0f;
+ }
+
+ // Update position
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ m_ps[i] += dt * m_vs[i];
+ }
+
+ // Solve constraints
+ for (int32 i = 0; i < iterations; ++i)
+ {
+ if (m_tuning.bendingModel == b2_pbdAngleBendingModel)
+ {
+ SolveBend_PBD_Angle();
+ }
+ else if (m_tuning.bendingModel == b2_xpbdAngleBendingModel)
+ {
+ SolveBend_XPBD_Angle(dt);
+ }
+ else if (m_tuning.bendingModel == b2_pbdDistanceBendingModel)
+ {
+ SolveBend_PBD_Distance();
+ }
+ else if (m_tuning.bendingModel == b2_pbdHeightBendingModel)
+ {
+ SolveBend_PBD_Height();
+ }
+ else if (m_tuning.bendingModel == b2_pbdTriangleBendingModel)
+ {
+ SolveBend_PBD_Triangle();
+ }
+
+ if (m_tuning.stretchingModel == b2_pbdStretchingModel)
+ {
+ SolveStretch_PBD();
+ }
+ else if (m_tuning.stretchingModel == b2_xpbdStretchingModel)
+ {
+ SolveStretch_XPBD(dt);
+ }
+ }
+
+ // Constrain velocity
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ m_vs[i] = inv_dt * (m_ps[i] - m_p0s[i]);
+ m_p0s[i] = m_ps[i];
+ }
+}
+
+void b2Rope::Reset(const b2Vec2& position)
+{
+ m_position = position;
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ m_ps[i] = m_bindPositions[i] + m_position;
+ m_p0s[i] = m_bindPositions[i] + m_position;
+ m_vs[i].SetZero();
+ }
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ m_bendConstraints[i].lambda = 0.0f;
+ }
+
+ for (int32 i = 0; i < m_stretchCount; ++i)
+ {
+ m_stretchConstraints[i].lambda = 0.0f;
+ }
+}
+
+void b2Rope::SolveStretch_PBD()
+{
+ const float stiffness = m_tuning.stretchStiffness;
+
+ for (int32 i = 0; i < m_stretchCount; ++i)
+ {
+ const b2RopeStretch& c = m_stretchConstraints[i];
+
+ b2Vec2 p1 = m_ps[c.i1];
+ b2Vec2 p2 = m_ps[c.i2];
+
+ b2Vec2 d = p2 - p1;
+ float L = d.Normalize();
+
+ float sum = c.invMass1 + c.invMass2;
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ float s1 = c.invMass1 / sum;
+ float s2 = c.invMass2 / sum;
+
+ p1 -= stiffness * s1 * (c.L - L) * d;
+ p2 += stiffness * s2 * (c.L - L) * d;
+
+ m_ps[c.i1] = p1;
+ m_ps[c.i2] = p2;
+ }
+}
+
+void b2Rope::SolveStretch_XPBD(float dt)
+{
+ b2Assert(dt > 0.0f);
+
+ for (int32 i = 0; i < m_stretchCount; ++i)
+ {
+ b2RopeStretch& c = m_stretchConstraints[i];
+
+ b2Vec2 p1 = m_ps[c.i1];
+ b2Vec2 p2 = m_ps[c.i2];
+
+ b2Vec2 dp1 = p1 - m_p0s[c.i1];
+ b2Vec2 dp2 = p2 - m_p0s[c.i2];
+
+ b2Vec2 u = p2 - p1;
+ float L = u.Normalize();
+
+ b2Vec2 J1 = -u;
+ b2Vec2 J2 = u;
+
+ float sum = c.invMass1 + c.invMass2;
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ const float alpha = 1.0f / (c.spring * dt * dt); // 1 / kg
+ const float beta = dt * dt * c.damper; // kg * s
+ const float sigma = alpha * beta / dt; // non-dimensional
+ float C = L - c.L;
+
+ // This is using the initial velocities
+ float Cdot = b2Dot(J1, dp1) + b2Dot(J2, dp2);
+
+ float B = C + alpha * c.lambda + sigma * Cdot;
+ float sum2 = (1.0f + sigma) * sum + alpha;
+
+ float impulse = -B / sum2;
+
+ p1 += (c.invMass1 * impulse) * J1;
+ p2 += (c.invMass2 * impulse) * J2;
+
+ m_ps[c.i1] = p1;
+ m_ps[c.i2] = p2;
+ c.lambda += impulse;
+ }
+}
+
+void b2Rope::SolveBend_PBD_Angle()
+{
+ const float stiffness = m_tuning.bendStiffness;
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ const b2RopeBend& c = m_bendConstraints[i];
+
+ b2Vec2 p1 = m_ps[c.i1];
+ b2Vec2 p2 = m_ps[c.i2];
+ b2Vec2 p3 = m_ps[c.i3];
+
+ b2Vec2 d1 = p2 - p1;
+ b2Vec2 d2 = p3 - p2;
+ float a = b2Cross(d1, d2);
+ float b = b2Dot(d1, d2);
+
+ float angle = b2Atan2(a, b);
+
+ float L1sqr, L2sqr;
+
+ if (m_tuning.isometric)
+ {
+ L1sqr = c.L1 * c.L1;
+ L2sqr = c.L2 * c.L2;
+ }
+ else
+ {
+ L1sqr = d1.LengthSquared();
+ L2sqr = d2.LengthSquared();
+ }
+
+ if (L1sqr * L2sqr == 0.0f)
+ {
+ continue;
+ }
+
+ b2Vec2 Jd1 = (-1.0f / L1sqr) * d1.Skew();
+ b2Vec2 Jd2 = (1.0f / L2sqr) * d2.Skew();
+
+ b2Vec2 J1 = -Jd1;
+ b2Vec2 J2 = Jd1 - Jd2;
+ b2Vec2 J3 = Jd2;
+
+ float sum;
+ if (m_tuning.fixedEffectiveMass)
+ {
+ sum = c.invEffectiveMass;
+ }
+ else
+ {
+ sum = c.invMass1 * b2Dot(J1, J1) + c.invMass2 * b2Dot(J2, J2) + c.invMass3 * b2Dot(J3, J3);
+ }
+
+ if (sum == 0.0f)
+ {
+ sum = c.invEffectiveMass;
+ }
+
+ float impulse = -stiffness * angle / sum;
+
+ p1 += (c.invMass1 * impulse) * J1;
+ p2 += (c.invMass2 * impulse) * J2;
+ p3 += (c.invMass3 * impulse) * J3;
+
+ m_ps[c.i1] = p1;
+ m_ps[c.i2] = p2;
+ m_ps[c.i3] = p3;
+ }
+}
+
+void b2Rope::SolveBend_XPBD_Angle(float dt)
+{
+ b2Assert(dt > 0.0f);
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ b2RopeBend& c = m_bendConstraints[i];
+
+ b2Vec2 p1 = m_ps[c.i1];
+ b2Vec2 p2 = m_ps[c.i2];
+ b2Vec2 p3 = m_ps[c.i3];
+
+ b2Vec2 dp1 = p1 - m_p0s[c.i1];
+ b2Vec2 dp2 = p2 - m_p0s[c.i2];
+ b2Vec2 dp3 = p3 - m_p0s[c.i3];
+
+ b2Vec2 d1 = p2 - p1;
+ b2Vec2 d2 = p3 - p2;
+
+ float L1sqr, L2sqr;
+
+ if (m_tuning.isometric)
+ {
+ L1sqr = c.L1 * c.L1;
+ L2sqr = c.L2 * c.L2;
+ }
+ else
+ {
+ L1sqr = d1.LengthSquared();
+ L2sqr = d2.LengthSquared();
+ }
+
+ if (L1sqr * L2sqr == 0.0f)
+ {
+ continue;
+ }
+
+ float a = b2Cross(d1, d2);
+ float b = b2Dot(d1, d2);
+
+ float angle = b2Atan2(a, b);
+
+ b2Vec2 Jd1 = (-1.0f / L1sqr) * d1.Skew();
+ b2Vec2 Jd2 = (1.0f / L2sqr) * d2.Skew();
+
+ b2Vec2 J1 = -Jd1;
+ b2Vec2 J2 = Jd1 - Jd2;
+ b2Vec2 J3 = Jd2;
+
+ float sum;
+ if (m_tuning.fixedEffectiveMass)
+ {
+ sum = c.invEffectiveMass;
+ }
+ else
+ {
+ sum = c.invMass1 * b2Dot(J1, J1) + c.invMass2 * b2Dot(J2, J2) + c.invMass3 * b2Dot(J3, J3);
+ }
+
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ const float alpha = 1.0f / (c.spring * dt * dt);
+ const float beta = dt * dt * c.damper;
+ const float sigma = alpha * beta / dt;
+ float C = angle;
+
+ // This is using the initial velocities
+ float Cdot = b2Dot(J1, dp1) + b2Dot(J2, dp2) + b2Dot(J3, dp3);
+
+ float B = C + alpha * c.lambda + sigma * Cdot;
+ float sum2 = (1.0f + sigma) * sum + alpha;
+
+ float impulse = -B / sum2;
+
+ p1 += (c.invMass1 * impulse) * J1;
+ p2 += (c.invMass2 * impulse) * J2;
+ p3 += (c.invMass3 * impulse) * J3;
+
+ m_ps[c.i1] = p1;
+ m_ps[c.i2] = p2;
+ m_ps[c.i3] = p3;
+ c.lambda += impulse;
+ }
+}
+
+void b2Rope::ApplyBendForces(float dt)
+{
+ // omega = 2 * pi * hz
+ const float omega = 2.0f * b2_pi * m_tuning.bendHertz;
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ const b2RopeBend& c = m_bendConstraints[i];
+
+ b2Vec2 p1 = m_ps[c.i1];
+ b2Vec2 p2 = m_ps[c.i2];
+ b2Vec2 p3 = m_ps[c.i3];
+
+ b2Vec2 v1 = m_vs[c.i1];
+ b2Vec2 v2 = m_vs[c.i2];
+ b2Vec2 v3 = m_vs[c.i3];
+
+ b2Vec2 d1 = p2 - p1;
+ b2Vec2 d2 = p3 - p2;
+
+ float L1sqr, L2sqr;
+
+ if (m_tuning.isometric)
+ {
+ L1sqr = c.L1 * c.L1;
+ L2sqr = c.L2 * c.L2;
+ }
+ else
+ {
+ L1sqr = d1.LengthSquared();
+ L2sqr = d2.LengthSquared();
+ }
+
+ if (L1sqr * L2sqr == 0.0f)
+ {
+ continue;
+ }
+
+ float a = b2Cross(d1, d2);
+ float b = b2Dot(d1, d2);
+
+ float angle = b2Atan2(a, b);
+
+ b2Vec2 Jd1 = (-1.0f / L1sqr) * d1.Skew();
+ b2Vec2 Jd2 = (1.0f / L2sqr) * d2.Skew();
+
+ b2Vec2 J1 = -Jd1;
+ b2Vec2 J2 = Jd1 - Jd2;
+ b2Vec2 J3 = Jd2;
+
+ float sum;
+ if (m_tuning.fixedEffectiveMass)
+ {
+ sum = c.invEffectiveMass;
+ }
+ else
+ {
+ sum = c.invMass1 * b2Dot(J1, J1) + c.invMass2 * b2Dot(J2, J2) + c.invMass3 * b2Dot(J3, J3);
+ }
+
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ float mass = 1.0f / sum;
+
+ const float spring = mass * omega * omega;
+ const float damper = 2.0f * mass * m_tuning.bendDamping * omega;
+
+ float C = angle;
+ float Cdot = b2Dot(J1, v1) + b2Dot(J2, v2) + b2Dot(J3, v3);
+
+ float impulse = -dt * (spring * C + damper * Cdot);
+
+ m_vs[c.i1] += (c.invMass1 * impulse) * J1;
+ m_vs[c.i2] += (c.invMass2 * impulse) * J2;
+ m_vs[c.i3] += (c.invMass3 * impulse) * J3;
+ }
+}
+
+void b2Rope::SolveBend_PBD_Distance()
+{
+ const float stiffness = m_tuning.bendStiffness;
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ const b2RopeBend& c = m_bendConstraints[i];
+
+ int32 i1 = c.i1;
+ int32 i2 = c.i3;
+
+ b2Vec2 p1 = m_ps[i1];
+ b2Vec2 p2 = m_ps[i2];
+
+ b2Vec2 d = p2 - p1;
+ float L = d.Normalize();
+
+ float sum = c.invMass1 + c.invMass3;
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ float s1 = c.invMass1 / sum;
+ float s2 = c.invMass3 / sum;
+
+ p1 -= stiffness * s1 * (c.L1 + c.L2 - L) * d;
+ p2 += stiffness * s2 * (c.L1 + c.L2 - L) * d;
+
+ m_ps[i1] = p1;
+ m_ps[i2] = p2;
+ }
+}
+
+// Constraint based implementation of:
+// P. Volino: Simple Linear Bending Stiffness in Particle Systems
+void b2Rope::SolveBend_PBD_Height()
+{
+ const float stiffness = m_tuning.bendStiffness;
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ const b2RopeBend& c = m_bendConstraints[i];
+
+ b2Vec2 p1 = m_ps[c.i1];
+ b2Vec2 p2 = m_ps[c.i2];
+ b2Vec2 p3 = m_ps[c.i3];
+
+ // Barycentric coordinates are held constant
+ b2Vec2 d = c.alpha1 * p1 + c.alpha2 * p3 - p2;
+ float dLen = d.Length();
+
+ if (dLen == 0.0f)
+ {
+ continue;
+ }
+
+ b2Vec2 dHat = (1.0f / dLen) * d;
+
+ b2Vec2 J1 = c.alpha1 * dHat;
+ b2Vec2 J2 = -dHat;
+ b2Vec2 J3 = c.alpha2 * dHat;
+
+ float sum = c.invMass1 * c.alpha1 * c.alpha1 + c.invMass2 + c.invMass3 * c.alpha2 * c.alpha2;
+
+ if (sum == 0.0f)
+ {
+ continue;
+ }
+
+ float C = dLen;
+ float mass = 1.0f / sum;
+ float impulse = -stiffness * mass * C;
+
+ p1 += (c.invMass1 * impulse) * J1;
+ p2 += (c.invMass2 * impulse) * J2;
+ p3 += (c.invMass3 * impulse) * J3;
+
+ m_ps[c.i1] = p1;
+ m_ps[c.i2] = p2;
+ m_ps[c.i3] = p3;
+ }
+}
+
+// M. Kelager: A Triangle Bending Constraint Model for PBD
+void b2Rope::SolveBend_PBD_Triangle()
+{
+ const float stiffness = m_tuning.bendStiffness;
+
+ for (int32 i = 0; i < m_bendCount; ++i)
+ {
+ const b2RopeBend& c = m_bendConstraints[i];
+
+ b2Vec2 b0 = m_ps[c.i1];
+ b2Vec2 v = m_ps[c.i2];
+ b2Vec2 b1 = m_ps[c.i3];
+
+ float wb0 = c.invMass1;
+ float wv = c.invMass2;
+ float wb1 = c.invMass3;
+
+ float W = wb0 + wb1 + 2.0f * wv;
+ float invW = stiffness / W;
+
+ b2Vec2 d = v - (1.0f / 3.0f) * (b0 + v + b1);
+
+ b2Vec2 db0 = 2.0f * wb0 * invW * d;
+ b2Vec2 dv = -4.0f * wv * invW * d;
+ b2Vec2 db1 = 2.0f * wb1 * invW * d;
+
+ b0 += db0;
+ v += dv;
+ b1 += db1;
+
+ m_ps[c.i1] = b0;
+ m_ps[c.i2] = v;
+ m_ps[c.i3] = b1;
+ }
+}
+
+void b2Rope::Draw(b2Draw* draw) const
+{
+ b2Color c(0.4f, 0.5f, 0.7f);
+ b2Color pg(0.1f, 0.8f, 0.1f);
+ b2Color pd(0.7f, 0.2f, 0.4f);
+
+ for (int32 i = 0; i < m_count - 1; ++i)
+ {
+ draw->DrawSegment(m_ps[i], m_ps[i+1], c);
+
+ const b2Color& pc = m_invMasses[i] > 0.0f ? pd : pg;
+ draw->DrawPoint(m_ps[i], 5.0f, pc);
+ }
+
+ const b2Color& pc = m_invMasses[m_count - 1] > 0.0f ? pd : pg;
+ draw->DrawPoint(m_ps[m_count - 1], 5.0f, pc);
+}
diff --git a/Client/ThirdParty/Box2D/testbed/CMakeLists.txt b/Client/ThirdParty/Box2D/testbed/CMakeLists.txt
new file mode 100644
index 0000000..5ef305e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/CMakeLists.txt
@@ -0,0 +1,92 @@
+set (TESTBED_SOURCE_FILES
+ draw.cpp
+ draw.h
+ imgui_impl_glfw.cpp
+ imgui_impl_glfw.h
+ imgui_impl_opengl3.cpp
+ imgui_impl_opengl3.h
+ main.cpp
+ settings.h
+ settings.cpp
+ test.cpp
+ test.h
+ tests/add_pair.cpp
+ tests/apply_force.cpp
+ tests/body_types.cpp
+ tests/box_stack.cpp
+ tests/breakable.cpp
+ tests/bridge.cpp
+ tests/bullet_test.cpp
+ tests/cantilever.cpp
+ tests/car.cpp
+ tests/chain.cpp
+ tests/chain_problem.cpp
+ tests/character_collision.cpp
+ tests/circle_stack.cpp
+ tests/collision_filtering.cpp
+ tests/collision_processing.cpp
+ tests/compound_shapes.cpp
+ tests/confined.cpp
+ tests/continuous_test.cpp
+ tests/convex_hull.cpp
+ tests/conveyor_belt.cpp
+ tests/distance_joint.cpp
+ tests/distance_test.cpp
+ tests/dominos.cpp
+ tests/dump_loader.cpp
+ tests/dynamic_tree.cpp
+ tests/edge_shapes.cpp
+ tests/edge_test.cpp
+ tests/friction.cpp
+ tests/gear_joint.cpp
+ tests/heavy1.cpp
+ tests/heavy2.cpp
+ tests/mobile_balanced.cpp
+ tests/mobile_unbalanced.cpp
+ tests/motor_joint.cpp
+ tests/pinball.cpp
+ tests/platformer.cpp
+ tests/polygon_collision.cpp
+ tests/polygon_shapes.cpp
+ tests/prismatic_joint.cpp
+ tests/pulley_joint.cpp
+ tests/pyramid.cpp
+ tests/ray_cast.cpp
+ tests/restitution.cpp
+ tests/revolute_joint.cpp
+ tests/rope.cpp
+ tests/sensor.cpp
+ tests/shape_cast.cpp
+ tests/shape_editing.cpp
+ tests/skier.cpp
+ tests/slider_crank_1.cpp
+ tests/slider_crank_2.cpp
+ tests/theo_jansen.cpp
+ tests/tiles.cpp
+ tests/time_of_impact.cpp
+ tests/tumbler.cpp
+ tests/web.cpp
+ tests/wheel_joint.cpp
+ tests/wrecking_ball.cpp
+)
+
+add_executable(testbed ${TESTBED_SOURCE_FILES})
+target_include_directories(testbed PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_link_libraries(testbed PUBLIC box2d glfw imgui sajson glad)
+set_target_properties(testbed PROPERTIES
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED YES
+ CXX_EXTENSIONS NO
+)
+
+# message(STATUS "runtime = ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+# message(STATUS "binary = ${CMAKE_CURRENT_BINARY_DIR}")
+
+# Copy font files, etc
+add_custom_command(
+ TARGET testbed POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${CMAKE_CURRENT_SOURCE_DIR}/data/
+ ${CMAKE_CURRENT_BINARY_DIR}/data/)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${TESTBED_SOURCE_FILES})
diff --git a/Client/ThirdParty/Box2D/testbed/MacOSXBundleInfo.plist.in b/Client/ThirdParty/Box2D/testbed/MacOSXBundleInfo.plist.in
new file mode 100644
index 0000000..8bdb5cd
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/MacOSXBundleInfo.plist.in
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CSResourcesFileMapped</key>
+ <true/>
+ <key>LSRequiresCarbon</key>
+ <true/>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+ <key>NSHighResolutionCapable</key>
+ <true/>
+</dict>
+</plist>
+
diff --git a/Client/ThirdParty/Box2D/testbed/data/droid_sans.ttf b/Client/ThirdParty/Box2D/testbed/data/droid_sans.ttf
new file mode 100644
index 0000000..767c63a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/data/droid_sans.ttf
Binary files differ
diff --git a/Client/ThirdParty/Box2D/testbed/draw.cpp b/Client/ThirdParty/Box2D/testbed/draw.cpp
new file mode 100644
index 0000000..03ab6af
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/draw.cpp
@@ -0,0 +1,829 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "draw.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "imgui/imgui.h"
+
+#define BUFFER_OFFSET(x) ((const void*) (x))
+
+DebugDraw g_debugDraw;
+Camera g_camera;
+
+//
+b2Vec2 Camera::ConvertScreenToWorld(const b2Vec2& ps)
+{
+ float w = float(m_width);
+ float h = float(m_height);
+ float u = ps.x / w;
+ float v = (h - ps.y) / h;
+
+ float ratio = w / h;
+ b2Vec2 extents(ratio * 25.0f, 25.0f);
+ extents *= m_zoom;
+
+ b2Vec2 lower = m_center - extents;
+ b2Vec2 upper = m_center + extents;
+
+ b2Vec2 pw;
+ pw.x = (1.0f - u) * lower.x + u * upper.x;
+ pw.y = (1.0f - v) * lower.y + v * upper.y;
+ return pw;
+}
+
+//
+b2Vec2 Camera::ConvertWorldToScreen(const b2Vec2& pw)
+{
+ float w = float(m_width);
+ float h = float(m_height);
+ float ratio = w / h;
+ b2Vec2 extents(ratio * 25.0f, 25.0f);
+ extents *= m_zoom;
+
+ b2Vec2 lower = m_center - extents;
+ b2Vec2 upper = m_center + extents;
+
+ float u = (pw.x - lower.x) / (upper.x - lower.x);
+ float v = (pw.y - lower.y) / (upper.y - lower.y);
+
+ b2Vec2 ps;
+ ps.x = u * w;
+ ps.y = (1.0f - v) * h;
+ return ps;
+}
+
+// Convert from world coordinates to normalized device coordinates.
+// http://www.songho.ca/opengl/gl_projectionmatrix.html
+void Camera::BuildProjectionMatrix(float* m, float zBias)
+{
+ float w = float(m_width);
+ float h = float(m_height);
+ float ratio = w / h;
+ b2Vec2 extents(ratio * 25.0f, 25.0f);
+ extents *= m_zoom;
+
+ b2Vec2 lower = m_center - extents;
+ b2Vec2 upper = m_center + extents;
+
+ m[0] = 2.0f / (upper.x - lower.x);
+ m[1] = 0.0f;
+ m[2] = 0.0f;
+ m[3] = 0.0f;
+
+ m[4] = 0.0f;
+ m[5] = 2.0f / (upper.y - lower.y);
+ m[6] = 0.0f;
+ m[7] = 0.0f;
+
+ m[8] = 0.0f;
+ m[9] = 0.0f;
+ m[10] = 1.0f;
+ m[11] = 0.0f;
+
+ m[12] = -(upper.x + lower.x) / (upper.x - lower.x);
+ m[13] = -(upper.y + lower.y) / (upper.y - lower.y);
+ m[14] = zBias;
+ m[15] = 1.0f;
+}
+
+//
+static void sCheckGLError()
+{
+ GLenum errCode = glGetError();
+ if (errCode != GL_NO_ERROR)
+ {
+ fprintf(stderr, "OpenGL error = %d\n", errCode);
+ assert(false);
+ }
+}
+
+// Prints shader compilation errors
+static void sPrintLog(GLuint object)
+{
+ GLint log_length = 0;
+ if (glIsShader(object))
+ glGetShaderiv(object, GL_INFO_LOG_LENGTH, &log_length);
+ else if (glIsProgram(object))
+ glGetProgramiv(object, GL_INFO_LOG_LENGTH, &log_length);
+ else
+ {
+ fprintf(stderr, "printlog: Not a shader or a program\n");
+ return;
+ }
+
+ char* log = (char*)malloc(log_length);
+
+ if (glIsShader(object))
+ glGetShaderInfoLog(object, log_length, NULL, log);
+ else if (glIsProgram(object))
+ glGetProgramInfoLog(object, log_length, NULL, log);
+
+ fprintf(stderr, "%s", log);
+ free(log);
+}
+
+
+//
+static GLuint sCreateShaderFromString(const char* source, GLenum type)
+{
+ GLuint res = glCreateShader(type);
+ const char* sources[] = { source };
+ glShaderSource(res, 1, sources, NULL);
+ glCompileShader(res);
+ GLint compile_ok = GL_FALSE;
+ glGetShaderiv(res, GL_COMPILE_STATUS, &compile_ok);
+ if (compile_ok == GL_FALSE)
+ {
+ fprintf(stderr, "Error compiling shader of type %d!\n", type);
+ sPrintLog(res);
+ glDeleteShader(res);
+ return 0;
+ }
+
+ return res;
+}
+
+//
+static GLuint sCreateShaderProgram(const char* vs, const char* fs)
+{
+ GLuint vsId = sCreateShaderFromString(vs, GL_VERTEX_SHADER);
+ GLuint fsId = sCreateShaderFromString(fs, GL_FRAGMENT_SHADER);
+ assert(vsId != 0 && fsId != 0);
+
+ GLuint programId = glCreateProgram();
+ glAttachShader(programId, vsId);
+ glAttachShader(programId, fsId);
+ glBindFragDataLocation(programId, 0, "color");
+ glLinkProgram(programId);
+
+ glDeleteShader(vsId);
+ glDeleteShader(fsId);
+
+ GLint status = GL_FALSE;
+ glGetProgramiv(programId, GL_LINK_STATUS, &status);
+ assert(status != GL_FALSE);
+
+ return programId;
+}
+
+//
+struct GLRenderPoints
+{
+ void Create()
+ {
+ const char* vs = \
+ "#version 330\n"
+ "uniform mat4 projectionMatrix;\n"
+ "layout(location = 0) in vec2 v_position;\n"
+ "layout(location = 1) in vec4 v_color;\n"
+ "layout(location = 2) in float v_size;\n"
+ "out vec4 f_color;\n"
+ "void main(void)\n"
+ "{\n"
+ " f_color = v_color;\n"
+ " gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
+ " gl_PointSize = v_size;\n"
+ "}\n";
+
+ const char* fs = \
+ "#version 330\n"
+ "in vec4 f_color;\n"
+ "out vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " color = f_color;\n"
+ "}\n";
+
+ m_programId = sCreateShaderProgram(vs, fs);
+ m_projectionUniform = glGetUniformLocation(m_programId, "projectionMatrix");
+ m_vertexAttribute = 0;
+ m_colorAttribute = 1;
+ m_sizeAttribute = 2;
+
+ // Generate
+ glGenVertexArrays(1, &m_vaoId);
+ glGenBuffers(3, m_vboIds);
+
+ glBindVertexArray(m_vaoId);
+ glEnableVertexAttribArray(m_vertexAttribute);
+ glEnableVertexAttribArray(m_colorAttribute);
+ glEnableVertexAttribArray(m_sizeAttribute);
+
+ // Vertex buffer
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[0]);
+ glVertexAttribPointer(m_vertexAttribute, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_vertices), m_vertices, GL_DYNAMIC_DRAW);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[1]);
+ glVertexAttribPointer(m_colorAttribute, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_colors), m_colors, GL_DYNAMIC_DRAW);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[2]);
+ glVertexAttribPointer(m_sizeAttribute, 1, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_sizes), m_sizes, GL_DYNAMIC_DRAW);
+
+ sCheckGLError();
+
+ // Cleanup
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+
+ m_count = 0;
+ }
+
+ void Destroy()
+ {
+ if (m_vaoId)
+ {
+ glDeleteVertexArrays(1, &m_vaoId);
+ glDeleteBuffers(3, m_vboIds);
+ m_vaoId = 0;
+ }
+
+ if (m_programId)
+ {
+ glDeleteProgram(m_programId);
+ m_programId = 0;
+ }
+ }
+
+ void Vertex(const b2Vec2& v, const b2Color& c, float size)
+ {
+ if (m_count == e_maxVertices)
+ Flush();
+
+ m_vertices[m_count] = v;
+ m_colors[m_count] = c;
+ m_sizes[m_count] = size;
+ ++m_count;
+ }
+
+ void Flush()
+ {
+ if (m_count == 0)
+ return;
+
+ glUseProgram(m_programId);
+
+ float proj[16] = { 0.0f };
+ g_camera.BuildProjectionMatrix(proj, 0.0f);
+
+ glUniformMatrix4fv(m_projectionUniform, 1, GL_FALSE, proj);
+
+ glBindVertexArray(m_vaoId);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[0]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(b2Vec2), m_vertices);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[1]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(b2Color), m_colors);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[2]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(float), m_sizes);
+
+ glEnable(GL_PROGRAM_POINT_SIZE);
+ glDrawArrays(GL_POINTS, 0, m_count);
+ glDisable(GL_PROGRAM_POINT_SIZE);
+
+ sCheckGLError();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+ glUseProgram(0);
+
+ m_count = 0;
+ }
+
+ enum { e_maxVertices = 512 };
+ b2Vec2 m_vertices[e_maxVertices];
+ b2Color m_colors[e_maxVertices];
+ float m_sizes[e_maxVertices];
+
+ int32 m_count;
+
+ GLuint m_vaoId;
+ GLuint m_vboIds[3];
+ GLuint m_programId;
+ GLint m_projectionUniform;
+ GLint m_vertexAttribute;
+ GLint m_colorAttribute;
+ GLint m_sizeAttribute;
+};
+
+//
+struct GLRenderLines
+{
+ void Create()
+ {
+ const char* vs = \
+ "#version 330\n"
+ "uniform mat4 projectionMatrix;\n"
+ "layout(location = 0) in vec2 v_position;\n"
+ "layout(location = 1) in vec4 v_color;\n"
+ "out vec4 f_color;\n"
+ "void main(void)\n"
+ "{\n"
+ " f_color = v_color;\n"
+ " gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
+ "}\n";
+
+ const char* fs = \
+ "#version 330\n"
+ "in vec4 f_color;\n"
+ "out vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " color = f_color;\n"
+ "}\n";
+
+ m_programId = sCreateShaderProgram(vs, fs);
+ m_projectionUniform = glGetUniformLocation(m_programId, "projectionMatrix");
+ m_vertexAttribute = 0;
+ m_colorAttribute = 1;
+
+ // Generate
+ glGenVertexArrays(1, &m_vaoId);
+ glGenBuffers(2, m_vboIds);
+
+ glBindVertexArray(m_vaoId);
+ glEnableVertexAttribArray(m_vertexAttribute);
+ glEnableVertexAttribArray(m_colorAttribute);
+
+ // Vertex buffer
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[0]);
+ glVertexAttribPointer(m_vertexAttribute, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_vertices), m_vertices, GL_DYNAMIC_DRAW);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[1]);
+ glVertexAttribPointer(m_colorAttribute, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_colors), m_colors, GL_DYNAMIC_DRAW);
+
+ sCheckGLError();
+
+ // Cleanup
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+
+ m_count = 0;
+ }
+
+ void Destroy()
+ {
+ if (m_vaoId)
+ {
+ glDeleteVertexArrays(1, &m_vaoId);
+ glDeleteBuffers(2, m_vboIds);
+ m_vaoId = 0;
+ }
+
+ if (m_programId)
+ {
+ glDeleteProgram(m_programId);
+ m_programId = 0;
+ }
+ }
+
+ void Vertex(const b2Vec2& v, const b2Color& c)
+ {
+ if (m_count == e_maxVertices)
+ Flush();
+
+ m_vertices[m_count] = v;
+ m_colors[m_count] = c;
+ ++m_count;
+ }
+
+ void Flush()
+ {
+ if (m_count == 0)
+ return;
+
+ glUseProgram(m_programId);
+
+ float proj[16] = { 0.0f };
+ g_camera.BuildProjectionMatrix(proj, 0.1f);
+
+ glUniformMatrix4fv(m_projectionUniform, 1, GL_FALSE, proj);
+
+ glBindVertexArray(m_vaoId);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[0]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(b2Vec2), m_vertices);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[1]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(b2Color), m_colors);
+
+ glDrawArrays(GL_LINES, 0, m_count);
+
+ sCheckGLError();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+ glUseProgram(0);
+
+ m_count = 0;
+ }
+
+ enum { e_maxVertices = 2 * 512 };
+ b2Vec2 m_vertices[e_maxVertices];
+ b2Color m_colors[e_maxVertices];
+
+ int32 m_count;
+
+ GLuint m_vaoId;
+ GLuint m_vboIds[2];
+ GLuint m_programId;
+ GLint m_projectionUniform;
+ GLint m_vertexAttribute;
+ GLint m_colorAttribute;
+};
+
+//
+struct GLRenderTriangles
+{
+ void Create()
+ {
+ const char* vs = \
+ "#version 330\n"
+ "uniform mat4 projectionMatrix;\n"
+ "layout(location = 0) in vec2 v_position;\n"
+ "layout(location = 1) in vec4 v_color;\n"
+ "out vec4 f_color;\n"
+ "void main(void)\n"
+ "{\n"
+ " f_color = v_color;\n"
+ " gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
+ "}\n";
+
+ const char* fs = \
+ "#version 330\n"
+ "in vec4 f_color;\n"
+ "out vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " color = f_color;\n"
+ "}\n";
+
+ m_programId = sCreateShaderProgram(vs, fs);
+ m_projectionUniform = glGetUniformLocation(m_programId, "projectionMatrix");
+ m_vertexAttribute = 0;
+ m_colorAttribute = 1;
+
+ // Generate
+ glGenVertexArrays(1, &m_vaoId);
+ glGenBuffers(2, m_vboIds);
+
+ glBindVertexArray(m_vaoId);
+ glEnableVertexAttribArray(m_vertexAttribute);
+ glEnableVertexAttribArray(m_colorAttribute);
+
+ // Vertex buffer
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[0]);
+ glVertexAttribPointer(m_vertexAttribute, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_vertices), m_vertices, GL_DYNAMIC_DRAW);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[1]);
+ glVertexAttribPointer(m_colorAttribute, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glBufferData(GL_ARRAY_BUFFER, sizeof(m_colors), m_colors, GL_DYNAMIC_DRAW);
+
+ sCheckGLError();
+
+ // Cleanup
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+
+ m_count = 0;
+ }
+
+ void Destroy()
+ {
+ if (m_vaoId)
+ {
+ glDeleteVertexArrays(1, &m_vaoId);
+ glDeleteBuffers(2, m_vboIds);
+ m_vaoId = 0;
+ }
+
+ if (m_programId)
+ {
+ glDeleteProgram(m_programId);
+ m_programId = 0;
+ }
+ }
+
+ void Vertex(const b2Vec2& v, const b2Color& c)
+ {
+ if (m_count == e_maxVertices)
+ Flush();
+
+ m_vertices[m_count] = v;
+ m_colors[m_count] = c;
+ ++m_count;
+ }
+
+ void Flush()
+ {
+ if (m_count == 0)
+ return;
+
+ glUseProgram(m_programId);
+
+ float proj[16] = { 0.0f };
+ g_camera.BuildProjectionMatrix(proj, 0.2f);
+
+ glUniformMatrix4fv(m_projectionUniform, 1, GL_FALSE, proj);
+
+ glBindVertexArray(m_vaoId);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[0]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(b2Vec2), m_vertices);
+
+ glBindBuffer(GL_ARRAY_BUFFER, m_vboIds[1]);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, m_count * sizeof(b2Color), m_colors);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDrawArrays(GL_TRIANGLES, 0, m_count);
+ glDisable(GL_BLEND);
+
+ sCheckGLError();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindVertexArray(0);
+ glUseProgram(0);
+
+ m_count = 0;
+ }
+
+ enum { e_maxVertices = 3 * 512 };
+ b2Vec2 m_vertices[e_maxVertices];
+ b2Color m_colors[e_maxVertices];
+
+ int32 m_count;
+
+ GLuint m_vaoId;
+ GLuint m_vboIds[2];
+ GLuint m_programId;
+ GLint m_projectionUniform;
+ GLint m_vertexAttribute;
+ GLint m_colorAttribute;
+};
+
+//
+DebugDraw::DebugDraw()
+{
+ m_showUI = true;
+ m_points = NULL;
+ m_lines = NULL;
+ m_triangles = NULL;
+}
+
+//
+DebugDraw::~DebugDraw()
+{
+ b2Assert(m_points == NULL);
+ b2Assert(m_lines == NULL);
+ b2Assert(m_triangles == NULL);
+}
+
+//
+void DebugDraw::Create()
+{
+ m_points = new GLRenderPoints;
+ m_points->Create();
+ m_lines = new GLRenderLines;
+ m_lines->Create();
+ m_triangles = new GLRenderTriangles;
+ m_triangles->Create();
+}
+
+//
+void DebugDraw::Destroy()
+{
+ m_points->Destroy();
+ delete m_points;
+ m_points = NULL;
+
+ m_lines->Destroy();
+ delete m_lines;
+ m_lines = NULL;
+
+ m_triangles->Destroy();
+ delete m_triangles;
+ m_triangles = NULL;
+}
+
+//
+void DebugDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
+{
+ b2Vec2 p1 = vertices[vertexCount - 1];
+ for (int32 i = 0; i < vertexCount; ++i)
+ {
+ b2Vec2 p2 = vertices[i];
+ m_lines->Vertex(p1, color);
+ m_lines->Vertex(p2, color);
+ p1 = p2;
+ }
+}
+
+//
+void DebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
+{
+ b2Color fillColor(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
+
+ for (int32 i = 1; i < vertexCount - 1; ++i)
+ {
+ m_triangles->Vertex(vertices[0], fillColor);
+ m_triangles->Vertex(vertices[i], fillColor);
+ m_triangles->Vertex(vertices[i + 1], fillColor);
+ }
+
+ b2Vec2 p1 = vertices[vertexCount - 1];
+ for (int32 i = 0; i < vertexCount; ++i)
+ {
+ b2Vec2 p2 = vertices[i];
+ m_lines->Vertex(p1, color);
+ m_lines->Vertex(p2, color);
+ p1 = p2;
+ }
+}
+
+//
+void DebugDraw::DrawCircle(const b2Vec2& center, float radius, const b2Color& color)
+{
+ const float k_segments = 16.0f;
+ const float k_increment = 2.0f * b2_pi / k_segments;
+ float sinInc = sinf(k_increment);
+ float cosInc = cosf(k_increment);
+ b2Vec2 r1(1.0f, 0.0f);
+ b2Vec2 v1 = center + radius * r1;
+ for (int32 i = 0; i < k_segments; ++i)
+ {
+ // Perform rotation to avoid additional trigonometry.
+ b2Vec2 r2;
+ r2.x = cosInc * r1.x - sinInc * r1.y;
+ r2.y = sinInc * r1.x + cosInc * r1.y;
+ b2Vec2 v2 = center + radius * r2;
+ m_lines->Vertex(v1, color);
+ m_lines->Vertex(v2, color);
+ r1 = r2;
+ v1 = v2;
+ }
+}
+
+//
+void DebugDraw::DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color)
+{
+ const float k_segments = 16.0f;
+ const float k_increment = 2.0f * b2_pi / k_segments;
+ float sinInc = sinf(k_increment);
+ float cosInc = cosf(k_increment);
+ b2Vec2 v0 = center;
+ b2Vec2 r1(cosInc, sinInc);
+ b2Vec2 v1 = center + radius * r1;
+ b2Color fillColor(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
+ for (int32 i = 0; i < k_segments; ++i)
+ {
+ // Perform rotation to avoid additional trigonometry.
+ b2Vec2 r2;
+ r2.x = cosInc * r1.x - sinInc * r1.y;
+ r2.y = sinInc * r1.x + cosInc * r1.y;
+ b2Vec2 v2 = center + radius * r2;
+ m_triangles->Vertex(v0, fillColor);
+ m_triangles->Vertex(v1, fillColor);
+ m_triangles->Vertex(v2, fillColor);
+ r1 = r2;
+ v1 = v2;
+ }
+
+ r1.Set(1.0f, 0.0f);
+ v1 = center + radius * r1;
+ for (int32 i = 0; i < k_segments; ++i)
+ {
+ b2Vec2 r2;
+ r2.x = cosInc * r1.x - sinInc * r1.y;
+ r2.y = sinInc * r1.x + cosInc * r1.y;
+ b2Vec2 v2 = center + radius * r2;
+ m_lines->Vertex(v1, color);
+ m_lines->Vertex(v2, color);
+ r1 = r2;
+ v1 = v2;
+ }
+
+ // Draw a line fixed in the circle to animate rotation.
+ b2Vec2 p = center + radius * axis;
+ m_lines->Vertex(center, color);
+ m_lines->Vertex(p, color);
+}
+
+//
+void DebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
+{
+ m_lines->Vertex(p1, color);
+ m_lines->Vertex(p2, color);
+}
+
+//
+void DebugDraw::DrawTransform(const b2Transform& xf)
+{
+ const float k_axisScale = 0.4f;
+ b2Color red(1.0f, 0.0f, 0.0f);
+ b2Color green(0.0f, 1.0f, 0.0f);
+ b2Vec2 p1 = xf.p, p2;
+
+ m_lines->Vertex(p1, red);
+ p2 = p1 + k_axisScale * xf.q.GetXAxis();
+ m_lines->Vertex(p2, red);
+
+ m_lines->Vertex(p1, green);
+ p2 = p1 + k_axisScale * xf.q.GetYAxis();
+ m_lines->Vertex(p2, green);
+}
+
+//
+void DebugDraw::DrawPoint(const b2Vec2& p, float size, const b2Color& color)
+{
+ m_points->Vertex(p, color, size);
+}
+
+//
+void DebugDraw::DrawString(int x, int y, const char* string, ...)
+{
+ if (m_showUI == false)
+ {
+ return;
+ }
+
+ va_list arg;
+ va_start(arg, string);
+ ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
+ ImGui::SetCursorPos(ImVec2(float(x), float(y)));
+ ImGui::TextColoredV(ImColor(230, 153, 153, 255), string, arg);
+ ImGui::End();
+ va_end(arg);
+}
+
+//
+void DebugDraw::DrawString(const b2Vec2& pw, const char* string, ...)
+{
+ b2Vec2 ps = g_camera.ConvertWorldToScreen(pw);
+
+ va_list arg;
+ va_start(arg, string);
+ ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
+ ImGui::SetCursorPos(ImVec2(ps.x, ps.y));
+ ImGui::TextColoredV(ImColor(230, 153, 153, 255), string, arg);
+ ImGui::End();
+ va_end(arg);
+}
+
+//
+void DebugDraw::DrawAABB(b2AABB* aabb, const b2Color& c)
+{
+ b2Vec2 p1 = aabb->lowerBound;
+ b2Vec2 p2 = b2Vec2(aabb->upperBound.x, aabb->lowerBound.y);
+ b2Vec2 p3 = aabb->upperBound;
+ b2Vec2 p4 = b2Vec2(aabb->lowerBound.x, aabb->upperBound.y);
+
+ m_lines->Vertex(p1, c);
+ m_lines->Vertex(p2, c);
+
+ m_lines->Vertex(p2, c);
+ m_lines->Vertex(p3, c);
+
+ m_lines->Vertex(p3, c);
+ m_lines->Vertex(p4, c);
+
+ m_lines->Vertex(p4, c);
+ m_lines->Vertex(p1, c);
+}
+
+//
+void DebugDraw::Flush()
+{
+ m_triangles->Flush();
+ m_lines->Flush();
+ m_points->Flush();
+}
diff --git a/Client/ThirdParty/Box2D/testbed/draw.h b/Client/ThirdParty/Box2D/testbed/draw.h
new file mode 100644
index 0000000..45ef234
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/draw.h
@@ -0,0 +1,102 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef DRAW_H
+#define DRAW_H
+
+#define GLFW_INCLUDE_NONE
+#include "glad/gl.h"
+#include "GLFW/glfw3.h"
+
+#include "box2d/box2d.h"
+
+struct b2AABB;
+struct GLRenderPoints;
+struct GLRenderLines;
+struct GLRenderTriangles;
+struct GLFWwindow;
+
+//
+struct Camera
+{
+ Camera()
+ {
+ m_center.Set(0.0f, 20.0f);
+ m_zoom = 1.0f;
+ m_width = 1280;
+ m_height = 800;
+ }
+
+ b2Vec2 ConvertScreenToWorld(const b2Vec2& screenPoint);
+ b2Vec2 ConvertWorldToScreen(const b2Vec2& worldPoint);
+ void BuildProjectionMatrix(float* m, float zBias);
+
+ b2Vec2 m_center;
+ float m_zoom;
+ int32 m_width;
+ int32 m_height;
+};
+
+// This class implements debug drawing callbacks that are invoked
+// inside b2World::Step.
+class DebugDraw : public b2Draw
+{
+public:
+ DebugDraw();
+ ~DebugDraw();
+
+ void Create();
+ void Destroy();
+
+ void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) override;
+
+ void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) override;
+
+ void DrawCircle(const b2Vec2& center, float radius, const b2Color& color) override;
+
+ void DrawSolidCircle(const b2Vec2& center, float radius, const b2Vec2& axis, const b2Color& color) override;
+
+ void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) override;
+
+ void DrawTransform(const b2Transform& xf) override;
+
+ void DrawPoint(const b2Vec2& p, float size, const b2Color& color) override;
+
+ void DrawString(int x, int y, const char* string, ...);
+
+ void DrawString(const b2Vec2& p, const char* string, ...);
+
+ void DrawAABB(b2AABB* aabb, const b2Color& color);
+
+ void Flush();
+
+ bool m_showUI;
+ GLRenderPoints* m_points;
+ GLRenderLines* m_lines;
+ GLRenderTriangles* m_triangles;
+};
+
+extern DebugDraw g_debugDraw;
+extern Camera g_camera;
+extern GLFWwindow* g_mainWindow;
+
+#endif
diff --git a/Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.cpp b/Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.cpp
new file mode 100644
index 0000000..359eece
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.cpp
@@ -0,0 +1,324 @@
+// dear imgui: Platform Binding for GLFW
+// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
+// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
+// (Requires: GLFW 3.1+)
+
+// Implemented features:
+// [X] Platform: Clipboard support.
+// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
+// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
+// 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them.
+// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
+// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
+// 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples.
+// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
+// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()).
+// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
+// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
+// 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set.
+// 2018-01-25: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
+// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
+// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
+// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
+// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
+
+#include "imgui/imgui.h"
+#include "imgui_impl_glfw.h"
+
+// GLFW
+#define GLFW_INCLUDE_NONE
+#include "glad/gl.h"
+#include "GLFW/glfw3.h"
+#ifdef _WIN32
+#undef APIENTRY
+#define GLFW_EXPOSE_NATIVE_WIN32
+#include "GLFW/glfw3native.h" // for glfwGetWin32Window
+#endif
+#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ GLFW_FLOATING
+#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_HOVERED
+#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
+#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
+#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
+
+// Data
+enum GlfwClientApi
+{
+ GlfwClientApi_Unknown,
+ GlfwClientApi_OpenGL,
+ GlfwClientApi_Vulkan
+};
+static GLFWwindow* g_Window = NULL;
+static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
+static double g_Time = 0.0;
+static bool g_MouseJustPressed[5] = { false, false, false, false, false };
+static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = { 0 };
+
+// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
+static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL;
+static GLFWscrollfun g_PrevUserCallbackScroll = NULL;
+static GLFWkeyfun g_PrevUserCallbackKey = NULL;
+static GLFWcharfun g_PrevUserCallbackChar = NULL;
+
+static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
+{
+ return glfwGetClipboardString((GLFWwindow*)user_data);
+}
+
+static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
+{
+ glfwSetClipboardString((GLFWwindow*)user_data, text);
+}
+
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
+{
+ if (g_PrevUserCallbackMousebutton != NULL)
+ g_PrevUserCallbackMousebutton(window, button, action, mods);
+
+ if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(g_MouseJustPressed))
+ g_MouseJustPressed[button] = true;
+}
+
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
+{
+ if (g_PrevUserCallbackScroll != NULL)
+ g_PrevUserCallbackScroll(window, xoffset, yoffset);
+
+ ImGuiIO& io = ImGui::GetIO();
+ io.MouseWheelH += (float)xoffset;
+ io.MouseWheel += (float)yoffset;
+}
+
+void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
+{
+ if (g_PrevUserCallbackKey != NULL)
+ g_PrevUserCallbackKey(window, key, scancode, action, mods);
+
+ ImGuiIO& io = ImGui::GetIO();
+ if (action == GLFW_PRESS)
+ io.KeysDown[key] = true;
+ if (action == GLFW_RELEASE)
+ io.KeysDown[key] = false;
+
+ // Modifiers are not reliable across systems
+ io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
+ io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
+ io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
+ io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
+}
+
+void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
+{
+ if (g_PrevUserCallbackChar != NULL)
+ g_PrevUserCallbackChar(window, c);
+
+ ImGuiIO& io = ImGui::GetIO();
+ if (c > 0 && c < 0x10000)
+ io.AddInputCharacter((unsigned short)c);
+}
+
+static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
+{
+ g_Window = window;
+ g_Time = 0.0;
+
+ // Setup back-end capabilities flags
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
+ io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
+ io.BackendPlatformName = "imgui_impl_glfw";
+
+ // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
+ io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;
+ io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
+ io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
+ io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
+ io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
+ io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
+ io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
+ io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
+ io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
+ io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
+ io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
+ io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
+ io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
+ io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
+ io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
+ io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
+ io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
+ io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
+ io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
+ io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
+ io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
+
+ io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
+ io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
+ io.ClipboardUserData = g_Window;
+#if defined(_WIN32)
+ io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
+#endif
+
+ g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this.
+ g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
+ g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this.
+ g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); // FIXME: GLFW doesn't have this.
+ g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
+
+ // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
+ g_PrevUserCallbackMousebutton = NULL;
+ g_PrevUserCallbackScroll = NULL;
+ g_PrevUserCallbackKey = NULL;
+ g_PrevUserCallbackChar = NULL;
+ if (install_callbacks)
+ {
+ g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
+ g_PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+ }
+
+ g_ClientApi = client_api;
+ return true;
+}
+
+bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks)
+{
+ return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL);
+}
+
+bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
+{
+ return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
+}
+
+void ImGui_ImplGlfw_Shutdown()
+{
+ for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
+ {
+ glfwDestroyCursor(g_MouseCursors[cursor_n]);
+ g_MouseCursors[cursor_n] = NULL;
+ }
+ g_ClientApi = GlfwClientApi_Unknown;
+}
+
+static void ImGui_ImplGlfw_UpdateMousePosAndButtons()
+{
+ // Update buttons
+ ImGuiIO& io = ImGui::GetIO();
+ for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++)
+ {
+ // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
+ io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
+ g_MouseJustPressed[i] = false;
+ }
+
+ // Update mouse position
+ const ImVec2 mouse_pos_backup = io.MousePos;
+ io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
+#ifdef __EMSCRIPTEN__
+ const bool focused = true; // Emscripten
+#else
+ const bool focused = glfwGetWindowAttrib(g_Window, GLFW_FOCUSED) != 0;
+#endif
+ if (focused)
+ {
+ if (io.WantSetMousePos)
+ {
+ glfwSetCursorPos(g_Window, (double)mouse_pos_backup.x, (double)mouse_pos_backup.y);
+ }
+ else
+ {
+ double mouse_x, mouse_y;
+ glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
+ io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
+ }
+ }
+}
+
+static void ImGui_ImplGlfw_UpdateMouseCursor()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
+ return;
+
+ ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
+ if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
+ {
+ // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
+ glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
+ }
+ else
+ {
+ // Show OS mouse cursor
+ // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
+ glfwSetCursor(g_Window, g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
+ glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
+ }
+}
+
+void ImGui_ImplGlfw_NewFrame()
+{
+ ImGuiIO& io = ImGui::GetIO();
+ IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
+
+ // Setup display size (every frame to accommodate for window resizing)
+ int w, h;
+ int display_w, display_h;
+ glfwGetWindowSize(g_Window, &w, &h);
+ glfwGetFramebufferSize(g_Window, &display_w, &display_h);
+ io.DisplaySize = ImVec2((float)w, (float)h);
+ io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
+
+ // Setup time step
+ double current_time = glfwGetTime();
+ io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
+ g_Time = current_time;
+
+ ImGui_ImplGlfw_UpdateMousePosAndButtons();
+ ImGui_ImplGlfw_UpdateMouseCursor();
+
+ // Gamepad navigation mapping [BETA]
+ memset(io.NavInputs, 0, sizeof(io.NavInputs));
+ if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad)
+ {
+ // Update gamepad inputs
+ #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
+ #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
+ int axes_count = 0, buttons_count = 0;
+ const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
+ const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
+ MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A
+ MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B
+ MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X
+ MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y
+ MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left
+ MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right
+ MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up
+ MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down
+ MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB
+ MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB
+ MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB
+ MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f);
+ MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f);
+ MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f);
+ MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f);
+ #undef MAP_BUTTON
+ #undef MAP_ANALOG
+ if (axes_count > 0 && buttons_count > 0)
+ io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
+ else
+ io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
+ }
+}
diff --git a/Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.h b/Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.h
new file mode 100644
index 0000000..ccbe840
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/imgui_impl_glfw.h
@@ -0,0 +1,33 @@
+// dear imgui: Platform Binding for GLFW
+// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
+// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
+
+// Implemented features:
+// [X] Platform: Clipboard support.
+// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
+// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
+// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// About GLSL version:
+// The 'glsl_version' initialization parameter defaults to "#version 150" if NULL.
+// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
+
+#pragma once
+
+struct GLFWwindow;
+
+IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
+IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
+IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
+
+// InitXXX function with 'install_callbacks=true': install GLFW callbacks. They will call user's previously installed callbacks, if any.
+// InitXXX function with 'install_callbacks=false': do not install GLFW callbacks. You will need to call them yourself from your own GLFW callbacks.
+IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.cpp b/Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.cpp
new file mode 100644
index 0000000..6e49ad4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.cpp
@@ -0,0 +1,556 @@
+// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline)
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+// (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..)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// CHANGELOG
+// (minor and older changes stripped away, please see git history for details)
+// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
+// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
+// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT).
+// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
+// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
+// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
+// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
+// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
+// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
+// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
+// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer.
+// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
+// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
+// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
+// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
+// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
+// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
+// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
+// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
+// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
+
+//----------------------------------------
+// OpenGL GLSL GLSL
+// version version string
+//----------------------------------------
+// 2.0 110 "#version 110"
+// 2.1 120
+// 3.0 130
+// 3.1 140
+// 3.2 150 "#version 150"
+// 3.3 330
+// 4.0 400
+// 4.1 410 "#version 410 core"
+// 4.2 420
+// 4.3 430
+// ES 2.0 100 "#version 100"
+// ES 3.0 300 "#version 300 es"
+//----------------------------------------
+
+#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+// MOD_ERIN
+#include "imgui/imgui.h"
+#include "imgui_impl_opengl3.h"
+#include <stdio.h>
+#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
+#include <stddef.h> // intptr_t
+#else
+#include <stdint.h> // intptr_t
+#endif
+#if defined(__APPLE__)
+#include "TargetConditionals.h"
+#endif
+
+// iOS, Android and Emscripten can use GL ES 3
+// Call ImGui_ImplOpenGL3_Init() with "#version 300 es"
+#if (defined(__APPLE__) && TARGET_OS_IOS) || (defined(__ANDROID__)) || (defined(__EMSCRIPTEN__))
+#define USE_GL_ES3
+#endif
+
+#ifdef USE_GL_ES3
+// OpenGL ES 3
+#include <GLES3/gl3.h> // Use GL ES 3
+#else
+// Regular OpenGL
+// About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually.
+// Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad.
+// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
+#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
+#include <GL/gl3w.h>
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
+#include <GL/glew.h>
+#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
+// MOD_ERIN
+#include "glad/gl.h"
+#else
+#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
+#endif
+#endif
+
+// OpenGL Data
+static char g_GlslVersionString[32] = "";
+static GLuint g_FontTexture = 0;
+static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
+static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
+static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
+static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
+
+// Functions
+bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.BackendRendererName = "imgui_impl_opengl3";
+
+ // Store GLSL version string so we can refer to it later in case we recreate shaders. Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
+#ifdef USE_GL_ES3
+ if (glsl_version == NULL)
+ glsl_version = "#version 300 es";
+#else
+ if (glsl_version == NULL)
+ glsl_version = "#version 130";
+#endif
+ IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
+ strcpy(g_GlslVersionString, glsl_version);
+ strcat(g_GlslVersionString, "\n");
+
+ return true;
+}
+
+void ImGui_ImplOpenGL3_Shutdown()
+{
+ ImGui_ImplOpenGL3_DestroyDeviceObjects();
+}
+
+void ImGui_ImplOpenGL3_NewFrame()
+{
+ if (!g_FontTexture)
+ ImGui_ImplOpenGL3_CreateDeviceObjects();
+}
+
+// OpenGL3 Render function.
+// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
+// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
+void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = (int)(draw_data->DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = (int)(draw_data->DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width <= 0 || fb_height <= 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // Backup GL state
+ GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
+ glActiveTexture(GL_TEXTURE0);
+ GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
+ GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+#ifdef GL_SAMPLER_BINDING
+ GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
+#endif
+ GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
+ GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
+#ifdef GL_POLYGON_MODE
+ GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
+#endif
+ GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
+ GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
+ GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
+ GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
+ GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
+ GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
+ GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
+ GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
+ GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
+ GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
+ bool clip_origin_lower_left = true;
+#ifdef GL_CLIP_ORIGIN
+ GLenum last_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&last_clip_origin); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
+ if (last_clip_origin == GL_UPPER_LEFT)
+ clip_origin_lower_left = false;
+#endif
+
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
+ glEnable(GL_BLEND);
+ glBlendEquation(GL_FUNC_ADD);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+#ifdef GL_POLYGON_MODE
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+#endif
+
+ // Setup viewport, orthographic projection matrix
+ // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps.
+ glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
+ float L = draw_data->DisplayPos.x;
+ float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
+ float T = draw_data->DisplayPos.y;
+ float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
+ const float ortho_projection[4][4] =
+ {
+ { 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
+ { 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
+ { 0.0f, 0.0f, -1.0f, 0.0f },
+ { (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
+ };
+ glUseProgram(g_ShaderHandle);
+ glUniform1i(g_AttribLocationTex, 0);
+ glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
+#ifdef GL_SAMPLER_BINDING
+ glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
+#endif
+ // Recreate the VAO every time
+ // (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
+ GLuint vao_handle = 0;
+ glGenVertexArrays(1, &vao_handle);
+ glBindVertexArray(vao_handle);
+ glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
+ glEnableVertexAttribArray(g_AttribLocationPosition);
+ glEnableVertexAttribArray(g_AttribLocationUV);
+ glEnableVertexAttribArray(g_AttribLocationColor);
+ glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
+ glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
+ glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
+
+ // Draw
+ ImVec2 pos = draw_data->DisplayPos;
+ for (int n = 0; n < draw_data->CmdListsCount; n++)
+ {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawIdx* idx_buffer_offset = 0;
+
+ glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
+ glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
+ {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback)
+ {
+ // User callback (registered via ImDrawList::AddCallback)
+ pcmd->UserCallback(cmd_list, pcmd);
+ }
+ else
+ {
+ ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pos.x, pcmd->ClipRect.w - pos.y);
+ if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
+ {
+ // Apply scissor/clipping rectangle
+ if (clip_origin_lower_left)
+ glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
+ else
+ glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
+
+ // Bind texture, Draw
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
+ }
+ }
+ idx_buffer_offset += pcmd->ElemCount;
+ }
+ }
+ glDeleteVertexArrays(1, &vao_handle);
+
+ // Restore modified GL state
+ glUseProgram(last_program);
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+#ifdef GL_SAMPLER_BINDING
+ glBindSampler(0, last_sampler);
+#endif
+ glActiveTexture(last_active_texture);
+ glBindVertexArray(last_vertex_array);
+ glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
+ glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
+ glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
+ if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
+ if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
+ if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
+ if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
+#ifdef GL_POLYGON_MODE
+ glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
+#endif
+ glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
+ glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
+}
+
+bool ImGui_ImplOpenGL3_CreateFontsTexture()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGenTextures(1, &g_FontTexture);
+ glBindTexture(GL_TEXTURE_2D, g_FontTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
+
+ // Restore state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+void ImGui_ImplOpenGL3_DestroyFontsTexture()
+{
+ if (g_FontTexture)
+ {
+ ImGuiIO& io = ImGui::GetIO();
+ glDeleteTextures(1, &g_FontTexture);
+ io.Fonts->TexID = 0;
+ g_FontTexture = 0;
+ }
+}
+
+// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
+static bool CheckShader(GLuint handle, const char* desc)
+{
+ GLint status = 0, log_length = 0;
+ glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
+ glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
+ if ((GLboolean)status == GL_FALSE)
+ fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
+ if (log_length > 0)
+ {
+ ImVector<char> buf;
+ buf.resize((int)(log_length + 1));
+ glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
+ fprintf(stderr, "%s\n", buf.begin());
+ }
+ return (GLboolean)status == GL_TRUE;
+}
+
+// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
+static bool CheckProgram(GLuint handle, const char* desc)
+{
+ GLint status = 0, log_length = 0;
+ glGetProgramiv(handle, GL_LINK_STATUS, &status);
+ glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
+ if ((GLboolean)status == GL_FALSE)
+ fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
+ if (log_length > 0)
+ {
+ ImVector<char> buf;
+ buf.resize((int)(log_length + 1));
+ glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
+ fprintf(stderr, "%s\n", buf.begin());
+ }
+ return (GLboolean)status == GL_TRUE;
+}
+
+bool ImGui_ImplOpenGL3_CreateDeviceObjects()
+{
+ // Backup GL state
+ GLint last_texture, last_array_buffer, last_vertex_array;
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
+ glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
+
+ // Parse GLSL version string
+ int glsl_version = 130;
+ sscanf(g_GlslVersionString, "#version %d", &glsl_version);
+
+ const GLchar* vertex_shader_glsl_120 =
+ "uniform mat4 ProjMtx;\n"
+ "attribute vec2 Position;\n"
+ "attribute vec2 UV;\n"
+ "attribute vec4 Color;\n"
+ "varying vec2 Frag_UV;\n"
+ "varying vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* vertex_shader_glsl_130 =
+ "uniform mat4 ProjMtx;\n"
+ "in vec2 Position;\n"
+ "in vec2 UV;\n"
+ "in vec4 Color;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* vertex_shader_glsl_300_es =
+ "precision mediump float;\n"
+ "layout (location = 0) in vec2 Position;\n"
+ "layout (location = 1) in vec2 UV;\n"
+ "layout (location = 2) in vec4 Color;\n"
+ "uniform mat4 ProjMtx;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* vertex_shader_glsl_410_core =
+ "layout (location = 0) in vec2 Position;\n"
+ "layout (location = 1) in vec2 UV;\n"
+ "layout (location = 2) in vec4 Color;\n"
+ "uniform mat4 ProjMtx;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_120 =
+ "#ifdef GL_ES\n"
+ " precision mediump float;\n"
+ "#endif\n"
+ "uniform sampler2D Texture;\n"
+ "varying vec2 Frag_UV;\n"
+ "varying vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_130 =
+ "uniform sampler2D Texture;\n"
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_300_es =
+ "precision mediump float;\n"
+ "uniform sampler2D Texture;\n"
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "layout (location = 0) out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_glsl_410_core =
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "uniform sampler2D Texture;\n"
+ "layout (location = 0) out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ // Select shaders matching our GLSL versions
+ const GLchar* vertex_shader = NULL;
+ const GLchar* fragment_shader = NULL;
+ if (glsl_version < 130)
+ {
+ vertex_shader = vertex_shader_glsl_120;
+ fragment_shader = fragment_shader_glsl_120;
+ }
+ else if (glsl_version >= 410)
+ {
+ vertex_shader = vertex_shader_glsl_410_core;
+ fragment_shader = fragment_shader_glsl_410_core;
+ }
+ else if (glsl_version == 300)
+ {
+ vertex_shader = vertex_shader_glsl_300_es;
+ fragment_shader = fragment_shader_glsl_300_es;
+ }
+ else
+ {
+ vertex_shader = vertex_shader_glsl_130;
+ fragment_shader = fragment_shader_glsl_130;
+ }
+
+ // Create shaders
+ const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
+ g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
+ glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
+ glCompileShader(g_VertHandle);
+ CheckShader(g_VertHandle, "vertex shader");
+
+ const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
+ g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
+ glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
+ glCompileShader(g_FragHandle);
+ CheckShader(g_FragHandle, "fragment shader");
+
+ g_ShaderHandle = glCreateProgram();
+ glAttachShader(g_ShaderHandle, g_VertHandle);
+ glAttachShader(g_ShaderHandle, g_FragHandle);
+ glLinkProgram(g_ShaderHandle);
+ CheckProgram(g_ShaderHandle, "shader program");
+
+ g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
+ g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
+ g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
+ g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV");
+ g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color");
+
+ // Create buffers
+ glGenBuffers(1, &g_VboHandle);
+ glGenBuffers(1, &g_ElementsHandle);
+
+ ImGui_ImplOpenGL3_CreateFontsTexture();
+
+ // Restore modified GL state
+ glBindTexture(GL_TEXTURE_2D, last_texture);
+ glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
+ glBindVertexArray(last_vertex_array);
+
+ return true;
+}
+
+void ImGui_ImplOpenGL3_DestroyDeviceObjects()
+{
+ if (g_VboHandle) glDeleteBuffers(1, &g_VboHandle);
+ if (g_ElementsHandle) glDeleteBuffers(1, &g_ElementsHandle);
+ g_VboHandle = g_ElementsHandle = 0;
+
+ if (g_ShaderHandle && g_VertHandle) glDetachShader(g_ShaderHandle, g_VertHandle);
+ if (g_VertHandle) glDeleteShader(g_VertHandle);
+ g_VertHandle = 0;
+
+ if (g_ShaderHandle && g_FragHandle) glDetachShader(g_ShaderHandle, g_FragHandle);
+ if (g_FragHandle) glDeleteShader(g_FragHandle);
+ g_FragHandle = 0;
+
+ if (g_ShaderHandle) glDeleteProgram(g_ShaderHandle);
+ g_ShaderHandle = 0;
+
+ ImGui_ImplOpenGL3_DestroyFontsTexture();
+}
diff --git a/Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.h b/Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.h
new file mode 100644
index 0000000..1683b6e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/imgui_impl_opengl3.h
@@ -0,0 +1,44 @@
+// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline)
+// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
+// (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..)
+
+// Implemented features:
+// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
+
+// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
+// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
+// https://github.com/ocornut/imgui
+
+// About OpenGL function loaders:
+// About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually.
+// Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad.
+// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
+
+// About GLSL version:
+// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
+// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
+// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
+
+#pragma once
+
+// MOD_ERIN
+#define IMGUI_IMPL_OPENGL_LOADER_GLAD
+
+// Set default OpenGL loader to be gl3w
+#if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
+ && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
+#define IMGUI_IMPL_OPENGL_LOADER_GL3W
+#endif
+
+IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
+
+// Called by Init/NewFrame/Shutdown
+IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
+IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
+IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
diff --git a/Client/ThirdParty/Box2D/testbed/main.cpp b/Client/ThirdParty/Box2D/testbed/main.cpp
new file mode 100644
index 0000000..c5969e3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/main.cpp
@@ -0,0 +1,651 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#define _CRT_SECURE_NO_WARNINGS
+#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 1
+
+#include "imgui/imgui.h"
+#include "imgui_impl_glfw.h"
+#include "imgui_impl_opengl3.h"
+#include "draw.h"
+#include "settings.h"
+#include "test.h"
+
+#include <algorithm>
+#include <stdio.h>
+#include <thread>
+#include <chrono>
+
+#if defined(_WIN32)
+#include <crtdbg.h>
+#endif
+
+GLFWwindow* g_mainWindow = nullptr;
+static int32 s_testSelection = 0;
+static Test* s_test = nullptr;
+static Settings s_settings;
+static bool s_rightMouseDown = false;
+static b2Vec2 s_clickPointWS = b2Vec2_zero;
+
+void glfwErrorCallback(int error, const char* description)
+{
+ fprintf(stderr, "GLFW error occured. Code: %d. Description: %s\n", error, description);
+}
+
+static inline bool CompareTests(const TestEntry& a, const TestEntry& b)
+{
+ int result = strcmp(a.category, b.category);
+ if (result == 0)
+ {
+ result = strcmp(a.name, b.name);
+ }
+
+ return result < 0;
+}
+
+static void SortTests()
+{
+ std::sort(g_testEntries, g_testEntries + g_testCount, CompareTests);
+}
+
+static void CreateUI(GLFWwindow* window, const char* glslVersion = NULL)
+{
+ IMGUI_CHECKVERSION();
+ ImGui::CreateContext();
+
+ bool success;
+ success = ImGui_ImplGlfw_InitForOpenGL(window, false);
+ if (success == false)
+ {
+ printf("ImGui_ImplGlfw_InitForOpenGL failed\n");
+ assert(false);
+ }
+
+ success = ImGui_ImplOpenGL3_Init(glslVersion);
+ if (success == false)
+ {
+ printf("ImGui_ImplOpenGL3_Init failed\n");
+ assert(false);
+ }
+
+ // Search for font file
+ const char* fontPath1 = "data/droid_sans.ttf";
+ const char* fontPath2 = "../data/droid_sans.ttf";
+ const char* fontPath = nullptr;
+ FILE* file1 = fopen(fontPath1, "rb");
+ FILE* file2 = fopen(fontPath2, "rb");
+ if (file1)
+ {
+ fontPath = fontPath1;
+ fclose(file1);
+ }
+
+ if (file2)
+ {
+ fontPath = fontPath2;
+ fclose(file2);
+ }
+
+ if (fontPath)
+ {
+ ImGui::GetIO().Fonts->AddFontFromFileTTF(fontPath, 13.0f);
+ }
+}
+
+static void ResizeWindowCallback(GLFWwindow*, int width, int height)
+{
+ g_camera.m_width = width;
+ g_camera.m_height = height;
+ s_settings.m_windowWidth = width;
+ s_settings.m_windowHeight = height;
+}
+
+static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
+{
+ ImGui_ImplGlfw_KeyCallback(window, key, scancode, action, mods);
+ if (ImGui::GetIO().WantCaptureKeyboard)
+ {
+ return;
+ }
+
+ if (action == GLFW_PRESS)
+ {
+ switch (key)
+ {
+ case GLFW_KEY_ESCAPE:
+ // Quit
+ glfwSetWindowShouldClose(g_mainWindow, GL_TRUE);
+ break;
+
+ case GLFW_KEY_LEFT:
+ // Pan left
+ if (mods == GLFW_MOD_CONTROL)
+ {
+ b2Vec2 newOrigin(2.0f, 0.0f);
+ s_test->ShiftOrigin(newOrigin);
+ }
+ else
+ {
+ g_camera.m_center.x -= 0.5f;
+ }
+ break;
+
+ case GLFW_KEY_RIGHT:
+ // Pan right
+ if (mods == GLFW_MOD_CONTROL)
+ {
+ b2Vec2 newOrigin(-2.0f, 0.0f);
+ s_test->ShiftOrigin(newOrigin);
+ }
+ else
+ {
+ g_camera.m_center.x += 0.5f;
+ }
+ break;
+
+ case GLFW_KEY_DOWN:
+ // Pan down
+ if (mods == GLFW_MOD_CONTROL)
+ {
+ b2Vec2 newOrigin(0.0f, 2.0f);
+ s_test->ShiftOrigin(newOrigin);
+ }
+ else
+ {
+ g_camera.m_center.y -= 0.5f;
+ }
+ break;
+
+ case GLFW_KEY_UP:
+ // Pan up
+ if (mods == GLFW_MOD_CONTROL)
+ {
+ b2Vec2 newOrigin(0.0f, -2.0f);
+ s_test->ShiftOrigin(newOrigin);
+ }
+ else
+ {
+ g_camera.m_center.y += 0.5f;
+ }
+ break;
+
+ case GLFW_KEY_HOME:
+ // Reset view
+ g_camera.m_zoom = 1.0f;
+ g_camera.m_center.Set(0.0f, 20.0f);
+ break;
+
+ case GLFW_KEY_Z:
+ // Zoom out
+ g_camera.m_zoom = b2Min(1.1f * g_camera.m_zoom, 20.0f);
+ break;
+
+ case GLFW_KEY_X:
+ // Zoom in
+ g_camera.m_zoom = b2Max(0.9f * g_camera.m_zoom, 0.02f);
+ break;
+
+ case GLFW_KEY_R:
+ // Reset test
+ delete s_test;
+ s_test = g_testEntries[s_settings.m_testIndex].createFcn();
+ break;
+
+ case GLFW_KEY_SPACE:
+ // Launch a bomb.
+ if (s_test)
+ {
+ s_test->LaunchBomb();
+ }
+ break;
+
+ case GLFW_KEY_O:
+ s_settings.m_singleStep = true;
+ break;
+
+ case GLFW_KEY_P:
+ s_settings.m_pause = !s_settings.m_pause;
+ break;
+
+ case GLFW_KEY_LEFT_BRACKET:
+ // Switch to previous test
+ --s_testSelection;
+ if (s_testSelection < 0)
+ {
+ s_testSelection = g_testCount - 1;
+ }
+ break;
+
+ case GLFW_KEY_RIGHT_BRACKET:
+ // Switch to next test
+ ++s_testSelection;
+ if (s_testSelection == g_testCount)
+ {
+ s_testSelection = 0;
+ }
+ break;
+
+ case GLFW_KEY_TAB:
+ g_debugDraw.m_showUI = !g_debugDraw.m_showUI;
+
+ default:
+ if (s_test)
+ {
+ s_test->Keyboard(key);
+ }
+ }
+ }
+ else if (action == GLFW_RELEASE)
+ {
+ s_test->KeyboardUp(key);
+ }
+ // else GLFW_REPEAT
+}
+
+static void CharCallback(GLFWwindow* window, unsigned int c)
+{
+ ImGui_ImplGlfw_CharCallback(window, c);
+}
+
+static void MouseButtonCallback(GLFWwindow* window, int32 button, int32 action, int32 mods)
+{
+ ImGui_ImplGlfw_MouseButtonCallback(window, button, action, mods);
+
+ double xd, yd;
+ glfwGetCursorPos(g_mainWindow, &xd, &yd);
+ b2Vec2 ps((float)xd, (float)yd);
+
+ // Use the mouse to move things around.
+ if (button == GLFW_MOUSE_BUTTON_1)
+ {
+ //<##>
+ //ps.Set(0, 0);
+ b2Vec2 pw = g_camera.ConvertScreenToWorld(ps);
+ if (action == GLFW_PRESS)
+ {
+ if (mods == GLFW_MOD_SHIFT)
+ {
+ s_test->ShiftMouseDown(pw);
+ }
+ else
+ {
+ s_test->MouseDown(pw);
+ }
+ }
+
+ if (action == GLFW_RELEASE)
+ {
+ s_test->MouseUp(pw);
+ }
+ }
+ else if (button == GLFW_MOUSE_BUTTON_2)
+ {
+ if (action == GLFW_PRESS)
+ {
+ s_clickPointWS = g_camera.ConvertScreenToWorld(ps);
+ s_rightMouseDown = true;
+ }
+
+ if (action == GLFW_RELEASE)
+ {
+ s_rightMouseDown = false;
+ }
+ }
+}
+
+static void MouseMotionCallback(GLFWwindow*, double xd, double yd)
+{
+ b2Vec2 ps((float)xd, (float)yd);
+
+ b2Vec2 pw = g_camera.ConvertScreenToWorld(ps);
+ s_test->MouseMove(pw);
+
+ if (s_rightMouseDown)
+ {
+ b2Vec2 diff = pw - s_clickPointWS;
+ g_camera.m_center.x -= diff.x;
+ g_camera.m_center.y -= diff.y;
+ s_clickPointWS = g_camera.ConvertScreenToWorld(ps);
+ }
+}
+
+static void ScrollCallback(GLFWwindow* window, double dx, double dy)
+{
+ ImGui_ImplGlfw_ScrollCallback(window, dx, dy);
+ if (ImGui::GetIO().WantCaptureMouse)
+ {
+ return;
+ }
+
+ if (dy > 0)
+ {
+ g_camera.m_zoom /= 1.1f;
+ }
+ else
+ {
+ g_camera.m_zoom *= 1.1f;
+ }
+}
+
+static void RestartTest()
+{
+ delete s_test;
+ s_test = g_testEntries[s_settings.m_testIndex].createFcn();
+}
+
+static void UpdateUI()
+{
+ int menuWidth = 180;
+ if (g_debugDraw.m_showUI)
+ {
+ ImGui::SetNextWindowPos(ImVec2((float)g_camera.m_width - menuWidth - 10, 10));
+ ImGui::SetNextWindowSize(ImVec2((float)menuWidth, (float)g_camera.m_height - 20));
+
+ ImGui::Begin("Tools", &g_debugDraw.m_showUI, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
+
+ if (ImGui::BeginTabBar("ControlTabs", ImGuiTabBarFlags_None))
+ {
+ if (ImGui::BeginTabItem("Controls"))
+ {
+ ImGui::SliderInt("Vel Iters", &s_settings.m_velocityIterations, 0, 50);
+ ImGui::SliderInt("Pos Iters", &s_settings.m_positionIterations, 0, 50);
+ ImGui::SliderFloat("Hertz", &s_settings.m_hertz, 5.0f, 120.0f, "%.0f hz");
+
+ ImGui::Separator();
+
+ ImGui::Checkbox("Sleep", &s_settings.m_enableSleep);
+ ImGui::Checkbox("Warm Starting", &s_settings.m_enableWarmStarting);
+ ImGui::Checkbox("Time of Impact", &s_settings.m_enableContinuous);
+ ImGui::Checkbox("Sub-Stepping", &s_settings.m_enableSubStepping);
+
+ ImGui::Separator();
+
+ ImGui::Checkbox("Shapes", &s_settings.m_drawShapes);
+ ImGui::Checkbox("Joints", &s_settings.m_drawJoints);
+ ImGui::Checkbox("AABBs", &s_settings.m_drawAABBs);
+ ImGui::Checkbox("Contact Points", &s_settings.m_drawContactPoints);
+ ImGui::Checkbox("Contact Normals", &s_settings.m_drawContactNormals);
+ ImGui::Checkbox("Contact Impulses", &s_settings.m_drawContactImpulse);
+ ImGui::Checkbox("Friction Impulses", &s_settings.m_drawFrictionImpulse);
+ ImGui::Checkbox("Center of Masses", &s_settings.m_drawCOMs);
+ ImGui::Checkbox("Statistics", &s_settings.m_drawStats);
+ ImGui::Checkbox("Profile", &s_settings.m_drawProfile);
+
+ ImVec2 button_sz = ImVec2(-1, 0);
+ if (ImGui::Button("Pause (P)", button_sz))
+ {
+ s_settings.m_pause = !s_settings.m_pause;
+ }
+
+ if (ImGui::Button("Single Step (O)", button_sz))
+ {
+ s_settings.m_singleStep = !s_settings.m_singleStep;
+ }
+
+ if (ImGui::Button("Restart (R)", button_sz))
+ {
+ RestartTest();
+ }
+
+ if (ImGui::Button("Quit", button_sz))
+ {
+ glfwSetWindowShouldClose(g_mainWindow, GL_TRUE);
+ }
+
+ ImGui::EndTabItem();
+ }
+
+ ImGuiTreeNodeFlags leafNodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
+ leafNodeFlags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
+
+ ImGuiTreeNodeFlags nodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
+
+ if (ImGui::BeginTabItem("Tests"))
+ {
+ int categoryIndex = 0;
+ const char* category = g_testEntries[categoryIndex].category;
+ int i = 0;
+ while (i < g_testCount)
+ {
+ bool categorySelected = strcmp(category, g_testEntries[s_settings.m_testIndex].category) == 0;
+ ImGuiTreeNodeFlags nodeSelectionFlags = categorySelected ? ImGuiTreeNodeFlags_Selected : 0;
+ bool nodeOpen = ImGui::TreeNodeEx(category, nodeFlags | nodeSelectionFlags);
+
+ if (nodeOpen)
+ {
+ while (i < g_testCount && strcmp(category, g_testEntries[i].category) == 0)
+ {
+ ImGuiTreeNodeFlags selectionFlags = 0;
+ if (s_settings.m_testIndex == i)
+ {
+ selectionFlags = ImGuiTreeNodeFlags_Selected;
+ }
+ ImGui::TreeNodeEx((void*)(intptr_t)i, leafNodeFlags | selectionFlags, "%s", g_testEntries[i].name);
+ if (ImGui::IsItemClicked())
+ {
+ delete s_test;
+ s_settings.m_testIndex = i;
+ s_test = g_testEntries[i].createFcn();
+ s_testSelection = i;
+ }
+ ++i;
+ }
+ ImGui::TreePop();
+ }
+ else
+ {
+ while (i < g_testCount && strcmp(category, g_testEntries[i].category) == 0)
+ {
+ ++i;
+ }
+ }
+
+ if (i < g_testCount)
+ {
+ category = g_testEntries[i].category;
+ categoryIndex = i;
+ }
+ }
+ ImGui::EndTabItem();
+ }
+ ImGui::EndTabBar();
+ }
+
+ ImGui::End();
+
+ s_test->UpdateUI();
+ }
+}
+
+//
+int main(int, char**)
+{
+#if defined(_WIN32)
+ // Enable memory-leak reports
+ _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
+#endif
+
+ char buffer[128];
+
+ s_settings.Load();
+ SortTests();
+
+ glfwSetErrorCallback(glfwErrorCallback);
+
+ g_camera.m_width = s_settings.m_windowWidth;
+ g_camera.m_height = s_settings.m_windowHeight;
+
+ if (glfwInit() == 0)
+ {
+ fprintf(stderr, "Failed to initialize GLFW\n");
+ return -1;
+ }
+
+#if __APPLE__
+ const char* glslVersion = "#version 150";
+#else
+ const char* glslVersion = NULL;
+#endif
+
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+
+ sprintf(buffer, "Box2D Testbed Version %d.%d.%d", b2_version.major, b2_version.minor, b2_version.revision);
+
+ bool fullscreen = false;
+ if (fullscreen)
+ {
+ g_mainWindow = glfwCreateWindow(1920, 1080, buffer, glfwGetPrimaryMonitor(), NULL);
+ }
+ else
+ {
+ g_mainWindow = glfwCreateWindow(g_camera.m_width, g_camera.m_height, buffer, NULL, NULL);
+ }
+
+ if (g_mainWindow == NULL)
+ {
+ fprintf(stderr, "Failed to open GLFW g_mainWindow.\n");
+ glfwTerminate();
+ return -1;
+ }
+
+ glfwMakeContextCurrent(g_mainWindow);
+
+ // Load OpenGL functions using glad
+ int version = gladLoadGL(glfwGetProcAddress);
+ printf("GL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
+ printf("OpenGL %s, GLSL %s\n", glGetString(GL_VERSION), glGetString(GL_SHADING_LANGUAGE_VERSION));
+
+ glfwSetScrollCallback(g_mainWindow, ScrollCallback);
+ glfwSetWindowSizeCallback(g_mainWindow, ResizeWindowCallback);
+ glfwSetKeyCallback(g_mainWindow, KeyCallback);
+ glfwSetCharCallback(g_mainWindow, CharCallback);
+ glfwSetMouseButtonCallback(g_mainWindow, MouseButtonCallback);
+ glfwSetCursorPosCallback(g_mainWindow, MouseMotionCallback);
+ glfwSetScrollCallback(g_mainWindow, ScrollCallback);
+
+ g_debugDraw.Create();
+
+ CreateUI(g_mainWindow, glslVersion);
+
+ s_settings.m_testIndex = b2Clamp(s_settings.m_testIndex, 0, g_testCount - 1);
+ s_testSelection = s_settings.m_testIndex;
+ s_test = g_testEntries[s_settings.m_testIndex].createFcn();
+
+ // Control the frame rate. One draw per monitor refresh.
+ //glfwSwapInterval(1);
+
+ glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
+
+ std::chrono::duration<double> frameTime(0.0);
+ std::chrono::duration<double> sleepAdjust(0.0);
+
+ while (!glfwWindowShouldClose(g_mainWindow))
+ {
+ std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
+
+ glfwGetWindowSize(g_mainWindow, &g_camera.m_width, &g_camera.m_height);
+
+ int bufferWidth, bufferHeight;
+ glfwGetFramebufferSize(g_mainWindow, &bufferWidth, &bufferHeight);
+ glViewport(0, 0, bufferWidth, bufferHeight);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ ImGui_ImplOpenGL3_NewFrame();
+ ImGui_ImplGlfw_NewFrame();
+
+ ImGui::NewFrame();
+
+ if (g_debugDraw.m_showUI)
+ {
+ ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
+ ImGui::SetNextWindowSize(ImVec2(float(g_camera.m_width), float(g_camera.m_height)));
+ ImGui::SetNextWindowBgAlpha(0.0f);
+ ImGui::Begin("Overlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
+ ImGui::End();
+
+ const TestEntry& entry = g_testEntries[s_settings.m_testIndex];
+ sprintf(buffer, "%s : %s", entry.category, entry.name);
+ s_test->DrawTitle(buffer);
+ }
+
+ s_test->Step(s_settings);
+
+ UpdateUI();
+
+ // ImGui::ShowDemoWindow();
+
+ if (g_debugDraw.m_showUI)
+ {
+ sprintf(buffer, "%.1f ms", 1000.0 * frameTime.count());
+ g_debugDraw.DrawString(5, g_camera.m_height - 20, buffer);
+ }
+
+ ImGui::Render();
+ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+
+ glfwSwapBuffers(g_mainWindow);
+
+ if (s_testSelection != s_settings.m_testIndex)
+ {
+ s_settings.m_testIndex = s_testSelection;
+ delete s_test;
+ s_test = g_testEntries[s_settings.m_testIndex].createFcn();
+ g_camera.m_zoom = 1.0f;
+ g_camera.m_center.Set(0.0f, 20.0f);
+ }
+
+ glfwPollEvents();
+
+ // Throttle to cap at 60Hz. This adaptive using a sleep adjustment. This could be improved by
+ // using mm_pause or equivalent for the last millisecond.
+ std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
+ std::chrono::duration<double> target(1.0 / 60.0);
+ std::chrono::duration<double> timeUsed = t2 - t1;
+ std::chrono::duration<double> sleepTime = target - timeUsed + sleepAdjust;
+ if (sleepTime > std::chrono::duration<double>(0))
+ {
+ std::this_thread::sleep_for(sleepTime);
+ }
+
+ std::chrono::steady_clock::time_point t3 = std::chrono::steady_clock::now();
+ frameTime = t3 - t1;
+
+ // Compute the sleep adjustment using a low pass filter
+ sleepAdjust = 0.9 * sleepAdjust + 0.1 * (target - frameTime);
+ }
+
+ delete s_test;
+ s_test = nullptr;
+
+ g_debugDraw.Destroy();
+ ImGui_ImplOpenGL3_Shutdown();
+ ImGui_ImplGlfw_Shutdown();
+ glfwTerminate();
+
+ s_settings.Save();
+
+ return 0;
+}
diff --git a/Client/ThirdParty/Box2D/testbed/settings.cpp b/Client/ThirdParty/Box2D/testbed/settings.cpp
new file mode 100644
index 0000000..fbdf9c0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/settings.cpp
@@ -0,0 +1,176 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#define _CRT_SECURE_NO_WARNINGS
+#include "settings.h"
+#include "sajson/sajson.h"
+#include <stdio.h>
+
+static const char* fileName = "settings.ini";
+
+// Load a file. You must free the character array.
+static bool sReadFile(char*& data, int& size, const char* filename)
+{
+ FILE* file = fopen(filename, "rb");
+ if (file == nullptr)
+ {
+ return false;
+ }
+
+ fseek(file, 0, SEEK_END);
+ size = ftell(file);
+ fseek(file, 0, SEEK_SET);
+
+ if (size == 0)
+ {
+ return false;
+ }
+
+ data = (char*)malloc(size + 1);
+ fread(data, size, 1, file);
+ fclose(file);
+ data[size] = 0;
+
+ return true;
+}
+
+void Settings::Save()
+{
+ FILE* file = fopen(fileName, "w");
+ fprintf(file, "{\n");
+ fprintf(file, " \"testIndex\": %d,\n", m_testIndex);
+ fprintf(file, " \"windowWidth\": %d,\n", m_windowWidth);
+ fprintf(file, " \"windowHeight\": %d,\n", m_windowHeight);
+ fprintf(file, " \"hertz\": %.9g,\n", m_hertz);
+ fprintf(file, " \"velocityIterations\": %d,\n", m_velocityIterations);
+ fprintf(file, " \"positionIterations\": %d,\n", m_positionIterations);
+ fprintf(file, " \"drawShapes\": %s,\n", m_drawShapes ? "true" : "false");
+ fprintf(file, " \"drawJoints\": %s,\n", m_drawJoints ? "true" : "false");
+ fprintf(file, " \"drawAABBs\": %s,\n", m_drawAABBs ? "true" : "false");
+ fprintf(file, " \"drawContactPoints\": %s,\n", m_drawContactPoints ? "true" : "false");
+ fprintf(file, " \"drawContactNormals\": %s,\n", m_drawContactNormals ? "true" : "false");
+ fprintf(file, " \"drawContactImpulse\": %s,\n", m_drawContactImpulse ? "true" : "false");
+ fprintf(file, " \"drawFrictionImpulse\": %s,\n", m_drawFrictionImpulse ? "true" : "false");
+ fprintf(file, " \"drawCOMs\": %s,\n", m_drawCOMs ? "true" : "false");
+ fprintf(file, " \"drawStats\": %s,\n", m_drawStats ? "true" : "false");
+ fprintf(file, " \"drawProfile\": %s,\n", m_drawProfile ? "true" : "false");
+ fprintf(file, " \"enableWarmStarting\": %s,\n", m_enableWarmStarting ? "true" : "false");
+ fprintf(file, " \"enableContinuous\": %s,\n", m_enableContinuous ? "true" : "false");
+ fprintf(file, " \"enableSubStepping\": %s,\n", m_enableSubStepping ? "true" : "false");
+ fprintf(file, " \"enableSleep\": %s\n", m_enableSleep ? "true" : "false");
+ fprintf(file, "}\n");
+ fclose(file);
+}
+
+void Settings::Load()
+{
+ char* data = nullptr;
+ int size = 0;
+ bool found = sReadFile(data, size, fileName);
+ if (found == false)
+ {
+ return;
+ }
+
+ const sajson::document& document = sajson::parse(sajson::dynamic_allocation(), sajson::mutable_string_view(size, data));
+ if (document.is_valid() == false)
+ {
+ return;
+ }
+
+ sajson::value root = document.get_root();
+ int fieldCount = int(root.get_length());
+ for (int i = 0; i < fieldCount; ++i)
+ {
+ sajson::string fieldName = root.get_object_key(i);
+ sajson::value fieldValue = root.get_object_value(i);
+
+ if (strncmp(fieldName.data(), "testIndex", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_INTEGER)
+ {
+ m_testIndex = fieldValue.get_integer_value();
+ }
+ continue;
+ }
+
+ if (strncmp(fieldName.data(), "windowWidth", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_INTEGER)
+ {
+ m_windowWidth = fieldValue.get_integer_value();
+ }
+ continue;
+ }
+
+ if (strncmp(fieldName.data(), "windowHeight", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_INTEGER)
+ {
+ m_windowHeight = fieldValue.get_integer_value();
+ }
+ continue;
+ }
+
+ if (strncmp(fieldName.data(), "hertz", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_DOUBLE || fieldValue.get_type() == sajson::TYPE_INTEGER)
+ {
+ m_hertz = float(fieldValue.get_number_value());
+ }
+ continue;
+ }
+
+ if (strncmp(fieldName.data(), "velocityIterations", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_INTEGER)
+ {
+ m_velocityIterations = fieldValue.get_integer_value();
+ }
+ continue;
+ }
+
+ if (strncmp(fieldName.data(), "positionIterations", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_INTEGER)
+ {
+ m_positionIterations = fieldValue.get_integer_value();
+ }
+ continue;
+ }
+
+ if (strncmp(fieldName.data(), "drawShapes", fieldName.length()) == 0)
+ {
+ if (fieldValue.get_type() == sajson::TYPE_FALSE)
+ {
+ m_drawShapes = false;
+ }
+ else if (fieldValue.get_type() == sajson::TYPE_TRUE)
+ {
+ m_drawShapes = true;
+ }
+ continue;
+ }
+ }
+
+ free(data);
+}
diff --git a/Client/ThirdParty/Box2D/testbed/settings.h b/Client/ThirdParty/Box2D/testbed/settings.h
new file mode 100644
index 0000000..dcb8426
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/settings.h
@@ -0,0 +1,83 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#pragma once
+
+struct Settings
+{
+ Settings()
+ {
+ Reset();
+ }
+
+ void Reset()
+ {
+ m_testIndex = 0;
+ m_windowWidth = 1600;
+ m_windowHeight = 900;
+ m_hertz = 60.0f;
+ m_velocityIterations = 8;
+ m_positionIterations = 3;
+ m_drawShapes = true;
+ m_drawJoints = true;
+ m_drawAABBs = false;
+ m_drawContactPoints = false;
+ m_drawContactNormals = false;
+ m_drawContactImpulse = false;
+ m_drawFrictionImpulse = false;
+ m_drawCOMs = false;
+ m_drawStats = false;
+ m_drawProfile = false;
+ m_enableWarmStarting = true;
+ m_enableContinuous = true;
+ m_enableSubStepping = false;
+ m_enableSleep = true;
+ m_pause = false;
+ m_singleStep = false;
+ }
+
+ void Save();
+ void Load();
+
+ int m_testIndex;
+ int m_windowWidth;
+ int m_windowHeight;
+ float m_hertz;
+ int m_velocityIterations;
+ int m_positionIterations;
+ bool m_drawShapes;
+ bool m_drawJoints;
+ bool m_drawAABBs;
+ bool m_drawContactPoints;
+ bool m_drawContactNormals;
+ bool m_drawContactImpulse;
+ bool m_drawFrictionImpulse;
+ bool m_drawCOMs;
+ bool m_drawStats;
+ bool m_drawProfile;
+ bool m_enableWarmStarting;
+ bool m_enableContinuous;
+ bool m_enableSubStepping;
+ bool m_enableSleep;
+ bool m_pause;
+ bool m_singleStep;
+};
diff --git a/Client/ThirdParty/Box2D/testbed/test.cpp b/Client/ThirdParty/Box2D/testbed/test.cpp
new file mode 100644
index 0000000..b871fa0
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/test.cpp
@@ -0,0 +1,469 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "settings.h"
+#include <stdio.h>
+
+void DestructionListener::SayGoodbye(b2Joint* joint)
+{
+ if (test->m_mouseJoint == joint)
+ {
+ test->m_mouseJoint = NULL;
+ }
+ else
+ {
+ test->JointDestroyed(joint);
+ }
+}
+
+Test::Test()
+{
+ b2Vec2 gravity;
+ gravity.Set(0.0f, -10.0f);
+ m_world = new b2World(gravity);
+ m_bomb = NULL;
+ m_textLine = 30;
+ m_textIncrement = 13;
+ m_mouseJoint = NULL;
+ m_pointCount = 0;
+
+ m_destructionListener.test = this;
+ m_world->SetDestructionListener(&m_destructionListener);
+ m_world->SetContactListener(this);
+ m_world->SetDebugDraw(&g_debugDraw);
+
+ m_bombSpawning = false;
+
+ m_stepCount = 0;
+
+ b2BodyDef bodyDef;
+ m_groundBody = m_world->CreateBody(&bodyDef);
+
+ memset(&m_maxProfile, 0, sizeof(b2Profile));
+ memset(&m_totalProfile, 0, sizeof(b2Profile));
+}
+
+Test::~Test()
+{
+ // By deleting the world, we delete the bomb, mouse joint, etc.
+ delete m_world;
+ m_world = NULL;
+}
+
+void Test::PreSolve(b2Contact* contact, const b2Manifold* oldManifold)
+{
+ const b2Manifold* manifold = contact->GetManifold();
+
+ if (manifold->pointCount == 0)
+ {
+ return;
+ }
+
+ b2Fixture* fixtureA = contact->GetFixtureA();
+ b2Fixture* fixtureB = contact->GetFixtureB();
+
+ b2PointState state1[b2_maxManifoldPoints], state2[b2_maxManifoldPoints];
+ b2GetPointStates(state1, state2, oldManifold, manifold);
+
+ b2WorldManifold worldManifold;
+ contact->GetWorldManifold(&worldManifold);
+
+ for (int32 i = 0; i < manifold->pointCount && m_pointCount < k_maxContactPoints; ++i)
+ {
+ ContactPoint* cp = m_points + m_pointCount;
+ cp->fixtureA = fixtureA;
+ cp->fixtureB = fixtureB;
+ cp->position = worldManifold.points[i];
+ cp->normal = worldManifold.normal;
+ cp->state = state2[i];
+ cp->normalImpulse = manifold->points[i].normalImpulse;
+ cp->tangentImpulse = manifold->points[i].tangentImpulse;
+ cp->separation = worldManifold.separations[i];
+ ++m_pointCount;
+ }
+}
+
+void Test::DrawTitle(const char *string)
+{
+ g_debugDraw.DrawString(5, 5, string);
+ m_textLine = int32(26.0f);
+}
+
+class QueryCallback : public b2QueryCallback
+{
+public:
+ QueryCallback(const b2Vec2& point)
+ {
+ m_point = point;
+ m_fixture = NULL;
+ }
+
+ bool ReportFixture(b2Fixture* fixture) override
+ {
+ b2Body* body = fixture->GetBody();
+ if (body->GetType() == b2_dynamicBody)
+ {
+ bool inside = fixture->TestPoint(m_point);
+ if (inside)
+ {
+ m_fixture = fixture;
+
+ // We are done, terminate the query.
+ return false;
+ }
+ }
+
+ // Continue the query.
+ return true;
+ }
+
+ b2Vec2 m_point;
+ b2Fixture* m_fixture;
+};
+
+void Test::MouseDown(const b2Vec2& p)
+{
+ m_mouseWorld = p;
+
+ if (m_mouseJoint != NULL)
+ {
+ return;
+ }
+
+ // Make a small box.
+ b2AABB aabb;
+ b2Vec2 d;
+ d.Set(0.001f, 0.001f);
+ aabb.lowerBound = p - d;
+ aabb.upperBound = p + d;
+
+ // Query the world for overlapping shapes.
+ QueryCallback callback(p);
+ m_world->QueryAABB(&callback, aabb);
+
+ if (callback.m_fixture)
+ {
+ float frequencyHz = 5.0f;
+ float dampingRatio = 0.7f;
+
+ b2Body* body = callback.m_fixture->GetBody();
+ b2MouseJointDef jd;
+ jd.bodyA = m_groundBody;
+ jd.bodyB = body;
+ jd.target = p;
+ jd.maxForce = 1000.0f * body->GetMass();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+
+ m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&jd);
+ body->SetAwake(true);
+ }
+}
+
+void Test::SpawnBomb(const b2Vec2& worldPt)
+{
+ m_bombSpawnPoint = worldPt;
+ m_bombSpawning = true;
+}
+
+void Test::CompleteBombSpawn(const b2Vec2& p)
+{
+ if (m_bombSpawning == false)
+ {
+ return;
+ }
+
+ const float multiplier = 30.0f;
+ b2Vec2 vel = m_bombSpawnPoint - p;
+ vel *= multiplier;
+ LaunchBomb(m_bombSpawnPoint,vel);
+ m_bombSpawning = false;
+}
+
+void Test::ShiftMouseDown(const b2Vec2& p)
+{
+ m_mouseWorld = p;
+
+ if (m_mouseJoint != NULL)
+ {
+ return;
+ }
+
+ SpawnBomb(p);
+}
+
+void Test::MouseUp(const b2Vec2& p)
+{
+ if (m_mouseJoint)
+ {
+ m_world->DestroyJoint(m_mouseJoint);
+ m_mouseJoint = NULL;
+ }
+
+ if (m_bombSpawning)
+ {
+ CompleteBombSpawn(p);
+ }
+}
+
+void Test::MouseMove(const b2Vec2& p)
+{
+ m_mouseWorld = p;
+
+ if (m_mouseJoint)
+ {
+ m_mouseJoint->SetTarget(p);
+ }
+}
+
+void Test::LaunchBomb()
+{
+ b2Vec2 p(RandomFloat(-15.0f, 15.0f), 30.0f);
+ b2Vec2 v = -5.0f * p;
+ LaunchBomb(p, v);
+}
+
+void Test::LaunchBomb(const b2Vec2& position, const b2Vec2& velocity)
+{
+ if (m_bomb)
+ {
+ m_world->DestroyBody(m_bomb);
+ m_bomb = NULL;
+ }
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = position;
+ bd.bullet = true;
+ m_bomb = m_world->CreateBody(&bd);
+ m_bomb->SetLinearVelocity(velocity);
+
+ b2CircleShape circle;
+ circle.m_radius = 0.3f;
+
+ b2FixtureDef fd;
+ fd.shape = &circle;
+ fd.density = 20.0f;
+ fd.restitution = 0.0f;
+
+ b2Vec2 minV = position - b2Vec2(0.3f,0.3f);
+ b2Vec2 maxV = position + b2Vec2(0.3f,0.3f);
+
+ b2AABB aabb;
+ aabb.lowerBound = minV;
+ aabb.upperBound = maxV;
+
+ m_bomb->CreateFixture(&fd);
+}
+
+void Test::Step(Settings& settings)
+{
+ float timeStep = settings.m_hertz > 0.0f ? 1.0f / settings.m_hertz : float(0.0f);
+
+ if (settings.m_pause)
+ {
+ if (settings.m_singleStep)
+ {
+ settings.m_singleStep = 0;
+ }
+ else
+ {
+ timeStep = 0.0f;
+ }
+
+ g_debugDraw.DrawString(5, m_textLine, "****PAUSED****");
+ m_textLine += m_textIncrement;
+ }
+
+ uint32 flags = 0;
+ flags += settings.m_drawShapes * b2Draw::e_shapeBit;
+ flags += settings.m_drawJoints * b2Draw::e_jointBit;
+ flags += settings.m_drawAABBs * b2Draw::e_aabbBit;
+ flags += settings.m_drawCOMs * b2Draw::e_centerOfMassBit;
+ g_debugDraw.SetFlags(flags);
+
+ m_world->SetAllowSleeping(settings.m_enableSleep);
+ m_world->SetWarmStarting(settings.m_enableWarmStarting);
+ m_world->SetContinuousPhysics(settings.m_enableContinuous);
+ m_world->SetSubStepping(settings.m_enableSubStepping);
+
+ m_pointCount = 0;
+
+ m_world->Step(timeStep, settings.m_velocityIterations, settings.m_positionIterations);
+
+ m_world->DebugDraw();
+ g_debugDraw.Flush();
+
+ if (timeStep > 0.0f)
+ {
+ ++m_stepCount;
+ }
+
+ if (settings.m_drawStats)
+ {
+ int32 bodyCount = m_world->GetBodyCount();
+ int32 contactCount = m_world->GetContactCount();
+ int32 jointCount = m_world->GetJointCount();
+ g_debugDraw.DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", bodyCount, contactCount, jointCount);
+ m_textLine += m_textIncrement;
+
+ int32 proxyCount = m_world->GetProxyCount();
+ int32 height = m_world->GetTreeHeight();
+ int32 balance = m_world->GetTreeBalance();
+ float quality = m_world->GetTreeQuality();
+ g_debugDraw.DrawString(5, m_textLine, "proxies/height/balance/quality = %d/%d/%d/%g", proxyCount, height, balance, quality);
+ m_textLine += m_textIncrement;
+ }
+
+ // Track maximum profile times
+ {
+ const b2Profile& p = m_world->GetProfile();
+ m_maxProfile.step = b2Max(m_maxProfile.step, p.step);
+ m_maxProfile.collide = b2Max(m_maxProfile.collide, p.collide);
+ m_maxProfile.solve = b2Max(m_maxProfile.solve, p.solve);
+ m_maxProfile.solveInit = b2Max(m_maxProfile.solveInit, p.solveInit);
+ m_maxProfile.solveVelocity = b2Max(m_maxProfile.solveVelocity, p.solveVelocity);
+ m_maxProfile.solvePosition = b2Max(m_maxProfile.solvePosition, p.solvePosition);
+ m_maxProfile.solveTOI = b2Max(m_maxProfile.solveTOI, p.solveTOI);
+ m_maxProfile.broadphase = b2Max(m_maxProfile.broadphase, p.broadphase);
+
+ m_totalProfile.step += p.step;
+ m_totalProfile.collide += p.collide;
+ m_totalProfile.solve += p.solve;
+ m_totalProfile.solveInit += p.solveInit;
+ m_totalProfile.solveVelocity += p.solveVelocity;
+ m_totalProfile.solvePosition += p.solvePosition;
+ m_totalProfile.solveTOI += p.solveTOI;
+ m_totalProfile.broadphase += p.broadphase;
+ }
+
+ if (settings.m_drawProfile)
+ {
+ const b2Profile& p = m_world->GetProfile();
+
+ b2Profile aveProfile;
+ memset(&aveProfile, 0, sizeof(b2Profile));
+ if (m_stepCount > 0)
+ {
+ float scale = 1.0f / m_stepCount;
+ aveProfile.step = scale * m_totalProfile.step;
+ aveProfile.collide = scale * m_totalProfile.collide;
+ aveProfile.solve = scale * m_totalProfile.solve;
+ aveProfile.solveInit = scale * m_totalProfile.solveInit;
+ aveProfile.solveVelocity = scale * m_totalProfile.solveVelocity;
+ aveProfile.solvePosition = scale * m_totalProfile.solvePosition;
+ aveProfile.solveTOI = scale * m_totalProfile.solveTOI;
+ aveProfile.broadphase = scale * m_totalProfile.broadphase;
+ }
+
+ g_debugDraw.DrawString(5, m_textLine, "step [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.step, aveProfile.step, m_maxProfile.step);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "collide [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.collide, aveProfile.collide, m_maxProfile.collide);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "solve [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solve, aveProfile.solve, m_maxProfile.solve);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "solve init [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveInit, aveProfile.solveInit, m_maxProfile.solveInit);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "solve velocity [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveVelocity, aveProfile.solveVelocity, m_maxProfile.solveVelocity);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "solve position [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solvePosition, aveProfile.solvePosition, m_maxProfile.solvePosition);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "solveTOI [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.solveTOI, aveProfile.solveTOI, m_maxProfile.solveTOI);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "broad-phase [ave] (max) = %5.2f [%6.2f] (%6.2f)", p.broadphase, aveProfile.broadphase, m_maxProfile.broadphase);
+ m_textLine += m_textIncrement;
+ }
+
+ if (m_bombSpawning)
+ {
+ b2Color c;
+ c.Set(0.0f, 0.0f, 1.0f);
+ g_debugDraw.DrawPoint(m_bombSpawnPoint, 4.0f, c);
+
+ c.Set(0.8f, 0.8f, 0.8f);
+ g_debugDraw.DrawSegment(m_mouseWorld, m_bombSpawnPoint, c);
+ }
+
+ if (settings.m_drawContactPoints)
+ {
+ const float k_impulseScale = 0.1f;
+ const float k_axisScale = 0.3f;
+
+ for (int32 i = 0; i < m_pointCount; ++i)
+ {
+ ContactPoint* point = m_points + i;
+
+ if (point->state == b2_addState)
+ {
+ // Add
+ g_debugDraw.DrawPoint(point->position, 10.0f, b2Color(0.3f, 0.95f, 0.3f));
+ }
+ else if (point->state == b2_persistState)
+ {
+ // Persist
+ g_debugDraw.DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f));
+ }
+
+ if (settings.m_drawContactNormals == 1)
+ {
+ b2Vec2 p1 = point->position;
+ b2Vec2 p2 = p1 + k_axisScale * point->normal;
+ g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.9f));
+ }
+ else if (settings.m_drawContactImpulse == 1)
+ {
+ b2Vec2 p1 = point->position;
+ b2Vec2 p2 = p1 + k_impulseScale * point->normalImpulse * point->normal;
+ g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f));
+ }
+
+ if (settings.m_drawFrictionImpulse == 1)
+ {
+ b2Vec2 tangent = b2Cross(point->normal, 1.0f);
+ b2Vec2 p1 = point->position;
+ b2Vec2 p2 = p1 + k_impulseScale * point->tangentImpulse * tangent;
+ g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f));
+ }
+ }
+ }
+}
+
+void Test::ShiftOrigin(const b2Vec2& newOrigin)
+{
+ m_world->ShiftOrigin(newOrigin);
+}
+
+TestEntry g_testEntries[MAX_TESTS] = { {nullptr} };
+int g_testCount = 0;
+
+int RegisterTest(const char* category, const char* name, TestCreateFcn* fcn)
+{
+ int index = g_testCount;
+ if (index < MAX_TESTS)
+ {
+ g_testEntries[index] = { category, name, fcn };
+ ++g_testCount;
+ return index;
+ }
+
+ return -1;
+}
diff --git a/Client/ThirdParty/Box2D/testbed/test.h b/Client/ThirdParty/Box2D/testbed/test.h
new file mode 100644
index 0000000..d4f36c7
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/test.h
@@ -0,0 +1,156 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#ifndef TEST_H
+#define TEST_H
+
+#include "box2d/box2d.h"
+#include "draw.h"
+
+#include <stdlib.h>
+
+struct Settings;
+class Test;
+
+#define RAND_LIMIT 32767
+
+/// Random number in range [-1,1]
+inline float RandomFloat()
+{
+ float r = (float)(rand() & (RAND_LIMIT));
+ r /= RAND_LIMIT;
+ r = 2.0f * r - 1.0f;
+ return r;
+}
+
+/// Random floating point number in range [lo, hi]
+inline float RandomFloat(float lo, float hi)
+{
+ float r = (float)(rand() & (RAND_LIMIT));
+ r /= RAND_LIMIT;
+ r = (hi - lo) * r + lo;
+ return r;
+}
+
+// This is called when a joint in the world is implicitly destroyed
+// because an attached body is destroyed. This gives us a chance to
+// nullify the mouse joint.
+class DestructionListener : public b2DestructionListener
+{
+public:
+ void SayGoodbye(b2Fixture* fixture) override { B2_NOT_USED(fixture); }
+ void SayGoodbye(b2Joint* joint) override;
+
+ Test* test;
+};
+
+const int32 k_maxContactPoints = 2048;
+
+struct ContactPoint
+{
+ b2Fixture* fixtureA;
+ b2Fixture* fixtureB;
+ b2Vec2 normal;
+ b2Vec2 position;
+ b2PointState state;
+ float normalImpulse;
+ float tangentImpulse;
+ float separation;
+};
+
+class Test : public b2ContactListener
+{
+public:
+
+ Test();
+ virtual ~Test();
+
+ void DrawTitle(const char* string);
+ virtual void Step(Settings& settings);
+ virtual void UpdateUI() {}
+ virtual void Keyboard(int key) { B2_NOT_USED(key); }
+ virtual void KeyboardUp(int key) { B2_NOT_USED(key); }
+ void ShiftMouseDown(const b2Vec2& p);
+ virtual void MouseDown(const b2Vec2& p);
+ virtual void MouseUp(const b2Vec2& p);
+ virtual void MouseMove(const b2Vec2& p);
+ void LaunchBomb();
+ void LaunchBomb(const b2Vec2& position, const b2Vec2& velocity);
+
+ void SpawnBomb(const b2Vec2& worldPt);
+ void CompleteBombSpawn(const b2Vec2& p);
+
+ // Let derived tests know that a joint was destroyed.
+ virtual void JointDestroyed(b2Joint* joint) { B2_NOT_USED(joint); }
+
+ // Callbacks for derived classes.
+ virtual void BeginContact(b2Contact* contact) override { B2_NOT_USED(contact); }
+ virtual void EndContact(b2Contact* contact) override { B2_NOT_USED(contact); }
+ virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override;
+ virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) override
+ {
+ B2_NOT_USED(contact);
+ B2_NOT_USED(impulse);
+ }
+
+ void ShiftOrigin(const b2Vec2& newOrigin);
+
+protected:
+ friend class DestructionListener;
+ friend class BoundaryListener;
+ friend class ContactListener;
+
+ b2Body* m_groundBody;
+ b2AABB m_worldAABB;
+ ContactPoint m_points[k_maxContactPoints];
+ int32 m_pointCount;
+ DestructionListener m_destructionListener;
+ int32 m_textLine;
+ b2World* m_world;
+ b2Body* m_bomb;
+ b2MouseJoint* m_mouseJoint;
+ b2Vec2 m_bombSpawnPoint;
+ bool m_bombSpawning;
+ b2Vec2 m_mouseWorld;
+ int32 m_stepCount;
+ int32 m_textIncrement;
+ b2Profile m_maxProfile;
+ b2Profile m_totalProfile;
+};
+
+typedef Test* TestCreateFcn();
+
+int RegisterTest(const char* category, const char* name, TestCreateFcn* fcn);
+
+//
+struct TestEntry
+{
+ const char* category;
+ const char* name;
+ TestCreateFcn* createFcn;
+};
+
+#define MAX_TESTS 256
+extern TestEntry g_testEntries[MAX_TESTS];
+extern int g_testCount;
+
+#endif
diff --git a/Client/ThirdParty/Box2D/testbed/tests/add_pair.cpp b/Client/ThirdParty/Box2D/testbed/tests/add_pair.cpp
new file mode 100644
index 0000000..ceccbf8
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/add_pair.cpp
@@ -0,0 +1,71 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class AddPair : public Test
+{
+public:
+
+ AddPair()
+ {
+ m_world->SetGravity(b2Vec2(0.0f,0.0f));
+ {
+ b2CircleShape shape;
+ shape.m_p.SetZero();
+ shape.m_radius = 0.1f;
+
+ float minX = -6.0f;
+ float maxX = 0.0f;
+ float minY = 4.0f;
+ float maxY = 6.0f;
+
+ for (int32 i = 0; i < 400; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = b2Vec2(RandomFloat(minX,maxX),RandomFloat(minY,maxY));
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 0.01f);
+ }
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(1.5f, 1.5f);
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-40.0f,5.0f);
+ bd.bullet = true;
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 1.0f);
+ body->SetLinearVelocity(b2Vec2(10.0f, 0.0f));
+ }
+ }
+
+ static Test* Create()
+ {
+ return new AddPair;
+ }
+};
+
+static int testIndex = RegisterTest("Benchmark", "Add Pair", AddPair::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/apply_force.cpp b/Client/ThirdParty/Box2D/testbed/tests/apply_force.cpp
new file mode 100644
index 0000000..65d8094
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/apply_force.cpp
@@ -0,0 +1,203 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// This test shows how to apply forces and torques to a body.
+// It also shows how to use the friction joint that can be useful
+// for overhead games.
+class ApplyForce : public Test
+{
+public:
+ ApplyForce()
+ {
+ m_world->SetGravity(b2Vec2(0.0f, 0.0f));
+
+ const float k_restitution = 0.4f;
+
+ b2Body* ground;
+ {
+ b2BodyDef bd;
+ bd.position.Set(0.0f, 20.0f);
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+
+ b2FixtureDef sd;
+ sd.shape = &shape;
+ sd.density = 0.0f;
+ sd.restitution = k_restitution;
+
+ // Left vertical
+ shape.SetTwoSided(b2Vec2(-20.0f, -20.0f), b2Vec2(-20.0f, 20.0f));
+ ground->CreateFixture(&sd);
+
+ // Right vertical
+ shape.SetTwoSided(b2Vec2(20.0f, -20.0f), b2Vec2(20.0f, 20.0f));
+ ground->CreateFixture(&sd);
+
+ // Top horizontal
+ shape.SetTwoSided(b2Vec2(-20.0f, 20.0f), b2Vec2(20.0f, 20.0f));
+ ground->CreateFixture(&sd);
+
+ // Bottom horizontal
+ shape.SetTwoSided(b2Vec2(-20.0f, -20.0f), b2Vec2(20.0f, -20.0f));
+ ground->CreateFixture(&sd);
+ }
+
+ {
+ b2Transform xf1;
+ xf1.q.Set(0.3524f * b2_pi);
+ xf1.p = xf1.q.GetXAxis();
+
+ b2Vec2 vertices[3];
+ vertices[0] = b2Mul(xf1, b2Vec2(-1.0f, 0.0f));
+ vertices[1] = b2Mul(xf1, b2Vec2(1.0f, 0.0f));
+ vertices[2] = b2Mul(xf1, b2Vec2(0.0f, 0.5f));
+
+ b2PolygonShape poly1;
+ poly1.Set(vertices, 3);
+
+ b2FixtureDef sd1;
+ sd1.shape = &poly1;
+ sd1.density = 2.0f;
+
+ b2Transform xf2;
+ xf2.q.Set(-0.3524f * b2_pi);
+ xf2.p = -xf2.q.GetXAxis();
+
+ vertices[0] = b2Mul(xf2, b2Vec2(-1.0f, 0.0f));
+ vertices[1] = b2Mul(xf2, b2Vec2(1.0f, 0.0f));
+ vertices[2] = b2Mul(xf2, b2Vec2(0.0f, 0.5f));
+
+ b2PolygonShape poly2;
+ poly2.Set(vertices, 3);
+
+ b2FixtureDef sd2;
+ sd2.shape = &poly2;
+ sd2.density = 2.0f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ bd.position.Set(0.0f, 3.0);
+ bd.angle = b2_pi;
+ bd.allowSleep = false;
+ m_body = m_world->CreateBody(&bd);
+ m_body->CreateFixture(&sd1);
+ m_body->CreateFixture(&sd2);
+
+ float gravity = 10.0f;
+ float I = m_body->GetInertia();
+ float mass = m_body->GetMass();
+
+ // Compute an effective radius that can be used to
+ // set the max torque for a friction joint
+ // For a circle: I = 0.5 * m * r * r ==> r = sqrt(2 * I / m)
+ float radius = b2Sqrt(2.0f * I / mass);
+
+ b2FrictionJointDef jd;
+ jd.bodyA = ground;
+ jd.bodyB = m_body;
+ jd.localAnchorA.SetZero();
+ jd.localAnchorB = m_body->GetLocalCenter();
+ jd.collideConnected = true;
+ jd.maxForce = 0.5f * mass * gravity;
+ jd.maxTorque = 0.2f * mass * radius * gravity;
+
+ m_world->CreateJoint(&jd);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+ fd.friction = 0.3f;
+
+ for (int i = 0; i < 10; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ bd.position.Set(0.0f, 7.0f + 1.54f * i);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ body->CreateFixture(&fd);
+
+ float gravity = 10.0f;
+ float I = body->GetInertia();
+ float mass = body->GetMass();
+
+ // For a circle: I = 0.5 * m * r * r ==> r = sqrt(2 * I / m)
+ float radius = b2Sqrt(2.0f * I / mass);
+
+ b2FrictionJointDef jd;
+ jd.localAnchorA.SetZero();
+ jd.localAnchorB.SetZero();
+ jd.bodyA = ground;
+ jd.bodyB = body;
+ jd.collideConnected = true;
+ jd.maxForce = mass * gravity;
+ jd.maxTorque = 0.1f * mass * radius * gravity;
+
+ m_world->CreateJoint(&jd);
+ }
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ g_debugDraw.DrawString(5, m_textLine, "Forward (W), Turn (A) and (D)");
+ m_textLine += m_textIncrement;
+
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_W) == GLFW_PRESS)
+ {
+ b2Vec2 f = m_body->GetWorldVector(b2Vec2(0.0f, -50.0f));
+ b2Vec2 p = m_body->GetWorldPoint(b2Vec2(0.0f, 3.0f));
+ m_body->ApplyForce(f, p, true);
+ }
+
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_A) == GLFW_PRESS)
+ {
+ m_body->ApplyTorque(10.0f, true);
+ }
+
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_D) == GLFW_PRESS)
+ {
+ m_body->ApplyTorque(-10.0f, true);
+ }
+
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new ApplyForce;
+ }
+
+ b2Body* m_body;
+};
+
+static int testIndex = RegisterTest("Forces", "Apply Force", ApplyForce::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/body_types.cpp b/Client/ThirdParty/Box2D/testbed/tests/body_types.cpp
new file mode 100644
index 0000000..279ae39
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/body_types.cpp
@@ -0,0 +1,163 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class BodyTypes : public Test
+{
+public:
+ BodyTypes()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+
+ ground->CreateFixture(&fd);
+ }
+
+ // Define attachment
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 3.0f);
+ m_attachment = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 2.0f);
+ m_attachment->CreateFixture(&shape, 2.0f);
+ }
+
+ // Define platform
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-4.0f, 5.0f);
+ m_platform = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 4.0f, b2Vec2(4.0f, 0.0f), 0.5f * b2_pi);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.friction = 0.6f;
+ fd.density = 2.0f;
+ m_platform->CreateFixture(&fd);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(m_attachment, m_platform, b2Vec2(0.0f, 5.0f));
+ rjd.maxMotorTorque = 50.0f;
+ rjd.enableMotor = true;
+ m_world->CreateJoint(&rjd);
+
+ b2PrismaticJointDef pjd;
+ pjd.Initialize(ground, m_platform, b2Vec2(0.0f, 5.0f), b2Vec2(1.0f, 0.0f));
+
+ pjd.maxMotorForce = 1000.0f;
+ pjd.enableMotor = true;
+ pjd.lowerTranslation = -10.0f;
+ pjd.upperTranslation = 10.0f;
+ pjd.enableLimit = true;
+
+ m_world->CreateJoint(&pjd);
+
+ m_speed = 3.0f;
+ }
+
+ // Create a payload
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 8.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.75f, 0.75f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.friction = 0.6f;
+ fd.density = 2.0f;
+
+ body->CreateFixture(&fd);
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_D:
+ m_platform->SetType(b2_dynamicBody);
+ break;
+
+ case GLFW_KEY_S:
+ m_platform->SetType(b2_staticBody);
+ break;
+
+ case GLFW_KEY_K:
+ m_platform->SetType(b2_kinematicBody);
+ m_platform->SetLinearVelocity(b2Vec2(-m_speed, 0.0f));
+ m_platform->SetAngularVelocity(0.0f);
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ // Drive the kinematic body.
+ if (m_platform->GetType() == b2_kinematicBody)
+ {
+ b2Vec2 p = m_platform->GetTransform().p;
+ b2Vec2 v = m_platform->GetLinearVelocity();
+
+ if ((p.x < -10.0f && v.x < 0.0f) ||
+ (p.x > 10.0f && v.x > 0.0f))
+ {
+ v.x = -v.x;
+ m_platform->SetLinearVelocity(v);
+ }
+ }
+
+ Test::Step(settings);
+
+ g_debugDraw.DrawString(5, m_textLine, "Keys: (d) dynamic, (s) static, (k) kinematic");
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new BodyTypes;
+ }
+
+ b2Body* m_attachment;
+ b2Body* m_platform;
+ float m_speed;
+};
+
+static int testIndex = RegisterTest("Examples", "Body Types", BodyTypes::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/box_stack.cpp b/Client/ThirdParty/Box2D/testbed/tests/box_stack.cpp
new file mode 100644
index 0000000..db9fec5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/box_stack.cpp
@@ -0,0 +1,174 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+extern B2_API bool g_blockSolve;
+
+class BoxStack : public Test
+{
+public:
+
+ enum
+ {
+ e_columnCount = 1,
+ e_rowCount = 15
+ //e_columnCount = 1,
+ //e_rowCount = 1
+ };
+
+ BoxStack()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(b2Vec2(20.0f, 0.0f), b2Vec2(20.0f, 20.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ float xs[5] = {0.0f, -10.0f, -5.0f, 5.0f, 10.0f};
+
+ for (int32 j = 0; j < e_columnCount; ++j)
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+ fd.friction = 0.3f;
+
+ for (int i = 0; i < e_rowCount; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ int32 n = j * e_rowCount + i;
+ b2Assert(n < e_rowCount * e_columnCount);
+ m_indices[n] = n;
+ bd.userData.pointer = n;
+
+ float x = 0.0f;
+ //float x = RandomFloat(-0.02f, 0.02f);
+ //float x = i % 2 == 0 ? -0.01f : 0.01f;
+ bd.position.Set(xs[j] + x, 0.55f + 1.1f * i);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ m_bodies[n] = body;
+
+ body->CreateFixture(&fd);
+ }
+ }
+
+ m_bullet = NULL;
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_COMMA:
+ if (m_bullet != NULL)
+ {
+ m_world->DestroyBody(m_bullet);
+ m_bullet = NULL;
+ }
+
+ {
+ b2CircleShape shape;
+ shape.m_radius = 0.25f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ fd.restitution = 0.05f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.bullet = true;
+ bd.position.Set(-31.0f, 5.0f);
+
+ m_bullet = m_world->CreateBody(&bd);
+ m_bullet->CreateFixture(&fd);
+
+ m_bullet->SetLinearVelocity(b2Vec2(400.0f, 0.0f));
+ }
+ break;
+
+ case GLFW_KEY_B:
+ g_blockSolve = !g_blockSolve;
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "Press: (,) to launch a bullet.");
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "Blocksolve = %d", g_blockSolve);
+ //if (m_stepCount == 300)
+ //{
+ // if (m_bullet != NULL)
+ // {
+ // m_world->DestroyBody(m_bullet);
+ // m_bullet = NULL;
+ // }
+
+ // {
+ // b2CircleShape shape;
+ // shape.m_radius = 0.25f;
+
+ // b2FixtureDef fd;
+ // fd.shape = &shape;
+ // fd.density = 20.0f;
+ // fd.restitution = 0.05f;
+
+ // b2BodyDef bd;
+ // bd.type = b2_dynamicBody;
+ // bd.bullet = true;
+ // bd.position.Set(-31.0f, 5.0f);
+
+ // m_bullet = m_world->CreateBody(&bd);
+ // m_bullet->CreateFixture(&fd);
+
+ // m_bullet->SetLinearVelocity(b2Vec2(400.0f, 0.0f));
+ // }
+ //}
+ }
+
+ static Test* Create()
+ {
+ return new BoxStack;
+ }
+
+ b2Body* m_bullet;
+ b2Body* m_bodies[e_rowCount * e_columnCount];
+ int32 m_indices[e_rowCount * e_columnCount];
+};
+
+static int testIndex = RegisterTest("Stacking", "Boxes", BoxStack::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/breakable.cpp b/Client/ThirdParty/Box2D/testbed/tests/breakable.cpp
new file mode 100644
index 0000000..136244a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/breakable.cpp
@@ -0,0 +1,158 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// This is used to test sensor shapes.
+class Breakable : public Test
+{
+public:
+
+ enum
+ {
+ e_count = 7
+ };
+
+ Breakable()
+ {
+ // Ground body
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Breakable dynamic body
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 40.0f);
+ bd.angle = 0.25f * b2_pi;
+ m_body1 = m_world->CreateBody(&bd);
+
+ m_shape1.SetAsBox(0.5f, 0.5f, b2Vec2(-0.5f, 0.0f), 0.0f);
+ m_piece1 = m_body1->CreateFixture(&m_shape1, 1.0f);
+
+ m_shape2.SetAsBox(0.5f, 0.5f, b2Vec2(0.5f, 0.0f), 0.0f);
+ m_piece2 = m_body1->CreateFixture(&m_shape2, 1.0f);
+ }
+
+ m_break = false;
+ m_broke = false;
+ }
+
+ void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) override
+ {
+ if (m_broke)
+ {
+ // The body already broke.
+ return;
+ }
+
+ // Should the body break?
+ int32 count = contact->GetManifold()->pointCount;
+
+ float maxImpulse = 0.0f;
+ for (int32 i = 0; i < count; ++i)
+ {
+ maxImpulse = b2Max(maxImpulse, impulse->normalImpulses[i]);
+ }
+
+ if (maxImpulse > 40.0f)
+ {
+ // Flag the body for breaking.
+ m_break = true;
+ }
+ }
+
+ void Break()
+ {
+ // Create two bodies from one.
+ b2Body* body1 = m_piece1->GetBody();
+ b2Vec2 center = body1->GetWorldCenter();
+
+ body1->DestroyFixture(m_piece2);
+ m_piece2 = NULL;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = body1->GetPosition();
+ bd.angle = body1->GetAngle();
+
+ b2Body* body2 = m_world->CreateBody(&bd);
+ m_piece2 = body2->CreateFixture(&m_shape2, 1.0f);
+
+ // Compute consistent velocities for new bodies based on
+ // cached velocity.
+ b2Vec2 center1 = body1->GetWorldCenter();
+ b2Vec2 center2 = body2->GetWorldCenter();
+
+ b2Vec2 velocity1 = m_velocity + b2Cross(m_angularVelocity, center1 - center);
+ b2Vec2 velocity2 = m_velocity + b2Cross(m_angularVelocity, center2 - center);
+
+ body1->SetAngularVelocity(m_angularVelocity);
+ body1->SetLinearVelocity(velocity1);
+
+ body2->SetAngularVelocity(m_angularVelocity);
+ body2->SetLinearVelocity(velocity2);
+ }
+
+ void Step(Settings& settings) override
+ {
+ if (m_break)
+ {
+ Break();
+ m_broke = true;
+ m_break = false;
+ }
+
+ // Cache velocities to improve movement on breakage.
+ if (m_broke == false)
+ {
+ m_velocity = m_body1->GetLinearVelocity();
+ m_angularVelocity = m_body1->GetAngularVelocity();
+ }
+
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new Breakable;
+ }
+
+ b2Body* m_body1;
+ b2Vec2 m_velocity;
+ float m_angularVelocity;
+ b2PolygonShape m_shape1;
+ b2PolygonShape m_shape2;
+ b2Fixture* m_piece1;
+ b2Fixture* m_piece2;
+
+ bool m_broke;
+ bool m_break;
+};
+
+static int testIndex = RegisterTest("Examples", "Breakable", Breakable::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/bridge.cpp b/Client/ThirdParty/Box2D/testbed/tests/bridge.cpp
new file mode 100644
index 0000000..d397a60
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/bridge.cpp
@@ -0,0 +1,128 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Bridge : public Test
+{
+public:
+
+ enum
+ {
+ e_count = 30
+ };
+
+ Bridge()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ fd.friction = 0.2f;
+
+ b2RevoluteJointDef jd;
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-14.5f + 1.0f * i, 5.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+
+ b2Vec2 anchor(-15.0f + 1.0f * i, 5.0f);
+ jd.Initialize(prevBody, body, anchor);
+ m_world->CreateJoint(&jd);
+
+ if (i == (e_count >> 1))
+ {
+ m_middle = body;
+ }
+ prevBody = body;
+ }
+
+ b2Vec2 anchor(-15.0f + 1.0f * e_count, 5.0f);
+ jd.Initialize(prevBody, ground, anchor);
+ m_world->CreateJoint(&jd);
+ }
+
+ for (int32 i = 0; i < 2; ++i)
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.5f, 0.0f);
+ vertices[1].Set(0.5f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+
+ b2PolygonShape shape;
+ shape.Set(vertices, 3);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-8.0f + 8.0f * i, 12.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+ }
+
+ for (int32 i = 0; i < 3; ++i)
+ {
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-6.0f + 6.0f * i, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Bridge;
+ }
+
+ b2Body* m_middle;
+};
+
+static int testIndex = RegisterTest("Joints", "Bridge", Bridge::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/bullet_test.cpp b/Client/ThirdParty/Box2D/testbed/tests/bullet_test.cpp
new file mode 100644
index 0000000..9ddd733
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/bullet_test.cpp
@@ -0,0 +1,139 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class BulletTest : public Test
+{
+public:
+
+ BulletTest()
+ {
+ {
+ b2BodyDef bd;
+ bd.position.Set(0.0f, 0.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2EdgeShape edge;
+
+ edge.SetTwoSided(b2Vec2(-10.0f, 0.0f), b2Vec2(10.0f, 0.0f));
+ body->CreateFixture(&edge, 0.0f);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.2f, 1.0f, b2Vec2(0.5f, 1.0f), 0.0f);
+ body->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 4.0f);
+
+ b2PolygonShape box;
+ box.SetAsBox(2.0f, 0.1f);
+
+ m_body = m_world->CreateBody(&bd);
+ m_body->CreateFixture(&box, 1.0f);
+
+ box.SetAsBox(0.25f, 0.25f);
+
+ //m_x = RandomFloat(-1.0f, 1.0f);
+ m_x = 0.20352793f;
+ bd.position.Set(m_x, 10.0f);
+ bd.bullet = true;
+
+ m_bullet = m_world->CreateBody(&bd);
+ m_bullet->CreateFixture(&box, 100.0f);
+
+ m_bullet->SetLinearVelocity(b2Vec2(0.0f, -50.0f));
+ }
+ }
+
+ void Launch()
+ {
+ m_body->SetTransform(b2Vec2(0.0f, 4.0f), 0.0f);
+ m_body->SetLinearVelocity(b2Vec2_zero);
+ m_body->SetAngularVelocity(0.0f);
+
+ m_x = RandomFloat(-1.0f, 1.0f);
+ m_bullet->SetTransform(b2Vec2(m_x, 10.0f), 0.0f);
+ m_bullet->SetLinearVelocity(b2Vec2(0.0f, -50.0f));
+ m_bullet->SetAngularVelocity(0.0f);
+
+ extern B2_API int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
+ extern B2_API int32 b2_toiCalls, b2_toiIters, b2_toiMaxIters;
+ extern B2_API int32 b2_toiRootIters, b2_toiMaxRootIters;
+
+ b2_gjkCalls = 0;
+ b2_gjkIters = 0;
+ b2_gjkMaxIters = 0;
+
+ b2_toiCalls = 0;
+ b2_toiIters = 0;
+ b2_toiMaxIters = 0;
+ b2_toiRootIters = 0;
+ b2_toiMaxRootIters = 0;
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ extern B2_API int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
+ extern B2_API int32 b2_toiCalls, b2_toiIters;
+ extern B2_API int32 b2_toiRootIters, b2_toiMaxRootIters;
+
+ if (b2_gjkCalls > 0)
+ {
+ g_debugDraw.DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d",
+ b2_gjkCalls, b2_gjkIters / float(b2_gjkCalls), b2_gjkMaxIters);
+ m_textLine += m_textIncrement;
+ }
+
+ if (b2_toiCalls > 0)
+ {
+ g_debugDraw.DrawString(5, m_textLine, "toi calls = %d, ave toi iters = %3.1f, max toi iters = %d",
+ b2_toiCalls, b2_toiIters / float(b2_toiCalls), b2_toiMaxRootIters);
+ m_textLine += m_textIncrement;
+
+ g_debugDraw.DrawString(5, m_textLine, "ave toi root iters = %3.1f, max toi root iters = %d",
+ b2_toiRootIters / float(b2_toiCalls), b2_toiMaxRootIters);
+ m_textLine += m_textIncrement;
+ }
+
+ if (m_stepCount % 60 == 0)
+ {
+ Launch();
+ }
+ }
+
+ static Test* Create()
+ {
+ return new BulletTest;
+ }
+
+ b2Body* m_body;
+ b2Body* m_bullet;
+ float m_x;
+};
+
+static int testIndex = RegisterTest("Continuous", "Bullet Test", BulletTest::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/cantilever.cpp b/Client/ThirdParty/Box2D/testbed/tests/cantilever.cpp
new file mode 100644
index 0000000..e54717b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/cantilever.cpp
@@ -0,0 +1,218 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// It is difficult to make a cantilever made of links completely rigid with weld joints.
+// You will have to use a high number of iterations to make them stiff.
+// So why not go ahead and use soft weld joints? They behave like a revolute
+// joint with a rotational spring.
+class Cantilever : public Test
+{
+public:
+
+ enum
+ {
+ e_count = 8
+ };
+
+ Cantilever()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+
+ b2WeldJointDef jd;
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-14.5f + 1.0f * i, 5.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+
+ b2Vec2 anchor(-15.0f + 1.0f * i, 5.0f);
+ jd.Initialize(prevBody, body, anchor);
+ m_world->CreateJoint(&jd);
+
+ prevBody = body;
+ }
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(1.0f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+
+ b2WeldJointDef jd;
+ float frequencyHz = 5.0f;
+ float dampingRatio = 0.7f;
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < 3; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-14.0f + 2.0f * i, 15.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+
+ b2Vec2 anchor(-15.0f + 2.0f * i, 15.0f);
+ jd.Initialize(prevBody, body, anchor);
+ b2AngularStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_world->CreateJoint(&jd);
+
+ prevBody = body;
+ }
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+
+ b2WeldJointDef jd;
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-4.5f + 1.0f * i, 5.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+
+ if (i > 0)
+ {
+ b2Vec2 anchor(-5.0f + 1.0f * i, 5.0f);
+ jd.Initialize(prevBody, body, anchor);
+ m_world->CreateJoint(&jd);
+ }
+
+ prevBody = body;
+ }
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+
+ b2WeldJointDef jd;
+ float frequencyHz = 8.0f;
+ float dampingRatio = 0.7f;
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(5.5f + 1.0f * i, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+
+ if (i > 0)
+ {
+ b2Vec2 anchor(5.0f + 1.0f * i, 10.0f);
+ jd.Initialize(prevBody, body, anchor);
+
+ b2AngularStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, prevBody, body);
+
+ m_world->CreateJoint(&jd);
+ }
+
+ prevBody = body;
+ }
+ }
+
+ for (int32 i = 0; i < 2; ++i)
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.5f, 0.0f);
+ vertices[1].Set(0.5f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+
+ b2PolygonShape shape;
+ shape.Set(vertices, 3);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-8.0f + 8.0f * i, 12.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+ }
+
+ for (int32 i = 0; i < 2; ++i)
+ {
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-6.0f + 6.0f * i, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Cantilever;
+ }
+
+ b2Body* m_middle;
+};
+
+static int testIndex = RegisterTest("Joints", "Cantilever", Cantilever::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/car.cpp b/Client/ThirdParty/Box2D/testbed/tests/car.cpp
new file mode 100644
index 0000000..06a9b65
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/car.cpp
@@ -0,0 +1,284 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// This is a fun demo that shows off the wheel joint
+class Car : public Test
+{
+public:
+ Car()
+ {
+ m_speed = 50.0f;
+
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 0.0f;
+ fd.friction = 0.6f;
+
+ shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
+ ground->CreateFixture(&fd);
+
+ float hs[10] = {0.25f, 1.0f, 4.0f, 0.0f, 0.0f, -1.0f, -2.0f, -2.0f, -1.25f, 0.0f};
+
+ float x = 20.0f, y1 = 0.0f, dx = 5.0f;
+
+ for (int32 i = 0; i < 10; ++i)
+ {
+ float y2 = hs[i];
+ shape.SetTwoSided(b2Vec2(x, y1), b2Vec2(x + dx, y2));
+ ground->CreateFixture(&fd);
+ y1 = y2;
+ x += dx;
+ }
+
+ for (int32 i = 0; i < 10; ++i)
+ {
+ float y2 = hs[i];
+ shape.SetTwoSided(b2Vec2(x, y1), b2Vec2(x + dx, y2));
+ ground->CreateFixture(&fd);
+ y1 = y2;
+ x += dx;
+ }
+
+ shape.SetTwoSided(b2Vec2(x, 0.0f), b2Vec2(x + 40.0f, 0.0f));
+ ground->CreateFixture(&fd);
+
+ x += 80.0f;
+ shape.SetTwoSided(b2Vec2(x, 0.0f), b2Vec2(x + 40.0f, 0.0f));
+ ground->CreateFixture(&fd);
+
+ x += 40.0f;
+ shape.SetTwoSided(b2Vec2(x, 0.0f), b2Vec2(x + 10.0f, 5.0f));
+ ground->CreateFixture(&fd);
+
+ x += 20.0f;
+ shape.SetTwoSided(b2Vec2(x, 0.0f), b2Vec2(x + 40.0f, 0.0f));
+ ground->CreateFixture(&fd);
+
+ x += 40.0f;
+ shape.SetTwoSided(b2Vec2(x, 0.0f), b2Vec2(x, 20.0f));
+ ground->CreateFixture(&fd);
+ }
+
+ // Teeter
+ {
+ b2BodyDef bd;
+ bd.position.Set(140.0f, 1.0f);
+ bd.type = b2_dynamicBody;
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape box;
+ box.SetAsBox(10.0f, 0.25f);
+ body->CreateFixture(&box, 1.0f);
+
+ b2RevoluteJointDef jd;
+ jd.Initialize(ground, body, body->GetPosition());
+ jd.lowerAngle = -8.0f * b2_pi / 180.0f;
+ jd.upperAngle = 8.0f * b2_pi / 180.0f;
+ jd.enableLimit = true;
+ m_world->CreateJoint(&jd);
+
+ body->ApplyAngularImpulse(100.0f, true);
+ }
+
+ // Bridge
+ {
+ int32 N = 20;
+ b2PolygonShape shape;
+ shape.SetAsBox(1.0f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+ fd.friction = 0.6f;
+
+ b2RevoluteJointDef jd;
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < N; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(161.0f + 2.0f * i, -0.125f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+
+ b2Vec2 anchor(160.0f + 2.0f * i, -0.125f);
+ jd.Initialize(prevBody, body, anchor);
+ m_world->CreateJoint(&jd);
+
+ prevBody = body;
+ }
+
+ b2Vec2 anchor(160.0f + 2.0f * N, -0.125f);
+ jd.Initialize(prevBody, ground, anchor);
+ m_world->CreateJoint(&jd);
+ }
+
+ // Boxes
+ {
+ b2PolygonShape box;
+ box.SetAsBox(0.5f, 0.5f);
+
+ b2Body* body = NULL;
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ bd.position.Set(230.0f, 0.5f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&box, 0.5f);
+
+ bd.position.Set(230.0f, 1.5f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&box, 0.5f);
+
+ bd.position.Set(230.0f, 2.5f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&box, 0.5f);
+
+ bd.position.Set(230.0f, 3.5f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&box, 0.5f);
+
+ bd.position.Set(230.0f, 4.5f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&box, 0.5f);
+ }
+
+ // Car
+ {
+ b2PolygonShape chassis;
+ b2Vec2 vertices[8];
+ vertices[0].Set(-1.5f, -0.5f);
+ vertices[1].Set(1.5f, -0.5f);
+ vertices[2].Set(1.5f, 0.0f);
+ vertices[3].Set(0.0f, 0.9f);
+ vertices[4].Set(-1.15f, 0.9f);
+ vertices[5].Set(-1.5f, 0.2f);
+ chassis.Set(vertices, 6);
+
+ b2CircleShape circle;
+ circle.m_radius = 0.4f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 1.0f);
+ m_car = m_world->CreateBody(&bd);
+ m_car->CreateFixture(&chassis, 1.0f);
+
+ b2FixtureDef fd;
+ fd.shape = &circle;
+ fd.density = 1.0f;
+ fd.friction = 0.9f;
+
+ bd.position.Set(-1.0f, 0.35f);
+ m_wheel1 = m_world->CreateBody(&bd);
+ m_wheel1->CreateFixture(&fd);
+
+ bd.position.Set(1.0f, 0.4f);
+ m_wheel2 = m_world->CreateBody(&bd);
+ m_wheel2->CreateFixture(&fd);
+
+ b2WheelJointDef jd;
+ b2Vec2 axis(0.0f, 1.0f);
+
+ float mass1 = m_wheel1->GetMass();
+ float mass2 = m_wheel2->GetMass();
+
+ float hertz = 4.0f;
+ float dampingRatio = 0.7f;
+ float omega = 2.0f * b2_pi * hertz;
+
+ jd.Initialize(m_car, m_wheel1, m_wheel1->GetPosition(), axis);
+ jd.motorSpeed = 0.0f;
+ jd.maxMotorTorque = 20.0f;
+ jd.enableMotor = true;
+ jd.stiffness = mass1 * omega * omega;
+ jd.damping = 2.0f * mass1 * dampingRatio * omega;
+ jd.lowerTranslation = -0.25f;
+ jd.upperTranslation = 0.25f;
+ jd.enableLimit = true;
+ m_spring1 = (b2WheelJoint*)m_world->CreateJoint(&jd);
+
+ jd.Initialize(m_car, m_wheel2, m_wheel2->GetPosition(), axis);
+ jd.motorSpeed = 0.0f;
+ jd.maxMotorTorque = 10.0f;
+ jd.enableMotor = false;
+ jd.stiffness = mass2 * omega * omega;
+ jd.damping = 2.0f * mass2 * dampingRatio * omega;
+ jd.lowerTranslation = -0.25f;
+ jd.upperTranslation = 0.25f;
+ jd.enableLimit = true;
+ m_spring2 = (b2WheelJoint*)m_world->CreateJoint(&jd);
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_spring1->SetMotorSpeed(m_speed);
+ break;
+
+ case GLFW_KEY_S:
+ m_spring1->SetMotorSpeed(0.0f);
+ break;
+
+ case GLFW_KEY_D:
+ m_spring1->SetMotorSpeed(-m_speed);
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ g_debugDraw.DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, hz down = q, hz up = e");
+ m_textLine += m_textIncrement;
+
+ g_camera.m_center.x = m_car->GetPosition().x;
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new Car;
+ }
+
+ b2Body* m_car;
+ b2Body* m_wheel1;
+ b2Body* m_wheel2;
+
+ float m_speed;
+ b2WheelJoint* m_spring1;
+ b2WheelJoint* m_spring2;
+};
+
+static int testIndex = RegisterTest("Examples", "Car", Car::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/chain.cpp b/Client/ThirdParty/Box2D/testbed/tests/chain.cpp
new file mode 100644
index 0000000..e158035
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/chain.cpp
@@ -0,0 +1,92 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+#define TEST_BAD_BODY 0
+
+class Chain : public Test
+{
+public:
+ Chain()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.6f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ fd.friction = 0.2f;
+
+ b2RevoluteJointDef jd;
+ jd.collideConnected = false;
+
+ const float y = 25.0f;
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < 30; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.5f + i, y);
+ b2Body* body = m_world->CreateBody(&bd);
+
+#if TEST_BAD_BODY == 1
+ if (i == 10)
+ {
+ // Test zero density dynamic body
+ fd.density = 0.0f;
+ }
+ else
+ {
+ fd.density = 20.0f;
+ }
+#endif
+
+ body->CreateFixture(&fd);
+
+ b2Vec2 anchor(float(i), y);
+ jd.Initialize(prevBody, body, anchor);
+ m_world->CreateJoint(&jd);
+
+ prevBody = body;
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Chain;
+ }
+};
+
+static int testIndex = RegisterTest("Joints", "Chain", Chain::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/chain_problem.cpp b/Client/ThirdParty/Box2D/testbed/tests/chain_problem.cpp
new file mode 100644
index 0000000..4b2ab38
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/chain_problem.cpp
@@ -0,0 +1,94 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class ChainProblem : public Test
+{
+public:
+
+ ChainProblem()
+ {
+ {
+ b2Vec2 g(0.0f, -10.0f);
+ m_world->SetGravity(g);
+ b2Body** bodies = (b2Body**)b2Alloc(2 * sizeof(b2Body*));
+ b2Joint** joints = (b2Joint**)b2Alloc(0 * sizeof(b2Joint*));
+ {
+ b2BodyDef bd;
+ bd.type = b2BodyType(0);
+ bodies[0] = m_world->CreateBody(&bd);
+
+ {
+ b2FixtureDef fd;
+
+ b2Vec2 v1(0.0f, 1.0f);
+ b2Vec2 v2(0.0f, 0.0f);
+ b2Vec2 v3(4.0f, 0.0f);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(v1, v2);
+ bodies[0]->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v2, v3);
+ bodies[0]->CreateFixture(&shape, 0.0f);
+ }
+ }
+ {
+ b2BodyDef bd;
+ bd.type = b2BodyType(2);
+ //bd.position.Set(6.033980250358582e-01f, 3.028350114822388e+00f);
+ bd.position.Set(1.0f, 3.0f);
+ bodies[1] = m_world->CreateBody(&bd);
+
+ {
+ b2FixtureDef fd;
+ fd.friction = 0.2f;
+ fd.density = 10.0f;
+ b2PolygonShape shape;
+ b2Vec2 vs[8];
+ vs[0].Set(0.5f, -3.0f);
+ vs[1].Set(0.5f, 3.0f);
+ vs[2].Set(-0.5f, 3.0f);
+ vs[3].Set(-0.5f, -3.0f);
+ shape.Set(vs, 4);
+
+ fd.shape = &shape;
+
+ bodies[1]->CreateFixture(&fd);
+ }
+ }
+ b2Free(joints);
+ b2Free(bodies);
+ joints = NULL;
+ bodies = NULL;
+ }
+ }
+
+ static Test* Create()
+ {
+ return new ChainProblem;
+ }
+
+};
+
+static int testIndex = RegisterTest("Bugs", "Chain Problem", ChainProblem::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/character_collision.cpp b/Client/ThirdParty/Box2D/testbed/tests/character_collision.cpp
new file mode 100644
index 0000000..3eab4a7
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/character_collision.cpp
@@ -0,0 +1,256 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+/// This is a test of typical character collision scenarios. This does not
+/// show how you should implement a character in your application.
+/// Instead this is used to test smooth collision on edge chains.
+class CharacterCollision : public Test
+{
+public:
+ CharacterCollision()
+ {
+ // Ground body
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Collinear edges with no adjacency information.
+ // This shows the problematic case where a box shape can hit
+ // an internal vertex.
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-8.0f, 1.0f), b2Vec2(-6.0f, 1.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ shape.SetTwoSided(b2Vec2(-6.0f, 1.0f), b2Vec2(-4.0f, 1.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ shape.SetTwoSided(b2Vec2(-4.0f, 1.0f), b2Vec2(-2.0f, 1.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Chain shape
+ {
+ b2BodyDef bd;
+ bd.angle = 0.25f * b2_pi;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2Vec2 vs[4];
+ vs[0].Set(5.0f, 7.0f);
+ vs[1].Set(6.0f, 8.0f);
+ vs[2].Set(7.0f, 8.0f);
+ vs[3].Set(8.0f, 7.0f);
+ b2ChainShape shape;
+ shape.CreateLoop(vs, 4);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Square tiles. This shows that adjacency shapes may
+ // have non-smooth collision. There is no solution
+ // to this problem.
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(1.0f, 1.0f, b2Vec2(4.0f, 3.0f), 0.0f);
+ ground->CreateFixture(&shape, 0.0f);
+ shape.SetAsBox(1.0f, 1.0f, b2Vec2(6.0f, 3.0f), 0.0f);
+ ground->CreateFixture(&shape, 0.0f);
+ shape.SetAsBox(1.0f, 1.0f, b2Vec2(8.0f, 3.0f), 0.0f);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Square made from an edge loop. Collision should be smooth.
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2Vec2 vs[4];
+ vs[0].Set(-1.0f, 3.0f);
+ vs[1].Set(1.0f, 3.0f);
+ vs[2].Set(1.0f, 5.0f);
+ vs[3].Set(-1.0f, 5.0f);
+ b2ChainShape shape;
+ shape.CreateLoop(vs, 4);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Edge loop. Collision should be smooth.
+ {
+ b2BodyDef bd;
+ bd.position.Set(-10.0f, 4.0f);
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2Vec2 vs[10];
+ vs[0].Set(0.0f, 0.0f);
+ vs[1].Set(6.0f, 0.0f);
+ vs[2].Set(6.0f, 2.0f);
+ vs[3].Set(4.0f, 1.0f);
+ vs[4].Set(2.0f, 2.0f);
+ vs[5].Set(0.0f, 2.0f);
+ vs[6].Set(-2.0f, 2.0f);
+ vs[7].Set(-4.0f, 3.0f);
+ vs[8].Set(-6.0f, 2.0f);
+ vs[9].Set(-6.0f, 0.0f);
+ b2ChainShape shape;
+ shape.CreateLoop(vs, 10);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Square character 1
+ {
+ b2BodyDef bd;
+ bd.position.Set(-3.0f, 8.0f);
+ bd.type = b2_dynamicBody;
+ bd.fixedRotation = true;
+ bd.allowSleep = false;
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ body->CreateFixture(&fd);
+ }
+
+ // Square character 2
+ {
+ b2BodyDef bd;
+ bd.position.Set(-5.0f, 5.0f);
+ bd.type = b2_dynamicBody;
+ bd.fixedRotation = true;
+ bd.allowSleep = false;
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f, 0.25f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ body->CreateFixture(&fd);
+ }
+
+ // Hexagon character
+ {
+ b2BodyDef bd;
+ bd.position.Set(-5.0f, 8.0f);
+ bd.type = b2_dynamicBody;
+ bd.fixedRotation = true;
+ bd.allowSleep = false;
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ float angle = 0.0f;
+ float delta = b2_pi / 3.0f;
+ b2Vec2 vertices[6];
+ for (int32 i = 0; i < 6; ++i)
+ {
+ vertices[i].Set(0.5f * cosf(angle), 0.5f * sinf(angle));
+ angle += delta;
+ }
+
+ b2PolygonShape shape;
+ shape.Set(vertices, 6);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ body->CreateFixture(&fd);
+ }
+
+ // Circle character
+ {
+ b2BodyDef bd;
+ bd.position.Set(3.0f, 5.0f);
+ bd.type = b2_dynamicBody;
+ bd.fixedRotation = true;
+ bd.allowSleep = false;
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ body->CreateFixture(&fd);
+ }
+
+ // Circle character
+ {
+ b2BodyDef bd;
+ bd.position.Set(-7.0f, 6.0f);
+ bd.type = b2_dynamicBody;
+ bd.allowSleep = false;
+
+ m_character = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.25f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ fd.friction = 1.0f;
+ m_character->CreateFixture(&fd);
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ b2Vec2 v = m_character->GetLinearVelocity();
+ v.x = -5.0f;
+ m_character->SetLinearVelocity(v);
+
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "This tests various character collision shapes.");
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "Limitation: square and hexagon can snag on aligned boxes.");
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "Feature: edge chains have smooth collision inside and out.");
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new CharacterCollision;
+ }
+
+ b2Body* m_character;
+};
+
+static int testIndex = RegisterTest("Examples", "Character Collision", CharacterCollision::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/circle_stack.cpp b/Client/ThirdParty/Box2D/testbed/tests/circle_stack.cpp
new file mode 100644
index 0000000..62d19ea
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/circle_stack.cpp
@@ -0,0 +1,89 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class CircleStack : public Test
+{
+public:
+
+ enum
+ {
+ e_count = 10
+ };
+
+ CircleStack()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2CircleShape shape;
+ shape.m_radius = 1.0f;
+
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0, 4.0f + 3.0f * i);
+
+ m_bodies[i] = m_world->CreateBody(&bd);
+
+ m_bodies[i]->CreateFixture(&shape, 1.0f);
+
+ m_bodies[i]->SetLinearVelocity(b2Vec2(0.0f, -50.0f));
+ }
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ //for (int32 i = 0; i < e_count; ++i)
+ //{
+ // printf("%g ", m_bodies[i]->GetWorldCenter().y);
+ //}
+
+ //for (int32 i = 0; i < e_count; ++i)
+ //{
+ // printf("%g ", m_bodies[i]->GetLinearVelocity().y);
+ //}
+
+ //printf("\n");
+ }
+
+ static Test* Create()
+ {
+ return new CircleStack;
+ }
+
+ b2Body* m_bodies[e_count];
+};
+
+static int testIndex = RegisterTest("Stacking", "Circles", CircleStack::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/collision_filtering.cpp b/Client/ThirdParty/Box2D/testbed/tests/collision_filtering.cpp
new file mode 100644
index 0000000..4903da5
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/collision_filtering.cpp
@@ -0,0 +1,179 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// This is a test of collision filtering.
+// There is a triangle, a box, and a circle.
+// There are 6 shapes. 3 large and 3 small.
+// The 3 small ones always collide.
+// The 3 large ones never collide.
+// The boxes don't collide with triangles (except if both are small).
+const int16 k_smallGroup = 1;
+const int16 k_largeGroup = -1;
+
+const uint16 k_triangleCategory = 0x0002;
+const uint16 k_boxCategory = 0x0004;
+const uint16 k_circleCategory = 0x0008;
+
+const uint16 k_triangleMask = 0xFFFF;
+const uint16 k_boxMask = 0xFFFF ^ k_triangleCategory;
+const uint16 k_circleMask = 0xFFFF;
+
+class CollisionFiltering : public Test
+{
+public:
+ CollisionFiltering()
+ {
+ // Ground body
+ {
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+
+ b2FixtureDef sd;
+ sd.shape = &shape;
+ sd.friction = 0.3f;
+
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&sd);
+ }
+
+ // Small triangle
+ b2Vec2 vertices[3];
+ vertices[0].Set(-1.0f, 0.0f);
+ vertices[1].Set(1.0f, 0.0f);
+ vertices[2].Set(0.0f, 2.0f);
+ b2PolygonShape polygon;
+ polygon.Set(vertices, 3);
+
+ b2FixtureDef triangleShapeDef;
+ triangleShapeDef.shape = &polygon;
+ triangleShapeDef.density = 1.0f;
+
+ triangleShapeDef.filter.groupIndex = k_smallGroup;
+ triangleShapeDef.filter.categoryBits = k_triangleCategory;
+ triangleShapeDef.filter.maskBits = k_triangleMask;
+
+ b2BodyDef triangleBodyDef;
+ triangleBodyDef.type = b2_dynamicBody;
+ triangleBodyDef.position.Set(-5.0f, 2.0f);
+
+ b2Body* body1 = m_world->CreateBody(&triangleBodyDef);
+ body1->CreateFixture(&triangleShapeDef);
+
+ // Large triangle (recycle definitions)
+ vertices[0] *= 2.0f;
+ vertices[1] *= 2.0f;
+ vertices[2] *= 2.0f;
+ polygon.Set(vertices, 3);
+ triangleShapeDef.filter.groupIndex = k_largeGroup;
+ triangleBodyDef.position.Set(-5.0f, 6.0f);
+ triangleBodyDef.fixedRotation = true; // look at me!
+
+ b2Body* body2 = m_world->CreateBody(&triangleBodyDef);
+ body2->CreateFixture(&triangleShapeDef);
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-5.0f, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape p;
+ p.SetAsBox(0.5f, 1.0f);
+ body->CreateFixture(&p, 1.0f);
+
+ b2PrismaticJointDef jd;
+ jd.bodyA = body2;
+ jd.bodyB = body;
+ jd.enableLimit = true;
+ jd.localAnchorA.Set(0.0f, 4.0f);
+ jd.localAnchorB.SetZero();
+ jd.localAxisA.Set(0.0f, 1.0f);
+ jd.lowerTranslation = -1.0f;
+ jd.upperTranslation = 1.0f;
+
+ m_world->CreateJoint(&jd);
+ }
+
+ // Small box
+ polygon.SetAsBox(1.0f, 0.5f);
+ b2FixtureDef boxShapeDef;
+ boxShapeDef.shape = &polygon;
+ boxShapeDef.density = 1.0f;
+ boxShapeDef.restitution = 0.1f;
+
+ boxShapeDef.filter.groupIndex = k_smallGroup;
+ boxShapeDef.filter.categoryBits = k_boxCategory;
+ boxShapeDef.filter.maskBits = k_boxMask;
+
+ b2BodyDef boxBodyDef;
+ boxBodyDef.type = b2_dynamicBody;
+ boxBodyDef.position.Set(0.0f, 2.0f);
+
+ b2Body* body3 = m_world->CreateBody(&boxBodyDef);
+ body3->CreateFixture(&boxShapeDef);
+
+ // Large box (recycle definitions)
+ polygon.SetAsBox(2.0f, 1.0f);
+ boxShapeDef.filter.groupIndex = k_largeGroup;
+ boxBodyDef.position.Set(0.0f, 6.0f);
+
+ b2Body* body4 = m_world->CreateBody(&boxBodyDef);
+ body4->CreateFixture(&boxShapeDef);
+
+ // Small circle
+ b2CircleShape circle;
+ circle.m_radius = 1.0f;
+
+ b2FixtureDef circleShapeDef;
+ circleShapeDef.shape = &circle;
+ circleShapeDef.density = 1.0f;
+
+ circleShapeDef.filter.groupIndex = k_smallGroup;
+ circleShapeDef.filter.categoryBits = k_circleCategory;
+ circleShapeDef.filter.maskBits = k_circleMask;
+
+ b2BodyDef circleBodyDef;
+ circleBodyDef.type = b2_dynamicBody;
+ circleBodyDef.position.Set(5.0f, 2.0f);
+
+ b2Body* body5 = m_world->CreateBody(&circleBodyDef);
+ body5->CreateFixture(&circleShapeDef);
+
+ // Large circle
+ circle.m_radius *= 2.0f;
+ circleShapeDef.filter.groupIndex = k_largeGroup;
+ circleBodyDef.position.Set(5.0f, 6.0f);
+
+ b2Body* body6 = m_world->CreateBody(&circleBodyDef);
+ body6->CreateFixture(&circleShapeDef);
+ }
+
+ static Test* Create()
+ {
+ return new CollisionFiltering;
+ }
+};
+
+static int testIndex = RegisterTest("Examples", "Collision Filtering", CollisionFiltering::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/collision_processing.cpp b/Client/ThirdParty/Box2D/testbed/tests/collision_processing.cpp
new file mode 100644
index 0000000..1c684bd
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/collision_processing.cpp
@@ -0,0 +1,191 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+#include <algorithm>
+
+// This test shows collision processing and tests
+// deferred body destruction.
+class CollisionProcessing : public Test
+{
+public:
+ CollisionProcessing()
+ {
+ // Ground body
+ {
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-50.0f, 0.0f), b2Vec2(50.0f, 0.0f));
+
+ b2FixtureDef sd;
+ sd.shape = &shape;;
+
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&sd);
+ }
+
+ float xLo = -5.0f, xHi = 5.0f;
+ float yLo = 2.0f, yHi = 35.0f;
+
+ // Small triangle
+ b2Vec2 vertices[3];
+ vertices[0].Set(-1.0f, 0.0f);
+ vertices[1].Set(1.0f, 0.0f);
+ vertices[2].Set(0.0f, 2.0f);
+
+ b2PolygonShape polygon;
+ polygon.Set(vertices, 3);
+
+ b2FixtureDef triangleShapeDef;
+ triangleShapeDef.shape = &polygon;
+ triangleShapeDef.density = 1.0f;
+
+ b2BodyDef triangleBodyDef;
+ triangleBodyDef.type = b2_dynamicBody;
+ triangleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi));
+
+ b2Body* body1 = m_world->CreateBody(&triangleBodyDef);
+ body1->CreateFixture(&triangleShapeDef);
+
+ // Large triangle (recycle definitions)
+ vertices[0] *= 2.0f;
+ vertices[1] *= 2.0f;
+ vertices[2] *= 2.0f;
+ polygon.Set(vertices, 3);
+
+ triangleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi));
+
+ b2Body* body2 = m_world->CreateBody(&triangleBodyDef);
+ body2->CreateFixture(&triangleShapeDef);
+
+ // Small box
+ polygon.SetAsBox(1.0f, 0.5f);
+
+ b2FixtureDef boxShapeDef;
+ boxShapeDef.shape = &polygon;
+ boxShapeDef.density = 1.0f;
+
+ b2BodyDef boxBodyDef;
+ boxBodyDef.type = b2_dynamicBody;
+ boxBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi));
+
+ b2Body* body3 = m_world->CreateBody(&boxBodyDef);
+ body3->CreateFixture(&boxShapeDef);
+
+ // Large box (recycle definitions)
+ polygon.SetAsBox(2.0f, 1.0f);
+ boxBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi));
+
+ b2Body* body4 = m_world->CreateBody(&boxBodyDef);
+ body4->CreateFixture(&boxShapeDef);
+
+ // Small circle
+ b2CircleShape circle;
+ circle.m_radius = 1.0f;
+
+ b2FixtureDef circleShapeDef;
+ circleShapeDef.shape = &circle;
+ circleShapeDef.density = 1.0f;
+
+ b2BodyDef circleBodyDef;
+ circleBodyDef.type = b2_dynamicBody;
+ circleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi));
+
+ b2Body* body5 = m_world->CreateBody(&circleBodyDef);
+ body5->CreateFixture(&circleShapeDef);
+
+ // Large circle
+ circle.m_radius *= 2.0f;
+ circleBodyDef.position.Set(RandomFloat(xLo, xHi), RandomFloat(yLo, yHi));
+
+ b2Body* body6 = m_world->CreateBody(&circleBodyDef);
+ body6->CreateFixture(&circleShapeDef);
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ // We are going to destroy some bodies according to contact
+ // points. We must buffer the bodies that should be destroyed
+ // because they may belong to multiple contact points.
+ const int32 k_maxNuke = 6;
+ b2Body* nuke[k_maxNuke];
+ int32 nukeCount = 0;
+
+ // Traverse the contact results. Destroy bodies that
+ // are touching heavier bodies.
+ for (int32 i = 0; i < m_pointCount; ++i)
+ {
+ ContactPoint* point = m_points + i;
+
+ b2Body* body1 = point->fixtureA->GetBody();
+ b2Body* body2 = point->fixtureB->GetBody();
+ float mass1 = body1->GetMass();
+ float mass2 = body2->GetMass();
+
+ if (mass1 > 0.0f && mass2 > 0.0f)
+ {
+ if (mass2 > mass1)
+ {
+ nuke[nukeCount++] = body1;
+ }
+ else
+ {
+ nuke[nukeCount++] = body2;
+ }
+
+ if (nukeCount == k_maxNuke)
+ {
+ break;
+ }
+ }
+ }
+
+ // Sort the nuke array to group duplicates.
+ std::sort(nuke, nuke + nukeCount);
+
+ // Destroy the bodies, skipping duplicates.
+ int32 i = 0;
+ while (i < nukeCount)
+ {
+ b2Body* b = nuke[i++];
+ while (i < nukeCount && nuke[i] == b)
+ {
+ ++i;
+ }
+
+ if (b != m_bomb)
+ {
+ m_world->DestroyBody(b);
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new CollisionProcessing;
+ }
+};
+
+static int testIndex = RegisterTest("Examples", "Collision Processing", CollisionProcessing::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/compound_shapes.cpp b/Client/ThirdParty/Box2D/testbed/tests/compound_shapes.cpp
new file mode 100644
index 0000000..5862e8e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/compound_shapes.cpp
@@ -0,0 +1,227 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "imgui/imgui.h"
+
+class CompoundShapes : public Test
+{
+public:
+ CompoundShapes()
+ {
+ {
+ b2BodyDef bd;
+ bd.position.Set(0.0f, 0.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(50.0f, 0.0f), b2Vec2(-50.0f, 0.0f));
+
+ body->CreateFixture(&shape, 0.0f);
+ }
+
+ // Table 1
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-15.0f, 1.0f);
+ m_table1 = m_world->CreateBody(&bd);
+
+ b2PolygonShape top;
+ top.SetAsBox(3.0f, 0.5f, b2Vec2(0.0f, 3.5f), 0.0f);
+
+ b2PolygonShape leftLeg;
+ leftLeg.SetAsBox(0.5f, 1.5f, b2Vec2(-2.5f, 1.5f), 0.0f);
+
+ b2PolygonShape rightLeg;
+ rightLeg.SetAsBox(0.5f, 1.5f, b2Vec2(2.5f, 1.5f), 0.0f);
+
+ m_table1->CreateFixture(&top, 2.0f);
+ m_table1->CreateFixture(&leftLeg, 2.0f);
+ m_table1->CreateFixture(&rightLeg, 2.0f);
+ }
+
+ // Table 2
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-5.0f, 1.0f);
+ m_table2 = m_world->CreateBody(&bd);
+
+ b2PolygonShape top;
+ top.SetAsBox(3.0f, 0.5f, b2Vec2(0.0f, 3.5f), 0.0f);
+
+ b2PolygonShape leftLeg;
+ leftLeg.SetAsBox(0.5f, 2.0f, b2Vec2(-2.5f, 2.0f), 0.0f);
+
+ b2PolygonShape rightLeg;
+ rightLeg.SetAsBox(0.5f, 2.0f, b2Vec2(2.5f, 2.0f), 0.0f);
+
+ m_table2->CreateFixture(&top, 2.0f);
+ m_table2->CreateFixture(&leftLeg, 2.0f);
+ m_table2->CreateFixture(&rightLeg, 2.0f);
+ }
+
+ // Spaceship 1
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(5.0f, 1.0f);
+ m_ship1 = m_world->CreateBody(&bd);
+
+ b2Vec2 vertices[3];
+
+ b2PolygonShape left;
+ vertices[0].Set(-2.0f, 0.0f);
+ vertices[1].Set(0.0f, 4.0f / 3.0f);
+ vertices[2].Set(0.0f, 4.0f);
+ left.Set(vertices, 3);
+
+ b2PolygonShape right;
+ vertices[0].Set(2.0f, 0.0f);
+ vertices[1].Set(0.0f, 4.0f / 3.0f);
+ vertices[2].Set(0.0f, 4.0f);
+ right.Set(vertices, 3);
+
+ m_ship1->CreateFixture(&left, 2.0f);
+ m_ship1->CreateFixture(&right, 2.0f);
+ }
+
+ // Spaceship 2
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(15.0f, 1.0f);
+ m_ship2 = m_world->CreateBody(&bd);
+
+ b2Vec2 vertices[3];
+
+ b2PolygonShape left;
+ vertices[0].Set(-2.0f, 0.0f);
+ vertices[1].Set(1.0f, 2.0f);
+ vertices[2].Set(0.0f, 4.0f);
+ left.Set(vertices, 3);
+
+ b2PolygonShape right;
+ vertices[0].Set(2.0f, 0.0f);
+ vertices[1].Set(-1.0f, 2.0f);
+ vertices[2].Set(0.0f, 4.0f);
+ right.Set(vertices, 3);
+
+ m_ship2->CreateFixture(&left, 2.0f);
+ m_ship2->CreateFixture(&right, 2.0f);
+ }
+ }
+
+ void Spawn()
+ {
+ // Table 1 obstruction
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = m_table1->GetPosition();
+ bd.angle = m_table1->GetAngle();
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape box;
+ box.SetAsBox(4.0f, 0.1f, b2Vec2(0.0f, 3.0f), 0.0f);
+
+ body->CreateFixture(&box, 2.0f);
+ }
+
+ // Table 2 obstruction
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = m_table2->GetPosition();
+ bd.angle = m_table2->GetAngle();
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape box;
+ box.SetAsBox(4.0f, 0.1f, b2Vec2(0.0f, 3.0f), 0.0f);
+
+ body->CreateFixture(&box, 2.0f);
+ }
+
+ // Ship 1 obstruction
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = m_ship1->GetPosition();
+ bd.angle = m_ship1->GetAngle();
+ bd.gravityScale = 0.0f;
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2CircleShape circle;
+ circle.m_radius = 0.5f;
+ circle.m_p.Set(0.0f, 2.0f);
+
+ body->CreateFixture(&circle, 2.0f);
+ }
+
+ // Ship 2 obstruction
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = m_ship2->GetPosition();
+ bd.angle = m_ship2->GetAngle();
+ bd.gravityScale = 0.0f;
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2CircleShape circle;
+ circle.m_radius = 0.5f;
+ circle.m_p.Set(0.0f, 2.0f);
+
+ body->CreateFixture(&circle, 2.0f);
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 100.0f));
+ ImGui::Begin("Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::Button("Spawn"))
+ {
+ Spawn();
+ }
+
+ ImGui::End();
+ }
+
+ static Test* Create()
+ {
+ return new CompoundShapes;
+ }
+
+ b2Body* m_table1;
+ b2Body* m_table2;
+ b2Body* m_ship1;
+ b2Body* m_ship2;
+};
+
+static int testIndex = RegisterTest("Examples", "Compound Shapes", CompoundShapes::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/confined.cpp b/Client/ThirdParty/Box2D/testbed/tests/confined.cpp
new file mode 100644
index 0000000..3ac9bd6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/confined.cpp
@@ -0,0 +1,170 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Confined : public Test
+{
+public:
+
+ enum
+ {
+ e_columnCount = 0,
+ e_rowCount = 0
+ };
+
+ Confined()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+
+ // Floor
+ shape.SetTwoSided(b2Vec2(-10.0f, 0.0f), b2Vec2(10.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+
+ // Left wall
+ shape.SetTwoSided(b2Vec2(-10.0f, 0.0f), b2Vec2(-10.0f, 20.0f));
+ ground->CreateFixture(&shape, 0.0f);
+
+ // Right wall
+ shape.SetTwoSided(b2Vec2(10.0f, 0.0f), b2Vec2(10.0f, 20.0f));
+ ground->CreateFixture(&shape, 0.0f);
+
+ // Roof
+ shape.SetTwoSided(b2Vec2(-10.0f, 20.0f), b2Vec2(10.0f, 20.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ float radius = 0.5f;
+ b2CircleShape shape;
+ shape.m_p.SetZero();
+ shape.m_radius = radius;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+ fd.friction = 0.1f;
+
+ for (int32 j = 0; j < e_columnCount; ++j)
+ {
+ for (int i = 0; i < e_rowCount; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-10.0f + (2.1f * j + 1.0f + 0.01f * i) * radius, (2.0f * i + 1.0f) * radius);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ body->CreateFixture(&fd);
+ }
+ }
+
+ m_world->SetGravity(b2Vec2(0.0f, 0.0f));
+ }
+
+ void CreateCircle()
+ {
+ float radius = 2.0f;
+ b2CircleShape shape;
+ shape.m_p.SetZero();
+ shape.m_radius = radius;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+ fd.friction = 0.0f;
+
+ b2Vec2 p(RandomFloat(), 3.0f + RandomFloat());
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = p;
+ //bd.allowSleep = false;
+ b2Body* body = m_world->CreateBody(&bd);
+
+ body->CreateFixture(&fd);
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_C:
+ CreateCircle();
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ bool sleeping = true;
+ for (b2Body* b = m_world->GetBodyList(); b; b = b->GetNext())
+ {
+ if (b->GetType() != b2_dynamicBody)
+ {
+ continue;
+ }
+
+ if (b->IsAwake())
+ {
+ sleeping = false;
+ }
+ }
+
+ if (m_stepCount == 180)
+ {
+ m_stepCount += 0;
+ }
+
+ //if (sleeping)
+ //{
+ // CreateCircle();
+ //}
+
+ Test::Step(settings);
+
+ for (b2Body* b = m_world->GetBodyList(); b; b = b->GetNext())
+ {
+ if (b->GetType() != b2_dynamicBody)
+ {
+ continue;
+ }
+
+ b2Vec2 p = b->GetPosition();
+ if (p.x <= -10.0f || 10.0f <= p.x || p.y <= 0.0f || 20.0f <= p.y)
+ {
+ p.x += 0.0f;
+ }
+ }
+
+ g_debugDraw.DrawString(5, m_textLine, "Press 'c' to create a circle.");
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new Confined;
+ }
+};
+
+static int testIndex = RegisterTest("Solver", "Confined", Confined::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/continuous_test.cpp b/Client/ThirdParty/Box2D/testbed/tests/continuous_test.cpp
new file mode 100644
index 0000000..1166c71
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/continuous_test.cpp
@@ -0,0 +1,160 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class ContinuousTest : public Test
+{
+public:
+
+ ContinuousTest()
+ {
+ {
+ b2BodyDef bd;
+ bd.position.Set(0.0f, 0.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2EdgeShape edge;
+
+ edge.SetTwoSided(b2Vec2(-10.0f, 0.0f), b2Vec2(10.0f, 0.0f));
+ body->CreateFixture(&edge, 0.0f);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.2f, 1.0f, b2Vec2(0.5f, 1.0f), 0.0f);
+ body->CreateFixture(&shape, 0.0f);
+ }
+
+#if 1
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 20.0f);
+ //bd.angle = 0.1f;
+
+ b2PolygonShape shape;
+ shape.SetAsBox(2.0f, 0.1f);
+
+ m_body = m_world->CreateBody(&bd);
+ m_body->CreateFixture(&shape, 1.0f);
+
+ m_angularVelocity = RandomFloat(-50.0f, 50.0f);
+ //m_angularVelocity = 46.661274f;
+ m_body->SetLinearVelocity(b2Vec2(0.0f, -100.0f));
+ m_body->SetAngularVelocity(m_angularVelocity);
+ }
+#else
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 2.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_p.SetZero();
+ shape.m_radius = 0.5f;
+ body->CreateFixture(&shape, 1.0f);
+
+ bd.bullet = true;
+ bd.position.Set(0.0f, 10.0f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 1.0f);
+ body->SetLinearVelocity(b2Vec2(0.0f, -100.0f));
+ }
+#endif
+
+ extern B2_API int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
+ extern B2_API int32 b2_toiCalls, b2_toiIters;
+ extern B2_API int32 b2_toiRootIters, b2_toiMaxRootIters;
+ extern B2_API float b2_toiTime, b2_toiMaxTime;
+
+ b2_gjkCalls = 0; b2_gjkIters = 0; b2_gjkMaxIters = 0;
+ b2_toiCalls = 0; b2_toiIters = 0;
+ b2_toiRootIters = 0; b2_toiMaxRootIters = 0;
+ b2_toiTime = 0.0f; b2_toiMaxTime = 0.0f;
+ }
+
+ void Launch()
+ {
+ extern B2_API int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
+ extern B2_API int32 b2_toiCalls, b2_toiIters;
+ extern B2_API int32 b2_toiRootIters, b2_toiMaxRootIters;
+ extern B2_API float b2_toiTime, b2_toiMaxTime;
+
+ b2_gjkCalls = 0; b2_gjkIters = 0; b2_gjkMaxIters = 0;
+ b2_toiCalls = 0; b2_toiIters = 0;
+ b2_toiRootIters = 0; b2_toiMaxRootIters = 0;
+ b2_toiTime = 0.0f; b2_toiMaxTime = 0.0f;
+
+ m_body->SetTransform(b2Vec2(0.0f, 20.0f), 0.0f);
+ m_angularVelocity = RandomFloat(-50.0f, 50.0f);
+ m_body->SetLinearVelocity(b2Vec2(0.0f, -100.0f));
+ m_body->SetAngularVelocity(m_angularVelocity);
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ extern B2_API int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
+
+ if (b2_gjkCalls > 0)
+ {
+ g_debugDraw.DrawString(5, m_textLine, "gjk calls = %d, ave gjk iters = %3.1f, max gjk iters = %d",
+ b2_gjkCalls, b2_gjkIters / float(b2_gjkCalls), b2_gjkMaxIters);
+ m_textLine += m_textIncrement;
+ }
+
+ extern B2_API int32 b2_toiCalls, b2_toiIters;
+ extern B2_API int32 b2_toiRootIters, b2_toiMaxRootIters;
+ extern B2_API float b2_toiTime, b2_toiMaxTime;
+
+ if (b2_toiCalls > 0)
+ {
+ g_debugDraw.DrawString(5, m_textLine, "toi calls = %d, ave [max] toi iters = %3.1f [%d]",
+ b2_toiCalls, b2_toiIters / float(b2_toiCalls), b2_toiMaxRootIters);
+ m_textLine += m_textIncrement;
+
+ g_debugDraw.DrawString(5, m_textLine, "ave [max] toi root iters = %3.1f [%d]",
+ b2_toiRootIters / float(b2_toiCalls), b2_toiMaxRootIters);
+ m_textLine += m_textIncrement;
+
+ g_debugDraw.DrawString(5, m_textLine, "ave [max] toi time = %.1f [%.1f] (microseconds)",
+ 1000.0f * b2_toiTime / float(b2_toiCalls), 1000.0f * b2_toiMaxTime);
+ m_textLine += m_textIncrement;
+ }
+
+ if (m_stepCount % 60 == 0)
+ {
+ //Launch();
+ }
+ }
+
+ static Test* Create()
+ {
+ return new ContinuousTest;
+ }
+
+ b2Body* m_body;
+ float m_angularVelocity;
+};
+
+static int testIndex = RegisterTest("Continuous", "Continuous Test", ContinuousTest::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/convex_hull.cpp b/Client/ThirdParty/Box2D/testbed/tests/convex_hull.cpp
new file mode 100644
index 0000000..ab56e91
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/convex_hull.cpp
@@ -0,0 +1,112 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class ConvexHull : public Test
+{
+public:
+ enum
+ {
+ e_count = b2_maxPolygonVertices
+ };
+
+ ConvexHull()
+ {
+ Generate();
+ m_auto = false;
+ }
+
+ void Generate()
+ {
+ b2Vec2 lowerBound(-8.0f, -8.0f);
+ b2Vec2 upperBound(8.0f, 8.0f);
+
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ float x = 10.0f * RandomFloat();
+ float y = 10.0f * RandomFloat();
+
+ // Clamp onto a square to help create collinearities.
+ // This will stress the convex hull algorithm.
+ b2Vec2 v(x, y);
+ v = b2Clamp(v, lowerBound, upperBound);
+ m_points[i] = v;
+ }
+
+ m_count = e_count;
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_auto = !m_auto;
+ break;
+
+ case GLFW_KEY_G:
+ Generate();
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ b2PolygonShape shape;
+ shape.Set(m_points, m_count);
+
+ g_debugDraw.DrawString(5, m_textLine, "Press g to generate a new random convex hull");
+ m_textLine += m_textIncrement;
+
+ g_debugDraw.DrawPolygon(shape.m_vertices, shape.m_count, b2Color(0.9f, 0.9f, 0.9f));
+
+ for (int32 i = 0; i < m_count; ++i)
+ {
+ g_debugDraw.DrawPoint(m_points[i], 3.0f, b2Color(0.3f, 0.9f, 0.3f));
+ g_debugDraw.DrawString(m_points[i] + b2Vec2(0.05f, 0.05f), "%d", i);
+ }
+
+ if (shape.Validate() == false)
+ {
+ m_textLine += 0;
+ }
+
+ if (m_auto)
+ {
+ Generate();
+ }
+ }
+
+ static Test* Create()
+ {
+ return new ConvexHull;
+ }
+
+ b2Vec2 m_points[b2_maxPolygonVertices];
+ int32 m_count;
+ bool m_auto;
+};
+
+static int testIndex = RegisterTest("Geometry", "Convex Hull", ConvexHull::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/conveyor_belt.cpp b/Client/ThirdParty/Box2D/testbed/tests/conveyor_belt.cpp
new file mode 100644
index 0000000..41d4f2c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/conveyor_belt.cpp
@@ -0,0 +1,101 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class ConveyorBelt : public Test
+{
+public:
+
+ ConveyorBelt()
+ {
+ // Ground
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Platform
+ {
+ b2BodyDef bd;
+ bd.position.Set(-5.0f, 5.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(10.0f, 0.5f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.friction = 0.8f;
+ m_platform = body->CreateFixture(&fd);
+ }
+
+ // Boxes
+ for (int32 i = 0; i < 5; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-10.0f + 2.0f * i, 7.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+ body->CreateFixture(&shape, 20.0f);
+ }
+ }
+
+ void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override
+ {
+ Test::PreSolve(contact, oldManifold);
+
+ b2Fixture* fixtureA = contact->GetFixtureA();
+ b2Fixture* fixtureB = contact->GetFixtureB();
+
+ if (fixtureA == m_platform)
+ {
+ contact->SetTangentSpeed(5.0f);
+ }
+
+ if (fixtureB == m_platform)
+ {
+ contact->SetTangentSpeed(-5.0f);
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new ConveyorBelt;
+ }
+
+ b2Fixture* m_platform;
+};
+
+static int testIndex = RegisterTest("Examples", "Conveyor Belt", ConveyorBelt::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/distance_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/distance_joint.cpp
new file mode 100644
index 0000000..389f403
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/distance_joint.cpp
@@ -0,0 +1,123 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "imgui/imgui.h"
+
+// This tests distance joints, body destruction, and joint destruction.
+class DistanceJoint : public Test
+{
+public:
+ DistanceJoint()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.angularDamping = 0.1f;
+
+ bd.position.Set(0.0f, 5.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+ body->CreateFixture(&shape, 5.0f);
+
+ m_hertz = 1.0f;
+ m_dampingRatio = 0.7f;
+
+ b2DistanceJointDef jd;
+ jd.Initialize(ground, body, b2Vec2(0.0f, 15.0f), bd.position);
+ jd.collideConnected = true;
+ m_length = jd.length;
+ m_minLength = m_length;
+ m_maxLength = m_length;
+ b2LinearStiffness(jd.stiffness, jd.damping, m_hertz, m_dampingRatio, jd.bodyA, jd.bodyB);
+ m_joint = (b2DistanceJoint*)m_world->CreateJoint(&jd);
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(260.0f, 150.0f));
+ ImGui::Begin("Joint Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::SliderFloat("Length", &m_length, 0.0f, 20.0f, "%.0f"))
+ {
+ m_length = m_joint->SetLength(m_length);
+ }
+
+ if (ImGui::SliderFloat("Min Length", &m_minLength, 0.0f, 20.0f, "%.0f"))
+ {
+ m_minLength = m_joint->SetMinLength(m_minLength);
+ }
+
+ if (ImGui::SliderFloat("Max Length", &m_maxLength, 0.0f, 20.0f, "%.0f"))
+ {
+ m_maxLength = m_joint->SetMaxLength(m_maxLength);
+ }
+
+ if (ImGui::SliderFloat("Hertz", &m_hertz, 0.0f, 10.0f, "%.1f"))
+ {
+ float stiffness;
+ float damping;
+ b2LinearStiffness(stiffness, damping, m_hertz, m_dampingRatio, m_joint->GetBodyA(), m_joint->GetBodyB());
+ m_joint->SetStiffness(stiffness);
+ m_joint->SetDamping(damping);
+ }
+
+ if (ImGui::SliderFloat("Damping Ratio", &m_dampingRatio, 0.0f, 2.0f, "%.1f"))
+ {
+ float stiffness;
+ float damping;
+ b2LinearStiffness(stiffness, damping, m_hertz, m_dampingRatio, m_joint->GetBodyA(), m_joint->GetBodyB());
+ m_joint->SetStiffness(stiffness);
+ m_joint->SetDamping(damping);
+ }
+
+ ImGui::End();
+ }
+
+ static Test* Create()
+ {
+ return new DistanceJoint;
+ }
+
+ b2DistanceJoint* m_joint;
+ float m_length;
+ float m_minLength;
+ float m_maxLength;
+ float m_hertz;
+ float m_dampingRatio;
+};
+
+static int testIndex = RegisterTest("Joints", "Distance Joint", DistanceJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/distance_test.cpp b/Client/ThirdParty/Box2D/testbed/tests/distance_test.cpp
new file mode 100644
index 0000000..90496ad
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/distance_test.cpp
@@ -0,0 +1,139 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "box2d/b2_distance.h"
+
+class DistanceTest : public Test
+{
+public:
+ DistanceTest()
+ {
+ {
+ m_transformA.SetIdentity();
+ m_transformA.p.Set(0.0f, -0.2f);
+ m_polygonA.SetAsBox(10.0f, 0.2f);
+ }
+
+ {
+ m_positionB.Set(12.017401f, 0.13678508f);
+ m_angleB = -0.0109265f;
+ m_transformB.Set(m_positionB, m_angleB);
+
+ m_polygonB.SetAsBox(2.0f, 0.1f);
+ }
+ }
+
+ static Test* Create()
+ {
+ return new DistanceTest;
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ b2DistanceInput input;
+ input.proxyA.Set(&m_polygonA, 0);
+ input.proxyB.Set(&m_polygonB, 0);
+ input.transformA = m_transformA;
+ input.transformB = m_transformB;
+ input.useRadii = true;
+ b2SimplexCache cache;
+ cache.count = 0;
+ b2DistanceOutput output;
+ b2Distance(&output, &cache, &input);
+
+ g_debugDraw.DrawString(5, m_textLine, "distance = %g", output.distance);
+ m_textLine += m_textIncrement;
+
+ g_debugDraw.DrawString(5, m_textLine, "iterations = %d", output.iterations);
+ m_textLine += m_textIncrement;
+
+ {
+ b2Color color(0.9f, 0.9f, 0.9f);
+ b2Vec2 v[b2_maxPolygonVertices];
+ for (int32 i = 0; i < m_polygonA.m_count; ++i)
+ {
+ v[i] = b2Mul(m_transformA, m_polygonA.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(v, m_polygonA.m_count, color);
+
+ for (int32 i = 0; i < m_polygonB.m_count; ++i)
+ {
+ v[i] = b2Mul(m_transformB, m_polygonB.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(v, m_polygonB.m_count, color);
+ }
+
+ b2Vec2 x1 = output.pointA;
+ b2Vec2 x2 = output.pointB;
+
+ b2Color c1(1.0f, 0.0f, 0.0f);
+ g_debugDraw.DrawPoint(x1, 4.0f, c1);
+
+ b2Color c2(1.0f, 1.0f, 0.0f);
+ g_debugDraw.DrawPoint(x2, 4.0f, c2);
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_positionB.x -= 0.1f;
+ break;
+
+ case GLFW_KEY_D:
+ m_positionB.x += 0.1f;
+ break;
+
+ case GLFW_KEY_S:
+ m_positionB.y -= 0.1f;
+ break;
+
+ case GLFW_KEY_W:
+ m_positionB.y += 0.1f;
+ break;
+
+ case GLFW_KEY_Q:
+ m_angleB += 0.1f * b2_pi;
+ break;
+
+ case GLFW_KEY_E:
+ m_angleB -= 0.1f * b2_pi;
+ break;
+ }
+
+ m_transformB.Set(m_positionB, m_angleB);
+ }
+
+ b2Vec2 m_positionB;
+ float m_angleB;
+
+ b2Transform m_transformA;
+ b2Transform m_transformB;
+ b2PolygonShape m_polygonA;
+ b2PolygonShape m_polygonB;
+};
+
+static int testIndex = RegisterTest("Geometry", "Distance Test", DistanceTest::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/dominos.cpp b/Client/ThirdParty/Box2D/testbed/tests/dominos.cpp
new file mode 100644
index 0000000..739876b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/dominos.cpp
@@ -0,0 +1,220 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Dominos : public Test
+{
+public:
+
+ Dominos()
+ {
+ b2Body* b1;
+ {
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+
+ b2BodyDef bd;
+ b1 = m_world->CreateBody(&bd);
+ b1->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(6.0f, 0.25f);
+
+ b2BodyDef bd;
+ bd.position.Set(-1.5f, 10.0f);
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.1f, 1.0f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ fd.friction = 0.1f;
+
+ for (int i = 0; i < 10; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-6.0f + 1.0f * i, 11.25f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&fd);
+ }
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(7.0f, 0.25f, b2Vec2_zero, 0.3f);
+
+ b2BodyDef bd;
+ bd.position.Set(1.0f, 6.0f);
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ b2Body* b2;
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f, 1.5f);
+
+ b2BodyDef bd;
+ bd.position.Set(-7.0f, 4.0f);
+ b2 = m_world->CreateBody(&bd);
+ b2->CreateFixture(&shape, 0.0f);
+ }
+
+ b2Body* b3;
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(6.0f, 0.125f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-0.9f, 1.0f);
+ bd.angle = -0.15f;
+
+ b3 = m_world->CreateBody(&bd);
+ b3->CreateFixture(&shape, 10.0f);
+ }
+
+ b2RevoluteJointDef jd;
+ b2Vec2 anchor;
+
+ anchor.Set(-2.0f, 1.0f);
+ jd.Initialize(b1, b3, anchor);
+ jd.collideConnected = true;
+ m_world->CreateJoint(&jd);
+
+ b2Body* b4;
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f, 0.25f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-10.0f, 15.0f);
+ b4 = m_world->CreateBody(&bd);
+ b4->CreateFixture(&shape, 10.0f);
+ }
+
+ anchor.Set(-7.0f, 15.0f);
+ jd.Initialize(b2, b4, anchor);
+ m_world->CreateJoint(&jd);
+
+ b2Body* b5;
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(6.5f, 3.0f);
+ b5 = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ b2FixtureDef fd;
+
+ fd.shape = &shape;
+ fd.density = 10.0f;
+ fd.friction = 0.1f;
+
+ shape.SetAsBox(1.0f, 0.1f, b2Vec2(0.0f, -0.9f), 0.0f);
+ b5->CreateFixture(&fd);
+
+ shape.SetAsBox(0.1f, 1.0f, b2Vec2(-0.9f, 0.0f), 0.0f);
+ b5->CreateFixture(&fd);
+
+ shape.SetAsBox(0.1f, 1.0f, b2Vec2(0.9f, 0.0f), 0.0f);
+ b5->CreateFixture(&fd);
+ }
+
+ anchor.Set(6.0f, 2.0f);
+ jd.Initialize(b1, b5, anchor);
+ m_world->CreateJoint(&jd);
+
+ b2Body* b6;
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(1.0f, 0.1f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(6.5f, 4.1f);
+ b6 = m_world->CreateBody(&bd);
+ b6->CreateFixture(&shape, 30.0f);
+ }
+
+ anchor.Set(7.5f, 4.0f);
+ jd.Initialize(b5, b6, anchor);
+ m_world->CreateJoint(&jd);
+
+ b2Body* b7;
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.1f, 1.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(7.4f, 1.0f);
+
+ b7 = m_world->CreateBody(&bd);
+ b7->CreateFixture(&shape, 10.0f);
+ }
+
+ b2DistanceJointDef djd;
+ djd.bodyA = b3;
+ djd.bodyB = b7;
+ djd.localAnchorA.Set(6.0f, 0.0f);
+ djd.localAnchorB.Set(0.0f, -1.0f);
+ b2Vec2 d = djd.bodyB->GetWorldPoint(djd.localAnchorB) - djd.bodyA->GetWorldPoint(djd.localAnchorA);
+ djd.length = d.Length();
+
+ b2LinearStiffness(djd.stiffness, djd.damping, 1.0f, 1.0f, djd.bodyA, djd.bodyB);
+ m_world->CreateJoint(&djd);
+
+ {
+ float radius = 0.2f;
+
+ b2CircleShape shape;
+ shape.m_radius = radius;
+
+ for (int32 i = 0; i < 4; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(5.9f + 2.0f * radius * i, 2.4f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 10.0f);
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Dominos;
+ }
+};
+
+static int testIndex = RegisterTest("Examples", "Dominos", Dominos::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/dump_loader.cpp b/Client/ThirdParty/Box2D/testbed/tests/dump_loader.cpp
new file mode 100644
index 0000000..882f59b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/dump_loader.cpp
@@ -0,0 +1,88 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// This test holds worlds dumped using b2World::Dump.
+class DumpLoader : public Test
+{
+public:
+
+ DumpLoader()
+ {
+ b2ChainShape chainShape;
+ b2Vec2 vertices[] = {b2Vec2(-5,0), b2Vec2(5,0), b2Vec2(5,5), b2Vec2(4,1), b2Vec2(-4,1), b2Vec2(-5,5)};
+ chainShape.CreateLoop(vertices, 6);
+
+ b2FixtureDef groundFixtureDef;
+ groundFixtureDef.density = 0;
+ groundFixtureDef.shape = &chainShape;
+
+ b2BodyDef groundBodyDef;
+ groundBodyDef.type = b2_staticBody;
+
+ b2Body *groundBody = m_world->CreateBody(&groundBodyDef);
+ b2Fixture *groundBodyFixture = groundBody->CreateFixture(&groundFixtureDef);
+
+ b2CircleShape ballShape;
+ ballShape.m_radius = 1;
+
+ b2FixtureDef ballFixtureDef;
+ ballFixtureDef.restitution = 0.75f;
+ ballFixtureDef.density = 1;
+ ballFixtureDef.shape = &ballShape;
+
+ b2BodyDef ballBodyDef;
+ ballBodyDef.type = b2BodyType::b2_dynamicBody;
+ ballBodyDef.position = b2Vec2(0, 10);
+ // ballBodyDef.angularDamping = 0.2f;
+
+ m_ball = m_world->CreateBody(&ballBodyDef);
+ b2Fixture *ballFixture = m_ball->CreateFixture(&ballFixtureDef);
+ m_ball->ApplyForceToCenter(b2Vec2(-1000, -400), true);
+ }
+
+ void Step(Settings& settings) override
+ {
+ b2Vec2 v = m_ball->GetLinearVelocity();
+ float omega = m_ball->GetAngularVelocity();
+
+ b2MassData massData;
+ m_ball->GetMassData(&massData);
+
+ float ke = 0.5f * massData.mass * b2Dot(v, v) + 0.5f * massData.I * omega * omega;
+
+ g_debugDraw.DrawString(5, m_textLine, "kinetic energy = %.6f", ke);
+ m_textLine += m_textIncrement;
+
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new DumpLoader;
+ }
+
+ b2Body* m_ball;
+};
+
+static int testIndex = RegisterTest("Bugs", "Dump Loader", DumpLoader::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/dynamic_tree.cpp b/Client/ThirdParty/Box2D/testbed/tests/dynamic_tree.cpp
new file mode 100644
index 0000000..7772d5c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/dynamic_tree.cpp
@@ -0,0 +1,360 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class DynamicTree : public Test
+{
+public:
+
+ enum
+ {
+ e_actorCount = 128
+ };
+
+ DynamicTree()
+ {
+ m_worldExtent = 15.0f;
+ m_proxyExtent = 0.5f;
+
+ srand(888);
+
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ Actor* actor = m_actors + i;
+ GetRandomAABB(&actor->aabb);
+ actor->proxyId = m_tree.CreateProxy(actor->aabb, actor);
+ }
+
+ m_stepCount = 0;
+
+ float h = m_worldExtent;
+ m_queryAABB.lowerBound.Set(-3.0f, -4.0f + h);
+ m_queryAABB.upperBound.Set(5.0f, 6.0f + h);
+
+ m_rayCastInput.p1.Set(-5.0, 5.0f + h);
+ m_rayCastInput.p2.Set(7.0f, -4.0f + h);
+ //m_rayCastInput.p1.Set(0.0f, 2.0f + h);
+ //m_rayCastInput.p2.Set(0.0f, -2.0f + h);
+ m_rayCastInput.maxFraction = 1.0f;
+
+ m_automated = false;
+ }
+
+ static Test* Create()
+ {
+ return new DynamicTree;
+ }
+
+ void Step(Settings& settings) override
+ {
+ B2_NOT_USED(settings);
+
+ m_rayActor = NULL;
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ m_actors[i].fraction = 1.0f;
+ m_actors[i].overlap = false;
+ }
+
+ if (m_automated == true)
+ {
+ int32 actionCount = b2Max(1, e_actorCount >> 2);
+
+ for (int32 i = 0; i < actionCount; ++i)
+ {
+ Action();
+ }
+ }
+
+ Query();
+ RayCast();
+
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ Actor* actor = m_actors + i;
+ if (actor->proxyId == b2_nullNode)
+ continue;
+
+ b2Color c(0.9f, 0.9f, 0.9f);
+ if (actor == m_rayActor && actor->overlap)
+ {
+ c.Set(0.9f, 0.6f, 0.6f);
+ }
+ else if (actor == m_rayActor)
+ {
+ c.Set(0.6f, 0.9f, 0.6f);
+ }
+ else if (actor->overlap)
+ {
+ c.Set(0.6f, 0.6f, 0.9f);
+ }
+
+ g_debugDraw.DrawAABB(&actor->aabb, c);
+ }
+
+ b2Color c(0.7f, 0.7f, 0.7f);
+ g_debugDraw.DrawAABB(&m_queryAABB, c);
+
+ g_debugDraw.DrawSegment(m_rayCastInput.p1, m_rayCastInput.p2, c);
+
+ b2Color c1(0.2f, 0.9f, 0.2f);
+ b2Color c2(0.9f, 0.2f, 0.2f);
+ g_debugDraw.DrawPoint(m_rayCastInput.p1, 6.0f, c1);
+ g_debugDraw.DrawPoint(m_rayCastInput.p2, 6.0f, c2);
+
+ if (m_rayActor)
+ {
+ b2Color cr(0.2f, 0.2f, 0.9f);
+ b2Vec2 p = m_rayCastInput.p1 + m_rayActor->fraction * (m_rayCastInput.p2 - m_rayCastInput.p1);
+ g_debugDraw.DrawPoint(p, 6.0f, cr);
+ }
+
+ {
+ int32 height = m_tree.GetHeight();
+ g_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d", height);
+ m_textLine += m_textIncrement;
+ }
+
+ ++m_stepCount;
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_automated = !m_automated;
+ break;
+
+ case GLFW_KEY_C:
+ CreateProxy();
+ break;
+
+ case GLFW_KEY_D:
+ DestroyProxy();
+ break;
+
+ case GLFW_KEY_M:
+ MoveProxy();
+ break;
+ }
+ }
+
+ bool QueryCallback(int32 proxyId)
+ {
+ Actor* actor = (Actor*)m_tree.GetUserData(proxyId);
+ actor->overlap = b2TestOverlap(m_queryAABB, actor->aabb);
+ return true;
+ }
+
+ float RayCastCallback(const b2RayCastInput& input, int32 proxyId)
+ {
+ Actor* actor = (Actor*)m_tree.GetUserData(proxyId);
+
+ b2RayCastOutput output;
+ bool hit = actor->aabb.RayCast(&output, input);
+
+ if (hit)
+ {
+ m_rayCastOutput = output;
+ m_rayActor = actor;
+ m_rayActor->fraction = output.fraction;
+ return output.fraction;
+ }
+
+ return input.maxFraction;
+ }
+
+private:
+
+ struct Actor
+ {
+ b2AABB aabb;
+ float fraction;
+ bool overlap;
+ int32 proxyId;
+ };
+
+ void GetRandomAABB(b2AABB* aabb)
+ {
+ b2Vec2 w; w.Set(2.0f * m_proxyExtent, 2.0f * m_proxyExtent);
+ //aabb->lowerBound.x = -m_proxyExtent;
+ //aabb->lowerBound.y = -m_proxyExtent + m_worldExtent;
+ aabb->lowerBound.x = RandomFloat(-m_worldExtent, m_worldExtent);
+ aabb->lowerBound.y = RandomFloat(0.0f, 2.0f * m_worldExtent);
+ aabb->upperBound = aabb->lowerBound + w;
+ }
+
+ void MoveAABB(b2AABB* aabb)
+ {
+ b2Vec2 d;
+ d.x = RandomFloat(-0.5f, 0.5f);
+ d.y = RandomFloat(-0.5f, 0.5f);
+ //d.x = 2.0f;
+ //d.y = 0.0f;
+ aabb->lowerBound += d;
+ aabb->upperBound += d;
+
+ b2Vec2 c0 = 0.5f * (aabb->lowerBound + aabb->upperBound);
+ b2Vec2 min; min.Set(-m_worldExtent, 0.0f);
+ b2Vec2 max; max.Set(m_worldExtent, 2.0f * m_worldExtent);
+ b2Vec2 c = b2Clamp(c0, min, max);
+
+ aabb->lowerBound += c - c0;
+ aabb->upperBound += c - c0;
+ }
+
+ void CreateProxy()
+ {
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ int32 j = rand() % e_actorCount;
+ Actor* actor = m_actors + j;
+ if (actor->proxyId == b2_nullNode)
+ {
+ GetRandomAABB(&actor->aabb);
+ actor->proxyId = m_tree.CreateProxy(actor->aabb, actor);
+ return;
+ }
+ }
+ }
+
+ void DestroyProxy()
+ {
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ int32 j = rand() % e_actorCount;
+ Actor* actor = m_actors + j;
+ if (actor->proxyId != b2_nullNode)
+ {
+ m_tree.DestroyProxy(actor->proxyId);
+ actor->proxyId = b2_nullNode;
+ return;
+ }
+ }
+ }
+
+ void MoveProxy()
+ {
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ int32 j = rand() % e_actorCount;
+ Actor* actor = m_actors + j;
+ if (actor->proxyId == b2_nullNode)
+ {
+ continue;
+ }
+
+ b2AABB aabb0 = actor->aabb;
+ MoveAABB(&actor->aabb);
+ b2Vec2 displacement = actor->aabb.GetCenter() - aabb0.GetCenter();
+ m_tree.MoveProxy(actor->proxyId, actor->aabb, displacement);
+ return;
+ }
+ }
+
+ void Action()
+ {
+ int32 choice = rand() % 20;
+
+ switch (choice)
+ {
+ case 0:
+ CreateProxy();
+ break;
+
+ case 1:
+ DestroyProxy();
+ break;
+
+ default:
+ MoveProxy();
+ }
+ }
+
+ void Query()
+ {
+ m_tree.Query(this, m_queryAABB);
+
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ if (m_actors[i].proxyId == b2_nullNode)
+ {
+ continue;
+ }
+
+ bool overlap = b2TestOverlap(m_queryAABB, m_actors[i].aabb);
+ B2_NOT_USED(overlap);
+ b2Assert(overlap == m_actors[i].overlap);
+ }
+ }
+
+ void RayCast()
+ {
+ m_rayActor = NULL;
+
+ b2RayCastInput input = m_rayCastInput;
+
+ // Ray cast against the dynamic tree.
+ m_tree.RayCast(this, input);
+
+ // Brute force ray cast.
+ Actor* bruteActor = NULL;
+ b2RayCastOutput bruteOutput;
+ for (int32 i = 0; i < e_actorCount; ++i)
+ {
+ if (m_actors[i].proxyId == b2_nullNode)
+ {
+ continue;
+ }
+
+ b2RayCastOutput output;
+ bool hit = m_actors[i].aabb.RayCast(&output, input);
+ if (hit)
+ {
+ bruteActor = m_actors + i;
+ bruteOutput = output;
+ input.maxFraction = output.fraction;
+ }
+ }
+
+ if (bruteActor != NULL)
+ {
+ b2Assert(bruteOutput.fraction == m_rayCastOutput.fraction);
+ }
+ }
+
+ float m_worldExtent;
+ float m_proxyExtent;
+
+ b2DynamicTree m_tree;
+ b2AABB m_queryAABB;
+ b2RayCastInput m_rayCastInput;
+ b2RayCastOutput m_rayCastOutput;
+ Actor* m_rayActor;
+ Actor m_actors[e_actorCount];
+ int32 m_stepCount;
+ bool m_automated;
+};
+
+static int testIndex = RegisterTest("Collision", "Dynamic Tree", DynamicTree::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/edge_shapes.cpp b/Client/ThirdParty/Box2D/testbed/tests/edge_shapes.cpp
new file mode 100644
index 0000000..6648c3c
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/edge_shapes.cpp
@@ -0,0 +1,253 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+
+class EdgeShapesCallback : public b2RayCastCallback
+{
+public:
+ EdgeShapesCallback()
+ {
+ m_fixture = NULL;
+ }
+
+ float ReportFixture(b2Fixture* fixture, const b2Vec2& point,
+ const b2Vec2& normal, float fraction) override
+ {
+ m_fixture = fixture;
+ m_point = point;
+ m_normal = normal;
+
+ return fraction;
+ }
+
+ b2Fixture* m_fixture;
+ b2Vec2 m_point;
+ b2Vec2 m_normal;
+};
+
+class EdgeShapes : public Test
+{
+public:
+
+ enum
+ {
+ e_maxBodies = 256
+ };
+
+ EdgeShapes()
+ {
+ // Ground body
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ float x1 = -20.0f;
+ float y1 = 2.0f * cosf(x1 / 10.0f * b2_pi);
+ for (int32 i = 0; i < 80; ++i)
+ {
+ float x2 = x1 + 0.5f;
+ float y2 = 2.0f * cosf(x2 / 10.0f * b2_pi);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(x1, y1), b2Vec2(x2, y2));
+ ground->CreateFixture(&shape, 0.0f);
+
+ x1 = x2;
+ y1 = y2;
+ }
+ }
+
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.5f, 0.0f);
+ vertices[1].Set(0.5f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+ m_polygons[0].Set(vertices, 3);
+ }
+
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.1f, 0.0f);
+ vertices[1].Set(0.1f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+ m_polygons[1].Set(vertices, 3);
+ }
+
+ {
+ float w = 1.0f;
+ float b = w / (2.0f + b2Sqrt(2.0f));
+ float s = b2Sqrt(2.0f) * b;
+
+ b2Vec2 vertices[8];
+ vertices[0].Set(0.5f * s, 0.0f);
+ vertices[1].Set(0.5f * w, b);
+ vertices[2].Set(0.5f * w, b + s);
+ vertices[3].Set(0.5f * s, w);
+ vertices[4].Set(-0.5f * s, w);
+ vertices[5].Set(-0.5f * w, b + s);
+ vertices[6].Set(-0.5f * w, b);
+ vertices[7].Set(-0.5f * s, 0.0f);
+
+ m_polygons[2].Set(vertices, 8);
+ }
+
+ {
+ m_polygons[3].SetAsBox(0.5f, 0.5f);
+ }
+
+ {
+ m_circle.m_radius = 0.5f;
+ }
+
+ m_bodyIndex = 0;
+ memset(m_bodies, 0, sizeof(m_bodies));
+
+ m_angle = 0.0f;
+ }
+
+ void Create(int32 index)
+ {
+ if (m_bodies[m_bodyIndex] != NULL)
+ {
+ m_world->DestroyBody(m_bodies[m_bodyIndex]);
+ m_bodies[m_bodyIndex] = NULL;
+ }
+
+ b2BodyDef bd;
+
+ float x = RandomFloat(-10.0f, 10.0f);
+ float y = RandomFloat(10.0f, 20.0f);
+ bd.position.Set(x, y);
+ bd.angle = RandomFloat(-b2_pi, b2_pi);
+ bd.type = b2_dynamicBody;
+
+ if (index == 4)
+ {
+ bd.angularDamping = 0.02f;
+ }
+
+ m_bodies[m_bodyIndex] = m_world->CreateBody(&bd);
+
+ if (index < 4)
+ {
+ b2FixtureDef fd;
+ fd.shape = m_polygons + index;
+ fd.friction = 0.3f;
+ fd.density = 20.0f;
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+ else
+ {
+ b2FixtureDef fd;
+ fd.shape = &m_circle;
+ fd.friction = 0.3f;
+ fd.density = 20.0f;
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+
+ m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies;
+ }
+
+ void DestroyBody()
+ {
+ for (int32 i = 0; i < e_maxBodies; ++i)
+ {
+ if (m_bodies[i] != NULL)
+ {
+ m_world->DestroyBody(m_bodies[i]);
+ m_bodies[i] = NULL;
+ return;
+ }
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_1:
+ case GLFW_KEY_2:
+ case GLFW_KEY_3:
+ case GLFW_KEY_4:
+ case GLFW_KEY_5:
+ Create(key - GLFW_KEY_1);
+ break;
+
+ case GLFW_KEY_D:
+ DestroyBody();
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ bool advanceRay = settings.m_pause == 0 || settings.m_singleStep;
+
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff");
+ m_textLine += m_textIncrement;
+
+ float L = 25.0f;
+ b2Vec2 point1(0.0f, 10.0f);
+ b2Vec2 d(L * cosf(m_angle), -L * b2Abs(sinf(m_angle)));
+ b2Vec2 point2 = point1 + d;
+
+ EdgeShapesCallback callback;
+
+ m_world->RayCast(&callback, point1, point2);
+
+ if (callback.m_fixture)
+ {
+ g_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
+
+ g_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
+
+ b2Vec2 head = callback.m_point + 0.5f * callback.m_normal;
+ g_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
+ }
+ else
+ {
+ g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
+ }
+
+ if (advanceRay)
+ {
+ m_angle += 0.25f * b2_pi / 180.0f;
+ }
+ }
+
+ static Test* Create()
+ {
+ return new EdgeShapes;
+ }
+
+ int32 m_bodyIndex;
+ b2Body* m_bodies[e_maxBodies];
+ b2PolygonShape m_polygons[4];
+ b2CircleShape m_circle;
+
+ float m_angle;
+};
+
+static int testIndex = RegisterTest("Geometry", "Edge Shapes", EdgeShapes::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/edge_test.cpp b/Client/ThirdParty/Box2D/testbed/tests/edge_test.cpp
new file mode 100644
index 0000000..335e9fe
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/edge_test.cpp
@@ -0,0 +1,282 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "imgui/imgui.h"
+
+class EdgeTest : public Test
+{
+public:
+
+ EdgeTest()
+ {
+ b2Vec2 vertices[10] =
+ {
+ {10.0f, -4.0f},
+ {10.0f, 0.0f},
+ {6.0f, 0.0f},
+ {4.0f, 2.0f},
+ {2.0f, 0.0f},
+ {-2.0f, 0.0f},
+ {-6.0f, 0.0f},
+ {-8.0f, -3.0f},
+ {-10.0f, 0.0f},
+ {-10.0f, -4.0f}
+ };
+
+ m_offset1.Set(0.0f, 8.0f);
+ m_offset2.Set(0.0f, 16.0f);
+
+ {
+ b2Vec2 v1 = vertices[0] + m_offset1;
+ b2Vec2 v2 = vertices[1] + m_offset1;
+ b2Vec2 v3 = vertices[2] + m_offset1;
+ b2Vec2 v4 = vertices[3] + m_offset1;
+ b2Vec2 v5 = vertices[4] + m_offset1;
+ b2Vec2 v6 = vertices[5] + m_offset1;
+ b2Vec2 v7 = vertices[6] + m_offset1;
+ b2Vec2 v8 = vertices[7] + m_offset1;
+ b2Vec2 v9 = vertices[8] + m_offset1;
+ b2Vec2 v10 = vertices[9] + m_offset1;
+
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+
+ shape.SetOneSided(v10, v1, v2, v3);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v1, v2, v3, v4);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v2, v3, v4, v5);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v3, v4, v5, v6);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v4, v5, v6, v7);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v5, v6, v7, v8);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v6, v7, v8, v9);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v7, v8, v9, v10);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v8, v9, v10, v1);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetOneSided(v9, v10, v1, v2);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2Vec2 v1 = vertices[0] + m_offset2;
+ b2Vec2 v2 = vertices[1] + m_offset2;
+ b2Vec2 v3 = vertices[2] + m_offset2;
+ b2Vec2 v4 = vertices[3] + m_offset2;
+ b2Vec2 v5 = vertices[4] + m_offset2;
+ b2Vec2 v6 = vertices[5] + m_offset2;
+ b2Vec2 v7 = vertices[6] + m_offset2;
+ b2Vec2 v8 = vertices[7] + m_offset2;
+ b2Vec2 v9 = vertices[8] + m_offset2;
+ b2Vec2 v10 = vertices[9] + m_offset2;
+
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+
+ shape.SetTwoSided(v1, v2);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v2, v3);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v3, v4);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v4, v5);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v5, v6);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v6, v7);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v7, v8);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v8, v9);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v9, v10);
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(v10, v1);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ m_body1 = nullptr;
+ m_body2 = nullptr;
+ CreateBoxes();
+ m_boxes = true;
+ }
+
+ void CreateBoxes()
+ {
+ if (m_body1)
+ {
+ m_world->DestroyBody(m_body1);
+ m_body1 = nullptr;
+ }
+
+ if (m_body2)
+ {
+ m_world->DestroyBody(m_body2);
+ m_body2 = nullptr;
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = b2Vec2(8.0f, 2.6f) + m_offset1;
+ bd.allowSleep = false;
+ m_body1 = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 1.0f);
+
+ m_body1->CreateFixture(&shape, 1.0f);
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = b2Vec2(8.0f, 2.6f) + m_offset2;
+ bd.allowSleep = false;
+ m_body2 = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 1.0f);
+
+ m_body2->CreateFixture(&shape, 1.0f);
+ }
+ }
+
+ void CreateCircles()
+ {
+ if (m_body1)
+ {
+ m_world->DestroyBody(m_body1);
+ m_body1 = nullptr;
+ }
+
+ if (m_body2)
+ {
+ m_world->DestroyBody(m_body2);
+ m_body2 = nullptr;
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = b2Vec2(-0.5f, 0.6f) + m_offset1;
+ bd.allowSleep = false;
+ m_body1 = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+
+ m_body1->CreateFixture(&shape, 1.0f);
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = b2Vec2(-0.5f, 0.6f) + m_offset2;
+ bd.allowSleep = false;
+ m_body2 = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+
+ m_body2->CreateFixture(&shape, 1.0f);
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 100.0f));
+ ImGui::Begin("Custom Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::RadioButton("Boxes", m_boxes == true))
+ {
+ CreateBoxes();
+ m_boxes = true;
+ }
+
+ if (ImGui::RadioButton("Circles", m_boxes == false))
+ {
+ CreateCircles();
+ m_boxes = false;
+ }
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_A) == GLFW_PRESS)
+ {
+ m_body1->ApplyForceToCenter(b2Vec2(-10.0f, 0.0f), true);
+ m_body2->ApplyForceToCenter(b2Vec2(-10.0f, 0.0f), true);
+ }
+
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_D) == GLFW_PRESS)
+ {
+ m_body1->ApplyForceToCenter(b2Vec2(10.0f, 0.0f), true);
+ m_body2->ApplyForceToCenter(b2Vec2(10.0f, 0.0f), true);
+ }
+
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new EdgeTest;
+ }
+
+ b2Vec2 m_offset1, m_offset2;
+ b2Body* m_body1;
+ b2Body* m_body2;
+ bool m_boxes;
+};
+
+static int testIndex = RegisterTest("Geometry", "Edge Test", EdgeTest::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/friction.cpp b/Client/ThirdParty/Box2D/testbed/tests/friction.cpp
new file mode 100644
index 0000000..9f1c06e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/friction.cpp
@@ -0,0 +1,127 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Friction : public Test
+{
+public:
+
+ Friction()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(13.0f, 0.25f);
+
+ b2BodyDef bd;
+ bd.position.Set(-4.0f, 22.0f);
+ bd.angle = -0.25f;
+
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f, 1.0f);
+
+ b2BodyDef bd;
+ bd.position.Set(10.5f, 19.0f);
+
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(13.0f, 0.25f);
+
+ b2BodyDef bd;
+ bd.position.Set(4.0f, 14.0f);
+ bd.angle = 0.25f;
+
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f, 1.0f);
+
+ b2BodyDef bd;
+ bd.position.Set(-10.5f, 11.0f);
+
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(13.0f, 0.25f);
+
+ b2BodyDef bd;
+ bd.position.Set(-4.0f, 6.0f);
+ bd.angle = -0.25f;
+
+ b2Body* ground = m_world->CreateBody(&bd);
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 25.0f;
+
+ float friction[5] = {0.75f, 0.5f, 0.35f, 0.1f, 0.0f};
+
+ for (int i = 0; i < 5; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-15.0f + 4.0f * i, 28.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ fd.friction = friction[i];
+ body->CreateFixture(&fd);
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Friction;
+ }
+};
+
+static int testIndex = RegisterTest("Forces", "Friction", Friction::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/gear_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/gear_joint.cpp
new file mode 100644
index 0000000..6f31283
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/gear_joint.cpp
@@ -0,0 +1,180 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class GearJoint : public Test
+{
+public:
+ GearJoint()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(50.0f, 0.0f), b2Vec2(-50.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2CircleShape circle1;
+ circle1.m_radius = 1.0f;
+
+ b2PolygonShape box;
+ box.SetAsBox(0.5f, 5.0f);
+
+ b2CircleShape circle2;
+ circle2.m_radius = 2.0f;
+
+ b2BodyDef bd1;
+ bd1.type = b2_staticBody;
+ bd1.position.Set(10.0f, 9.0f);
+ b2Body* body1 = m_world->CreateBody(&bd1);
+ body1->CreateFixture(&circle1, 5.0f);
+
+ b2BodyDef bd2;
+ bd2.type = b2_dynamicBody;
+ bd2.position.Set(10.0f, 8.0f);
+ b2Body* body2 = m_world->CreateBody(&bd2);
+ body2->CreateFixture(&box, 5.0f);
+
+ b2BodyDef bd3;
+ bd3.type = b2_dynamicBody;
+ bd3.position.Set(10.0f, 6.0f);
+ b2Body* body3 = m_world->CreateBody(&bd3);
+ body3->CreateFixture(&circle2, 5.0f);
+
+ b2RevoluteJointDef jd1;
+ jd1.Initialize(body1, body2, bd1.position);
+ b2Joint* joint1 = m_world->CreateJoint(&jd1);
+
+ b2RevoluteJointDef jd2;
+ jd2.Initialize(body2, body3, bd3.position);
+ b2Joint* joint2 = m_world->CreateJoint(&jd2);
+
+ b2GearJointDef jd4;
+ jd4.bodyA = body1;
+ jd4.bodyB = body3;
+ jd4.joint1 = joint1;
+ jd4.joint2 = joint2;
+ jd4.ratio = circle2.m_radius / circle1.m_radius;
+ m_world->CreateJoint(&jd4);
+ }
+
+ {
+ b2CircleShape circle1;
+ circle1.m_radius = 1.0f;
+
+ b2CircleShape circle2;
+ circle2.m_radius = 2.0f;
+
+ b2PolygonShape box;
+ box.SetAsBox(0.5f, 5.0f);
+
+ b2BodyDef bd1;
+ bd1.type = b2_dynamicBody;
+ bd1.position.Set(-3.0f, 12.0f);
+ b2Body* body1 = m_world->CreateBody(&bd1);
+ body1->CreateFixture(&circle1, 5.0f);
+
+ b2RevoluteJointDef jd1;
+ jd1.bodyA = ground;
+ jd1.bodyB = body1;
+ jd1.localAnchorA = ground->GetLocalPoint(bd1.position);
+ jd1.localAnchorB = body1->GetLocalPoint(bd1.position);
+ jd1.referenceAngle = body1->GetAngle() - ground->GetAngle();
+ m_joint1 = (b2RevoluteJoint*)m_world->CreateJoint(&jd1);
+
+ b2BodyDef bd2;
+ bd2.type = b2_dynamicBody;
+ bd2.position.Set(0.0f, 12.0f);
+ b2Body* body2 = m_world->CreateBody(&bd2);
+ body2->CreateFixture(&circle2, 5.0f);
+
+ b2RevoluteJointDef jd2;
+ jd2.Initialize(ground, body2, bd2.position);
+ m_joint2 = (b2RevoluteJoint*)m_world->CreateJoint(&jd2);
+
+ b2BodyDef bd3;
+ bd3.type = b2_dynamicBody;
+ bd3.position.Set(2.5f, 12.0f);
+ b2Body* body3 = m_world->CreateBody(&bd3);
+ body3->CreateFixture(&box, 5.0f);
+
+ b2PrismaticJointDef jd3;
+ jd3.Initialize(ground, body3, bd3.position, b2Vec2(0.0f, 1.0f));
+ jd3.lowerTranslation = -5.0f;
+ jd3.upperTranslation = 5.0f;
+ jd3.enableLimit = true;
+
+ m_joint3 = (b2PrismaticJoint*)m_world->CreateJoint(&jd3);
+
+ b2GearJointDef jd4;
+ jd4.bodyA = body1;
+ jd4.bodyB = body2;
+ jd4.joint1 = m_joint1;
+ jd4.joint2 = m_joint2;
+ jd4.ratio = circle2.m_radius / circle1.m_radius;
+ m_joint4 = (b2GearJoint*)m_world->CreateJoint(&jd4);
+
+ b2GearJointDef jd5;
+ jd5.bodyA = body2;
+ jd5.bodyB = body3;
+ jd5.joint1 = m_joint2;
+ jd5.joint2 = m_joint3;
+ jd5.ratio = -1.0f / circle2.m_radius;
+ m_joint5 = (b2GearJoint*)m_world->CreateJoint(&jd5);
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ float ratio, value;
+
+ ratio = m_joint4->GetRatio();
+ value = m_joint1->GetJointAngle() + ratio * m_joint2->GetJointAngle();
+ g_debugDraw.DrawString(5, m_textLine, "theta1 + %4.2f * theta2 = %4.2f", (float) ratio, (float) value);
+ m_textLine += m_textIncrement;
+
+ ratio = m_joint5->GetRatio();
+ value = m_joint2->GetJointAngle() + ratio * m_joint3->GetJointTranslation();
+ g_debugDraw.DrawString(5, m_textLine, "theta2 + %4.2f * delta = %4.2f", (float) ratio, (float) value);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new GearJoint;
+ }
+
+ b2RevoluteJoint* m_joint1;
+ b2RevoluteJoint* m_joint2;
+ b2PrismaticJoint* m_joint3;
+ b2GearJoint* m_joint4;
+ b2GearJoint* m_joint5;
+};
+
+static int testIndex = RegisterTest("Joints", "Gear", GearJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/heavy1.cpp b/Client/ThirdParty/Box2D/testbed/tests/heavy1.cpp
new file mode 100644
index 0000000..d302808
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/heavy1.cpp
@@ -0,0 +1,61 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Heavy1 : public Test
+{
+public:
+
+ Heavy1()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 0.5f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+ body->CreateFixture(&shape, 10.0f);
+
+ bd.position.Set(0.0f, 6.0f);
+ body = m_world->CreateBody(&bd);
+ shape.m_radius = 5.0f;
+ body->CreateFixture(&shape, 10.0f);
+ }
+
+ static Test* Create()
+ {
+ return new Heavy1;
+ }
+};
+
+static int testIndex = RegisterTest("Solver", "Heavy 1", Heavy1::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/heavy2.cpp b/Client/ThirdParty/Box2D/testbed/tests/heavy2.cpp
new file mode 100644
index 0000000..271c089
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/heavy2.cpp
@@ -0,0 +1,94 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Heavy2 : public Test
+{
+public:
+
+ Heavy2()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 2.5f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.5f;
+ body->CreateFixture(&shape, 10.0f);
+
+ bd.position.Set(0.0f, 3.5f);
+ body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 10.0f);
+
+ m_heavy = NULL;
+ }
+
+ void ToggleHeavy()
+ {
+ if (m_heavy)
+ {
+ m_world->DestroyBody(m_heavy);
+ m_heavy = NULL;
+ }
+ else
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 9.0f);
+ m_heavy = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 5.0f;
+ m_heavy->CreateFixture(&shape, 10.0f);
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_H:
+ ToggleHeavy();
+ break;
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Heavy2;
+ }
+
+ b2Body* m_heavy;
+};
+
+static int testIndex = RegisterTest("Solver", "Heavy 2", Heavy2::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/mobile_balanced.cpp b/Client/ThirdParty/Box2D/testbed/tests/mobile_balanced.cpp
new file mode 100644
index 0000000..ee5af37
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/mobile_balanced.cpp
@@ -0,0 +1,108 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class MobileBalanced : public Test
+{
+public:
+
+ enum
+ {
+ e_depth = 4
+ };
+
+ MobileBalanced()
+ {
+ b2Body* ground;
+
+ // Create ground body.
+ {
+ b2BodyDef bodyDef;
+ bodyDef.position.Set(0.0f, 20.0f);
+ ground = m_world->CreateBody(&bodyDef);
+ }
+
+ float a = 0.5f;
+ b2Vec2 h(0.0f, a);
+
+ b2Body* root = AddNode(ground, b2Vec2_zero, 0, 3.0f, a);
+
+ b2RevoluteJointDef jointDef;
+ jointDef.bodyA = ground;
+ jointDef.bodyB = root;
+ jointDef.localAnchorA.SetZero();
+ jointDef.localAnchorB = h;
+ m_world->CreateJoint(&jointDef);
+ }
+
+ b2Body* AddNode(b2Body* parent, const b2Vec2& localAnchor, int32 depth, float offset, float a)
+ {
+ float density = 20.0f;
+ b2Vec2 h(0.0f, a);
+
+ b2Vec2 p = parent->GetPosition() + localAnchor - h;
+
+ b2BodyDef bodyDef;
+ bodyDef.type = b2_dynamicBody;
+ bodyDef.position = p;
+ b2Body* body = m_world->CreateBody(&bodyDef);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f * a, a);
+ body->CreateFixture(&shape, density);
+
+ if (depth == e_depth)
+ {
+ return body;
+ }
+
+ shape.SetAsBox(offset, 0.25f * a, b2Vec2(0, -a), 0.0f);
+ body->CreateFixture(&shape, density);
+
+ b2Vec2 a1 = b2Vec2(offset, -a);
+ b2Vec2 a2 = b2Vec2(-offset, -a);
+ b2Body* body1 = AddNode(body, a1, depth + 1, 0.5f * offset, a);
+ b2Body* body2 = AddNode(body, a2, depth + 1, 0.5f * offset, a);
+
+ b2RevoluteJointDef jointDef;
+ jointDef.bodyA = body;
+ jointDef.localAnchorB = h;
+
+ jointDef.localAnchorA = a1;
+ jointDef.bodyB = body1;
+ m_world->CreateJoint(&jointDef);
+
+ jointDef.localAnchorA = a2;
+ jointDef.bodyB = body2;
+ m_world->CreateJoint(&jointDef);
+
+ return body;
+ }
+
+ static Test* Create()
+ {
+ return new MobileBalanced;
+ }
+};
+
+static int testIndex = RegisterTest("Solver", "Mobile Balanced", MobileBalanced::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/mobile_unbalanced.cpp b/Client/ThirdParty/Box2D/testbed/tests/mobile_unbalanced.cpp
new file mode 100644
index 0000000..5f62fb6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/mobile_unbalanced.cpp
@@ -0,0 +1,105 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class MobileUnbalanced : public Test
+{
+public:
+
+ enum
+ {
+ e_depth = 4
+ };
+
+ MobileUnbalanced()
+ {
+ b2Body* ground;
+
+ // Create ground body.
+ {
+ b2BodyDef bodyDef;
+ bodyDef.position.Set(0.0f, 20.0f);
+ ground = m_world->CreateBody(&bodyDef);
+ }
+
+ float a = 0.5f;
+ b2Vec2 h(0.0f, a);
+
+ b2Body* root = AddNode(ground, b2Vec2_zero, 0, 3.0f, a);
+
+ b2RevoluteJointDef jointDef;
+ jointDef.bodyA = ground;
+ jointDef.bodyB = root;
+ jointDef.localAnchorA.SetZero();
+ jointDef.localAnchorB = h;
+ m_world->CreateJoint(&jointDef);
+ }
+
+ b2Body* AddNode(b2Body* parent, const b2Vec2& localAnchor, int32 depth, float offset, float a)
+ {
+ float density = 20.0f;
+ b2Vec2 h(0.0f, a);
+
+ b2Vec2 p = parent->GetPosition() + localAnchor - h;
+
+ b2BodyDef bodyDef;
+ bodyDef.type = b2_dynamicBody;
+ bodyDef.position = p;
+ b2Body* body = m_world->CreateBody(&bodyDef);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f * a, a);
+ body->CreateFixture(&shape, density);
+
+ if (depth == e_depth)
+ {
+ return body;
+ }
+
+ b2Vec2 a1 = b2Vec2(offset, -a);
+ b2Vec2 a2 = b2Vec2(-offset, -a);
+ b2Body* body1 = AddNode(body, a1, depth + 1, 0.5f * offset, a);
+ b2Body* body2 = AddNode(body, a2, depth + 1, 0.5f * offset, a);
+
+ b2RevoluteJointDef jointDef;
+ jointDef.bodyA = body;
+ jointDef.localAnchorB = h;
+
+ jointDef.localAnchorA = a1;
+ jointDef.bodyB = body1;
+ m_world->CreateJoint(&jointDef);
+
+ jointDef.localAnchorA = a2;
+ jointDef.bodyB = body2;
+ m_world->CreateJoint(&jointDef);
+
+ return body;
+ }
+
+ static Test* Create()
+ {
+ return new MobileUnbalanced;
+ }
+};
+
+static int testIndex = RegisterTest("Solver", "Mobile Unbalanced", MobileUnbalanced::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/motor_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/motor_joint.cpp
new file mode 100644
index 0000000..dcda76f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/motor_joint.cpp
@@ -0,0 +1,118 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+
+/// This test shows how to use a motor joint. A motor joint
+/// can be used to animate a dynamic body. With finite motor forces
+/// the body can be blocked by collision with other bodies.
+class MotorJoint : public Test
+{
+public:
+ MotorJoint()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+
+ ground->CreateFixture(&fd);
+ }
+
+ // Define motorized body
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 8.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(2.0f, 0.5f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.friction = 0.6f;
+ fd.density = 2.0f;
+ body->CreateFixture(&fd);
+
+ b2MotorJointDef mjd;
+ mjd.Initialize(ground, body);
+ mjd.maxForce = 1000.0f;
+ mjd.maxTorque = 1000.0f;
+ m_joint = (b2MotorJoint*)m_world->CreateJoint(&mjd);
+ }
+
+ m_go = false;
+ m_time = 0.0f;
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_S:
+ m_go = !m_go;
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ if (m_go && settings.m_hertz > 0.0f)
+ {
+ m_time += 1.0f / settings.m_hertz;
+ }
+
+ b2Vec2 linearOffset;
+ linearOffset.x = 6.0f * sinf(2.0f * m_time);
+ linearOffset.y = 8.0f + 4.0f * sinf(1.0f * m_time);
+
+ float angularOffset = 4.0f * m_time;
+
+ m_joint->SetLinearOffset(linearOffset);
+ m_joint->SetAngularOffset(angularOffset);
+
+ g_debugDraw.DrawPoint(linearOffset, 4.0f, b2Color(0.9f, 0.9f, 0.9f));
+
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "Keys: (s) pause");
+ m_textLine += 15;
+ }
+
+ static Test* Create()
+ {
+ return new MotorJoint;
+ }
+
+ b2MotorJoint* m_joint;
+ float m_time;
+ bool m_go;
+};
+
+static int testIndex = RegisterTest("Joints", "Motor Joint", MotorJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/pinball.cpp b/Client/ThirdParty/Box2D/testbed/tests/pinball.cpp
new file mode 100644
index 0000000..9a9826d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/pinball.cpp
@@ -0,0 +1,170 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+/// This tests bullet collision and provides an example of a gameplay scenario.
+/// This also uses a loop shape.
+class Pinball : public Test
+{
+public:
+ Pinball()
+ {
+ // Ground body
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2Vec2 vs[5];
+ vs[0].Set(-8.0f, 6.0f);
+ vs[1].Set(-8.0f, 20.0f);
+ vs[2].Set(8.0f, 20.0f);
+ vs[3].Set(8.0f, 6.0f);
+ vs[4].Set(0.0f, -2.0f);
+
+ b2ChainShape loop;
+ loop.CreateLoop(vs, 5);
+ b2FixtureDef fd;
+ fd.shape = &loop;
+ fd.density = 0.0f;
+ ground->CreateFixture(&fd);
+ }
+
+ // Flippers
+ {
+ b2Vec2 p1(-2.0f, 0.0f), p2(2.0f, 0.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ bd.position = p1;
+ b2Body* leftFlipper = m_world->CreateBody(&bd);
+
+ bd.position = p2;
+ b2Body* rightFlipper = m_world->CreateBody(&bd);
+
+ b2PolygonShape box;
+ box.SetAsBox(1.75f, 0.1f);
+
+ b2FixtureDef fd;
+ fd.shape = &box;
+ fd.density = 1.0f;
+
+ leftFlipper->CreateFixture(&fd);
+ rightFlipper->CreateFixture(&fd);
+
+ b2RevoluteJointDef jd;
+ jd.bodyA = ground;
+ jd.localAnchorB.SetZero();
+ jd.enableMotor = true;
+ jd.maxMotorTorque = 1000.0f;
+ jd.enableLimit = true;
+
+ jd.motorSpeed = 0.0f;
+ jd.localAnchorA = p1;
+ jd.bodyB = leftFlipper;
+ jd.lowerAngle = -30.0f * b2_pi / 180.0f;
+ jd.upperAngle = 5.0f * b2_pi / 180.0f;
+ m_leftJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
+
+ jd.motorSpeed = 0.0f;
+ jd.localAnchorA = p2;
+ jd.bodyB = rightFlipper;
+ jd.lowerAngle = -5.0f * b2_pi / 180.0f;
+ jd.upperAngle = 30.0f * b2_pi / 180.0f;
+ m_rightJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
+ }
+
+ // Circle character
+ {
+ b2BodyDef bd;
+ bd.position.Set(1.0f, 15.0f);
+ bd.type = b2_dynamicBody;
+ bd.bullet = true;
+
+ m_ball = m_world->CreateBody(&bd);
+
+ b2CircleShape shape;
+ shape.m_radius = 0.2f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+ m_ball->CreateFixture(&fd);
+ }
+
+ m_button = false;
+ }
+
+ void Step(Settings& settings) override
+ {
+ if (m_button)
+ {
+ m_leftJoint->SetMotorSpeed(20.0f);
+ m_rightJoint->SetMotorSpeed(-20.0f);
+ }
+ else
+ {
+ m_leftJoint->SetMotorSpeed(-10.0f);
+ m_rightJoint->SetMotorSpeed(10.0f);
+ }
+
+ Test::Step(settings);
+
+ g_debugDraw.DrawString(5, m_textLine, "Press 'a' to control the flippers");
+ m_textLine += m_textIncrement;
+
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_button = true;
+ break;
+ }
+ }
+
+ void KeyboardUp(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_button = false;
+ break;
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Pinball;
+ }
+
+ b2RevoluteJoint* m_leftJoint;
+ b2RevoluteJoint* m_rightJoint;
+ b2Body* m_ball;
+ bool m_button;
+};
+
+static int testIndex = RegisterTest("Examples", "Pinball", Pinball::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/platformer.cpp b/Client/ThirdParty/Box2D/testbed/tests/platformer.cpp
new file mode 100644
index 0000000..388892f
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/platformer.cpp
@@ -0,0 +1,133 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Platformer : public Test
+{
+public:
+
+ enum State
+ {
+ e_unknown,
+ e_above,
+ e_below
+ };
+
+ Platformer()
+ {
+ // Ground
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-20.0f, 0.0f), b2Vec2(20.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Platform
+ {
+ b2BodyDef bd;
+ bd.position.Set(0.0f, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(3.0f, 0.5f);
+ m_platform = body->CreateFixture(&shape, 0.0f);
+
+ m_bottom = 10.0f - 0.5f;
+ m_top = 10.0f + 0.5f;
+ }
+
+ // Actor
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 12.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ m_radius = 0.5f;
+ b2CircleShape shape;
+ shape.m_radius = m_radius;
+ m_character = body->CreateFixture(&shape, 20.0f);
+
+ body->SetLinearVelocity(b2Vec2(0.0f, -50.0f));
+
+ m_state = e_unknown;
+ }
+ }
+
+ void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override
+ {
+ Test::PreSolve(contact, oldManifold);
+
+ b2Fixture* fixtureA = contact->GetFixtureA();
+ b2Fixture* fixtureB = contact->GetFixtureB();
+
+ if (fixtureA != m_platform && fixtureA != m_character)
+ {
+ return;
+ }
+
+ if (fixtureB != m_platform && fixtureB != m_character)
+ {
+ return;
+ }
+
+#if 1
+ b2Vec2 position = m_character->GetBody()->GetPosition();
+
+ if (position.y < m_top + m_radius - 3.0f * b2_linearSlop)
+ {
+ contact->SetEnabled(false);
+ }
+#else
+ b2Vec2 v = m_character->GetBody()->GetLinearVelocity();
+ if (v.y > 0.0f)
+ {
+ contact->SetEnabled(false);
+ }
+#endif
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ b2Vec2 v = m_character->GetBody()->GetLinearVelocity();
+ g_debugDraw.DrawString(5, m_textLine, "Character Linear Velocity: %f", v.y);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new Platformer;
+ }
+
+ float m_radius, m_top, m_bottom;
+ State m_state;
+ b2Fixture* m_platform;
+ b2Fixture* m_character;
+};
+
+static int testIndex = RegisterTest("Examples", "Platformer", Platformer::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/polygon_collision.cpp b/Client/ThirdParty/Box2D/testbed/tests/polygon_collision.cpp
new file mode 100644
index 0000000..e55f133
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/polygon_collision.cpp
@@ -0,0 +1,127 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class PolygonCollision : public Test
+{
+public:
+ PolygonCollision()
+ {
+ {
+ m_polygonA.SetAsBox(0.2f, 0.4f);
+ m_transformA.Set(b2Vec2(0.0f, 0.0f), 0.0f);
+ }
+
+ {
+ m_polygonB.SetAsBox(0.5f, 0.5f);
+ m_positionB.Set(19.345284f, 1.5632932f);
+ m_angleB = 1.9160721f;
+ m_transformB.Set(m_positionB, m_angleB);
+ }
+ }
+
+ static Test* Create()
+ {
+ return new PolygonCollision;
+ }
+
+ void Step(Settings& settings) override
+ {
+ B2_NOT_USED(settings);
+
+ b2Manifold manifold;
+ b2CollidePolygons(&manifold, &m_polygonA, m_transformA, &m_polygonB, m_transformB);
+
+ b2WorldManifold worldManifold;
+ worldManifold.Initialize(&manifold, m_transformA, m_polygonA.m_radius, m_transformB, m_polygonB.m_radius);
+
+ g_debugDraw.DrawString(5, m_textLine, "point count = %d", manifold.pointCount);
+ m_textLine += m_textIncrement;
+
+ {
+ b2Color color(0.9f, 0.9f, 0.9f);
+ b2Vec2 v[b2_maxPolygonVertices];
+ for (int32 i = 0; i < m_polygonA.m_count; ++i)
+ {
+ v[i] = b2Mul(m_transformA, m_polygonA.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(v, m_polygonA.m_count, color);
+
+ for (int32 i = 0; i < m_polygonB.m_count; ++i)
+ {
+ v[i] = b2Mul(m_transformB, m_polygonB.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(v, m_polygonB.m_count, color);
+ }
+
+ for (int32 i = 0; i < manifold.pointCount; ++i)
+ {
+ g_debugDraw.DrawPoint(worldManifold.points[i], 4.0f, b2Color(0.9f, 0.3f, 0.3f));
+ }
+
+ Test::Step(settings);
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_positionB.x -= 0.1f;
+ break;
+
+ case GLFW_KEY_D:
+ m_positionB.x += 0.1f;
+ break;
+
+ case GLFW_KEY_S:
+ m_positionB.y -= 0.1f;
+ break;
+
+ case GLFW_KEY_W:
+ m_positionB.y += 0.1f;
+ break;
+
+ case GLFW_KEY_Q:
+ m_angleB += 0.1f * b2_pi;
+ break;
+
+ case GLFW_KEY_E:
+ m_angleB -= 0.1f * b2_pi;
+ break;
+ }
+
+ m_transformB.Set(m_positionB, m_angleB);
+ }
+
+ b2PolygonShape m_polygonA;
+ b2PolygonShape m_polygonB;
+
+ b2Transform m_transformA;
+ b2Transform m_transformB;
+
+ b2Vec2 m_positionB;
+ float m_angleB;
+};
+
+static int testIndex = RegisterTest("Geometry", "Polygon Collision", PolygonCollision::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/polygon_shapes.cpp b/Client/ThirdParty/Box2D/testbed/tests/polygon_shapes.cpp
new file mode 100644
index 0000000..e12875b
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/polygon_shapes.cpp
@@ -0,0 +1,265 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+/// This tests stacking. It also shows how to use b2World::Query
+/// and b2TestOverlap.
+
+/// This callback is called by b2World::QueryAABB. We find all the fixtures
+/// that overlap an AABB. Of those, we use b2TestOverlap to determine which fixtures
+/// overlap a circle. Up to 4 overlapped fixtures will be highlighted with a yellow border.
+class PolygonShapesCallback : public b2QueryCallback
+{
+public:
+
+ enum
+ {
+ e_maxCount = 4
+ };
+
+ PolygonShapesCallback()
+ {
+ m_count = 0;
+ }
+
+ /// Called for each fixture found in the query AABB.
+ /// @return false to terminate the query.
+ bool ReportFixture(b2Fixture* fixture) override
+ {
+ if (m_count == e_maxCount)
+ {
+ return false;
+ }
+
+ b2Body* body = fixture->GetBody();
+ b2Shape* shape = fixture->GetShape();
+
+ bool overlap = b2TestOverlap(shape, 0, &m_circle, 0, body->GetTransform(), m_transform);
+
+ if (overlap)
+ {
+ b2Color color(0.95f, 0.95f, 0.6f);
+ b2Vec2 center = body->GetWorldCenter();
+ g_debugDraw->DrawPoint(center, 5.0f, color);
+ ++m_count;
+ }
+
+ return true;
+ }
+
+ b2CircleShape m_circle;
+ b2Transform m_transform;
+ b2Draw* g_debugDraw;
+ int32 m_count;
+};
+
+class PolygonShapes : public Test
+{
+public:
+
+ enum
+ {
+ e_maxBodies = 256
+ };
+
+ PolygonShapes()
+ {
+ // Ground body
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.5f, 0.0f);
+ vertices[1].Set(0.5f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+ m_polygons[0].Set(vertices, 3);
+ }
+
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.1f, 0.0f);
+ vertices[1].Set(0.1f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+ m_polygons[1].Set(vertices, 3);
+ }
+
+ {
+ float w = 1.0f;
+ float b = w / (2.0f + b2Sqrt(2.0f));
+ float s = b2Sqrt(2.0f) * b;
+
+ b2Vec2 vertices[8];
+ vertices[0].Set(0.5f * s, 0.0f);
+ vertices[1].Set(0.5f * w, b);
+ vertices[2].Set(0.5f * w, b + s);
+ vertices[3].Set(0.5f * s, w);
+ vertices[4].Set(-0.5f * s, w);
+ vertices[5].Set(-0.5f * w, b + s);
+ vertices[6].Set(-0.5f * w, b);
+ vertices[7].Set(-0.5f * s, 0.0f);
+
+ m_polygons[2].Set(vertices, 8);
+ }
+
+ {
+ m_polygons[3].SetAsBox(0.5f, 0.5f);
+ }
+
+ {
+ m_circle.m_radius = 0.5f;
+ }
+
+ m_bodyIndex = 0;
+ memset(m_bodies, 0, sizeof(m_bodies));
+ }
+
+ void Create(int32 index)
+ {
+ if (m_bodies[m_bodyIndex] != NULL)
+ {
+ m_world->DestroyBody(m_bodies[m_bodyIndex]);
+ m_bodies[m_bodyIndex] = NULL;
+ }
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ float x = RandomFloat(-2.0f, 2.0f);
+ bd.position.Set(x, 10.0f);
+ bd.angle = RandomFloat(-b2_pi, b2_pi);
+
+ if (index == 4)
+ {
+ bd.angularDamping = 0.02f;
+ }
+
+ m_bodies[m_bodyIndex] = m_world->CreateBody(&bd);
+
+ if (index < 4)
+ {
+ b2FixtureDef fd;
+ fd.shape = m_polygons + index;
+ fd.density = 1.0f;
+ fd.friction = 0.3f;
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+ else
+ {
+ b2FixtureDef fd;
+ fd.shape = &m_circle;
+ fd.density = 1.0f;
+ fd.friction = 0.3f;
+
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+
+ m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies;
+ }
+
+ void DestroyBody()
+ {
+ for (int32 i = 0; i < e_maxBodies; ++i)
+ {
+ if (m_bodies[i] != NULL)
+ {
+ m_world->DestroyBody(m_bodies[i]);
+ m_bodies[i] = NULL;
+ return;
+ }
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_1:
+ case GLFW_KEY_2:
+ case GLFW_KEY_3:
+ case GLFW_KEY_4:
+ case GLFW_KEY_5:
+ Create(key - GLFW_KEY_1);
+ break;
+
+ case GLFW_KEY_A:
+ for (int32 i = 0; i < e_maxBodies; i += 2)
+ {
+ if (m_bodies[i])
+ {
+ bool enabled = m_bodies[i]->IsEnabled();
+ m_bodies[i]->SetEnabled(!enabled);
+ }
+ }
+ break;
+
+ case GLFW_KEY_D:
+ DestroyBody();
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ PolygonShapesCallback callback;
+ callback.m_circle.m_radius = 2.0f;
+ callback.m_circle.m_p.Set(0.0f, 1.1f);
+ callback.m_transform.SetIdentity();
+ callback.g_debugDraw = &g_debugDraw;
+
+ b2AABB aabb;
+ callback.m_circle.ComputeAABB(&aabb, callback.m_transform, 0);
+
+ m_world->QueryAABB(&callback, aabb);
+
+ b2Color color(0.4f, 0.7f, 0.8f);
+ g_debugDraw.DrawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color);
+
+ g_debugDraw.DrawString(5, m_textLine, "Press 1-5 to drop stuff, maximum of %d overlaps detected", PolygonShapesCallback::e_maxCount);
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "Press 'a' to enable/disable some bodies");
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "Press 'd' to destroy a body");
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new PolygonShapes;
+ }
+
+ int32 m_bodyIndex;
+ b2Body* m_bodies[e_maxBodies];
+ b2PolygonShape m_polygons[4];
+ b2CircleShape m_circle;
+};
+
+static int testIndex = RegisterTest("Geometry", "Polygon Shapes", PolygonShapes::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/prismatic_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/prismatic_joint.cpp
new file mode 100644
index 0000000..a3788cc
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/prismatic_joint.cpp
@@ -0,0 +1,118 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+#include "imgui/imgui.h"
+
+// Test the prismatic joint with limits and motor options.
+class PrismaticJoint : public Test
+{
+public:
+ PrismaticJoint()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ m_enableLimit = true;
+ m_enableMotor = false;
+ m_motorSpeed = 10.0f;
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(1.0f, 1.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 10.0f);
+ bd.angle = 0.5f * b2_pi;
+ bd.allowSleep = false;
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 5.0f);
+
+ b2PrismaticJointDef pjd;
+
+ // Horizontal
+ pjd.Initialize(ground, body, bd.position, b2Vec2(1.0f, 0.0f));
+
+ pjd.motorSpeed = m_motorSpeed;
+ pjd.maxMotorForce = 10000.0f;
+ pjd.enableMotor = m_enableMotor;
+ pjd.lowerTranslation = -10.0f;
+ pjd.upperTranslation = 10.0f;
+ pjd.enableLimit = m_enableLimit;
+
+ m_joint = (b2PrismaticJoint*)m_world->CreateJoint(&pjd);
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 100.0f));
+ ImGui::Begin("Joint Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::Checkbox("Limit", &m_enableLimit))
+ {
+ m_joint->EnableLimit(m_enableLimit);
+ }
+
+ if (ImGui::Checkbox("Motor", &m_enableMotor))
+ {
+ m_joint->EnableMotor(m_enableMotor);
+ }
+
+ if (ImGui::SliderFloat("Speed", &m_motorSpeed, -100.0f, 100.0f, "%.0f"))
+ {
+ m_joint->SetMotorSpeed(m_motorSpeed);
+ }
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+ float force = m_joint->GetMotorForce(settings.m_hertz);
+ g_debugDraw.DrawString(5, m_textLine, "Motor Force = %4.0f", force);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new PrismaticJoint;
+ }
+
+ b2PrismaticJoint* m_joint;
+ float m_motorSpeed;
+ bool m_enableMotor;
+ bool m_enableLimit;
+};
+
+static int testIndex = RegisterTest("Joints", "Prismatic", PrismaticJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/pulley_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/pulley_joint.cpp
new file mode 100644
index 0000000..c2ff683
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/pulley_joint.cpp
@@ -0,0 +1,96 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class PulleyJoint : public Test
+{
+public:
+ PulleyJoint()
+ {
+ float y = 16.0f;
+ float L = 12.0f;
+ float a = 1.0f;
+ float b = 2.0f;
+
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2CircleShape circle;
+ circle.m_radius = 2.0f;
+
+ circle.m_p.Set(-10.0f, y + b + L);
+ ground->CreateFixture(&circle, 0.0f);
+
+ circle.m_p.Set(10.0f, y + b + L);
+ ground->CreateFixture(&circle, 0.0f);
+ }
+
+ {
+
+ b2PolygonShape shape;
+ shape.SetAsBox(a, b);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ //bd.fixedRotation = true;
+ bd.position.Set(-10.0f, y);
+ b2Body* body1 = m_world->CreateBody(&bd);
+ body1->CreateFixture(&shape, 5.0f);
+
+ bd.position.Set(10.0f, y);
+ b2Body* body2 = m_world->CreateBody(&bd);
+ body2->CreateFixture(&shape, 5.0f);
+
+ b2PulleyJointDef pulleyDef;
+ b2Vec2 anchor1(-10.0f, y + b);
+ b2Vec2 anchor2(10.0f, y + b);
+ b2Vec2 groundAnchor1(-10.0f, y + b + L);
+ b2Vec2 groundAnchor2(10.0f, y + b + L);
+ pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 1.5f);
+
+ m_joint1 = (b2PulleyJoint*)m_world->CreateJoint(&pulleyDef);
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ float ratio = m_joint1->GetRatio();
+ float L = m_joint1->GetCurrentLengthA() + ratio * m_joint1->GetCurrentLengthB();
+ g_debugDraw.DrawString(5, m_textLine, "L1 + %4.2f * L2 = %4.2f", (float) ratio, (float) L);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new PulleyJoint;
+ }
+
+ b2PulleyJoint* m_joint1;
+};
+
+static int testIndex = RegisterTest("Joints", "Pulley", PulleyJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/pyramid.cpp b/Client/ThirdParty/Box2D/testbed/tests/pyramid.cpp
new file mode 100644
index 0000000..ee90d5d
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/pyramid.cpp
@@ -0,0 +1,92 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Pyramid : public Test
+{
+public:
+ enum
+ {
+ e_count = 20
+ };
+
+ Pyramid()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ float a = 0.5f;
+ b2PolygonShape shape;
+ shape.SetAsBox(a, a);
+
+ b2Vec2 x(-7.0f, 0.75f);
+ b2Vec2 y;
+ b2Vec2 deltaX(0.5625f, 1.25f);
+ b2Vec2 deltaY(1.125f, 0.0f);
+
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ y = x;
+
+ for (int32 j = i; j < e_count; ++j)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = y;
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 5.0f);
+
+ y += deltaY;
+ }
+
+ x += deltaX;
+ }
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree;
+
+ //if (m_stepCount == 400)
+ //{
+ // tree->RebuildBottomUp();
+ //}
+ }
+
+ static Test* Create()
+ {
+ return new Pyramid;
+ }
+};
+
+static int testIndex = RegisterTest("Stacking", "Pyramid", Pyramid::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/ray_cast.cpp b/Client/ThirdParty/Box2D/testbed/tests/ray_cast.cpp
new file mode 100644
index 0000000..c3c648e
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/ray_cast.cpp
@@ -0,0 +1,479 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+#include "imgui/imgui.h"
+
+enum
+{
+ e_maxBodies = 256
+};
+
+// This test demonstrates how to use the world ray-cast feature.
+// NOTE: we are intentionally filtering one of the polygons, therefore
+// the ray will always miss one type of polygon.
+
+// This callback finds the closest hit. Polygon 0 is filtered.
+class RayCastClosestCallback : public b2RayCastCallback
+{
+public:
+ RayCastClosestCallback()
+ {
+ m_hit = false;
+ }
+
+ float ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float fraction) override
+ {
+ uintptr_t index = fixture->GetUserData().pointer;
+ if (index == 1)
+ {
+ // By returning -1, we instruct the calling code to ignore this fixture and
+ // continue the ray-cast to the next fixture.
+ return -1.0f;
+ }
+
+ m_hit = true;
+ m_point = point;
+ m_normal = normal;
+
+ // By returning the current fraction, we instruct the calling code to clip the ray and
+ // continue the ray-cast to the next fixture. WARNING: do not assume that fixtures
+ // are reported in order. However, by clipping, we can always get the closest fixture.
+ return fraction;
+ }
+
+ bool m_hit;
+ b2Vec2 m_point;
+ b2Vec2 m_normal;
+};
+
+// This callback finds any hit. Polygon 0 is filtered. For this type of query we are usually
+// just checking for obstruction, so the actual fixture and hit point are irrelevant.
+class RayCastAnyCallback : public b2RayCastCallback
+{
+public:
+ RayCastAnyCallback()
+ {
+ m_hit = false;
+ }
+
+ float ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float) override
+ {
+ uintptr_t index = fixture->GetUserData().pointer;
+ if (index == 1)
+ {
+ // By returning -1, we instruct the calling code to ignore this fixture and
+ // continue the ray-cast to the next fixture.
+ return -1.0f;
+ }
+
+ m_hit = true;
+ m_point = point;
+ m_normal = normal;
+
+ // At this point we have a hit, so we know the ray is obstructed.
+ // By returning 0, we instruct the calling code to terminate the ray-cast.
+ return 0.0f;
+ }
+
+ bool m_hit;
+ b2Vec2 m_point;
+ b2Vec2 m_normal;
+};
+
+// This ray cast collects multiple hits along the ray. Polygon 0 is filtered.
+// The fixtures are not necessary reported in order, so we might not capture
+// the closest fixture.
+class RayCastMultipleCallback : public b2RayCastCallback
+{
+public:
+ enum
+ {
+ e_maxCount = 3
+ };
+
+ RayCastMultipleCallback()
+ {
+ m_count = 0;
+ }
+
+ float ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float) override
+ {
+ uintptr_t index = fixture->GetUserData().pointer;
+ if (index == 1)
+ {
+ // By returning -1, we instruct the calling code to ignore this fixture and
+ // continue the ray-cast to the next fixture.
+ return -1.0f;
+ }
+
+ b2Assert(m_count < e_maxCount);
+
+ m_points[m_count] = point;
+ m_normals[m_count] = normal;
+ ++m_count;
+
+ if (m_count == e_maxCount)
+ {
+ // At this point the buffer is full.
+ // By returning 0, we instruct the calling code to terminate the ray-cast.
+ return 0.0f;
+ }
+
+ // By returning 1, we instruct the caller to continue without clipping the ray.
+ return 1.0f;
+ }
+
+ b2Vec2 m_points[e_maxCount];
+ b2Vec2 m_normals[e_maxCount];
+ int32 m_count;
+};
+
+
+class RayCast : public Test
+{
+public:
+
+ enum Mode
+ {
+ e_any = 0,
+ e_closest = 1,
+ e_multiple = 2
+ };
+
+ RayCast()
+ {
+ // Ground body
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.5f, 0.0f);
+ vertices[1].Set(0.5f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+ m_polygons[0].Set(vertices, 3);
+ }
+
+ {
+ b2Vec2 vertices[3];
+ vertices[0].Set(-0.1f, 0.0f);
+ vertices[1].Set(0.1f, 0.0f);
+ vertices[2].Set(0.0f, 1.5f);
+ m_polygons[1].Set(vertices, 3);
+ }
+
+ {
+ float w = 1.0f;
+ float b = w / (2.0f + b2Sqrt(2.0f));
+ float s = b2Sqrt(2.0f) * b;
+
+ b2Vec2 vertices[8];
+ vertices[0].Set(0.5f * s, 0.0f);
+ vertices[1].Set(0.5f * w, b);
+ vertices[2].Set(0.5f * w, b + s);
+ vertices[3].Set(0.5f * s, w);
+ vertices[4].Set(-0.5f * s, w);
+ vertices[5].Set(-0.5f * w, b + s);
+ vertices[6].Set(-0.5f * w, b);
+ vertices[7].Set(-0.5f * s, 0.0f);
+
+ m_polygons[2].Set(vertices, 8);
+ }
+
+ {
+ m_polygons[3].SetAsBox(0.5f, 0.5f);
+ }
+
+ {
+ m_circle.m_radius = 0.5f;
+ }
+
+ {
+ m_edge.SetTwoSided(b2Vec2(-1.0f, 0.0f), b2Vec2(1.0f, 0.0f));
+ }
+
+ m_bodyIndex = 0;
+ memset(m_bodies, 0, sizeof(m_bodies));
+
+ m_degrees = 0.0f;
+
+ m_mode = e_closest;
+ }
+
+ void Create(int32 index)
+ {
+ if (m_bodies[m_bodyIndex] != NULL)
+ {
+ m_world->DestroyBody(m_bodies[m_bodyIndex]);
+ m_bodies[m_bodyIndex] = NULL;
+ }
+
+ b2BodyDef bd;
+
+ float x = RandomFloat(-10.0f, 10.0f);
+ float y = RandomFloat(0.0f, 20.0f);
+ bd.position.Set(x, y);
+ bd.angle = RandomFloat(-b2_pi, b2_pi);
+
+ if (index == 4)
+ {
+ bd.angularDamping = 0.02f;
+ }
+
+ m_bodies[m_bodyIndex] = m_world->CreateBody(&bd);
+
+ if (index < 4)
+ {
+ b2FixtureDef fd;
+ fd.shape = m_polygons + index;
+ fd.friction = 0.3f;
+ fd.userData.pointer = index + 1;
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+ else if (index < 5)
+ {
+ b2FixtureDef fd;
+ fd.shape = &m_circle;
+ fd.friction = 0.3f;
+ fd.userData.pointer = index + 1;
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+ else
+ {
+ b2FixtureDef fd;
+ fd.shape = &m_edge;
+ fd.friction = 0.3f;
+ fd.userData.pointer = index + 1;
+
+ m_bodies[m_bodyIndex]->CreateFixture(&fd);
+ }
+
+ m_bodyIndex = (m_bodyIndex + 1) % e_maxBodies;
+ }
+
+ void DestroyBody()
+ {
+ for (int32 i = 0; i < e_maxBodies; ++i)
+ {
+ if (m_bodies[i] != NULL)
+ {
+ m_world->DestroyBody(m_bodies[i]);
+ m_bodies[i] = NULL;
+ return;
+ }
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(210.0f, 285.0f));
+ ImGui::Begin("Ray-cast Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::Button("Shape 1"))
+ {
+ Create(0);
+ }
+
+ if (ImGui::Button("Shape 2"))
+ {
+ Create(1);
+ }
+
+ if (ImGui::Button("Shape 3"))
+ {
+ Create(2);
+ }
+
+ if (ImGui::Button("Shape 4"))
+ {
+ Create(3);
+ }
+
+ if (ImGui::Button("Shape 5"))
+ {
+ Create(4);
+ }
+
+ if (ImGui::Button("Shape 6"))
+ {
+ Create(5);
+ }
+
+ if (ImGui::Button("Destroy Shape"))
+ {
+ DestroyBody();
+ }
+
+ ImGui::RadioButton("Any", &m_mode, e_any);
+ ImGui::RadioButton("Closest", &m_mode, e_closest);
+ ImGui::RadioButton("Multiple", &m_mode, e_multiple);
+
+ ImGui::SliderFloat("Angle", &m_degrees, 0.0f, 360.0f, "%.0f");
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ g_debugDraw.DrawString(5, m_textLine, "Shape 1 is intentionally ignored by the ray");
+ m_textLine += m_textIncrement;
+ switch (m_mode)
+ {
+ case e_closest:
+ g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: closest - find closest fixture along the ray");
+ break;
+
+ case e_any:
+ g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: any - check for obstruction");
+ break;
+
+ case e_multiple:
+ g_debugDraw.DrawString(5, m_textLine, "Ray-cast mode: multiple - gather multiple fixtures");
+ break;
+ }
+
+ m_textLine += m_textIncrement;
+
+ float angle = b2_pi * m_degrees / 180.0f;
+ float L = 11.0f;
+ b2Vec2 point1(0.0f, 10.0f);
+ b2Vec2 d(L * cosf(angle), L * sinf(angle));
+ b2Vec2 point2 = point1 + d;
+
+ if (m_mode == e_closest)
+ {
+ RayCastClosestCallback callback;
+ m_world->RayCast(&callback, point1, point2);
+
+ if (callback.m_hit)
+ {
+ g_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
+ g_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
+ b2Vec2 head = callback.m_point + 0.5f * callback.m_normal;
+ g_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
+ }
+ else
+ {
+ g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
+ }
+ }
+ else if (m_mode == e_any)
+ {
+ RayCastAnyCallback callback;
+ m_world->RayCast(&callback, point1, point2);
+
+ if (callback.m_hit)
+ {
+ g_debugDraw.DrawPoint(callback.m_point, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
+ g_debugDraw.DrawSegment(point1, callback.m_point, b2Color(0.8f, 0.8f, 0.8f));
+ b2Vec2 head = callback.m_point + 0.5f * callback.m_normal;
+ g_debugDraw.DrawSegment(callback.m_point, head, b2Color(0.9f, 0.9f, 0.4f));
+ }
+ else
+ {
+ g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
+ }
+ }
+ else if (m_mode == e_multiple)
+ {
+ RayCastMultipleCallback callback;
+ m_world->RayCast(&callback, point1, point2);
+ g_debugDraw.DrawSegment(point1, point2, b2Color(0.8f, 0.8f, 0.8f));
+
+ for (int32 i = 0; i < callback.m_count; ++i)
+ {
+ b2Vec2 p = callback.m_points[i];
+ b2Vec2 n = callback.m_normals[i];
+ g_debugDraw.DrawPoint(p, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
+ g_debugDraw.DrawSegment(point1, p, b2Color(0.8f, 0.8f, 0.8f));
+ b2Vec2 head = p + 0.5f * n;
+ g_debugDraw.DrawSegment(p, head, b2Color(0.9f, 0.9f, 0.4f));
+ }
+ }
+
+#if 0
+ // This case was failing.
+ {
+ b2Vec2 vertices[4];
+ //vertices[0].Set(-22.875f, -3.0f);
+ //vertices[1].Set(22.875f, -3.0f);
+ //vertices[2].Set(22.875f, 3.0f);
+ //vertices[3].Set(-22.875f, 3.0f);
+
+ b2PolygonShape shape;
+ //shape.Set(vertices, 4);
+ shape.SetAsBox(22.875f, 3.0f);
+
+ b2RayCastInput input;
+ input.p1.Set(10.2725f,1.71372f);
+ input.p2.Set(10.2353f,2.21807f);
+ //input.maxFraction = 0.567623f;
+ input.maxFraction = 0.56762173f;
+
+ b2Transform xf;
+ xf.SetIdentity();
+ xf.position.Set(23.0f, 5.0f);
+
+ b2RayCastOutput output;
+ bool hit;
+ hit = shape.RayCast(&output, input, xf);
+ hit = false;
+
+ b2Color color(1.0f, 1.0f, 1.0f);
+ b2Vec2 vs[4];
+ for (int32 i = 0; i < 4; ++i)
+ {
+ vs[i] = b2Mul(xf, shape.m_vertices[i]);
+ }
+
+ g_debugDraw.DrawPolygon(vs, 4, color);
+ g_debugDraw.DrawSegment(input.p1, input.p2, color);
+ }
+#endif
+ }
+
+ static Test* Create()
+ {
+ return new RayCast;
+ }
+
+ int32 m_bodyIndex;
+ b2Body* m_bodies[e_maxBodies];
+ b2PolygonShape m_polygons[4];
+ b2CircleShape m_circle;
+ b2EdgeShape m_edge;
+ float m_degrees;
+ int32 m_mode;
+};
+
+static int testIndex = RegisterTest("Collision", "Ray Cast", RayCast::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/restitution.cpp b/Client/ThirdParty/Box2D/testbed/tests/restitution.cpp
new file mode 100644
index 0000000..7772c62
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/restitution.cpp
@@ -0,0 +1,79 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// Note: even with a restitution of 1.0, there is some energy change
+// due to position correction.
+class Restitution : public Test
+{
+public:
+
+ Restitution()
+ {
+ const float threshold = 10.0f;
+
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.restitutionThreshold = threshold;
+ ground->CreateFixture(&fd);
+ }
+
+ {
+ b2CircleShape shape;
+ shape.m_radius = 1.0f;
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 1.0f;
+
+ float restitution[7] = { 0.0f, 0.1f, 0.3f, 0.5f, 0.75f, 0.9f, 1.0f };
+
+ for (int32 i = 0; i < 7; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-10.0f + 3.0f * i, 20.0f);
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ fd.restitution = restitution[i];
+ fd.restitutionThreshold = threshold;
+ body->CreateFixture(&fd);
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Restitution;
+ }
+};
+
+static int testIndex = RegisterTest("Forces", "Restitution", Restitution::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/revolute_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/revolute_joint.cpp
new file mode 100644
index 0000000..a67fea6
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/revolute_joint.cpp
@@ -0,0 +1,162 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+#include "imgui/imgui.h"
+
+class RevoluteJoint : public Test
+{
+public:
+ RevoluteJoint()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ //fd.filter.categoryBits = 2;
+
+ ground->CreateFixture(&fd);
+ }
+
+ m_enableLimit = true;
+ m_enableMotor = false;
+ m_motorSpeed = 1.0f;
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.25f, 3.0f, b2Vec2(0.0f, 3.0f), 0.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-10.0f, 20.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 5.0f);
+
+ b2RevoluteJointDef jd;
+ jd.Initialize(ground, body, b2Vec2(-10.0f, 20.5f));
+ jd.motorSpeed = m_motorSpeed;
+ jd.maxMotorTorque = 10000.0f;
+ jd.enableMotor = m_enableMotor;
+ jd.lowerAngle = -0.25f * b2_pi;
+ jd.upperAngle = 0.5f * b2_pi;
+ jd.enableLimit = m_enableLimit;
+
+ m_joint1 = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
+ }
+
+ {
+ b2CircleShape circle_shape;
+ circle_shape.m_radius = 2.0f;
+
+ b2BodyDef circle_bd;
+ circle_bd.type = b2_dynamicBody;
+ circle_bd.position.Set(5.0f, 30.0f);
+
+ b2FixtureDef fd;
+ fd.density = 5.0f;
+ fd.filter.maskBits = 1;
+ fd.shape = &circle_shape;
+
+ m_ball = m_world->CreateBody(&circle_bd);
+ m_ball->CreateFixture(&fd);
+
+ b2PolygonShape polygon_shape;
+ polygon_shape.SetAsBox(10.0f, 0.5f, b2Vec2 (-10.0f, 0.0f), 0.0f);
+
+ b2BodyDef polygon_bd;
+ polygon_bd.position.Set(20.0f, 10.0f);
+ polygon_bd.type = b2_dynamicBody;
+ polygon_bd.bullet = true;
+ b2Body* polygon_body = m_world->CreateBody(&polygon_bd);
+ polygon_body->CreateFixture(&polygon_shape, 2.0f);
+
+ b2RevoluteJointDef jd;
+ jd.Initialize(ground, polygon_body, b2Vec2(19.0f, 10.0f));
+ jd.lowerAngle = -0.25f * b2_pi;
+ jd.upperAngle = 0.0f * b2_pi;
+ jd.enableLimit = true;
+ jd.enableMotor = true;
+ jd.motorSpeed = 0.0f;
+ jd.maxMotorTorque = 10000.0f;
+
+ m_joint2 = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 100.0f));
+ ImGui::Begin("Joint Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::Checkbox("Limit", &m_enableLimit))
+ {
+ m_joint1->EnableLimit(m_enableLimit);
+ }
+
+ if (ImGui::Checkbox("Motor", &m_enableMotor))
+ {
+ m_joint1->EnableMotor(m_enableMotor);
+ }
+
+ if (ImGui::SliderFloat("Speed", &m_motorSpeed, -20.0f, 20.0f, "%.0f"))
+ {
+ m_joint1->SetMotorSpeed(m_motorSpeed);
+ }
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ float torque1 = m_joint1->GetMotorTorque(settings.m_hertz);
+ g_debugDraw.DrawString(5, m_textLine, "Motor Torque 1= %4.0f", torque1);
+ m_textLine += m_textIncrement;
+
+ float torque2 = m_joint2->GetMotorTorque(settings.m_hertz);
+ g_debugDraw.DrawString(5, m_textLine, "Motor Torque 2= %4.0f", torque2);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new RevoluteJoint;
+ }
+
+ b2Body* m_ball;
+ b2RevoluteJoint* m_joint1;
+ b2RevoluteJoint* m_joint2;
+ float m_motorSpeed;
+ bool m_enableMotor;
+ bool m_enableLimit;
+};
+
+static int testIndex = RegisterTest("Joints", "Revolute", RevoluteJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/rope.cpp b/Client/ThirdParty/Box2D/testbed/tests/rope.cpp
new file mode 100644
index 0000000..e4bf5d2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/rope.cpp
@@ -0,0 +1,286 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+#include "box2d/b2_rope.h"
+#include "imgui/imgui.h"
+
+///
+class Rope : public Test
+{
+public:
+ Rope()
+ {
+ const int32 N = 20;
+ const float L = 0.5f;
+ b2Vec2 vertices[N];
+ float masses[N];
+
+ for (int32 i = 0; i < N; ++i)
+ {
+ vertices[i].Set(0.0f, L * (N - i));
+ masses[i] = 1.0f;
+ }
+ masses[0] = 0.0f;
+ masses[1] = 0.0f;
+
+ m_tuning1.bendHertz = 30.0f;
+ m_tuning1.bendDamping = 4.0f;
+ m_tuning1.bendStiffness = 1.0f;
+ m_tuning1.bendingModel = b2_pbdTriangleBendingModel;
+ m_tuning1.isometric = true;
+
+ m_tuning1.stretchHertz = 30.0f;
+ m_tuning1.stretchDamping = 4.0f;
+ m_tuning1.stretchStiffness = 1.0f;
+ m_tuning1.stretchingModel = b2_pbdStretchingModel;
+
+ m_tuning2.bendHertz = 30.0f;
+ m_tuning2.bendDamping = 0.7f;
+ m_tuning2.bendStiffness = 1.0f;
+ m_tuning2.bendingModel = b2_pbdHeightBendingModel;
+ m_tuning2.isometric = true;
+
+ m_tuning2.stretchHertz = 30.0f;
+ m_tuning2.stretchDamping = 1.0f;
+ m_tuning2.stretchStiffness = 1.0f;
+ m_tuning2.stretchingModel = b2_pbdStretchingModel;
+
+ m_position1.Set(-5.0f, 15.0f);
+ m_position2.Set(5.0f, 15.0f);
+
+ b2RopeDef def;
+ def.vertices = vertices;
+ def.count = N;
+ def.gravity.Set(0.0f, -10.0f);
+ def.masses = masses;
+
+ def.position = m_position1;
+ def.tuning = m_tuning1;
+ m_rope1.Create(def);
+
+ def.position = m_position2;
+ def.tuning = m_tuning2;
+ m_rope2.Create(def);
+
+ m_iterations1 = 8;
+ m_iterations2 = 8;
+
+ m_speed = 10.0f;
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 700.0f));
+ ImGui::Begin("Tuning", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ ImGui::Separator();
+
+ ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
+
+ const ImGuiComboFlags comboFlags = 0;
+ const char* bendModels[] = { "Spring", "PBD Ang", "XPBD Ang", "PBD Dist", "PBD Height", "PBD Triangle" };
+ const char* stretchModels[] = { "PBD", "XPBD" };
+
+ ImGui::Text("Rope 1");
+ static int bendModel1 = m_tuning1.bendingModel;
+ if (ImGui::BeginCombo("Bend Model##1", bendModels[bendModel1], comboFlags))
+ {
+ for (int i = 0; i < IM_ARRAYSIZE(bendModels); ++i)
+ {
+ bool isSelected = (bendModel1 == i);
+ if (ImGui::Selectable(bendModels[i], isSelected))
+ {
+ bendModel1 = i;
+ m_tuning1.bendingModel = b2BendingModel(i);
+ }
+
+ if (isSelected)
+ {
+ ImGui::SetItemDefaultFocus();
+ }
+ }
+ ImGui::EndCombo();
+ }
+
+ ImGui::SliderFloat("Damping##B1", &m_tuning1.bendDamping, 0.0f, 4.0f, "%.1f");
+ ImGui::SliderFloat("Hertz##B1", &m_tuning1.bendHertz, 0.0f, 60.0f, "%.0f");
+ ImGui::SliderFloat("Stiffness##B1", &m_tuning1.bendStiffness, 0.0f, 1.0f, "%.1f");
+
+ ImGui::Checkbox("Isometric##1", &m_tuning1.isometric);
+ ImGui::Checkbox("Fixed Mass##1", &m_tuning1.fixedEffectiveMass);
+ ImGui::Checkbox("Warm Start##1", &m_tuning1.warmStart);
+
+ static int stretchModel1 = m_tuning1.stretchingModel;
+ if (ImGui::BeginCombo("Stretch Model##1", stretchModels[stretchModel1], comboFlags))
+ {
+ for (int i = 0; i < IM_ARRAYSIZE(stretchModels); ++i)
+ {
+ bool isSelected = (stretchModel1 == i);
+ if (ImGui::Selectable(stretchModels[i], isSelected))
+ {
+ stretchModel1 = i;
+ m_tuning1.stretchingModel = b2StretchingModel(i);
+ }
+
+ if (isSelected)
+ {
+ ImGui::SetItemDefaultFocus();
+ }
+ }
+ ImGui::EndCombo();
+ }
+
+ ImGui::SliderFloat("Damping##S1", &m_tuning1.stretchDamping, 0.0f, 4.0f, "%.1f");
+ ImGui::SliderFloat("Hertz##S1", &m_tuning1.stretchHertz, 0.0f, 60.0f, "%.0f");
+ ImGui::SliderFloat("Stiffness##S1", &m_tuning1.stretchStiffness, 0.0f, 1.0f, "%.1f");
+
+ ImGui::SliderInt("Iterations##1", &m_iterations1, 1, 100, "%d");
+
+ ImGui::Separator();
+
+ ImGui::Text("Rope 2");
+ static int bendModel2 = m_tuning2.bendingModel;
+ if (ImGui::BeginCombo("Bend Model##2", bendModels[bendModel2], comboFlags))
+ {
+ for (int i = 0; i < IM_ARRAYSIZE(bendModels); ++i)
+ {
+ bool isSelected = (bendModel2 == i);
+ if (ImGui::Selectable(bendModels[i], isSelected))
+ {
+ bendModel2 = i;
+ m_tuning2.bendingModel = b2BendingModel(i);
+ }
+
+ if (isSelected)
+ {
+ ImGui::SetItemDefaultFocus();
+ }
+ }
+ ImGui::EndCombo();
+ }
+
+ ImGui::SliderFloat("Damping##B2", &m_tuning2.bendDamping, 0.0f, 4.0f, "%.1f");
+ ImGui::SliderFloat("Hertz##B2", &m_tuning2.bendHertz, 0.0f, 60.0f, "%.0f");
+ ImGui::SliderFloat("Stiffness##B2", &m_tuning2.bendStiffness, 0.0f, 1.0f, "%.1f");
+
+ ImGui::Checkbox("Isometric##2", &m_tuning2.isometric);
+ ImGui::Checkbox("Fixed Mass##2", &m_tuning2.fixedEffectiveMass);
+ ImGui::Checkbox("Warm Start##2", &m_tuning2.warmStart);
+
+ static int stretchModel2 = m_tuning2.stretchingModel;
+ if (ImGui::BeginCombo("Stretch Model##2", stretchModels[stretchModel2], comboFlags))
+ {
+ for (int i = 0; i < IM_ARRAYSIZE(stretchModels); ++i)
+ {
+ bool isSelected = (stretchModel2 == i);
+ if (ImGui::Selectable(stretchModels[i], isSelected))
+ {
+ stretchModel2 = i;
+ m_tuning2.stretchingModel = b2StretchingModel(i);
+ }
+
+ if (isSelected)
+ {
+ ImGui::SetItemDefaultFocus();
+ }
+ }
+ ImGui::EndCombo();
+ }
+
+ ImGui::SliderFloat("Damping##S2", &m_tuning2.stretchDamping, 0.0f, 4.0f, "%.1f");
+ ImGui::SliderFloat("Hertz##S2", &m_tuning2.stretchHertz, 0.0f, 60.0f, "%.0f");
+ ImGui::SliderFloat("Stiffness##S2", &m_tuning2.stretchStiffness, 0.0f, 1.0f, "%.1f");
+
+ ImGui::SliderInt("Iterations##2", &m_iterations2, 1, 100, "%d");
+
+ ImGui::Separator();
+
+ ImGui::SliderFloat("Speed", &m_speed, 10.0f, 100.0f, "%.0f");
+
+ if (ImGui::Button("Reset"))
+ {
+ m_position1.Set(-5.0f, 15.0f);
+ m_position2.Set(5.0f, 15.0f);
+ m_rope1.Reset(m_position1);
+ m_rope2.Reset(m_position2);
+ }
+
+ ImGui::PopItemWidth();
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ float dt = settings.m_hertz > 0.0f ? 1.0f / settings.m_hertz : 0.0f;
+
+ if (settings.m_pause == 1 && settings.m_singleStep == 0)
+ {
+ dt = 0.0f;
+ }
+
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_COMMA) == GLFW_PRESS)
+ {
+ m_position1.x -= m_speed * dt;
+ m_position2.x -= m_speed * dt;
+ }
+
+ if (glfwGetKey(g_mainWindow, GLFW_KEY_PERIOD) == GLFW_PRESS)
+ {
+ m_position1.x += m_speed * dt;
+ m_position2.x += m_speed * dt;
+ }
+
+ m_rope1.SetTuning(m_tuning1);
+ m_rope2.SetTuning(m_tuning2);
+ m_rope1.Step(dt, m_iterations1, m_position1);
+ m_rope2.Step(dt, m_iterations2, m_position2);
+
+ Test::Step(settings);
+
+ m_rope1.Draw(&g_debugDraw);
+ m_rope2.Draw(&g_debugDraw);
+
+ g_debugDraw.DrawString(5, m_textLine, "Press comma and period to move left and right");
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new Rope;
+ }
+
+ b2Rope m_rope1;
+ b2Rope m_rope2;
+ b2RopeTuning m_tuning1;
+ b2RopeTuning m_tuning2;
+ int32 m_iterations1;
+ int32 m_iterations2;
+ b2Vec2 m_position1;
+ b2Vec2 m_position2;
+ float m_speed;
+};
+
+static int testIndex = RegisterTest("Rope", "Bending", Rope::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/sensor.cpp b/Client/ThirdParty/Box2D/testbed/tests/sensor.cpp
new file mode 100644
index 0000000..613a0e9
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/sensor.cpp
@@ -0,0 +1,195 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "imgui/imgui.h"
+
+// This shows how to use sensor shapes. Sensors don't have collision, but report overlap events.
+class Sensors : public Test
+{
+public:
+
+ enum
+ {
+ e_count = 7
+ };
+
+ Sensors()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ {
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+#if 0
+ {
+ b2FixtureDef sd;
+ sd.SetAsBox(10.0f, 2.0f, b2Vec2(0.0f, 20.0f), 0.0f);
+ sd.isSensor = true;
+ m_sensor = ground->CreateFixture(&sd);
+ }
+#else
+ {
+ b2CircleShape shape;
+ shape.m_radius = 5.0f;
+ shape.m_p.Set(0.0f, 10.0f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.isSensor = true;
+ m_sensor = ground->CreateFixture(&fd);
+ }
+#endif
+ }
+
+ {
+ b2CircleShape shape;
+ shape.m_radius = 1.0f;
+
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-10.0f + 3.0f * i, 20.0f);
+ bd.userData.pointer = i;
+
+ m_touching[i] = false;
+ m_bodies[i] = m_world->CreateBody(&bd);
+
+ m_bodies[i]->CreateFixture(&shape, 1.0f);
+ }
+ }
+
+ m_force = 100.0f;
+ }
+
+ // Implement contact listener.
+ void BeginContact(b2Contact* contact) override
+ {
+ b2Fixture* fixtureA = contact->GetFixtureA();
+ b2Fixture* fixtureB = contact->GetFixtureB();
+
+ if (fixtureA == m_sensor)
+ {
+ uintptr_t index = fixtureB->GetBody()->GetUserData().pointer;
+ if (index < e_count)
+ {
+ m_touching[index] = true;
+ }
+ }
+
+ if (fixtureB == m_sensor)
+ {
+ uintptr_t index = fixtureA->GetBody()->GetUserData().pointer;
+ if (index < e_count)
+ {
+ m_touching[index] = true;
+ }
+ }
+ }
+
+ // Implement contact listener.
+ void EndContact(b2Contact* contact) override
+ {
+ b2Fixture* fixtureA = contact->GetFixtureA();
+ b2Fixture* fixtureB = contact->GetFixtureB();
+
+ if (fixtureA == m_sensor)
+ {
+ uintptr_t index = fixtureB->GetBody()->GetUserData().pointer;
+ if (index < e_count)
+ {
+ m_touching[index] = false;
+ }
+ }
+
+ if (fixtureB == m_sensor)
+ {
+ uintptr_t index = fixtureA->GetBody()->GetUserData().pointer;
+ if (index < e_count)
+ {
+ m_touching[index] = false;
+ }
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 60.0f));
+ ImGui::Begin("Sensor Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ ImGui::SliderFloat("Force", &m_force, 0.0f, 2000.0f, "%.0f");
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ // Traverse the contact results. Apply a force on shapes
+ // that overlap the sensor.
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ if (m_touching[i] == false)
+ {
+ continue;
+ }
+
+ b2Body* body = m_bodies[i];
+ b2Body* ground = m_sensor->GetBody();
+
+ b2CircleShape* circle = (b2CircleShape*)m_sensor->GetShape();
+ b2Vec2 center = ground->GetWorldPoint(circle->m_p);
+
+ b2Vec2 position = body->GetPosition();
+
+ b2Vec2 d = center - position;
+ if (d.LengthSquared() < FLT_EPSILON * FLT_EPSILON)
+ {
+ continue;
+ }
+
+ d.Normalize();
+ b2Vec2 F = m_force * d;
+ body->ApplyForce(F, position, false);
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Sensors;
+ }
+
+ b2Fixture* m_sensor;
+ b2Body* m_bodies[e_count];
+ float m_force;
+ bool m_touching[e_count];
+};
+
+static int testIndex = RegisterTest("Collision", "Sensors", Sensors::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/shape_cast.cpp b/Client/ThirdParty/Box2D/testbed/tests/shape_cast.cpp
new file mode 100644
index 0000000..85ce422
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/shape_cast.cpp
@@ -0,0 +1,193 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "box2d/b2_distance.h"
+
+class ShapeCast : public Test
+{
+public:
+ enum
+ {
+ e_vertexCount = 8
+ };
+
+ ShapeCast()
+ {
+#if 1
+ m_vAs[0].Set(-0.5f, 1.0f);
+ m_vAs[1].Set(0.5f, 1.0f);
+ m_vAs[2].Set(0.0f, 0.0f);
+ m_countA = 3;
+ m_radiusA = b2_polygonRadius;
+
+ m_vBs[0].Set(-0.5f, -0.5f);
+ m_vBs[1].Set(0.5f, -0.5f);
+ m_vBs[2].Set(0.5f, 0.5f);
+ m_vBs[3].Set(-0.5f, 0.5f);
+ m_countB = 4;
+ m_radiusB = b2_polygonRadius;
+
+ m_transformA.p.Set(0.0f, 0.25f);
+ m_transformA.q.SetIdentity();
+ m_transformB.p.Set(-4.0f, 0.0f);
+ m_transformB.q.SetIdentity();
+ m_translationB.Set(8.0f, 0.0f);
+#elif 0
+ m_vAs[0].Set(0.0f, 0.0f);
+ m_countA = 1;
+ m_radiusA = 0.5f;
+
+ m_vBs[0].Set(0.0f, 0.0f);
+ m_countB = 1;
+ m_radiusB = 0.5f;
+
+ m_transformA.p.Set(0.0f, 0.25f);
+ m_transformA.q.SetIdentity();
+ m_transformB.p.Set(-4.0f, 0.0f);
+ m_transformB.q.SetIdentity();
+ m_translationB.Set(8.0f, 0.0f);
+#else
+ m_vAs[0].Set(0.0f, 0.0f);
+ m_vAs[1].Set(2.0f, 0.0f);
+ m_countA = 2;
+ m_radiusA = b2_polygonRadius;
+
+ m_vBs[0].Set(0.0f, 0.0f);
+ m_countB = 1;
+ m_radiusB = 0.25f;
+
+ // Initial overlap
+ m_transformA.p.Set(0.0f, 0.0f);
+ m_transformA.q.SetIdentity();
+ m_transformB.p.Set(-0.244360745f, 0.05999358f);
+ m_transformB.q.SetIdentity();
+ m_translationB.Set(0.0f, 0.0399999991f);
+#endif
+ }
+
+ static Test* Create()
+ {
+ return new ShapeCast;
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ b2ShapeCastInput input;
+ input.proxyA.Set(m_vAs, m_countA, m_radiusA);
+ input.proxyB.Set(m_vBs, m_countB, m_radiusB);
+ input.transformA = m_transformA;
+ input.transformB = m_transformB;
+ input.translationB = m_translationB;
+
+ b2ShapeCastOutput output;
+ bool hit = b2ShapeCast(&output, &input);
+
+ b2Transform transformB2;
+ transformB2.q = m_transformB.q;
+ transformB2.p = m_transformB.p + output.lambda * input.translationB;
+
+ b2DistanceInput distanceInput;
+ distanceInput.proxyA.Set(m_vAs, m_countA, m_radiusA);
+ distanceInput.proxyB.Set(m_vBs, m_countB, m_radiusB);
+ distanceInput.transformA = m_transformA;
+ distanceInput.transformB = transformB2;
+ distanceInput.useRadii = false;
+ b2SimplexCache simplexCache;
+ simplexCache.count = 0;
+ b2DistanceOutput distanceOutput;
+
+ b2Distance(&distanceOutput, &simplexCache, &distanceInput);
+
+ g_debugDraw.DrawString(5, m_textLine, "hit = %s, iters = %d, lambda = %g, distance = %g",
+ hit ? "true" : "false", output.iterations, output.lambda, distanceOutput.distance);
+ m_textLine += m_textIncrement;
+
+ b2Vec2 vertices[b2_maxPolygonVertices];
+
+ for (int32 i = 0; i < m_countA; ++i)
+ {
+ vertices[i] = b2Mul(m_transformA, m_vAs[i]);
+ }
+
+ if (m_countA == 1)
+ {
+ g_debugDraw.DrawCircle(vertices[0], m_radiusA, b2Color(0.9f, 0.9f, 0.9f));
+ }
+ else
+ {
+ g_debugDraw.DrawPolygon(vertices, m_countA, b2Color(0.9f, 0.9f, 0.9f));
+ }
+
+ for (int32 i = 0; i < m_countB; ++i)
+ {
+ vertices[i] = b2Mul(m_transformB, m_vBs[i]);
+ }
+
+ if (m_countB == 1)
+ {
+ g_debugDraw.DrawCircle(vertices[0], m_radiusB, b2Color(0.5f, 0.9f, 0.5f));
+ }
+ else
+ {
+ g_debugDraw.DrawPolygon(vertices, m_countB, b2Color(0.5f, 0.9f, 0.5f));
+ }
+
+ for (int32 i = 0; i < m_countB; ++i)
+ {
+ vertices[i] = b2Mul(transformB2, m_vBs[i]);
+ }
+
+ if (m_countB == 1)
+ {
+ g_debugDraw.DrawCircle(vertices[0], m_radiusB, b2Color(0.5f, 0.7f, 0.9f));
+ }
+ else
+ {
+ g_debugDraw.DrawPolygon(vertices, m_countB, b2Color(0.5f, 0.7f, 0.9f));
+ }
+
+ if (hit)
+ {
+ b2Vec2 p1 = output.point;
+ g_debugDraw.DrawPoint(p1, 10.0f, b2Color(0.9f, 0.3f, 0.3f));
+ b2Vec2 p2 = p1 + output.normal;
+ g_debugDraw.DrawSegment(p1, p2, b2Color(0.9f, 0.3f, 0.3f));
+ }
+ }
+
+ b2Vec2 m_vAs[b2_maxPolygonVertices];
+ int32 m_countA;
+ float m_radiusA;
+
+ b2Vec2 m_vBs[b2_maxPolygonVertices];
+ int32 m_countB;
+ float m_radiusB;
+
+ b2Transform m_transformA;
+ b2Transform m_transformB;
+ b2Vec2 m_translationB;
+};
+
+static int testIndex = RegisterTest("Collision", "Shape Cast", ShapeCast::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/shape_editing.cpp b/Client/ThirdParty/Box2D/testbed/tests/shape_editing.cpp
new file mode 100644
index 0000000..307f295
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/shape_editing.cpp
@@ -0,0 +1,108 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class ShapeEditing : public Test
+{
+public:
+
+ ShapeEditing()
+ {
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 10.0f);
+ m_body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(4.0f, 4.0f, b2Vec2(0.0f, 0.0f), 0.0f);
+ m_fixture1 = m_body->CreateFixture(&shape, 10.0f);
+
+ m_fixture2 = NULL;
+
+ m_sensor = false;
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_C:
+ if (m_fixture2 == NULL)
+ {
+ b2CircleShape shape;
+ shape.m_radius = 3.0f;
+ shape.m_p.Set(0.5f, -4.0f);
+ m_fixture2 = m_body->CreateFixture(&shape, 10.0f);
+ m_body->SetAwake(true);
+ }
+ break;
+
+ case GLFW_KEY_D:
+ if (m_fixture2 != NULL)
+ {
+ m_body->DestroyFixture(m_fixture2);
+ m_fixture2 = NULL;
+ m_body->SetAwake(true);
+ }
+ break;
+
+ case GLFW_KEY_S:
+ if (m_fixture2 != NULL)
+ {
+ m_sensor = !m_sensor;
+ m_fixture2->SetSensor(m_sensor);
+ }
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape.");
+ m_textLine += m_textIncrement;
+ g_debugDraw.DrawString(5, m_textLine, "sensor = %d", m_sensor);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new ShapeEditing;
+ }
+
+ b2Body* m_body;
+ b2Fixture* m_fixture1;
+ b2Fixture* m_fixture2;
+ bool m_sensor;
+};
+
+static int testIndex = RegisterTest("Examples", "Shape Editing", ShapeEditing::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/skier.cpp b/Client/ThirdParty/Box2D/testbed/tests/skier.cpp
new file mode 100644
index 0000000..8604363
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/skier.cpp
@@ -0,0 +1,150 @@
+/*
+Test case for collision/jerking issue.
+*/
+
+#include "test.h"
+
+#include <vector>
+#include <iostream>
+
+class Skier : public Test
+{
+public:
+ Skier()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ float const PlatformWidth = 8.0f;
+
+ /*
+ First angle is from the horizontal and should be negative for a downward slope.
+ Second angle is relative to the preceding slope, and should be positive, creating a kind of
+ loose 'Z'-shape from the 3 edges.
+ If A1 = -10, then A2 <= ~1.5 will result in the collision glitch.
+ If A1 = -30, then A2 <= ~10.0 will result in the glitch.
+ */
+ float const Angle1Degrees = -30.0f;
+ float const Angle2Degrees = 10.0f;
+
+ /*
+ The larger the value of SlopeLength, the less likely the glitch will show up.
+ */
+ float const SlopeLength = 2.0f;
+
+ float const SurfaceFriction = 0.2f;
+
+ // Convert to radians
+ float const Slope1Incline = -Angle1Degrees * b2_pi / 180.0f;
+ float const Slope2Incline = Slope1Incline - Angle2Degrees * b2_pi / 180.0f;
+ //
+
+ m_platform_width = PlatformWidth;
+
+ // Horizontal platform
+ b2Vec2 v1(-PlatformWidth, 0.0f);
+ b2Vec2 v2(0.0f, 0.0f);
+ b2Vec2 v3(SlopeLength * cosf(Slope1Incline), -SlopeLength * sinf(Slope1Incline));
+ b2Vec2 v4(v3.x + SlopeLength * cosf(Slope2Incline), v3.y - SlopeLength * sinf(Slope2Incline));
+ b2Vec2 v5(v4.x, v4.y - 1.0f);
+
+ b2Vec2 vertices[5] = { v5, v4, v3, v2, v1 };
+
+ b2ChainShape shape;
+ shape.CreateLoop(vertices, 5);
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 0.0f;
+ fd.friction = SurfaceFriction;
+
+ ground->CreateFixture(&fd);
+ }
+
+ {
+ float const BodyWidth = 1.0f;
+ float const BodyHeight = 2.5f;
+ float const SkiLength = 3.0f;
+
+ /*
+ Larger values for this seem to alleviate the issue to some extent.
+ */
+ float const SkiThickness = 0.3f;
+
+ float const SkiFriction = 0.0f;
+ float const SkiRestitution = 0.15f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ float initial_y = BodyHeight / 2 + SkiThickness;
+ bd.position.Set(-m_platform_width / 2, initial_y);
+
+ b2Body* skier = m_world->CreateBody(&bd);
+
+ b2PolygonShape ski;
+ b2Vec2 verts[4];
+ verts[0].Set(-SkiLength / 2 - SkiThickness, -BodyHeight / 2);
+ verts[1].Set(-SkiLength / 2, -BodyHeight / 2 - SkiThickness);
+ verts[2].Set(SkiLength / 2, -BodyHeight / 2 - SkiThickness);
+ verts[3].Set(SkiLength / 2 + SkiThickness, -BodyHeight / 2);
+ ski.Set(verts, 4);
+
+ b2FixtureDef fd;
+ fd.density = 1.0f;
+
+ fd.friction = SkiFriction;
+ fd.restitution = SkiRestitution;
+
+ fd.shape = &ski;
+ skier->CreateFixture(&fd);
+
+ skier->SetLinearVelocity(b2Vec2(0.5f, 0.0f));
+
+ m_skier = skier;
+ }
+
+ g_camera.m_center = b2Vec2(m_platform_width / 2.0f, 0.0f);
+ g_camera.m_zoom = 0.4f;
+ m_fixed_camera = true;
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_C:
+ m_fixed_camera = !m_fixed_camera;
+ if(m_fixed_camera)
+ {
+ g_camera.m_center = b2Vec2(m_platform_width / 2.0f, 0.0f);
+ }
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ g_debugDraw.DrawString(5, m_textLine, "Keys: c = Camera fixed/tracking");
+ m_textLine += m_textIncrement;
+
+ if(!m_fixed_camera)
+ {
+ g_camera.m_center = m_skier->GetPosition();
+ }
+
+ Test::Step(settings);
+ }
+
+ static Test* Create()
+ {
+ return new Skier;
+ }
+
+ b2Body* m_skier;
+ float m_platform_width;
+ bool m_fixed_camera;
+};
+
+static int testIndex = RegisterTest("Bugs", "Skier", Skier::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/slider_crank_1.cpp b/Client/ThirdParty/Box2D/testbed/tests/slider_crank_1.cpp
new file mode 100644
index 0000000..395b939
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/slider_crank_1.cpp
@@ -0,0 +1,106 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// A basic slider crank created for GDC tutorial: Understanding Constraints
+class SliderCrank1 : public Test
+{
+public:
+ SliderCrank1()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ bd.position.Set(0.0f, 17.0f);
+ ground = m_world->CreateBody(&bd);
+ }
+
+ {
+ b2Body* prevBody = ground;
+
+ // Define crank.
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(4.0f, 1.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-8.0f, 20.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(prevBody, body, b2Vec2(-12.0f, 20.0f));
+ m_world->CreateJoint(&rjd);
+
+ prevBody = body;
+ }
+
+ // Define connecting rod
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(8.0f, 1.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(4.0f, 20.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(prevBody, body, b2Vec2(-4.0f, 20.0f));
+ m_world->CreateJoint(&rjd);
+
+ prevBody = body;
+ }
+
+ // Define piston
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(3.0f, 3.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.fixedRotation = true;
+ bd.position.Set(12.0f, 20.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(prevBody, body, b2Vec2(12.0f, 20.0f));
+ m_world->CreateJoint(&rjd);
+
+ b2PrismaticJointDef pjd;
+ pjd.Initialize(ground, body, b2Vec2(12.0f, 17.0f), b2Vec2(1.0f, 0.0f));
+ m_world->CreateJoint(&pjd);
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new SliderCrank1;
+ }
+};
+
+static int testIndex = RegisterTest("Examples", "Slider Crank 1", SliderCrank1::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/slider_crank_2.cpp b/Client/ThirdParty/Box2D/testbed/tests/slider_crank_2.cpp
new file mode 100644
index 0000000..546d6a1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/slider_crank_2.cpp
@@ -0,0 +1,160 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+
+// A motor driven slider crank with joint friction.
+
+class SliderCrank2 : public Test
+{
+public:
+ SliderCrank2()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2Body* prevBody = ground;
+
+ // Define crank.
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 2.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 7.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(prevBody, body, b2Vec2(0.0f, 5.0f));
+ rjd.motorSpeed = 1.0f * b2_pi;
+ rjd.maxMotorTorque = 10000.0f;
+ rjd.enableMotor = true;
+ m_joint1 = (b2RevoluteJoint*)m_world->CreateJoint(&rjd);
+
+ prevBody = body;
+ }
+
+ // Define follower.
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 4.0f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 13.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(prevBody, body, b2Vec2(0.0f, 9.0f));
+ rjd.enableMotor = false;
+ m_world->CreateJoint(&rjd);
+
+ prevBody = body;
+ }
+
+ // Define piston
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(1.5f, 1.5f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.fixedRotation = true;
+ bd.position.Set(0.0f, 17.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+
+ b2RevoluteJointDef rjd;
+ rjd.Initialize(prevBody, body, b2Vec2(0.0f, 17.0f));
+ m_world->CreateJoint(&rjd);
+
+ b2PrismaticJointDef pjd;
+ pjd.Initialize(ground, body, b2Vec2(0.0f, 17.0f), b2Vec2(0.0f, 1.0f));
+
+ pjd.maxMotorForce = 1000.0f;
+ pjd.enableMotor = true;
+
+ m_joint2 = (b2PrismaticJoint*)m_world->CreateJoint(&pjd);
+ }
+
+ // Create a payload
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(1.5f, 1.5f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 23.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 2.0f);
+ }
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_F:
+ m_joint2->EnableMotor(!m_joint2->IsMotorEnabled());
+ m_joint2->GetBodyB()->SetAwake(true);
+ break;
+
+ case GLFW_KEY_M:
+ m_joint1->EnableMotor(!m_joint1->IsMotorEnabled());
+ m_joint1->GetBodyB()->SetAwake(true);
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "Keys: (f) toggle friction, (m) toggle motor");
+ m_textLine += m_textIncrement;
+ float torque = m_joint1->GetMotorTorque(settings.m_hertz);
+ g_debugDraw.DrawString(5, m_textLine, "Motor Torque = %5.0f", (float) torque);
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new SliderCrank2;
+ }
+
+ b2RevoluteJoint* m_joint1;
+ b2PrismaticJoint* m_joint2;
+};
+
+static int testIndex = RegisterTest("Examples", "Slider Crank 2", SliderCrank2::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/theo_jansen.cpp b/Client/ThirdParty/Box2D/testbed/tests/theo_jansen.cpp
new file mode 100644
index 0000000..a3155ac
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/theo_jansen.cpp
@@ -0,0 +1,266 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+// Inspired by a contribution from roman_m
+// Dimensions scooped from APE (http://www.cove.org/ape/index.htm)
+
+#include "test.h"
+
+class TheoJansen : public Test
+{
+public:
+
+ void CreateLeg(float s, const b2Vec2& wheelAnchor)
+ {
+ b2Vec2 p1(5.4f * s, -6.1f);
+ b2Vec2 p2(7.2f * s, -1.2f);
+ b2Vec2 p3(4.3f * s, -1.9f);
+ b2Vec2 p4(3.1f * s, 0.8f);
+ b2Vec2 p5(6.0f * s, 1.5f);
+ b2Vec2 p6(2.5f * s, 3.7f);
+
+ b2FixtureDef fd1, fd2;
+ fd1.filter.groupIndex = -1;
+ fd2.filter.groupIndex = -1;
+ fd1.density = 1.0f;
+ fd2.density = 1.0f;
+
+ b2PolygonShape poly1, poly2;
+
+ if (s > 0.0f)
+ {
+ b2Vec2 vertices[3];
+
+ vertices[0] = p1;
+ vertices[1] = p2;
+ vertices[2] = p3;
+ poly1.Set(vertices, 3);
+
+ vertices[0] = b2Vec2_zero;
+ vertices[1] = p5 - p4;
+ vertices[2] = p6 - p4;
+ poly2.Set(vertices, 3);
+ }
+ else
+ {
+ b2Vec2 vertices[3];
+
+ vertices[0] = p1;
+ vertices[1] = p3;
+ vertices[2] = p2;
+ poly1.Set(vertices, 3);
+
+ vertices[0] = b2Vec2_zero;
+ vertices[1] = p6 - p4;
+ vertices[2] = p5 - p4;
+ poly2.Set(vertices, 3);
+ }
+
+ fd1.shape = &poly1;
+ fd2.shape = &poly2;
+
+ b2BodyDef bd1, bd2;
+ bd1.type = b2_dynamicBody;
+ bd2.type = b2_dynamicBody;
+ bd1.position = m_offset;
+ bd2.position = p4 + m_offset;
+
+ bd1.angularDamping = 10.0f;
+ bd2.angularDamping = 10.0f;
+
+ b2Body* body1 = m_world->CreateBody(&bd1);
+ b2Body* body2 = m_world->CreateBody(&bd2);
+
+ body1->CreateFixture(&fd1);
+ body2->CreateFixture(&fd2);
+
+ {
+ b2DistanceJointDef jd;
+
+ // Using a soft distance constraint can reduce some jitter.
+ // It also makes the structure seem a bit more fluid by
+ // acting like a suspension system.
+ float dampingRatio = 0.5f;
+ float frequencyHz = 10.0f;
+
+ jd.Initialize(body1, body2, p2 + m_offset, p5 + m_offset);
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_world->CreateJoint(&jd);
+
+ jd.Initialize(body1, body2, p3 + m_offset, p4 + m_offset);
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_world->CreateJoint(&jd);
+
+ jd.Initialize(body1, m_wheel, p3 + m_offset, wheelAnchor + m_offset);
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_world->CreateJoint(&jd);
+
+ jd.Initialize(body2, m_wheel, p6 + m_offset, wheelAnchor + m_offset);
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_world->CreateJoint(&jd);
+ }
+
+ {
+ b2RevoluteJointDef jd;
+ jd.Initialize(body2, m_chassis, p4 + m_offset);
+ m_world->CreateJoint(&jd);
+ }
+ }
+
+ TheoJansen()
+ {
+ m_offset.Set(0.0f, 8.0f);
+ m_motorSpeed = 2.0f;
+ m_motorOn = true;
+ b2Vec2 pivot(0.0f, 0.8f);
+
+ // Ground
+ {
+ b2BodyDef bd;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-50.0f, 0.0f), b2Vec2(50.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(b2Vec2(-50.0f, 0.0f), b2Vec2(-50.0f, 10.0f));
+ ground->CreateFixture(&shape, 0.0f);
+
+ shape.SetTwoSided(b2Vec2(50.0f, 0.0f), b2Vec2(50.0f, 10.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ // Balls
+ for (int32 i = 0; i < 40; ++i)
+ {
+ b2CircleShape shape;
+ shape.m_radius = 0.25f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(-40.0f + 2.0f * i, 0.5f);
+
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 1.0f);
+ }
+
+ // Chassis
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(2.5f, 1.0f);
+
+ b2FixtureDef sd;
+ sd.density = 1.0f;
+ sd.shape = &shape;
+ sd.filter.groupIndex = -1;
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = pivot + m_offset;
+ m_chassis = m_world->CreateBody(&bd);
+ m_chassis->CreateFixture(&sd);
+ }
+
+ {
+ b2CircleShape shape;
+ shape.m_radius = 1.6f;
+
+ b2FixtureDef sd;
+ sd.density = 1.0f;
+ sd.shape = &shape;
+ sd.filter.groupIndex = -1;
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = pivot + m_offset;
+ m_wheel = m_world->CreateBody(&bd);
+ m_wheel->CreateFixture(&sd);
+ }
+
+ {
+ b2RevoluteJointDef jd;
+ jd.Initialize(m_wheel, m_chassis, pivot + m_offset);
+ jd.collideConnected = false;
+ jd.motorSpeed = m_motorSpeed;
+ jd.maxMotorTorque = 400.0f;
+ jd.enableMotor = m_motorOn;
+ m_motorJoint = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
+ }
+
+ b2Vec2 wheelAnchor;
+
+ wheelAnchor = pivot + b2Vec2(0.0f, -0.8f);
+
+ CreateLeg(-1.0f, wheelAnchor);
+ CreateLeg(1.0f, wheelAnchor);
+
+ m_wheel->SetTransform(m_wheel->GetPosition(), 120.0f * b2_pi / 180.0f);
+ CreateLeg(-1.0f, wheelAnchor);
+ CreateLeg(1.0f, wheelAnchor);
+
+ m_wheel->SetTransform(m_wheel->GetPosition(), -120.0f * b2_pi / 180.0f);
+ CreateLeg(-1.0f, wheelAnchor);
+ CreateLeg(1.0f, wheelAnchor);
+ }
+
+ void Step(Settings& settings) override
+ {
+ g_debugDraw.DrawString(5, m_textLine, "Keys: left = a, brake = s, right = d, toggle motor = m");
+ m_textLine += m_textIncrement;
+
+ Test::Step(settings);
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_A:
+ m_motorJoint->SetMotorSpeed(-m_motorSpeed);
+ break;
+
+ case GLFW_KEY_S:
+ m_motorJoint->SetMotorSpeed(0.0f);
+ break;
+
+ case GLFW_KEY_D:
+ m_motorJoint->SetMotorSpeed(m_motorSpeed);
+ break;
+
+ case GLFW_KEY_M:
+ m_motorJoint->EnableMotor(!m_motorJoint->IsMotorEnabled());
+ break;
+ }
+ }
+
+ static Test* Create()
+ {
+ return new TheoJansen;
+ }
+
+ b2Vec2 m_offset;
+ b2Body* m_chassis;
+ b2Body* m_wheel;
+ b2RevoluteJoint* m_motorJoint;
+ bool m_motorOn;
+ float m_motorSpeed;
+};
+
+static int testIndex = RegisterTest("Examples", "Theo Jansen", TheoJansen::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/tiles.cpp b/Client/ThirdParty/Box2D/testbed/tests/tiles.cpp
new file mode 100644
index 0000000..e6a4e56
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/tiles.cpp
@@ -0,0 +1,159 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+/// This stress tests the dynamic tree broad-phase. This also shows that tile
+/// based collision is _not_ smooth due to Box2D not knowing about adjacency.
+class Tiles : public Test
+{
+public:
+ enum
+ {
+ e_count = 20
+ };
+
+ Tiles()
+ {
+ m_fixtureCount = 0;
+ b2Timer timer;
+
+ {
+ float a = 0.5f;
+ b2BodyDef bd;
+ bd.position.y = -a;
+ b2Body* ground = m_world->CreateBody(&bd);
+
+#if 1
+ int32 N = 200;
+ int32 M = 10;
+ b2Vec2 position;
+ position.y = 0.0f;
+ for (int32 j = 0; j < M; ++j)
+ {
+ position.x = -N * a;
+ for (int32 i = 0; i < N; ++i)
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(a, a, position, 0.0f);
+ ground->CreateFixture(&shape, 0.0f);
+ ++m_fixtureCount;
+ position.x += 2.0f * a;
+ }
+ position.y -= 2.0f * a;
+ }
+#else
+ int32 N = 200;
+ int32 M = 10;
+ b2Vec2 position;
+ position.x = -N * a;
+ for (int32 i = 0; i < N; ++i)
+ {
+ position.y = 0.0f;
+ for (int32 j = 0; j < M; ++j)
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(a, a, position, 0.0f);
+ ground->CreateFixture(&shape, 0.0f);
+ position.y -= 2.0f * a;
+ }
+ position.x += 2.0f * a;
+ }
+#endif
+ }
+
+ {
+ float a = 0.5f;
+ b2PolygonShape shape;
+ shape.SetAsBox(a, a);
+
+ b2Vec2 x(-7.0f, 0.75f);
+ b2Vec2 y;
+ b2Vec2 deltaX(0.5625f, 1.25f);
+ b2Vec2 deltaY(1.125f, 0.0f);
+
+ for (int32 i = 0; i < e_count; ++i)
+ {
+ y = x;
+
+ for (int32 j = i; j < e_count; ++j)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position = y;
+
+ //if (i == 0 && j == 0)
+ //{
+ // bd.allowSleep = false;
+ //}
+ //else
+ //{
+ // bd.allowSleep = true;
+ //}
+
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 5.0f);
+ ++m_fixtureCount;
+ y += deltaY;
+ }
+
+ x += deltaX;
+ }
+ }
+
+ m_createTime = timer.GetMilliseconds();
+ }
+
+ void Step(Settings& settings) override
+ {
+ const b2ContactManager& cm = m_world->GetContactManager();
+ int32 height = cm.m_broadPhase.GetTreeHeight();
+ int32 leafCount = cm.m_broadPhase.GetProxyCount();
+ int32 minimumNodeCount = 2 * leafCount - 1;
+ float minimumHeight = ceilf(logf(float(minimumNodeCount)) / logf(2.0f));
+ g_debugDraw.DrawString(5, m_textLine, "dynamic tree height = %d, min = %d", height, int32(minimumHeight));
+ m_textLine += m_textIncrement;
+
+ Test::Step(settings);
+
+ g_debugDraw.DrawString(5, m_textLine, "create time = %6.2f ms, fixture count = %d",
+ m_createTime, m_fixtureCount);
+ m_textLine += m_textIncrement;
+
+ //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree;
+
+ //if (m_stepCount == 400)
+ //{
+ // tree->RebuildBottomUp();
+ //}
+ }
+
+ static Test* Create()
+ {
+ return new Tiles;
+ }
+
+ int32 m_fixtureCount;
+ float m_createTime;
+};
+
+static int testIndex = RegisterTest("Benchmark", "Tiles", Tiles::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/time_of_impact.cpp b/Client/ThirdParty/Box2D/testbed/tests/time_of_impact.cpp
new file mode 100644
index 0000000..a081ff3
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/time_of_impact.cpp
@@ -0,0 +1,131 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "box2d/b2_time_of_impact.h"
+
+class TimeOfImpact : public Test
+{
+public:
+ TimeOfImpact()
+ {
+ m_shapeA.SetAsBox(25.0f, 5.0f);
+ m_shapeB.SetAsBox(2.5f, 2.5f);
+ }
+
+ static Test* Create()
+ {
+ return new TimeOfImpact;
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ b2Sweep sweepA;
+ sweepA.c0.Set(24.0f, -60.0f);
+ sweepA.a0 = 2.95f;
+ sweepA.c = sweepA.c0;
+ sweepA.a = sweepA.a0;
+ sweepA.localCenter.SetZero();
+
+ b2Sweep sweepB;
+ sweepB.c0.Set(53.474274f, -50.252514f);
+ sweepB.a0 = 513.36676f; // - 162.0f * b2_pi;
+ sweepB.c.Set(54.595478f, -51.083473f);
+ sweepB.a = 513.62781f; // - 162.0f * b2_pi;
+ sweepB.localCenter.SetZero();
+
+ //sweepB.a0 -= 300.0f * b2_pi;
+ //sweepB.a -= 300.0f * b2_pi;
+
+ b2TOIInput input;
+ input.proxyA.Set(&m_shapeA, 0);
+ input.proxyB.Set(&m_shapeB, 0);
+ input.sweepA = sweepA;
+ input.sweepB = sweepB;
+ input.tMax = 1.0f;
+
+ b2TOIOutput output;
+
+ b2TimeOfImpact(&output, &input);
+
+ g_debugDraw.DrawString(5, m_textLine, "toi = %g", output.t);
+ m_textLine += m_textIncrement;
+
+ extern B2_API int32 b2_toiMaxIters, b2_toiMaxRootIters;
+ g_debugDraw.DrawString(5, m_textLine, "max toi iters = %d, max root iters = %d", b2_toiMaxIters, b2_toiMaxRootIters);
+ m_textLine += m_textIncrement;
+
+ b2Vec2 vertices[b2_maxPolygonVertices];
+
+ b2Transform transformA;
+ sweepA.GetTransform(&transformA, 0.0f);
+ for (int32 i = 0; i < m_shapeA.m_count; ++i)
+ {
+ vertices[i] = b2Mul(transformA, m_shapeA.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(vertices, m_shapeA.m_count, b2Color(0.9f, 0.9f, 0.9f));
+
+ b2Transform transformB;
+ sweepB.GetTransform(&transformB, 0.0f);
+
+ //b2Vec2 localPoint(2.0f, -0.1f);
+
+ for (int32 i = 0; i < m_shapeB.m_count; ++i)
+ {
+ vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.5f, 0.9f, 0.5f));
+
+ sweepB.GetTransform(&transformB, output.t);
+ for (int32 i = 0; i < m_shapeB.m_count; ++i)
+ {
+ vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.5f, 0.7f, 0.9f));
+
+ sweepB.GetTransform(&transformB, 1.0f);
+ for (int32 i = 0; i < m_shapeB.m_count; ++i)
+ {
+ vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.9f, 0.5f, 0.5f));
+
+#if 0
+ for (float t = 0.0f; t < 1.0f; t += 0.1f)
+ {
+ sweepB.GetTransform(&transformB, t);
+ for (int32 i = 0; i < m_shapeB.m_count; ++i)
+ {
+ vertices[i] = b2Mul(transformB, m_shapeB.m_vertices[i]);
+ }
+ g_debugDraw.DrawPolygon(vertices, m_shapeB.m_count, b2Color(0.9f, 0.5f, 0.5f));
+ }
+#endif
+ }
+
+ b2PolygonShape m_shapeA;
+ b2PolygonShape m_shapeB;
+};
+
+static int testIndex = RegisterTest("Collision", "Time of Impact", TimeOfImpact::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/tumbler.cpp b/Client/ThirdParty/Box2D/testbed/tests/tumbler.cpp
new file mode 100644
index 0000000..f7972bc
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/tumbler.cpp
@@ -0,0 +1,102 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+class Tumbler : public Test
+{
+public:
+
+ enum
+ {
+ e_count = 800
+ };
+
+ Tumbler()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+ }
+
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.allowSleep = false;
+ bd.position.Set(0.0f, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 10.0f, b2Vec2( 10.0f, 0.0f), 0.0);
+ body->CreateFixture(&shape, 5.0f);
+ shape.SetAsBox(0.5f, 10.0f, b2Vec2(-10.0f, 0.0f), 0.0);
+ body->CreateFixture(&shape, 5.0f);
+ shape.SetAsBox(10.0f, 0.5f, b2Vec2(0.0f, 10.0f), 0.0);
+ body->CreateFixture(&shape, 5.0f);
+ shape.SetAsBox(10.0f, 0.5f, b2Vec2(0.0f, -10.0f), 0.0);
+ body->CreateFixture(&shape, 5.0f);
+
+ b2RevoluteJointDef jd;
+ jd.bodyA = ground;
+ jd.bodyB = body;
+ jd.localAnchorA.Set(0.0f, 10.0f);
+ jd.localAnchorB.Set(0.0f, 0.0f);
+ jd.referenceAngle = 0.0f;
+ jd.motorSpeed = 0.05f * b2_pi;
+ jd.maxMotorTorque = 1e8f;
+ jd.enableMotor = true;
+ m_joint = (b2RevoluteJoint*)m_world->CreateJoint(&jd);
+ }
+
+ m_count = 0;
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ if (m_count < e_count)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 10.0f);
+ b2Body* body = m_world->CreateBody(&bd);
+
+ b2PolygonShape shape;
+ shape.SetAsBox(0.125f, 0.125f);
+ body->CreateFixture(&shape, 1.0f);
+
+ ++m_count;
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Tumbler;
+ }
+
+ b2RevoluteJoint* m_joint;
+ int32 m_count;
+};
+
+static int testIndex = RegisterTest("Benchmark", "Tumbler", Tumbler::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/web.cpp b/Client/ThirdParty/Box2D/testbed/tests/web.cpp
new file mode 100644
index 0000000..aefa46a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/web.cpp
@@ -0,0 +1,218 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+
+// Test distance joints, body destruction, and joint destruction.
+class Web : public Test
+{
+public:
+ Web()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.5f);
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+
+ bd.position.Set(-5.0f, 5.0f);
+ m_bodies[0] = m_world->CreateBody(&bd);
+ m_bodies[0]->CreateFixture(&shape, 5.0f);
+
+ bd.position.Set(5.0f, 5.0f);
+ m_bodies[1] = m_world->CreateBody(&bd);
+ m_bodies[1]->CreateFixture(&shape, 5.0f);
+
+ bd.position.Set(5.0f, 15.0f);
+ m_bodies[2] = m_world->CreateBody(&bd);
+ m_bodies[2]->CreateFixture(&shape, 5.0f);
+
+ bd.position.Set(-5.0f, 15.0f);
+ m_bodies[3] = m_world->CreateBody(&bd);
+ m_bodies[3]->CreateFixture(&shape, 5.0f);
+
+ b2DistanceJointDef jd;
+ b2Vec2 p1, p2, d;
+
+ float frequencyHz = 2.0f;
+ float dampingRatio = 0.0f;
+
+ jd.bodyA = ground;
+ jd.bodyB = m_bodies[0];
+ jd.localAnchorA.Set(-10.0f, 0.0f);
+ jd.localAnchorB.Set(-0.5f, -0.5f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[0] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = ground;
+ jd.bodyB = m_bodies[1];
+ jd.localAnchorA.Set(10.0f, 0.0f);
+ jd.localAnchorB.Set(0.5f, -0.5f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[1] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = ground;
+ jd.bodyB = m_bodies[2];
+ jd.localAnchorA.Set(10.0f, 20.0f);
+ jd.localAnchorB.Set(0.5f, 0.5f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[2] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = ground;
+ jd.bodyB = m_bodies[3];
+ jd.localAnchorA.Set(-10.0f, 20.0f);
+ jd.localAnchorB.Set(-0.5f, 0.5f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[3] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = m_bodies[0];
+ jd.bodyB = m_bodies[1];
+ jd.localAnchorA.Set(0.5f, 0.0f);
+ jd.localAnchorB.Set(-0.5f, 0.0f);;
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[4] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = m_bodies[1];
+ jd.bodyB = m_bodies[2];
+ jd.localAnchorA.Set(0.0f, 0.5f);
+ jd.localAnchorB.Set(0.0f, -0.5f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[5] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = m_bodies[2];
+ jd.bodyB = m_bodies[3];
+ jd.localAnchorA.Set(-0.5f, 0.0f);
+ jd.localAnchorB.Set(0.5f, 0.0f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[6] = m_world->CreateJoint(&jd);
+
+ jd.bodyA = m_bodies[3];
+ jd.bodyB = m_bodies[0];
+ jd.localAnchorA.Set(0.0f, -0.5f);
+ jd.localAnchorB.Set(0.0f, 0.5f);
+ p1 = jd.bodyA->GetWorldPoint(jd.localAnchorA);
+ p2 = jd.bodyB->GetWorldPoint(jd.localAnchorB);
+ d = p2 - p1;
+ jd.length = d.Length();
+ b2LinearStiffness(jd.stiffness, jd.damping, frequencyHz, dampingRatio, jd.bodyA, jd.bodyB);
+ m_joints[7] = m_world->CreateJoint(&jd);
+ }
+ }
+
+ void Keyboard(int key) override
+ {
+ switch (key)
+ {
+ case GLFW_KEY_B:
+ for (int32 i = 0; i < 4; ++i)
+ {
+ if (m_bodies[i])
+ {
+ m_world->DestroyBody(m_bodies[i]);
+ m_bodies[i] = NULL;
+ break;
+ }
+ }
+ break;
+
+ case GLFW_KEY_J:
+ for (int32 i = 0; i < 8; ++i)
+ {
+ if (m_joints[i])
+ {
+ m_world->DestroyJoint(m_joints[i]);
+ m_joints[i] = NULL;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+ g_debugDraw.DrawString(5, m_textLine, "Press: (b) to delete a body, (j) to delete a joint");
+ m_textLine += m_textIncrement;
+ }
+
+ void JointDestroyed(b2Joint* joint) override
+ {
+ for (int32 i = 0; i < 8; ++i)
+ {
+ if (m_joints[i] == joint)
+ {
+ m_joints[i] = NULL;
+ break;
+ }
+ }
+ }
+
+ static Test* Create()
+ {
+ return new Web;
+ }
+
+ b2Body* m_bodies[4];
+ b2Joint* m_joints[8];
+};
+
+static int testIndex = RegisterTest("Examples", "Web", Web::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/wheel_joint.cpp b/Client/ThirdParty/Box2D/testbed/tests/wheel_joint.cpp
new file mode 100644
index 0000000..153cac1
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/wheel_joint.cpp
@@ -0,0 +1,126 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "settings.h"
+#include "test.h"
+#include "imgui/imgui.h"
+
+// Test the wheel joint with motor, spring, and limit options.
+class WheelJoint : public Test
+{
+public:
+ WheelJoint()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ m_enableLimit = true;
+ m_enableMotor = false;
+ m_motorSpeed = 10.0f;
+
+ {
+ b2CircleShape shape;
+ shape.m_radius = 2.0f;
+
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.0f, 10.0f);
+ bd.allowSleep = false;
+ b2Body* body = m_world->CreateBody(&bd);
+ body->CreateFixture(&shape, 5.0f);
+
+ b2WheelJointDef jd;
+
+ // Horizontal
+ jd.Initialize(ground, body, bd.position, b2Vec2(0.0f, 1.0f));
+
+ jd.motorSpeed = m_motorSpeed;
+ jd.maxMotorTorque = 10000.0f;
+ jd.enableMotor = m_enableMotor;
+ jd.lowerTranslation = -3.0f;
+ jd.upperTranslation = 3.0f;
+ jd.enableLimit = m_enableLimit;
+
+ float hertz = 1.0f;
+ float dampingRatio = 0.7f;
+ b2LinearStiffness(jd.stiffness, jd.damping, hertz, dampingRatio, ground, body);
+
+ m_joint = (b2WheelJoint*)m_world->CreateJoint(&jd);
+ }
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ float torque = m_joint->GetMotorTorque(settings.m_hertz);
+ g_debugDraw.DrawString(5, m_textLine, "Motor Torque = %4.0f", torque);
+ m_textLine += m_textIncrement;
+
+ b2Vec2 F = m_joint->GetReactionForce(settings.m_hertz);
+ g_debugDraw.DrawString(5, m_textLine, "Reaction Force = (%4.1f, %4.1f)", F.x, F.y);
+ m_textLine += m_textIncrement;
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 100.0f));
+ ImGui::Begin("Joint Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::Checkbox("Limit", &m_enableLimit))
+ {
+ m_joint->EnableLimit(m_enableLimit);
+ }
+
+ if (ImGui::Checkbox("Motor", &m_enableMotor))
+ {
+ m_joint->EnableMotor(m_enableMotor);
+ }
+
+ if (ImGui::SliderFloat("Speed", &m_motorSpeed, -100.0f, 100.0f, "%.0f"))
+ {
+ m_joint->SetMotorSpeed(m_motorSpeed);
+ }
+
+ ImGui::End();
+ }
+
+ static Test* Create()
+ {
+ return new WheelJoint;
+ }
+
+ b2WheelJoint* m_joint;
+ float m_motorSpeed;
+ bool m_enableMotor;
+ bool m_enableLimit;
+};
+
+static int testIndex = RegisterTest("Joints", "Wheel", WheelJoint::Create);
diff --git a/Client/ThirdParty/Box2D/testbed/tests/wrecking_ball.cpp b/Client/ThirdParty/Box2D/testbed/tests/wrecking_ball.cpp
new file mode 100644
index 0000000..74a61b4
--- /dev/null
+++ b/Client/ThirdParty/Box2D/testbed/tests/wrecking_ball.cpp
@@ -0,0 +1,165 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "test.h"
+#include "imgui/imgui.h"
+
+/// This test shows how a distance joint can be used to stabilize a chain of
+/// bodies with a heavy payload. Notice that the distance joint just prevents
+/// excessive stretching and has no other effect.
+/// By disabling the distance joint you can see that the Box2D solver has trouble
+/// supporting heavy bodies with light bodies. Try playing around with the
+/// densities, time step, and iterations to see how they affect stability.
+/// This test also shows how to use contact filtering. Filtering is configured
+/// so that the payload does not collide with the chain.
+class WreckingBall : public Test
+{
+public:
+ WreckingBall()
+ {
+ b2Body* ground = NULL;
+ {
+ b2BodyDef bd;
+ ground = m_world->CreateBody(&bd);
+
+ b2EdgeShape shape;
+ shape.SetTwoSided(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
+ ground->CreateFixture(&shape, 0.0f);
+ }
+
+ {
+ b2PolygonShape shape;
+ shape.SetAsBox(0.5f, 0.125f);
+
+ b2FixtureDef fd;
+ fd.shape = &shape;
+ fd.density = 20.0f;
+ fd.friction = 0.2f;
+ fd.filter.categoryBits = 0x0001;
+ fd.filter.maskBits = 0xFFFF & ~0x0002;
+
+ b2RevoluteJointDef jd;
+ jd.collideConnected = false;
+
+ const int32 N = 10;
+ const float y = 15.0f;
+ m_distanceJointDef.localAnchorA.Set(0.0f, y);
+
+ b2Body* prevBody = ground;
+ for (int32 i = 0; i < N; ++i)
+ {
+ b2BodyDef bd;
+ bd.type = b2_dynamicBody;
+ bd.position.Set(0.5f + 1.0f * i, y);
+ if (i == N - 1)
+ {
+ bd.position.Set(1.0f * i, y);
+ bd.angularDamping = 0.4f;
+ }
+
+ b2Body* body = m_world->CreateBody(&bd);
+
+ if (i == N - 1)
+ {
+ b2CircleShape circleShape;
+ circleShape.m_radius = 1.5f;
+ b2FixtureDef sfd;
+ sfd.shape = &circleShape;
+ sfd.density = 100.0f;
+ sfd.filter.categoryBits = 0x0002;
+ body->CreateFixture(&sfd);
+ }
+ else
+ {
+ body->CreateFixture(&fd);
+ }
+
+ b2Vec2 anchor(float(i), y);
+ jd.Initialize(prevBody, body, anchor);
+ m_world->CreateJoint(&jd);
+
+ prevBody = body;
+ }
+
+ m_distanceJointDef.localAnchorB.SetZero();
+
+ float extraLength = 0.01f;
+ m_distanceJointDef.minLength = 0.0f;
+ m_distanceJointDef.maxLength = N - 1.0f + extraLength;
+ m_distanceJointDef.bodyB = prevBody;
+ }
+
+ {
+ m_distanceJointDef.bodyA = ground;
+ m_distanceJoint = m_world->CreateJoint(&m_distanceJointDef);
+ m_stabilize = true;
+ }
+ }
+
+ void UpdateUI() override
+ {
+ ImGui::SetNextWindowPos(ImVec2(10.0f, 100.0f));
+ ImGui::SetNextWindowSize(ImVec2(200.0f, 100.0f));
+ ImGui::Begin("Wrecking Ball Controls", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
+
+ if (ImGui::Checkbox("Stabilize", &m_stabilize))
+ {
+ if (m_stabilize == true && m_distanceJoint == nullptr)
+ {
+ m_distanceJoint = m_world->CreateJoint(&m_distanceJointDef);
+ }
+ else if (m_stabilize == false && m_distanceJoint != nullptr)
+ {
+ m_world->DestroyJoint(m_distanceJoint);
+ m_distanceJoint = nullptr;
+ }
+ }
+
+ ImGui::End();
+ }
+
+ void Step(Settings& settings) override
+ {
+ Test::Step(settings);
+
+ if (m_distanceJoint)
+ {
+ g_debugDraw.DrawString(5, m_textLine, "Distance Joint ON");
+ }
+ else
+ {
+ g_debugDraw.DrawString(5, m_textLine, "Distance Joint OFF");
+ }
+ m_textLine += m_textIncrement;
+ }
+
+ static Test* Create()
+ {
+ return new WreckingBall;
+ }
+
+ b2DistanceJointDef m_distanceJointDef;
+ b2Joint* m_distanceJoint;
+ bool m_stabilize;
+};
+
+static int testIndex = RegisterTest("Examples", "Wrecking Ball", WreckingBall::Create);
diff --git a/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt b/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt
new file mode 100644
index 0000000..d941579
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/CMakeLists.txt
@@ -0,0 +1,18 @@
+add_executable(unit_test
+ doctest.h
+ hello_world.cpp
+ collision_test.cpp
+ joint_test.cpp
+ math_test.cpp
+ world_test.cpp
+)
+
+set_target_properties(unit_test PROPERTIES
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED YES
+ CXX_EXTENSIONS NO
+)
+target_link_libraries(unit_test PUBLIC box2d)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES doctest.h
+ hello_world.cpp collision_test.cpp joint_test.cpp math_test.cpp world_test.cpp )
diff --git a/Client/ThirdParty/Box2D/unit-test/collision_test.cpp b/Client/ThirdParty/Box2D/unit-test/collision_test.cpp
new file mode 100644
index 0000000..2e24b20
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/collision_test.cpp
@@ -0,0 +1,81 @@
+// MIT License
+
+// Copyright (c) 2020 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/box2d.h"
+#include "doctest.h"
+#include <stdio.h>
+
+// Unit tests for collision algorithms
+DOCTEST_TEST_CASE("collision test")
+{
+ SUBCASE("polygon mass data")
+ {
+ const b2Vec2 center(100.0f, -50.0f);
+ const float hx = 0.5f, hy = 1.5f;
+ const float angle1 = 0.25f;
+
+ // Data from issue #422. Not used because the data exceeds accuracy limits.
+ //const b2Vec2 center(-15000.0f, -15000.0f);
+ //const float hx = 0.72f, hy = 0.72f;
+ //const float angle1 = 0.0f;
+
+ b2PolygonShape polygon1;
+ polygon1.SetAsBox(hx, hy, center, angle1);
+
+ const float absTol = 2.0f * b2_epsilon;
+ const float relTol = 2.0f * b2_epsilon;
+
+ CHECK(b2Abs(polygon1.m_centroid.x - center.x) < absTol + relTol * b2Abs(center.x));
+ CHECK(b2Abs(polygon1.m_centroid.y - center.y) < absTol + relTol * b2Abs(center.y));
+
+ b2Vec2 vertices[4];
+ vertices[0].Set(center.x - hx, center.y - hy);
+ vertices[1].Set(center.x + hx, center.y - hy);
+ vertices[2].Set(center.x - hx, center.y + hy);
+ vertices[3].Set(center.x + hx, center.y + hy);
+
+ b2PolygonShape polygon2;
+ polygon2.Set(vertices, 4);
+
+ CHECK(b2Abs(polygon2.m_centroid.x - center.x) < absTol + relTol * b2Abs(center.x));
+ CHECK(b2Abs(polygon2.m_centroid.y - center.y) < absTol + relTol * b2Abs(center.y));
+
+ const float mass = 4.0f * hx * hy;
+ const float inertia = (mass / 3.0f) * (hx * hx + hy * hy) + mass * b2Dot(center, center);
+
+ b2MassData massData1;
+ polygon1.ComputeMass(&massData1, 1.0f);
+
+ CHECK(b2Abs(massData1.center.x - center.x) < absTol + relTol * b2Abs(center.x));
+ CHECK(b2Abs(massData1.center.y - center.y) < absTol + relTol * b2Abs(center.y));
+ CHECK(b2Abs(massData1.mass - mass) < 20.0f * (absTol + relTol * mass));
+ CHECK(b2Abs(massData1.I - inertia) < 40.0f * (absTol + relTol * inertia));
+
+ b2MassData massData2;
+ polygon2.ComputeMass(&massData2, 1.0f);
+
+ CHECK(b2Abs(massData2.center.x - center.x) < absTol + relTol * b2Abs(center.x));
+ CHECK(b2Abs(massData2.center.y - center.y) < absTol + relTol * b2Abs(center.y));
+ CHECK(b2Abs(massData2.mass - mass) < 20.0f * (absTol + relTol * mass));
+ CHECK(b2Abs(massData2.I - inertia) < 40.0f * (absTol + relTol * inertia));
+ }
+}
diff --git a/Client/ThirdParty/Box2D/unit-test/doctest.h b/Client/ThirdParty/Box2D/unit-test/doctest.h
new file mode 100644
index 0000000..42eb039
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/doctest.h
@@ -0,0 +1,6580 @@
+// ====================================================================== lgtm [cpp/missing-header-guard]
+// == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! ==
+// ======================================================================
+//
+// doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD
+//
+// Copyright (c) 2016-2021 Viktor Kirilov
+//
+// Distributed under the MIT Software License
+// See accompanying file LICENSE.txt or copy at
+// https://opensource.org/licenses/MIT
+//
+// The documentation can be found at the library's page:
+// https://github.com/onqtam/doctest/blob/master/doc/markdown/readme.md
+//
+// =================================================================================================
+// =================================================================================================
+// =================================================================================================
+//
+// The library is heavily influenced by Catch - https://github.com/catchorg/Catch2
+// which uses the Boost Software License - Version 1.0
+// see here - https://github.com/catchorg/Catch2/blob/master/LICENSE.txt
+//
+// The concept of subcases (sections in Catch) and expression decomposition are from there.
+// Some parts of the code are taken directly:
+// - stringification - the detection of "ostream& operator<<(ostream&, const T&)" and StringMaker<>
+// - the Approx() helper class for floating point comparison
+// - colors in the console
+// - breaking into a debugger
+// - signal / SEH handling
+// - timer
+// - XmlWriter class - thanks to Phil Nash for allowing the direct reuse (AKA copy/paste)
+//
+// The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest
+// which uses the Boost Software License - Version 1.0
+// see here - https://github.com/martinmoene/lest/blob/master/LICENSE.txt
+//
+// =================================================================================================
+// =================================================================================================
+// =================================================================================================
+
+#ifndef DOCTEST_LIBRARY_INCLUDED
+#define DOCTEST_LIBRARY_INCLUDED
+
+// =================================================================================================
+// == VERSION ======================================================================================
+// =================================================================================================
+
+#define DOCTEST_VERSION_MAJOR 2
+#define DOCTEST_VERSION_MINOR 4
+#define DOCTEST_VERSION_PATCH 6
+#define DOCTEST_VERSION_STR "2.4.6"
+
+#define DOCTEST_VERSION \
+ (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH)
+
+// =================================================================================================
+// == COMPILER VERSION =============================================================================
+// =================================================================================================
+
+// ideas for the version stuff are taken from here: https://github.com/cxxstuff/cxx_detect
+
+#define DOCTEST_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR)*10000000 + (MINOR)*100000 + (PATCH))
+
+// GCC/Clang and GCC/MSVC are mutually exclusive, but Clang/MSVC are not because of clang-cl...
+#if defined(_MSC_VER) && defined(_MSC_FULL_VER)
+#if _MSC_VER == _MSC_FULL_VER / 10000
+#define DOCTEST_MSVC DOCTEST_COMPILER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000)
+#else // MSVC
+#define DOCTEST_MSVC \
+ DOCTEST_COMPILER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000)
+#endif // MSVC
+#endif // MSVC
+#if defined(__clang__) && defined(__clang_minor__)
+#define DOCTEST_CLANG DOCTEST_COMPILER(__clang_major__, __clang_minor__, __clang_patchlevel__)
+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && \
+ !defined(__INTEL_COMPILER)
+#define DOCTEST_GCC DOCTEST_COMPILER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
+#endif // GCC
+
+#ifndef DOCTEST_MSVC
+#define DOCTEST_MSVC 0
+#endif // DOCTEST_MSVC
+#ifndef DOCTEST_CLANG
+#define DOCTEST_CLANG 0
+#endif // DOCTEST_CLANG
+#ifndef DOCTEST_GCC
+#define DOCTEST_GCC 0
+#endif // DOCTEST_GCC
+
+// =================================================================================================
+// == COMPILER WARNINGS HELPERS ====================================================================
+// =================================================================================================
+
+#if DOCTEST_CLANG
+#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x)
+#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
+#define DOCTEST_CLANG_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(clang diagnostic ignored w)
+#define DOCTEST_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
+#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
+ DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING(w)
+#else // DOCTEST_CLANG
+#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
+#define DOCTEST_CLANG_SUPPRESS_WARNING(w)
+#define DOCTEST_CLANG_SUPPRESS_WARNING_POP
+#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
+#endif // DOCTEST_CLANG
+
+#if DOCTEST_GCC
+#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x)
+#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH _Pragma("GCC diagnostic push")
+#define DOCTEST_GCC_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(GCC diagnostic ignored w)
+#define DOCTEST_GCC_SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop")
+#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) \
+ DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING(w)
+#else // DOCTEST_GCC
+#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH
+#define DOCTEST_GCC_SUPPRESS_WARNING(w)
+#define DOCTEST_GCC_SUPPRESS_WARNING_POP
+#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w)
+#endif // DOCTEST_GCC
+
+#if DOCTEST_MSVC
+#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH __pragma(warning(push))
+#define DOCTEST_MSVC_SUPPRESS_WARNING(w) __pragma(warning(disable : w))
+#define DOCTEST_MSVC_SUPPRESS_WARNING_POP __pragma(warning(pop))
+#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) \
+ DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(w)
+#else // DOCTEST_MSVC
+#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
+#define DOCTEST_MSVC_SUPPRESS_WARNING(w)
+#define DOCTEST_MSVC_SUPPRESS_WARNING_POP
+#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w)
+#endif // DOCTEST_MSVC
+
+// =================================================================================================
+// == COMPILER WARNINGS ============================================================================
+// =================================================================================================
+
+DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wnon-virtual-dtor")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
+
+DOCTEST_GCC_SUPPRESS_WARNING_PUSH
+DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas")
+DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wctor-dtor-privacy")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-promo")
+
+DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
+DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning
+DOCTEST_MSVC_SUPPRESS_WARNING(4619) // invalid compiler warning
+DOCTEST_MSVC_SUPPRESS_WARNING(4996) // The compiler encountered a deprecated declaration
+DOCTEST_MSVC_SUPPRESS_WARNING(4706) // assignment within conditional expression
+DOCTEST_MSVC_SUPPRESS_WARNING(4512) // 'class' : assignment operator could not be generated
+DOCTEST_MSVC_SUPPRESS_WARNING(4127) // conditional expression is constant
+DOCTEST_MSVC_SUPPRESS_WARNING(4820) // padding
+DOCTEST_MSVC_SUPPRESS_WARNING(4625) // copy constructor was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(5027) // move assignment operator was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(5026) // move constructor was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(4623) // default constructor was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(4640) // construction of local static object is not thread-safe
+// static analysis
+DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept'
+DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable
+DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ...
+DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtr...
+DOCTEST_MSVC_SUPPRESS_WARNING(26812) // Prefer 'enum class' over 'enum'
+
+// 4548 - expression before comma has no effect; expected expression with side - effect
+// 4265 - class has virtual functions, but destructor is not virtual
+// 4986 - exception specification does not match previous declaration
+// 4350 - behavior change: 'member1' called instead of 'member2'
+// 4668 - 'x' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
+// 4365 - conversion from 'int' to 'unsigned long', signed/unsigned mismatch
+// 4774 - format string expected in argument 'x' is not a string literal
+// 4820 - padding in structs
+
+// only 4 should be disabled globally:
+// - 4514 # unreferenced inline function has been removed
+// - 4571 # SEH related
+// - 4710 # function not inlined
+// - 4711 # function 'x' selected for automatic inline expansion
+
+#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN \
+ DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4548) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4265) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4986) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4350) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4668) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4365) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4774) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4820) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4625) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4626) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(5027) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(5026) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(4623) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(5039) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(5045) \
+ DOCTEST_MSVC_SUPPRESS_WARNING(5105)
+
+#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END DOCTEST_MSVC_SUPPRESS_WARNING_POP
+
+// =================================================================================================
+// == FEATURE DETECTION ============================================================================
+// =================================================================================================
+
+// general compiler feature support table: https://en.cppreference.com/w/cpp/compiler_support
+// MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx
+// GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html
+// MSVC version table:
+// https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
+// MSVC++ 14.2 (16) _MSC_VER == 1920 (Visual Studio 2019)
+// MSVC++ 14.1 (15) _MSC_VER == 1910 (Visual Studio 2017)
+// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
+// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
+// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
+// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
+// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
+// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
+
+#if DOCTEST_MSVC && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
+#define DOCTEST_CONFIG_WINDOWS_SEH
+#endif // MSVC
+#if defined(DOCTEST_CONFIG_NO_WINDOWS_SEH) && defined(DOCTEST_CONFIG_WINDOWS_SEH)
+#undef DOCTEST_CONFIG_WINDOWS_SEH
+#endif // DOCTEST_CONFIG_NO_WINDOWS_SEH
+
+#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && \
+ !defined(__EMSCRIPTEN__)
+#define DOCTEST_CONFIG_POSIX_SIGNALS
+#endif // _WIN32
+#if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS)
+#undef DOCTEST_CONFIG_POSIX_SIGNALS
+#endif // DOCTEST_CONFIG_NO_POSIX_SIGNALS
+
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+#if !defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND)
+#define DOCTEST_CONFIG_NO_EXCEPTIONS
+#endif // no exceptions
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+
+#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+#define DOCTEST_CONFIG_NO_EXCEPTIONS
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
+
+#if defined(DOCTEST_CONFIG_NO_EXCEPTIONS) && !defined(DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS)
+#define DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS && !DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
+
+#if defined(DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) && !defined(DOCTEST_CONFIG_IMPLEMENT)
+#define DOCTEST_CONFIG_IMPLEMENT
+#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+#if DOCTEST_MSVC
+#define DOCTEST_SYMBOL_EXPORT __declspec(dllexport)
+#define DOCTEST_SYMBOL_IMPORT __declspec(dllimport)
+#else // MSVC
+#define DOCTEST_SYMBOL_EXPORT __attribute__((dllexport))
+#define DOCTEST_SYMBOL_IMPORT __attribute__((dllimport))
+#endif // MSVC
+#else // _WIN32
+#define DOCTEST_SYMBOL_EXPORT __attribute__((visibility("default")))
+#define DOCTEST_SYMBOL_IMPORT
+#endif // _WIN32
+
+#ifdef DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
+#ifdef DOCTEST_CONFIG_IMPLEMENT
+#define DOCTEST_INTERFACE DOCTEST_SYMBOL_EXPORT
+#else // DOCTEST_CONFIG_IMPLEMENT
+#define DOCTEST_INTERFACE DOCTEST_SYMBOL_IMPORT
+#endif // DOCTEST_CONFIG_IMPLEMENT
+#else // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
+#define DOCTEST_INTERFACE
+#endif // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
+
+#define DOCTEST_EMPTY
+
+#if DOCTEST_MSVC
+#define DOCTEST_NOINLINE __declspec(noinline)
+#define DOCTEST_UNUSED
+#define DOCTEST_ALIGNMENT(x)
+#elif DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 5, 0)
+#define DOCTEST_NOINLINE
+#define DOCTEST_UNUSED
+#define DOCTEST_ALIGNMENT(x)
+#else
+#define DOCTEST_NOINLINE __attribute__((noinline))
+#define DOCTEST_UNUSED __attribute__((unused))
+#define DOCTEST_ALIGNMENT(x) __attribute__((aligned(x)))
+#endif
+
+#ifndef DOCTEST_NORETURN
+#define DOCTEST_NORETURN [[noreturn]]
+#endif // DOCTEST_NORETURN
+
+#ifndef DOCTEST_NOEXCEPT
+#define DOCTEST_NOEXCEPT noexcept
+#endif // DOCTEST_NOEXCEPT
+
+// =================================================================================================
+// == FEATURE DETECTION END ========================================================================
+// =================================================================================================
+
+// internal macros for string concatenation and anonymous variable name generation
+#define DOCTEST_CAT_IMPL(s1, s2) s1##s2
+#define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2)
+#ifdef __COUNTER__ // not standard and may be missing for some compilers
+#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__)
+#else // __COUNTER__
+#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__)
+#endif // __COUNTER__
+
+#define DOCTEST_TOSTR(x) #x
+
+#ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
+#define DOCTEST_REF_WRAP(x) x&
+#else // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
+#define DOCTEST_REF_WRAP(x) x
+#endif // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
+
+// not using __APPLE__ because... this is how Catch does it
+#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
+#define DOCTEST_PLATFORM_MAC
+#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
+#define DOCTEST_PLATFORM_IPHONE
+#elif defined(_WIN32)
+#define DOCTEST_PLATFORM_WINDOWS
+#else // DOCTEST_PLATFORM
+#define DOCTEST_PLATFORM_LINUX
+#endif // DOCTEST_PLATFORM
+
+#define DOCTEST_GLOBAL_NO_WARNINGS(var) \
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wglobal-constructors") \
+ DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-variable") \
+ static const int var DOCTEST_UNUSED // NOLINT(fuchsia-statically-constructed-objects,cert-err58-cpp)
+#define DOCTEST_GLOBAL_NO_WARNINGS_END() DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#ifndef DOCTEST_BREAK_INTO_DEBUGGER
+// should probably take a look at https://github.com/scottt/debugbreak
+#ifdef DOCTEST_PLATFORM_LINUX
+#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
+// Break at the location of the failing check if possible
+#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT (hicpp-no-assembler)
+#else
+#include <signal.h>
+#define DOCTEST_BREAK_INTO_DEBUGGER() raise(SIGTRAP)
+#endif
+#elif defined(DOCTEST_PLATFORM_MAC)
+#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(__i386)
+#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT (hicpp-no-assembler)
+#else
+#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("brk #0"); // NOLINT (hicpp-no-assembler)
+#endif
+#elif DOCTEST_MSVC
+#define DOCTEST_BREAK_INTO_DEBUGGER() __debugbreak()
+#elif defined(__MINGW32__)
+DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wredundant-decls")
+extern "C" __declspec(dllimport) void __stdcall DebugBreak();
+DOCTEST_GCC_SUPPRESS_WARNING_POP
+#define DOCTEST_BREAK_INTO_DEBUGGER() ::DebugBreak()
+#else // linux
+#define DOCTEST_BREAK_INTO_DEBUGGER() (static_cast<void>(0))
+#endif // linux
+#endif // DOCTEST_BREAK_INTO_DEBUGGER
+
+// this is kept here for backwards compatibility since the config option was changed
+#ifdef DOCTEST_CONFIG_USE_IOSFWD
+#define DOCTEST_CONFIG_USE_STD_HEADERS
+#endif // DOCTEST_CONFIG_USE_IOSFWD
+
+#ifdef DOCTEST_CONFIG_USE_STD_HEADERS
+#ifndef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+#define DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+#include <iosfwd>
+#include <cstddef>
+#include <ostream>
+#else // DOCTEST_CONFIG_USE_STD_HEADERS
+
+#if DOCTEST_CLANG
+// to detect if libc++ is being used with clang (the _LIBCPP_VERSION identifier)
+#include <ciso646>
+#endif // clang
+
+#ifdef _LIBCPP_VERSION
+#define DOCTEST_STD_NAMESPACE_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD
+#define DOCTEST_STD_NAMESPACE_END _LIBCPP_END_NAMESPACE_STD
+#else // _LIBCPP_VERSION
+#define DOCTEST_STD_NAMESPACE_BEGIN namespace std {
+#define DOCTEST_STD_NAMESPACE_END }
+#endif // _LIBCPP_VERSION
+
+// Forward declaring 'X' in namespace std is not permitted by the C++ Standard.
+DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4643)
+
+DOCTEST_STD_NAMESPACE_BEGIN // NOLINT (cert-dcl58-cpp)
+typedef decltype(nullptr) nullptr_t;
+template <class charT>
+struct char_traits;
+template <>
+struct char_traits<char>;
+template <class charT, class traits>
+class basic_ostream;
+typedef basic_ostream<char, char_traits<char>> ostream;
+template <class... Types>
+class tuple;
+#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
+// see this issue on why this is needed: https://github.com/onqtam/doctest/issues/183
+template <class _Ty>
+class allocator;
+template <class _Elem, class _Traits, class _Alloc>
+class basic_string;
+using string = basic_string<char, char_traits<char>, allocator<char>>;
+#endif // VS 2019
+DOCTEST_STD_NAMESPACE_END
+
+DOCTEST_MSVC_SUPPRESS_WARNING_POP
+
+#endif // DOCTEST_CONFIG_USE_STD_HEADERS
+
+#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+#include <type_traits>
+#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+
+namespace doctest {
+
+DOCTEST_INTERFACE extern bool is_running_in_test;
+
+// A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length
+// of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used for:
+// - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128)
+// - if small - capacity left before going on the heap - using the lowest 5 bits
+// - if small - 2 bits are left unused - the second and third highest ones
+// - if small - acts as a null terminator if strlen() is 23 (24 including the null terminator)
+// and the "is small" bit remains "0" ("as well as the capacity left") so its OK
+// Idea taken from this lecture about the string implementation of facebook/folly - fbstring
+// https://www.youtube.com/watch?v=kPR8h4-qZdk
+// TODO:
+// - optimizations - like not deleting memory unnecessarily in operator= and etc.
+// - resize/reserve/clear
+// - substr
+// - replace
+// - back/front
+// - iterator stuff
+// - find & friends
+// - push_back/pop_back
+// - assign/insert/erase
+// - relational operators as free functions - taking const char* as one of the params
+class DOCTEST_INTERFACE String
+{
+ static const unsigned len = 24; //!OCLINT avoid private static members
+ static const unsigned last = len - 1; //!OCLINT avoid private static members
+
+ struct view // len should be more than sizeof(view) - because of the final byte for flags
+ {
+ char* ptr;
+ unsigned size;
+ unsigned capacity;
+ };
+
+ union
+ {
+ char buf[len];
+ view data;
+ };
+
+ bool isOnStack() const { return (buf[last] & 128) == 0; }
+ void setOnHeap();
+ void setLast(unsigned in = last);
+
+ void copy(const String& other);
+
+public:
+ String();
+ ~String();
+
+ // cppcheck-suppress noExplicitConstructor
+ String(const char* in);
+ String(const char* in, unsigned in_size);
+
+ String(const String& other);
+ String& operator=(const String& other);
+
+ String& operator+=(const String& other);
+ String operator+(const String& other) const;
+
+ String(String&& other);
+ String& operator=(String&& other);
+
+ char operator[](unsigned i) const;
+ char& operator[](unsigned i);
+
+ // the only functions I'm willing to leave in the interface - available for inlining
+ const char* c_str() const { return const_cast<String*>(this)->c_str(); } // NOLINT
+ char* c_str() {
+ if(isOnStack())
+ return reinterpret_cast<char*>(buf);
+ return data.ptr;
+ }
+
+ unsigned size() const;
+ unsigned capacity() const;
+
+ int compare(const char* other, bool no_case = false) const;
+ int compare(const String& other, bool no_case = false) const;
+};
+
+DOCTEST_INTERFACE bool operator==(const String& lhs, const String& rhs);
+DOCTEST_INTERFACE bool operator!=(const String& lhs, const String& rhs);
+DOCTEST_INTERFACE bool operator<(const String& lhs, const String& rhs);
+DOCTEST_INTERFACE bool operator>(const String& lhs, const String& rhs);
+DOCTEST_INTERFACE bool operator<=(const String& lhs, const String& rhs);
+DOCTEST_INTERFACE bool operator>=(const String& lhs, const String& rhs);
+
+DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, const String& in);
+
+namespace Color {
+ enum Enum
+ {
+ None = 0,
+ White,
+ Red,
+ Green,
+ Blue,
+ Cyan,
+ Yellow,
+ Grey,
+
+ Bright = 0x10,
+
+ BrightRed = Bright | Red,
+ BrightGreen = Bright | Green,
+ LightGrey = Bright | Grey,
+ BrightWhite = Bright | White
+ };
+
+ DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, Color::Enum code);
+} // namespace Color
+
+namespace assertType {
+ enum Enum
+ {
+ // macro traits
+
+ is_warn = 1,
+ is_check = 2 * is_warn,
+ is_require = 2 * is_check,
+
+ is_normal = 2 * is_require,
+ is_throws = 2 * is_normal,
+ is_throws_as = 2 * is_throws,
+ is_throws_with = 2 * is_throws_as,
+ is_nothrow = 2 * is_throws_with,
+
+ is_false = 2 * is_nothrow,
+ is_unary = 2 * is_false, // not checked anywhere - used just to distinguish the types
+
+ is_eq = 2 * is_unary,
+ is_ne = 2 * is_eq,
+
+ is_lt = 2 * is_ne,
+ is_gt = 2 * is_lt,
+
+ is_ge = 2 * is_gt,
+ is_le = 2 * is_ge,
+
+ // macro types
+
+ DT_WARN = is_normal | is_warn,
+ DT_CHECK = is_normal | is_check,
+ DT_REQUIRE = is_normal | is_require,
+
+ DT_WARN_FALSE = is_normal | is_false | is_warn,
+ DT_CHECK_FALSE = is_normal | is_false | is_check,
+ DT_REQUIRE_FALSE = is_normal | is_false | is_require,
+
+ DT_WARN_THROWS = is_throws | is_warn,
+ DT_CHECK_THROWS = is_throws | is_check,
+ DT_REQUIRE_THROWS = is_throws | is_require,
+
+ DT_WARN_THROWS_AS = is_throws_as | is_warn,
+ DT_CHECK_THROWS_AS = is_throws_as | is_check,
+ DT_REQUIRE_THROWS_AS = is_throws_as | is_require,
+
+ DT_WARN_THROWS_WITH = is_throws_with | is_warn,
+ DT_CHECK_THROWS_WITH = is_throws_with | is_check,
+ DT_REQUIRE_THROWS_WITH = is_throws_with | is_require,
+
+ DT_WARN_THROWS_WITH_AS = is_throws_with | is_throws_as | is_warn,
+ DT_CHECK_THROWS_WITH_AS = is_throws_with | is_throws_as | is_check,
+ DT_REQUIRE_THROWS_WITH_AS = is_throws_with | is_throws_as | is_require,
+
+ DT_WARN_NOTHROW = is_nothrow | is_warn,
+ DT_CHECK_NOTHROW = is_nothrow | is_check,
+ DT_REQUIRE_NOTHROW = is_nothrow | is_require,
+
+ DT_WARN_EQ = is_normal | is_eq | is_warn,
+ DT_CHECK_EQ = is_normal | is_eq | is_check,
+ DT_REQUIRE_EQ = is_normal | is_eq | is_require,
+
+ DT_WARN_NE = is_normal | is_ne | is_warn,
+ DT_CHECK_NE = is_normal | is_ne | is_check,
+ DT_REQUIRE_NE = is_normal | is_ne | is_require,
+
+ DT_WARN_GT = is_normal | is_gt | is_warn,
+ DT_CHECK_GT = is_normal | is_gt | is_check,
+ DT_REQUIRE_GT = is_normal | is_gt | is_require,
+
+ DT_WARN_LT = is_normal | is_lt | is_warn,
+ DT_CHECK_LT = is_normal | is_lt | is_check,
+ DT_REQUIRE_LT = is_normal | is_lt | is_require,
+
+ DT_WARN_GE = is_normal | is_ge | is_warn,
+ DT_CHECK_GE = is_normal | is_ge | is_check,
+ DT_REQUIRE_GE = is_normal | is_ge | is_require,
+
+ DT_WARN_LE = is_normal | is_le | is_warn,
+ DT_CHECK_LE = is_normal | is_le | is_check,
+ DT_REQUIRE_LE = is_normal | is_le | is_require,
+
+ DT_WARN_UNARY = is_normal | is_unary | is_warn,
+ DT_CHECK_UNARY = is_normal | is_unary | is_check,
+ DT_REQUIRE_UNARY = is_normal | is_unary | is_require,
+
+ DT_WARN_UNARY_FALSE = is_normal | is_false | is_unary | is_warn,
+ DT_CHECK_UNARY_FALSE = is_normal | is_false | is_unary | is_check,
+ DT_REQUIRE_UNARY_FALSE = is_normal | is_false | is_unary | is_require,
+ };
+} // namespace assertType
+
+DOCTEST_INTERFACE const char* assertString(assertType::Enum at);
+DOCTEST_INTERFACE const char* failureString(assertType::Enum at);
+DOCTEST_INTERFACE const char* skipPathFromFilename(const char* file);
+
+struct DOCTEST_INTERFACE TestCaseData
+{
+ String m_file; // the file in which the test was registered (using String - see #350)
+ unsigned m_line; // the line where the test was registered
+ const char* m_name; // name of the test case
+ const char* m_test_suite; // the test suite in which the test was added
+ const char* m_description;
+ bool m_skip;
+ bool m_no_breaks;
+ bool m_no_output;
+ bool m_may_fail;
+ bool m_should_fail;
+ int m_expected_failures;
+ double m_timeout;
+};
+
+struct DOCTEST_INTERFACE AssertData
+{
+ // common - for all asserts
+ const TestCaseData* m_test_case;
+ assertType::Enum m_at;
+ const char* m_file;
+ int m_line;
+ const char* m_expr;
+ bool m_failed;
+
+ // exception-related - for all asserts
+ bool m_threw;
+ String m_exception;
+
+ // for normal asserts
+ String m_decomp;
+
+ // for specific exception-related asserts
+ bool m_threw_as;
+ const char* m_exception_type;
+ const char* m_exception_string;
+};
+
+struct DOCTEST_INTERFACE MessageData
+{
+ String m_string;
+ const char* m_file;
+ int m_line;
+ assertType::Enum m_severity;
+};
+
+struct DOCTEST_INTERFACE SubcaseSignature
+{
+ String m_name;
+ const char* m_file;
+ int m_line;
+
+ bool operator<(const SubcaseSignature& other) const;
+};
+
+struct DOCTEST_INTERFACE IContextScope
+{
+ IContextScope();
+ virtual ~IContextScope();
+ virtual void stringify(std::ostream*) const = 0;
+};
+
+namespace detail {
+ struct DOCTEST_INTERFACE TestCase;
+} // namespace detail
+
+struct ContextOptions //!OCLINT too many fields
+{
+ std::ostream* cout; // stdout stream - std::cout by default
+ std::ostream* cerr; // stderr stream - std::cerr by default
+ String binary_name; // the test binary name
+
+ const detail::TestCase* currentTest = nullptr;
+
+ // == parameters from the command line
+ String out; // output filename
+ String order_by; // how tests should be ordered
+ unsigned rand_seed; // the seed for rand ordering
+
+ unsigned first; // the first (matching) test to be executed
+ unsigned last; // the last (matching) test to be executed
+
+ int abort_after; // stop tests after this many failed assertions
+ int subcase_filter_levels; // apply the subcase filters for the first N levels
+
+ bool success; // include successful assertions in output
+ bool case_sensitive; // if filtering should be case sensitive
+ bool exit; // if the program should be exited after the tests are ran/whatever
+ bool duration; // print the time duration of each test case
+ bool no_throw; // to skip exceptions-related assertion macros
+ bool no_exitcode; // if the framework should return 0 as the exitcode
+ bool no_run; // to not run the tests at all (can be done with an "*" exclude)
+ bool no_version; // to not print the version of the framework
+ bool no_colors; // if output to the console should be colorized
+ bool force_colors; // forces the use of colors even when a tty cannot be detected
+ bool no_breaks; // to not break into the debugger
+ bool no_skip; // don't skip test cases which are marked to be skipped
+ bool gnu_file_line; // if line numbers should be surrounded with :x: and not (x):
+ bool no_path_in_filenames; // if the path to files should be removed from the output
+ bool no_line_numbers; // if source code line numbers should be omitted from the output
+ bool no_debug_output; // no output in the debug console when a debugger is attached
+ bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!!
+ bool no_time_in_output; // omit any time/timestamps from output !!! UNDOCUMENTED !!!
+
+ bool help; // to print the help
+ bool version; // to print the version
+ bool count; // if only the count of matching tests is to be retrieved
+ bool list_test_cases; // to list all tests matching the filters
+ bool list_test_suites; // to list all suites matching the filters
+ bool list_reporters; // lists all registered reporters
+};
+
+namespace detail {
+ template <bool CONDITION, typename TYPE = void>
+ struct enable_if
+ {};
+
+ template <typename TYPE>
+ struct enable_if<true, TYPE>
+ { typedef TYPE type; };
+
+ // clang-format off
+ template<class T> struct remove_reference { typedef T type; };
+ template<class T> struct remove_reference<T&> { typedef T type; };
+ template<class T> struct remove_reference<T&&> { typedef T type; };
+
+ template<typename T, typename U = T&&> U declval(int);
+
+ template<typename T> T declval(long);
+
+ template<typename T> auto declval() DOCTEST_NOEXCEPT -> decltype(declval<T>(0)) ;
+
+ template<class T> struct is_lvalue_reference { const static bool value=false; };
+ template<class T> struct is_lvalue_reference<T&> { const static bool value=true; };
+
+ template <class T>
+ inline T&& forward(typename remove_reference<T>::type& t) DOCTEST_NOEXCEPT
+ {
+ return static_cast<T&&>(t);
+ }
+
+ template <class T>
+ inline T&& forward(typename remove_reference<T>::type&& t) DOCTEST_NOEXCEPT
+ {
+ static_assert(!is_lvalue_reference<T>::value,
+ "Can not forward an rvalue as an lvalue.");
+ return static_cast<T&&>(t);
+ }
+
+ template<class T> struct remove_const { typedef T type; };
+ template<class T> struct remove_const<const T> { typedef T type; };
+#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+ template<class T> struct is_enum : public std::is_enum<T> {};
+ template<class T> struct underlying_type : public std::underlying_type<T> {};
+#else
+ // Use compiler intrinsics
+ template<class T> struct is_enum { constexpr static bool value = __is_enum(T); };
+ template<class T> struct underlying_type { typedef __underlying_type(T) type; };
+#endif
+ // clang-format on
+
+ template <typename T>
+ struct deferred_false
+ // cppcheck-suppress unusedStructMember
+ { static const bool value = false; };
+
+ namespace has_insertion_operator_impl {
+ std::ostream &os();
+ template<class T>
+ DOCTEST_REF_WRAP(T) val();
+
+ template<class, class = void>
+ struct check {
+ static constexpr bool value = false;
+ };
+
+ template<class T>
+ struct check<T, decltype(os() << val<T>(), void())> {
+ static constexpr bool value = true;
+ };
+ } // namespace has_insertion_operator_impl
+
+ template<class T>
+ using has_insertion_operator = has_insertion_operator_impl::check<const T>;
+
+ DOCTEST_INTERFACE void my_memcpy(void* dest, const void* src, unsigned num);
+
+ DOCTEST_INTERFACE std::ostream* getTlsOss(); // returns a thread-local ostringstream
+ DOCTEST_INTERFACE String getTlsOssResult();
+
+ template <bool C>
+ struct StringMakerBase
+ {
+ template <typename T>
+ static String convert(const DOCTEST_REF_WRAP(T)) {
+ return "{?}";
+ }
+ };
+
+ template <>
+ struct StringMakerBase<true>
+ {
+ template <typename T>
+ static String convert(const DOCTEST_REF_WRAP(T) in) {
+ *getTlsOss() << in;
+ return getTlsOssResult();
+ }
+ };
+
+ DOCTEST_INTERFACE String rawMemoryToString(const void* object, unsigned size);
+
+ template <typename T>
+ String rawMemoryToString(const DOCTEST_REF_WRAP(T) object) {
+ return rawMemoryToString(&object, sizeof(object));
+ }
+
+ template <typename T>
+ const char* type_to_string() {
+ return "<>";
+ }
+} // namespace detail
+
+template <typename T>
+struct StringMaker : public detail::StringMakerBase<detail::has_insertion_operator<T>::value>
+{};
+
+template <typename T>
+struct StringMaker<T*>
+{
+ template <typename U>
+ static String convert(U* p) {
+ if(p)
+ return detail::rawMemoryToString(p);
+ return "NULL";
+ }
+};
+
+template <typename R, typename C>
+struct StringMaker<R C::*>
+{
+ static String convert(R C::*p) {
+ if(p)
+ return detail::rawMemoryToString(p);
+ return "NULL";
+ }
+};
+
+template <typename T, typename detail::enable_if<!detail::is_enum<T>::value, bool>::type = true>
+String toString(const DOCTEST_REF_WRAP(T) value) {
+ return StringMaker<T>::convert(value);
+}
+
+#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+DOCTEST_INTERFACE String toString(char* in);
+DOCTEST_INTERFACE String toString(const char* in);
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+DOCTEST_INTERFACE String toString(bool in);
+DOCTEST_INTERFACE String toString(float in);
+DOCTEST_INTERFACE String toString(double in);
+DOCTEST_INTERFACE String toString(double long in);
+
+DOCTEST_INTERFACE String toString(char in);
+DOCTEST_INTERFACE String toString(char signed in);
+DOCTEST_INTERFACE String toString(char unsigned in);
+DOCTEST_INTERFACE String toString(int short in);
+DOCTEST_INTERFACE String toString(int short unsigned in);
+DOCTEST_INTERFACE String toString(int in);
+DOCTEST_INTERFACE String toString(int unsigned in);
+DOCTEST_INTERFACE String toString(int long in);
+DOCTEST_INTERFACE String toString(int long unsigned in);
+DOCTEST_INTERFACE String toString(int long long in);
+DOCTEST_INTERFACE String toString(int long long unsigned in);
+DOCTEST_INTERFACE String toString(std::nullptr_t in);
+
+template <typename T, typename detail::enable_if<detail::is_enum<T>::value, bool>::type = true>
+String toString(const DOCTEST_REF_WRAP(T) value) {
+ typedef typename detail::underlying_type<T>::type UT;
+ return toString(static_cast<UT>(value));
+}
+
+#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
+// see this issue on why this is needed: https://github.com/onqtam/doctest/issues/183
+DOCTEST_INTERFACE String toString(const std::string& in);
+#endif // VS 2019
+
+class DOCTEST_INTERFACE Approx
+{
+public:
+ explicit Approx(double value);
+
+ Approx operator()(double value) const;
+
+#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+ template <typename T>
+ explicit Approx(const T& value,
+ typename detail::enable_if<std::is_constructible<double, T>::value>::type* =
+ static_cast<T*>(nullptr)) {
+ *this = Approx(static_cast<double>(value));
+ }
+#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+
+ Approx& epsilon(double newEpsilon);
+
+#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+ template <typename T>
+ typename detail::enable_if<std::is_constructible<double, T>::value, Approx&>::type epsilon(
+ const T& newEpsilon) {
+ m_epsilon = static_cast<double>(newEpsilon);
+ return *this;
+ }
+#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+
+ Approx& scale(double newScale);
+
+#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+ template <typename T>
+ typename detail::enable_if<std::is_constructible<double, T>::value, Approx&>::type scale(
+ const T& newScale) {
+ m_scale = static_cast<double>(newScale);
+ return *this;
+ }
+#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+
+ // clang-format off
+ DOCTEST_INTERFACE friend bool operator==(double lhs, const Approx & rhs);
+ DOCTEST_INTERFACE friend bool operator==(const Approx & lhs, double rhs);
+ DOCTEST_INTERFACE friend bool operator!=(double lhs, const Approx & rhs);
+ DOCTEST_INTERFACE friend bool operator!=(const Approx & lhs, double rhs);
+ DOCTEST_INTERFACE friend bool operator<=(double lhs, const Approx & rhs);
+ DOCTEST_INTERFACE friend bool operator<=(const Approx & lhs, double rhs);
+ DOCTEST_INTERFACE friend bool operator>=(double lhs, const Approx & rhs);
+ DOCTEST_INTERFACE friend bool operator>=(const Approx & lhs, double rhs);
+ DOCTEST_INTERFACE friend bool operator< (double lhs, const Approx & rhs);
+ DOCTEST_INTERFACE friend bool operator< (const Approx & lhs, double rhs);
+ DOCTEST_INTERFACE friend bool operator> (double lhs, const Approx & rhs);
+ DOCTEST_INTERFACE friend bool operator> (const Approx & lhs, double rhs);
+
+ DOCTEST_INTERFACE friend String toString(const Approx& in);
+
+#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+#define DOCTEST_APPROX_PREFIX \
+ template <typename T> friend typename detail::enable_if<std::is_constructible<double, T>::value, bool>::type
+
+ DOCTEST_APPROX_PREFIX operator==(const T& lhs, const Approx& rhs) { return operator==(double(lhs), rhs); }
+ DOCTEST_APPROX_PREFIX operator==(const Approx& lhs, const T& rhs) { return operator==(rhs, lhs); }
+ DOCTEST_APPROX_PREFIX operator!=(const T& lhs, const Approx& rhs) { return !operator==(lhs, rhs); }
+ DOCTEST_APPROX_PREFIX operator!=(const Approx& lhs, const T& rhs) { return !operator==(rhs, lhs); }
+ DOCTEST_APPROX_PREFIX operator<=(const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value || lhs == rhs; }
+ DOCTEST_APPROX_PREFIX operator<=(const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) || lhs == rhs; }
+ DOCTEST_APPROX_PREFIX operator>=(const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value || lhs == rhs; }
+ DOCTEST_APPROX_PREFIX operator>=(const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) || lhs == rhs; }
+ DOCTEST_APPROX_PREFIX operator< (const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value && lhs != rhs; }
+ DOCTEST_APPROX_PREFIX operator< (const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) && lhs != rhs; }
+ DOCTEST_APPROX_PREFIX operator> (const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value && lhs != rhs; }
+ DOCTEST_APPROX_PREFIX operator> (const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) && lhs != rhs; }
+#undef DOCTEST_APPROX_PREFIX
+#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
+
+ // clang-format on
+
+private:
+ double m_epsilon;
+ double m_scale;
+ double m_value;
+};
+
+DOCTEST_INTERFACE String toString(const Approx& in);
+
+DOCTEST_INTERFACE const ContextOptions* getContextOptions();
+
+#if !defined(DOCTEST_CONFIG_DISABLE)
+
+namespace detail {
+ // clang-format off
+#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ template<class T> struct decay_array { typedef T type; };
+ template<class T, unsigned N> struct decay_array<T[N]> { typedef T* type; };
+ template<class T> struct decay_array<T[]> { typedef T* type; };
+
+ template<class T> struct not_char_pointer { enum { value = 1 }; };
+ template<> struct not_char_pointer<char*> { enum { value = 0 }; };
+ template<> struct not_char_pointer<const char*> { enum { value = 0 }; };
+
+ template<class T> struct can_use_op : public not_char_pointer<typename decay_array<T>::type> {};
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ // clang-format on
+
+ struct DOCTEST_INTERFACE TestFailureException
+ {
+ };
+
+ DOCTEST_INTERFACE bool checkIfShouldThrow(assertType::Enum at);
+
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ DOCTEST_NORETURN
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+ DOCTEST_INTERFACE void throwException();
+
+ struct DOCTEST_INTERFACE Subcase
+ {
+ SubcaseSignature m_signature;
+ bool m_entered = false;
+
+ Subcase(const String& name, const char* file, int line);
+ ~Subcase();
+
+ operator bool() const;
+ };
+
+ template <typename L, typename R>
+ String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op,
+ const DOCTEST_REF_WRAP(R) rhs) {
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+ return toString(lhs) + op + toString(rhs);
+ }
+
+#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
+DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-comparison")
+#endif
+
+// This will check if there is any way it could find a operator like member or friend and uses it.
+// If not it doesn't find the operator or if the operator at global scope is defined after
+// this template, the template won't be instantiated due to SFINAE. Once the template is not
+// instantiated it can look for global operator using normal conversions.
+#define SFINAE_OP(ret,op) decltype(doctest::detail::declval<L>() op doctest::detail::declval<R>(),static_cast<ret>(0))
+
+#define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro) \
+ template <typename R> \
+ DOCTEST_NOINLINE SFINAE_OP(Result,op) operator op(R&& rhs) { \
+ bool res = op_macro(doctest::detail::forward<L>(lhs), doctest::detail::forward<R>(rhs)); \
+ if(m_at & assertType::is_false) \
+ res = !res; \
+ if(!res || doctest::getContextOptions()->success) \
+ return Result(res, stringifyBinaryExpr(lhs, op_str, rhs)); \
+ return Result(res); \
+ }
+
+ // more checks could be added - like in Catch:
+ // https://github.com/catchorg/Catch2/pull/1480/files
+ // https://github.com/catchorg/Catch2/pull/1481/files
+#define DOCTEST_FORBIT_EXPRESSION(rt, op) \
+ template <typename R> \
+ rt& operator op(const R&) { \
+ static_assert(deferred_false<R>::value, \
+ "Expression Too Complex Please Rewrite As Binary Comparison!"); \
+ return *this; \
+ }
+
+ struct DOCTEST_INTERFACE Result
+ {
+ bool m_passed;
+ String m_decomp;
+
+ Result(bool passed, const String& decomposition = String());
+
+ // forbidding some expressions based on this table: https://en.cppreference.com/w/cpp/language/operator_precedence
+ DOCTEST_FORBIT_EXPRESSION(Result, &)
+ DOCTEST_FORBIT_EXPRESSION(Result, ^)
+ DOCTEST_FORBIT_EXPRESSION(Result, |)
+ DOCTEST_FORBIT_EXPRESSION(Result, &&)
+ DOCTEST_FORBIT_EXPRESSION(Result, ||)
+ DOCTEST_FORBIT_EXPRESSION(Result, ==)
+ DOCTEST_FORBIT_EXPRESSION(Result, !=)
+ DOCTEST_FORBIT_EXPRESSION(Result, <)
+ DOCTEST_FORBIT_EXPRESSION(Result, >)
+ DOCTEST_FORBIT_EXPRESSION(Result, <=)
+ DOCTEST_FORBIT_EXPRESSION(Result, >=)
+ DOCTEST_FORBIT_EXPRESSION(Result, =)
+ DOCTEST_FORBIT_EXPRESSION(Result, +=)
+ DOCTEST_FORBIT_EXPRESSION(Result, -=)
+ DOCTEST_FORBIT_EXPRESSION(Result, *=)
+ DOCTEST_FORBIT_EXPRESSION(Result, /=)
+ DOCTEST_FORBIT_EXPRESSION(Result, %=)
+ DOCTEST_FORBIT_EXPRESSION(Result, <<=)
+ DOCTEST_FORBIT_EXPRESSION(Result, >>=)
+ DOCTEST_FORBIT_EXPRESSION(Result, &=)
+ DOCTEST_FORBIT_EXPRESSION(Result, ^=)
+ DOCTEST_FORBIT_EXPRESSION(Result, |=)
+ };
+
+#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
+
+ DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
+ DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion")
+ DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-compare")
+ //DOCTEST_CLANG_SUPPRESS_WARNING("-Wdouble-promotion")
+ //DOCTEST_CLANG_SUPPRESS_WARNING("-Wconversion")
+ //DOCTEST_CLANG_SUPPRESS_WARNING("-Wfloat-equal")
+
+ DOCTEST_GCC_SUPPRESS_WARNING_PUSH
+ DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion")
+ DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-compare")
+ //DOCTEST_GCC_SUPPRESS_WARNING("-Wdouble-promotion")
+ //DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion")
+ //DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal")
+
+ DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
+ // https://stackoverflow.com/questions/39479163 what's the difference between 4018 and 4389
+ DOCTEST_MSVC_SUPPRESS_WARNING(4388) // signed/unsigned mismatch
+ DOCTEST_MSVC_SUPPRESS_WARNING(4389) // 'operator' : signed/unsigned mismatch
+ DOCTEST_MSVC_SUPPRESS_WARNING(4018) // 'expression' : signed/unsigned mismatch
+ //DOCTEST_MSVC_SUPPRESS_WARNING(4805) // 'operation' : unsafe mix of type 'type' and type 'type' in operation
+
+#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
+
+ // clang-format off
+#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+#define DOCTEST_COMPARISON_RETURN_TYPE bool
+#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+#define DOCTEST_COMPARISON_RETURN_TYPE typename enable_if<can_use_op<L>::value || can_use_op<R>::value, bool>::type
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+ inline bool eq(const char* lhs, const char* rhs) { return String(lhs) == String(rhs); }
+ inline bool ne(const char* lhs, const char* rhs) { return String(lhs) != String(rhs); }
+ inline bool lt(const char* lhs, const char* rhs) { return String(lhs) < String(rhs); }
+ inline bool gt(const char* lhs, const char* rhs) { return String(lhs) > String(rhs); }
+ inline bool le(const char* lhs, const char* rhs) { return String(lhs) <= String(rhs); }
+ inline bool ge(const char* lhs, const char* rhs) { return String(lhs) >= String(rhs); }
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ // clang-format on
+
+#define DOCTEST_RELATIONAL_OP(name, op) \
+ template <typename L, typename R> \
+ DOCTEST_COMPARISON_RETURN_TYPE name(const DOCTEST_REF_WRAP(L) lhs, \
+ const DOCTEST_REF_WRAP(R) rhs) { \
+ return lhs op rhs; \
+ }
+
+ DOCTEST_RELATIONAL_OP(eq, ==)
+ DOCTEST_RELATIONAL_OP(ne, !=)
+ DOCTEST_RELATIONAL_OP(lt, <)
+ DOCTEST_RELATIONAL_OP(gt, >)
+ DOCTEST_RELATIONAL_OP(le, <=)
+ DOCTEST_RELATIONAL_OP(ge, >=)
+
+#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+#define DOCTEST_CMP_EQ(l, r) l == r
+#define DOCTEST_CMP_NE(l, r) l != r
+#define DOCTEST_CMP_GT(l, r) l > r
+#define DOCTEST_CMP_LT(l, r) l < r
+#define DOCTEST_CMP_GE(l, r) l >= r
+#define DOCTEST_CMP_LE(l, r) l <= r
+#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+#define DOCTEST_CMP_EQ(l, r) eq(l, r)
+#define DOCTEST_CMP_NE(l, r) ne(l, r)
+#define DOCTEST_CMP_GT(l, r) gt(l, r)
+#define DOCTEST_CMP_LT(l, r) lt(l, r)
+#define DOCTEST_CMP_GE(l, r) ge(l, r)
+#define DOCTEST_CMP_LE(l, r) le(l, r)
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+
+ template <typename L>
+ // cppcheck-suppress copyCtorAndEqOperator
+ struct Expression_lhs
+ {
+ L lhs;
+ assertType::Enum m_at;
+
+ explicit Expression_lhs(L&& in, assertType::Enum at)
+ : lhs(doctest::detail::forward<L>(in))
+ , m_at(at) {}
+
+ DOCTEST_NOINLINE operator Result() {
+// this is needed only foc MSVC 2015:
+// https://ci.appveyor.com/project/onqtam/doctest/builds/38181202
+DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4800) // 'int': forcing value to bool
+ bool res = static_cast<bool>(lhs);
+DOCTEST_MSVC_SUPPRESS_WARNING_POP
+ if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional
+ res = !res;
+
+ if(!res || getContextOptions()->success)
+ return Result(res, toString(lhs));
+ return Result(res);
+ }
+
+ /* This is required for user-defined conversions from Expression_lhs to L */
+ //operator L() const { return lhs; }
+ operator L() const { return lhs; }
+
+ // clang-format off
+ DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(==, " == ", DOCTEST_CMP_EQ) //!OCLINT bitwise operator in conditional
+ DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(!=, " != ", DOCTEST_CMP_NE) //!OCLINT bitwise operator in conditional
+ DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>, " > ", DOCTEST_CMP_GT) //!OCLINT bitwise operator in conditional
+ DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<, " < ", DOCTEST_CMP_LT) //!OCLINT bitwise operator in conditional
+ DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>=, " >= ", DOCTEST_CMP_GE) //!OCLINT bitwise operator in conditional
+ DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<=, " <= ", DOCTEST_CMP_LE) //!OCLINT bitwise operator in conditional
+ // clang-format on
+
+ // forbidding some expressions based on this table: https://en.cppreference.com/w/cpp/language/operator_precedence
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &&)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ||)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, =)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, +=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, -=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, *=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, /=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, %=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^=)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |=)
+ // these 2 are unfortunate because they should be allowed - they have higher precedence over the comparisons, but the
+ // ExpressionDecomposer class uses the left shift operator to capture the left operand of the binary expression...
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<)
+ DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>)
+ };
+
+#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
+
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP
+ DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
+
+#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
+DOCTEST_CLANG_SUPPRESS_WARNING_POP
+#endif
+
+ struct DOCTEST_INTERFACE ExpressionDecomposer
+ {
+ assertType::Enum m_at;
+
+ ExpressionDecomposer(assertType::Enum at);
+
+ // The right operator for capturing expressions is "<=" instead of "<<" (based on the operator precedence table)
+ // but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problematic this will stay for now...
+ // https://github.com/catchorg/Catch2/issues/870
+ // https://github.com/catchorg/Catch2/issues/565
+ template <typename L>
+ Expression_lhs<L> operator<<(L &&operand) {
+ return Expression_lhs<L>(doctest::detail::forward<L>(operand), m_at);
+ }
+ };
+
+ struct DOCTEST_INTERFACE TestSuite
+ {
+ const char* m_test_suite;
+ const char* m_description;
+ bool m_skip;
+ bool m_no_breaks;
+ bool m_no_output;
+ bool m_may_fail;
+ bool m_should_fail;
+ int m_expected_failures;
+ double m_timeout;
+
+ TestSuite& operator*(const char* in);
+
+ template <typename T>
+ TestSuite& operator*(const T& in) {
+ in.fill(*this);
+ return *this;
+ }
+ };
+
+ typedef void (*funcType)();
+
+ struct DOCTEST_INTERFACE TestCase : public TestCaseData
+ {
+ funcType m_test; // a function pointer to the test case
+
+ const char* m_type; // for templated test cases - gets appended to the real name
+ int m_template_id; // an ID used to distinguish between the different versions of a templated test case
+ String m_full_name; // contains the name (only for templated test cases!) + the template type
+
+ TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite,
+ const char* type = "", int template_id = -1);
+
+ TestCase(const TestCase& other);
+
+ DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function
+ TestCase& operator=(const TestCase& other);
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP
+
+ TestCase& operator*(const char* in);
+
+ template <typename T>
+ TestCase& operator*(const T& in) {
+ in.fill(*this);
+ return *this;
+ }
+
+ bool operator<(const TestCase& other) const;
+ };
+
+ // forward declarations of functions used by the macros
+ DOCTEST_INTERFACE int regTest(const TestCase& tc);
+ DOCTEST_INTERFACE int setTestSuite(const TestSuite& ts);
+ DOCTEST_INTERFACE bool isDebuggerActive();
+
+ template<typename T>
+ int instantiationHelper(const T&) { return 0; }
+
+ namespace binaryAssertComparison {
+ enum Enum
+ {
+ eq = 0,
+ ne,
+ gt,
+ lt,
+ ge,
+ le
+ };
+ } // namespace binaryAssertComparison
+
+ // clang-format off
+ template <int, class L, class R> struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L), const DOCTEST_REF_WRAP(R) ) const { return false; } };
+
+#define DOCTEST_BINARY_RELATIONAL_OP(n, op) \
+ template <class L, class R> struct RelationalComparator<n, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return op(lhs, rhs); } };
+ // clang-format on
+
+ DOCTEST_BINARY_RELATIONAL_OP(0, doctest::detail::eq)
+ DOCTEST_BINARY_RELATIONAL_OP(1, doctest::detail::ne)
+ DOCTEST_BINARY_RELATIONAL_OP(2, doctest::detail::gt)
+ DOCTEST_BINARY_RELATIONAL_OP(3, doctest::detail::lt)
+ DOCTEST_BINARY_RELATIONAL_OP(4, doctest::detail::ge)
+ DOCTEST_BINARY_RELATIONAL_OP(5, doctest::detail::le)
+
+ struct DOCTEST_INTERFACE ResultBuilder : public AssertData
+ {
+ ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
+ const char* exception_type = "", const char* exception_string = "");
+
+ void setResult(const Result& res);
+
+ template <int comparison, typename L, typename R>
+ DOCTEST_NOINLINE void binary_assert(const DOCTEST_REF_WRAP(L) lhs,
+ const DOCTEST_REF_WRAP(R) rhs) {
+ m_failed = !RelationalComparator<comparison, L, R>()(lhs, rhs);
+ if(m_failed || getContextOptions()->success)
+ m_decomp = stringifyBinaryExpr(lhs, ", ", rhs);
+ }
+
+ template <typename L>
+ DOCTEST_NOINLINE void unary_assert(const DOCTEST_REF_WRAP(L) val) {
+ m_failed = !val;
+
+ if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional
+ m_failed = !m_failed;
+
+ if(m_failed || getContextOptions()->success)
+ m_decomp = toString(val);
+ }
+
+ void translateException();
+
+ bool log();
+ void react() const;
+ };
+
+ namespace assertAction {
+ enum Enum
+ {
+ nothing = 0,
+ dbgbreak = 1,
+ shouldthrow = 2
+ };
+ } // namespace assertAction
+
+ DOCTEST_INTERFACE void failed_out_of_a_testing_context(const AssertData& ad);
+
+ DOCTEST_INTERFACE void decomp_assert(assertType::Enum at, const char* file, int line,
+ const char* expr, Result result);
+
+#define DOCTEST_ASSERT_OUT_OF_TESTS(decomp) \
+ do { \
+ if(!is_running_in_test) { \
+ if(failed) { \
+ ResultBuilder rb(at, file, line, expr); \
+ rb.m_failed = failed; \
+ rb.m_decomp = decomp; \
+ failed_out_of_a_testing_context(rb); \
+ if(isDebuggerActive() && !getContextOptions()->no_breaks) \
+ DOCTEST_BREAK_INTO_DEBUGGER(); \
+ if(checkIfShouldThrow(at)) \
+ throwException(); \
+ } \
+ return; \
+ } \
+ } while(false)
+
+#define DOCTEST_ASSERT_IN_TESTS(decomp) \
+ ResultBuilder rb(at, file, line, expr); \
+ rb.m_failed = failed; \
+ if(rb.m_failed || getContextOptions()->success) \
+ rb.m_decomp = decomp; \
+ if(rb.log()) \
+ DOCTEST_BREAK_INTO_DEBUGGER(); \
+ if(rb.m_failed && checkIfShouldThrow(at)) \
+ throwException()
+
+ template <int comparison, typename L, typename R>
+ DOCTEST_NOINLINE void binary_assert(assertType::Enum at, const char* file, int line,
+ const char* expr, const DOCTEST_REF_WRAP(L) lhs,
+ const DOCTEST_REF_WRAP(R) rhs) {
+ bool failed = !RelationalComparator<comparison, L, R>()(lhs, rhs);
+
+ // ###################################################################################
+ // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
+ // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
+ // ###################################################################################
+ DOCTEST_ASSERT_OUT_OF_TESTS(stringifyBinaryExpr(lhs, ", ", rhs));
+ DOCTEST_ASSERT_IN_TESTS(stringifyBinaryExpr(lhs, ", ", rhs));
+ }
+
+ template <typename L>
+ DOCTEST_NOINLINE void unary_assert(assertType::Enum at, const char* file, int line,
+ const char* expr, const DOCTEST_REF_WRAP(L) val) {
+ bool failed = !val;
+
+ if(at & assertType::is_false) //!OCLINT bitwise operator in conditional
+ failed = !failed;
+
+ // ###################################################################################
+ // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
+ // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
+ // ###################################################################################
+ DOCTEST_ASSERT_OUT_OF_TESTS(toString(val));
+ DOCTEST_ASSERT_IN_TESTS(toString(val));
+ }
+
+ struct DOCTEST_INTERFACE IExceptionTranslator
+ {
+ IExceptionTranslator();
+ virtual ~IExceptionTranslator();
+ virtual bool translate(String&) const = 0;
+ };
+
+ template <typename T>
+ class ExceptionTranslator : public IExceptionTranslator //!OCLINT destructor of virtual class
+ {
+ public:
+ explicit ExceptionTranslator(String (*translateFunction)(T))
+ : m_translateFunction(translateFunction) {}
+
+ bool translate(String& res) const override {
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ try {
+ throw; // lgtm [cpp/rethrow-no-exception]
+ // cppcheck-suppress catchExceptionByValue
+ } catch(T ex) { // NOLINT
+ res = m_translateFunction(ex); //!OCLINT parameter reassignment
+ return true;
+ } catch(...) {} //!OCLINT - empty catch statement
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+ static_cast<void>(res); // to silence -Wunused-parameter
+ return false;
+ }
+
+ private:
+ String (*m_translateFunction)(T);
+ };
+
+ DOCTEST_INTERFACE void registerExceptionTranslatorImpl(const IExceptionTranslator* et);
+
+ template <bool C>
+ struct StringStreamBase
+ {
+ template <typename T>
+ static void convert(std::ostream* s, const T& in) {
+ *s << toString(in);
+ }
+
+ // always treat char* as a string in this context - no matter
+ // if DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING is defined
+ static void convert(std::ostream* s, const char* in) { *s << String(in); }
+ };
+
+ template <>
+ struct StringStreamBase<true>
+ {
+ template <typename T>
+ static void convert(std::ostream* s, const T& in) {
+ *s << in;
+ }
+ };
+
+ template <typename T>
+ struct StringStream : public StringStreamBase<has_insertion_operator<T>::value>
+ {};
+
+ template <typename T>
+ void toStream(std::ostream* s, const T& value) {
+ StringStream<T>::convert(s, value);
+ }
+
+#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ DOCTEST_INTERFACE void toStream(std::ostream* s, char* in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, const char* in);
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ DOCTEST_INTERFACE void toStream(std::ostream* s, bool in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, float in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, double in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, double long in);
+
+ DOCTEST_INTERFACE void toStream(std::ostream* s, char in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, char signed in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, char unsigned in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int short in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int short unsigned in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int unsigned in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int long in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int long unsigned in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int long long in);
+ DOCTEST_INTERFACE void toStream(std::ostream* s, int long long unsigned in);
+
+ // ContextScope base class used to allow implementing methods of ContextScope
+ // that don't depend on the template parameter in doctest.cpp.
+ class DOCTEST_INTERFACE ContextScopeBase : public IContextScope {
+ protected:
+ ContextScopeBase();
+
+ void destroy();
+ };
+
+ template <typename L> class ContextScope : public ContextScopeBase
+ {
+ const L lambda_;
+
+ public:
+ explicit ContextScope(const L &lambda) : lambda_(lambda) {}
+
+ ContextScope(ContextScope &&other) : lambda_(other.lambda_) {}
+
+ void stringify(std::ostream* s) const override { lambda_(s); }
+
+ ~ContextScope() override { destroy(); }
+ };
+
+ struct DOCTEST_INTERFACE MessageBuilder : public MessageData
+ {
+ std::ostream* m_stream;
+
+ MessageBuilder(const char* file, int line, assertType::Enum severity);
+ MessageBuilder() = delete;
+ ~MessageBuilder();
+
+ // the preferred way of chaining parameters for stringification
+ template <typename T>
+ MessageBuilder& operator,(const T& in) {
+ toStream(m_stream, in);
+ return *this;
+ }
+
+ // kept here just for backwards-compatibility - the comma operator should be preferred now
+ template <typename T>
+ MessageBuilder& operator<<(const T& in) { return this->operator,(in); }
+
+ // the `,` operator has the lowest operator precedence - if `<<` is used by the user then
+ // the `,` operator will be called last which is not what we want and thus the `*` operator
+ // is used first (has higher operator precedence compared to `<<`) so that we guarantee that
+ // an operator of the MessageBuilder class is called first before the rest of the parameters
+ template <typename T>
+ MessageBuilder& operator*(const T& in) { return this->operator,(in); }
+
+ bool log();
+ void react();
+ };
+
+ template <typename L>
+ ContextScope<L> MakeContextScope(const L &lambda) {
+ return ContextScope<L>(lambda);
+ }
+} // namespace detail
+
+#define DOCTEST_DEFINE_DECORATOR(name, type, def) \
+ struct name \
+ { \
+ type data; \
+ name(type in = def) \
+ : data(in) {} \
+ void fill(detail::TestCase& state) const { state.DOCTEST_CAT(m_, name) = data; } \
+ void fill(detail::TestSuite& state) const { state.DOCTEST_CAT(m_, name) = data; } \
+ }
+
+DOCTEST_DEFINE_DECORATOR(test_suite, const char*, "");
+DOCTEST_DEFINE_DECORATOR(description, const char*, "");
+DOCTEST_DEFINE_DECORATOR(skip, bool, true);
+DOCTEST_DEFINE_DECORATOR(no_breaks, bool, true);
+DOCTEST_DEFINE_DECORATOR(no_output, bool, true);
+DOCTEST_DEFINE_DECORATOR(timeout, double, 0);
+DOCTEST_DEFINE_DECORATOR(may_fail, bool, true);
+DOCTEST_DEFINE_DECORATOR(should_fail, bool, true);
+DOCTEST_DEFINE_DECORATOR(expected_failures, int, 0);
+
+template <typename T>
+int registerExceptionTranslator(String (*translateFunction)(T)) {
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors")
+ static detail::ExceptionTranslator<T> exceptionTranslator(translateFunction);
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ detail::registerExceptionTranslatorImpl(&exceptionTranslator);
+ return 0;
+}
+
+} // namespace doctest
+
+// in a separate namespace outside of doctest because the DOCTEST_TEST_SUITE macro
+// introduces an anonymous namespace in which getCurrentTestSuite gets overridden
+namespace doctest_detail_test_suite_ns {
+DOCTEST_INTERFACE doctest::detail::TestSuite& getCurrentTestSuite();
+} // namespace doctest_detail_test_suite_ns
+
+namespace doctest {
+#else // DOCTEST_CONFIG_DISABLE
+template <typename T>
+int registerExceptionTranslator(String (*)(T)) {
+ return 0;
+}
+#endif // DOCTEST_CONFIG_DISABLE
+
+namespace detail {
+ typedef void (*assert_handler)(const AssertData&);
+ struct ContextState;
+} // namespace detail
+
+class DOCTEST_INTERFACE Context
+{
+ detail::ContextState* p;
+
+ void parseArgs(int argc, const char* const* argv, bool withDefaults = false);
+
+public:
+ explicit Context(int argc = 0, const char* const* argv = nullptr);
+
+ ~Context();
+
+ void applyCommandLine(int argc, const char* const* argv);
+
+ void addFilter(const char* filter, const char* value);
+ void clearFilters();
+ void setOption(const char* option, int value);
+ void setOption(const char* option, const char* value);
+
+ bool shouldExit();
+
+ void setAsDefaultForAssertsOutOfTestCases();
+
+ void setAssertHandler(detail::assert_handler ah);
+
+ int run();
+};
+
+namespace TestCaseFailureReason {
+ enum Enum
+ {
+ None = 0,
+ AssertFailure = 1, // an assertion has failed in the test case
+ Exception = 2, // test case threw an exception
+ Crash = 4, // a crash...
+ TooManyFailedAsserts = 8, // the abort-after option
+ Timeout = 16, // see the timeout decorator
+ ShouldHaveFailedButDidnt = 32, // see the should_fail decorator
+ ShouldHaveFailedAndDid = 64, // see the should_fail decorator
+ DidntFailExactlyNumTimes = 128, // see the expected_failures decorator
+ FailedExactlyNumTimes = 256, // see the expected_failures decorator
+ CouldHaveFailedAndDid = 512 // see the may_fail decorator
+ };
+} // namespace TestCaseFailureReason
+
+struct DOCTEST_INTERFACE CurrentTestCaseStats
+{
+ int numAssertsCurrentTest;
+ int numAssertsFailedCurrentTest;
+ double seconds;
+ int failure_flags; // use TestCaseFailureReason::Enum
+};
+
+struct DOCTEST_INTERFACE TestCaseException
+{
+ String error_string;
+ bool is_crash;
+};
+
+struct DOCTEST_INTERFACE TestRunStats
+{
+ unsigned numTestCases;
+ unsigned numTestCasesPassingFilters;
+ unsigned numTestSuitesPassingFilters;
+ unsigned numTestCasesFailed;
+ int numAsserts;
+ int numAssertsFailed;
+};
+
+struct QueryData
+{
+ const TestRunStats* run_stats = nullptr;
+ const TestCaseData** data = nullptr;
+ unsigned num_data = 0;
+};
+
+struct DOCTEST_INTERFACE IReporter
+{
+ // The constructor has to accept "const ContextOptions&" as a single argument
+ // which has most of the options for the run + a pointer to the stdout stream
+ // Reporter(const ContextOptions& in)
+
+ // called when a query should be reported (listing test cases, printing the version, etc.)
+ virtual void report_query(const QueryData&) = 0;
+
+ // called when the whole test run starts
+ virtual void test_run_start() = 0;
+ // called when the whole test run ends (caching a pointer to the input doesn't make sense here)
+ virtual void test_run_end(const TestRunStats&) = 0;
+
+ // called when a test case is started (safe to cache a pointer to the input)
+ virtual void test_case_start(const TestCaseData&) = 0;
+ // called when a test case is reentered because of unfinished subcases (safe to cache a pointer to the input)
+ virtual void test_case_reenter(const TestCaseData&) = 0;
+ // called when a test case has ended
+ virtual void test_case_end(const CurrentTestCaseStats&) = 0;
+
+ // called when an exception is thrown from the test case (or it crashes)
+ virtual void test_case_exception(const TestCaseException&) = 0;
+
+ // called whenever a subcase is entered (don't cache pointers to the input)
+ virtual void subcase_start(const SubcaseSignature&) = 0;
+ // called whenever a subcase is exited (don't cache pointers to the input)
+ virtual void subcase_end() = 0;
+
+ // called for each assert (don't cache pointers to the input)
+ virtual void log_assert(const AssertData&) = 0;
+ // called for each message (don't cache pointers to the input)
+ virtual void log_message(const MessageData&) = 0;
+
+ // called when a test case is skipped either because it doesn't pass the filters, has a skip decorator
+ // or isn't in the execution range (between first and last) (safe to cache a pointer to the input)
+ virtual void test_case_skipped(const TestCaseData&) = 0;
+
+ // doctest will not be managing the lifetimes of reporters given to it but this would still be nice to have
+ virtual ~IReporter();
+
+ // can obtain all currently active contexts and stringify them if one wishes to do so
+ static int get_num_active_contexts();
+ static const IContextScope* const* get_active_contexts();
+
+ // can iterate through contexts which have been stringified automatically in their destructors when an exception has been thrown
+ static int get_num_stringified_contexts();
+ static const String* get_stringified_contexts();
+};
+
+namespace detail {
+ typedef IReporter* (*reporterCreatorFunc)(const ContextOptions&);
+
+ DOCTEST_INTERFACE void registerReporterImpl(const char* name, int prio, reporterCreatorFunc c, bool isReporter);
+
+ template <typename Reporter>
+ IReporter* reporterCreator(const ContextOptions& o) {
+ return new Reporter(o);
+ }
+} // namespace detail
+
+template <typename Reporter>
+int registerReporter(const char* name, int priority, bool isReporter) {
+ detail::registerReporterImpl(name, priority, detail::reporterCreator<Reporter>, isReporter);
+ return 0;
+}
+} // namespace doctest
+
+// if registering is not disabled
+#if !defined(DOCTEST_CONFIG_DISABLE)
+
+// common code in asserts - for convenience
+#define DOCTEST_ASSERT_LOG_AND_REACT(b) \
+ if(b.log()) \
+ DOCTEST_BREAK_INTO_DEBUGGER(); \
+ b.react()
+
+#ifdef DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
+#define DOCTEST_WRAP_IN_TRY(x) x;
+#else // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
+#define DOCTEST_WRAP_IN_TRY(x) \
+ try { \
+ x; \
+ } catch(...) { _DOCTEST_RB.translateException(); }
+#endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
+
+#ifdef DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
+#define DOCTEST_CAST_TO_VOID(...) \
+ DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wuseless-cast") \
+ static_cast<void>(__VA_ARGS__); \
+ DOCTEST_GCC_SUPPRESS_WARNING_POP
+#else // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
+#define DOCTEST_CAST_TO_VOID(...) __VA_ARGS__;
+#endif // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
+
+// registers the test by initializing a dummy var with a function
+#define DOCTEST_REGISTER_FUNCTION(global_prefix, f, decorators) \
+ global_prefix DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
+ doctest::detail::regTest( \
+ doctest::detail::TestCase( \
+ f, __FILE__, __LINE__, \
+ doctest_detail_test_suite_ns::getCurrentTestSuite()) * \
+ decorators); \
+ DOCTEST_GLOBAL_NO_WARNINGS_END()
+
+#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \
+ namespace { \
+ struct der : public base \
+ { \
+ void f(); \
+ }; \
+ static void func() { \
+ der v; \
+ v.f(); \
+ } \
+ DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, func, decorators) \
+ } \
+ inline DOCTEST_NOINLINE void der::f()
+
+#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \
+ static void f(); \
+ DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, f, decorators) \
+ static void f()
+
+#define DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(f, proxy, decorators) \
+ static doctest::detail::funcType proxy() { return f; } \
+ DOCTEST_REGISTER_FUNCTION(inline const, proxy(), decorators) \
+ static void f()
+
+// for registering tests
+#define DOCTEST_TEST_CASE(decorators) \
+ DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators)
+
+// for registering tests in classes - requires C++17 for inline variables!
+#if __cplusplus >= 201703L || (DOCTEST_MSVC >= DOCTEST_COMPILER(19, 12, 0) && _MSVC_LANG >= 201703L)
+#define DOCTEST_TEST_CASE_CLASS(decorators) \
+ DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), \
+ DOCTEST_ANONYMOUS(_DOCTEST_ANON_PROXY_), \
+ decorators)
+#else // DOCTEST_TEST_CASE_CLASS
+#define DOCTEST_TEST_CASE_CLASS(...) \
+ TEST_CASES_CAN_BE_REGISTERED_IN_CLASSES_ONLY_IN_CPP17_MODE_OR_WITH_VS_2017_OR_NEWER
+#endif // DOCTEST_TEST_CASE_CLASS
+
+// for registering tests with a fixture
+#define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \
+ DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), c, \
+ DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators)
+
+// for converting types to strings without the <typeinfo> header and demangling
+#define DOCTEST_TYPE_TO_STRING_IMPL(...) \
+ template <> \
+ inline const char* type_to_string<__VA_ARGS__>() { \
+ return "<" #__VA_ARGS__ ">"; \
+ }
+#define DOCTEST_TYPE_TO_STRING(...) \
+ namespace doctest { namespace detail { \
+ DOCTEST_TYPE_TO_STRING_IMPL(__VA_ARGS__) \
+ } \
+ } \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \
+ template <typename T> \
+ static void func(); \
+ namespace { \
+ template <typename Tuple> \
+ struct iter; \
+ template <typename Type, typename... Rest> \
+ struct iter<std::tuple<Type, Rest...>> \
+ { \
+ iter(const char* file, unsigned line, int index) { \
+ doctest::detail::regTest(doctest::detail::TestCase(func<Type>, file, line, \
+ doctest_detail_test_suite_ns::getCurrentTestSuite(), \
+ doctest::detail::type_to_string<Type>(), \
+ int(line) * 1000 + index) \
+ * dec); \
+ iter<std::tuple<Rest...>>(file, line, index + 1); \
+ } \
+ }; \
+ template <> \
+ struct iter<std::tuple<>> \
+ { \
+ iter(const char*, unsigned, int) {} \
+ }; \
+ } \
+ template <typename T> \
+ static void func()
+
+#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \
+ DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \
+ DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
+
+#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \
+ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = \
+ doctest::detail::instantiationHelper(DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__>(__FILE__, __LINE__, 0));\
+ DOCTEST_GLOBAL_NO_WARNINGS_END()
+
+#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \
+ DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), std::tuple<__VA_ARGS__>) \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \
+ DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__) \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+#define DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, anon, ...) \
+ DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \
+ DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(anon, anon, std::tuple<__VA_ARGS__>) \
+ template <typename T> \
+ static void anon()
+
+#define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \
+ DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__)
+
+// for subcases
+#define DOCTEST_SUBCASE(name) \
+ if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
+ doctest::detail::Subcase(name, __FILE__, __LINE__))
+
+// for grouping tests in test suites by using code blocks
+#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \
+ namespace ns_name { namespace doctest_detail_test_suite_ns { \
+ static DOCTEST_NOINLINE doctest::detail::TestSuite& getCurrentTestSuite() { \
+ DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4640) \
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") \
+ DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmissing-field-initializers") \
+ static doctest::detail::TestSuite data{}; \
+ static bool inited = false; \
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP \
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP \
+ DOCTEST_GCC_SUPPRESS_WARNING_POP \
+ if(!inited) { \
+ data* decorators; \
+ inited = true; \
+ } \
+ return data; \
+ } \
+ } \
+ } \
+ namespace ns_name
+
+#define DOCTEST_TEST_SUITE(decorators) \
+ DOCTEST_TEST_SUITE_IMPL(decorators, DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUITE_))
+
+// for starting a testsuite block
+#define DOCTEST_TEST_SUITE_BEGIN(decorators) \
+ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
+ doctest::detail::setTestSuite(doctest::detail::TestSuite() * decorators); \
+ DOCTEST_GLOBAL_NO_WARNINGS_END() \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+// for ending a testsuite block
+#define DOCTEST_TEST_SUITE_END \
+ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
+ doctest::detail::setTestSuite(doctest::detail::TestSuite() * ""); \
+ DOCTEST_GLOBAL_NO_WARNINGS_END() \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+// for registering exception translators
+#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(translatorName, signature) \
+ inline doctest::String translatorName(signature); \
+ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)) = \
+ doctest::registerExceptionTranslator(translatorName); \
+ DOCTEST_GLOBAL_NO_WARNINGS_END() \
+ doctest::String translatorName(signature)
+
+#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
+ DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_), \
+ signature)
+
+// for registering reporters
+#define DOCTEST_REGISTER_REPORTER(name, priority, reporter) \
+ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_REPORTER_)) = \
+ doctest::registerReporter<reporter>(name, priority, true); \
+ DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+// for registering listeners
+#define DOCTEST_REGISTER_LISTENER(name, priority, reporter) \
+ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_REPORTER_)) = \
+ doctest::registerReporter<reporter>(name, priority, false); \
+ DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+// for logging
+#define DOCTEST_INFO(...) \
+ DOCTEST_INFO_IMPL(DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_), DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_), \
+ __VA_ARGS__)
+
+#define DOCTEST_INFO_IMPL(mb_name, s_name, ...) \
+ auto DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_) = doctest::detail::MakeContextScope( \
+ [&](std::ostream* s_name) { \
+ doctest::detail::MessageBuilder mb_name(__FILE__, __LINE__, doctest::assertType::is_warn); \
+ mb_name.m_stream = s_name; \
+ mb_name * __VA_ARGS__; \
+ })
+
+#define DOCTEST_CAPTURE(x) DOCTEST_INFO(#x " := ", x)
+
+#define DOCTEST_ADD_AT_IMPL(type, file, line, mb, ...) \
+ do { \
+ doctest::detail::MessageBuilder mb(file, line, doctest::assertType::type); \
+ mb * __VA_ARGS__; \
+ DOCTEST_ASSERT_LOG_AND_REACT(mb); \
+ } while(false)
+
+// clang-format off
+#define DOCTEST_ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_warn, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), __VA_ARGS__)
+#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_check, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), __VA_ARGS__)
+#define DOCTEST_ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_require, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), __VA_ARGS__)
+// clang-format on
+
+#define DOCTEST_MESSAGE(...) DOCTEST_ADD_MESSAGE_AT(__FILE__, __LINE__, __VA_ARGS__)
+#define DOCTEST_FAIL_CHECK(...) DOCTEST_ADD_FAIL_CHECK_AT(__FILE__, __LINE__, __VA_ARGS__)
+#define DOCTEST_FAIL(...) DOCTEST_ADD_FAIL_AT(__FILE__, __LINE__, __VA_ARGS__)
+
+#define DOCTEST_TO_LVALUE(...) __VA_ARGS__ // Not removed to keep backwards compatibility.
+
+#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
+
+#define DOCTEST_ASSERT_IMPLEMENT_2(assert_type, ...) \
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
+ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
+ __LINE__, #__VA_ARGS__); \
+ DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.setResult( \
+ doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \
+ << __VA_ARGS__)) \
+ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB) \
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \
+ do { \
+ DOCTEST_ASSERT_IMPLEMENT_2(assert_type, __VA_ARGS__); \
+ } while(false)
+
+#else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
+
+// necessary for <ASSERT>_MESSAGE
+#define DOCTEST_ASSERT_IMPLEMENT_2 DOCTEST_ASSERT_IMPLEMENT_1
+
+#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
+ doctest::detail::decomp_assert( \
+ doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, \
+ doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \
+ << __VA_ARGS__) DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
+
+#define DOCTEST_WARN(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN, __VA_ARGS__)
+#define DOCTEST_CHECK(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK, __VA_ARGS__)
+#define DOCTEST_REQUIRE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE, __VA_ARGS__)
+#define DOCTEST_WARN_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN_FALSE, __VA_ARGS__)
+#define DOCTEST_CHECK_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK_FALSE, __VA_ARGS__)
+#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE_FALSE, __VA_ARGS__)
+
+// clang-format off
+#define DOCTEST_WARN_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN, cond); } while(false)
+#define DOCTEST_CHECK_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK, cond); } while(false)
+#define DOCTEST_REQUIRE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE, cond); } while(false)
+#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN_FALSE, cond); } while(false)
+#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK_FALSE, cond); } while(false)
+#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while(false)
+// clang-format on
+
+#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, message, ...) \
+ do { \
+ if(!doctest::getContextOptions()->no_throw) { \
+ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
+ __LINE__, #expr, #__VA_ARGS__, message); \
+ try { \
+ DOCTEST_CAST_TO_VOID(expr) \
+ } catch(const typename doctest::detail::remove_const< \
+ typename doctest::detail::remove_reference<__VA_ARGS__>::type>::type&) { \
+ _DOCTEST_RB.translateException(); \
+ _DOCTEST_RB.m_threw_as = true; \
+ } catch(...) { _DOCTEST_RB.translateException(); } \
+ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
+ } \
+ } while(false)
+
+#define DOCTEST_ASSERT_THROWS_WITH(expr, expr_str, assert_type, ...) \
+ do { \
+ if(!doctest::getContextOptions()->no_throw) { \
+ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
+ __LINE__, expr_str, "", __VA_ARGS__); \
+ try { \
+ DOCTEST_CAST_TO_VOID(expr) \
+ } catch(...) { _DOCTEST_RB.translateException(); } \
+ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
+ } \
+ } while(false)
+
+#define DOCTEST_ASSERT_NOTHROW(assert_type, ...) \
+ do { \
+ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
+ __LINE__, #__VA_ARGS__); \
+ try { \
+ DOCTEST_CAST_TO_VOID(__VA_ARGS__) \
+ } catch(...) { _DOCTEST_RB.translateException(); } \
+ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
+ } while(false)
+
+// clang-format off
+#define DOCTEST_WARN_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_WARN_THROWS, "")
+#define DOCTEST_CHECK_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_CHECK_THROWS, "")
+#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_REQUIRE_THROWS, "")
+
+#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, "", __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, "", __VA_ARGS__)
+
+#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_WARN_THROWS_WITH, __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_CHECK_THROWS_WITH, __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__)
+
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_WITH_AS, message, __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_WITH_AS, message, __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_WITH_AS, message, __VA_ARGS__)
+
+#define DOCTEST_WARN_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_WARN_NOTHROW, __VA_ARGS__)
+#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_CHECK_NOTHROW, __VA_ARGS__)
+#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_REQUIRE_NOTHROW, __VA_ARGS__)
+
+#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS(expr); } while(false)
+#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS(expr); } while(false)
+#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS(expr); } while(false)
+#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_AS(expr, ex); } while(false)
+#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_AS(expr, ex); } while(false)
+#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } while(false)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH(expr, with); } while(false)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH(expr, with); } while(false)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH(expr, with); } while(false)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex); } while(false)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex); } while(false)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex); } while(false)
+#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_NOTHROW(expr); } while(false)
+#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_NOTHROW(expr); } while(false)
+#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_NOTHROW(expr); } while(false)
+// clang-format on
+
+#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
+
+#define DOCTEST_BINARY_ASSERT(assert_type, comp, ...) \
+ do { \
+ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
+ __LINE__, #__VA_ARGS__); \
+ DOCTEST_WRAP_IN_TRY( \
+ _DOCTEST_RB.binary_assert<doctest::detail::binaryAssertComparison::comp>( \
+ __VA_ARGS__)) \
+ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
+ } while(false)
+
+#define DOCTEST_UNARY_ASSERT(assert_type, ...) \
+ do { \
+ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
+ __LINE__, #__VA_ARGS__); \
+ DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.unary_assert(__VA_ARGS__)) \
+ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
+ } while(false)
+
+#else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
+
+#define DOCTEST_BINARY_ASSERT(assert_type, comparison, ...) \
+ doctest::detail::binary_assert<doctest::detail::binaryAssertComparison::comparison>( \
+ doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, __VA_ARGS__)
+
+#define DOCTEST_UNARY_ASSERT(assert_type, ...) \
+ doctest::detail::unary_assert(doctest::assertType::assert_type, __FILE__, __LINE__, \
+ #__VA_ARGS__, __VA_ARGS__)
+
+#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
+
+#define DOCTEST_WARN_EQ(...) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, eq, __VA_ARGS__)
+#define DOCTEST_CHECK_EQ(...) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, eq, __VA_ARGS__)
+#define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, eq, __VA_ARGS__)
+#define DOCTEST_WARN_NE(...) DOCTEST_BINARY_ASSERT(DT_WARN_NE, ne, __VA_ARGS__)
+#define DOCTEST_CHECK_NE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, ne, __VA_ARGS__)
+#define DOCTEST_REQUIRE_NE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, ne, __VA_ARGS__)
+#define DOCTEST_WARN_GT(...) DOCTEST_BINARY_ASSERT(DT_WARN_GT, gt, __VA_ARGS__)
+#define DOCTEST_CHECK_GT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, gt, __VA_ARGS__)
+#define DOCTEST_REQUIRE_GT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, gt, __VA_ARGS__)
+#define DOCTEST_WARN_LT(...) DOCTEST_BINARY_ASSERT(DT_WARN_LT, lt, __VA_ARGS__)
+#define DOCTEST_CHECK_LT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, lt, __VA_ARGS__)
+#define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lt, __VA_ARGS__)
+#define DOCTEST_WARN_GE(...) DOCTEST_BINARY_ASSERT(DT_WARN_GE, ge, __VA_ARGS__)
+#define DOCTEST_CHECK_GE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, ge, __VA_ARGS__)
+#define DOCTEST_REQUIRE_GE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, ge, __VA_ARGS__)
+#define DOCTEST_WARN_LE(...) DOCTEST_BINARY_ASSERT(DT_WARN_LE, le, __VA_ARGS__)
+#define DOCTEST_CHECK_LE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, le, __VA_ARGS__)
+#define DOCTEST_REQUIRE_LE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, le, __VA_ARGS__)
+
+#define DOCTEST_WARN_UNARY(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, __VA_ARGS__)
+#define DOCTEST_CHECK_UNARY(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, __VA_ARGS__)
+#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, __VA_ARGS__)
+#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, __VA_ARGS__)
+#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, __VA_ARGS__)
+#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, __VA_ARGS__)
+
+#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS
+
+#undef DOCTEST_WARN_THROWS
+#undef DOCTEST_CHECK_THROWS
+#undef DOCTEST_REQUIRE_THROWS
+#undef DOCTEST_WARN_THROWS_AS
+#undef DOCTEST_CHECK_THROWS_AS
+#undef DOCTEST_REQUIRE_THROWS_AS
+#undef DOCTEST_WARN_THROWS_WITH
+#undef DOCTEST_CHECK_THROWS_WITH
+#undef DOCTEST_REQUIRE_THROWS_WITH
+#undef DOCTEST_WARN_THROWS_WITH_AS
+#undef DOCTEST_CHECK_THROWS_WITH_AS
+#undef DOCTEST_REQUIRE_THROWS_WITH_AS
+#undef DOCTEST_WARN_NOTHROW
+#undef DOCTEST_CHECK_NOTHROW
+#undef DOCTEST_REQUIRE_NOTHROW
+
+#undef DOCTEST_WARN_THROWS_MESSAGE
+#undef DOCTEST_CHECK_THROWS_MESSAGE
+#undef DOCTEST_REQUIRE_THROWS_MESSAGE
+#undef DOCTEST_WARN_THROWS_AS_MESSAGE
+#undef DOCTEST_CHECK_THROWS_AS_MESSAGE
+#undef DOCTEST_REQUIRE_THROWS_AS_MESSAGE
+#undef DOCTEST_WARN_THROWS_WITH_MESSAGE
+#undef DOCTEST_CHECK_THROWS_WITH_MESSAGE
+#undef DOCTEST_REQUIRE_THROWS_WITH_MESSAGE
+#undef DOCTEST_WARN_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_WARN_NOTHROW_MESSAGE
+#undef DOCTEST_CHECK_NOTHROW_MESSAGE
+#undef DOCTEST_REQUIRE_NOTHROW_MESSAGE
+
+#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
+
+#define DOCTEST_WARN_THROWS(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS(...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_AS(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_AS(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_NOTHROW(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_NOTHROW(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_NOTHROW(...) (static_cast<void>(0))
+
+#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
+
+#else // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
+
+#undef DOCTEST_REQUIRE
+#undef DOCTEST_REQUIRE_FALSE
+#undef DOCTEST_REQUIRE_MESSAGE
+#undef DOCTEST_REQUIRE_FALSE_MESSAGE
+#undef DOCTEST_REQUIRE_EQ
+#undef DOCTEST_REQUIRE_NE
+#undef DOCTEST_REQUIRE_GT
+#undef DOCTEST_REQUIRE_LT
+#undef DOCTEST_REQUIRE_GE
+#undef DOCTEST_REQUIRE_LE
+#undef DOCTEST_REQUIRE_UNARY
+#undef DOCTEST_REQUIRE_UNARY_FALSE
+
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
+
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+
+// =================================================================================================
+// == WHAT FOLLOWS IS VERSIONS OF THE MACROS THAT DO NOT DO ANY REGISTERING! ==
+// == THIS CAN BE ENABLED BY DEFINING DOCTEST_CONFIG_DISABLE GLOBALLY! ==
+// =================================================================================================
+#else // DOCTEST_CONFIG_DISABLE
+
+#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, name) \
+ namespace { \
+ template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
+ struct der : public base \
+ { void f(); }; \
+ } \
+ template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
+ inline void der<DOCTEST_UNUSED_TEMPLATE_TYPE>::f()
+
+#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, name) \
+ template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
+ static inline void f()
+
+// for registering tests
+#define DOCTEST_TEST_CASE(name) \
+ DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
+
+// for registering tests in classes
+#define DOCTEST_TEST_CASE_CLASS(name) \
+ DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
+
+// for registering tests with a fixture
+#define DOCTEST_TEST_CASE_FIXTURE(x, name) \
+ DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), x, \
+ DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
+
+// for converting types to strings without the <typeinfo> header and demangling
+#define DOCTEST_TYPE_TO_STRING(...) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+#define DOCTEST_TYPE_TO_STRING_IMPL(...)
+
+// for typed tests
+#define DOCTEST_TEST_CASE_TEMPLATE(name, type, ...) \
+ template <typename type> \
+ inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)()
+
+#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, type, id) \
+ template <typename type> \
+ inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)()
+
+#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \
+ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+// for subcases
+#define DOCTEST_SUBCASE(name)
+
+// for a testsuite block
+#define DOCTEST_TEST_SUITE(name) namespace
+
+// for starting a testsuite block
+#define DOCTEST_TEST_SUITE_BEGIN(name) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+// for ending a testsuite block
+#define DOCTEST_TEST_SUITE_END typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
+
+#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
+ template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
+ static inline doctest::String DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)(signature)
+
+#define DOCTEST_REGISTER_REPORTER(name, priority, reporter)
+#define DOCTEST_REGISTER_LISTENER(name, priority, reporter)
+
+#define DOCTEST_INFO(...) (static_cast<void>(0))
+#define DOCTEST_CAPTURE(x) (static_cast<void>(0))
+#define DOCTEST_ADD_MESSAGE_AT(file, line, ...) (static_cast<void>(0))
+#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) (static_cast<void>(0))
+#define DOCTEST_ADD_FAIL_AT(file, line, ...) (static_cast<void>(0))
+#define DOCTEST_MESSAGE(...) (static_cast<void>(0))
+#define DOCTEST_FAIL_CHECK(...) (static_cast<void>(0))
+#define DOCTEST_FAIL(...) (static_cast<void>(0))
+
+#define DOCTEST_WARN(...) (static_cast<void>(0))
+#define DOCTEST_CHECK(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE(...) (static_cast<void>(0))
+#define DOCTEST_WARN_FALSE(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_FALSE(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_FALSE(...) (static_cast<void>(0))
+
+#define DOCTEST_WARN_MESSAGE(cond, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_MESSAGE(cond, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_MESSAGE(cond, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) (static_cast<void>(0))
+
+#define DOCTEST_WARN_THROWS(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS(...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_AS(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_AS(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_NOTHROW(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_NOTHROW(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_NOTHROW(...) (static_cast<void>(0))
+
+#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
+#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
+
+#define DOCTEST_WARN_EQ(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_EQ(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_EQ(...) (static_cast<void>(0))
+#define DOCTEST_WARN_NE(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_NE(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_NE(...) (static_cast<void>(0))
+#define DOCTEST_WARN_GT(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_GT(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_GT(...) (static_cast<void>(0))
+#define DOCTEST_WARN_LT(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_LT(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_LT(...) (static_cast<void>(0))
+#define DOCTEST_WARN_GE(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_GE(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_GE(...) (static_cast<void>(0))
+#define DOCTEST_WARN_LE(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_LE(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_LE(...) (static_cast<void>(0))
+
+#define DOCTEST_WARN_UNARY(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_UNARY(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_UNARY(...) (static_cast<void>(0))
+#define DOCTEST_WARN_UNARY_FALSE(...) (static_cast<void>(0))
+#define DOCTEST_CHECK_UNARY_FALSE(...) (static_cast<void>(0))
+#define DOCTEST_REQUIRE_UNARY_FALSE(...) (static_cast<void>(0))
+
+#endif // DOCTEST_CONFIG_DISABLE
+
+// clang-format off
+// KEPT FOR BACKWARDS COMPATIBILITY - FORWARDING TO THE RIGHT MACROS
+#define DOCTEST_FAST_WARN_EQ DOCTEST_WARN_EQ
+#define DOCTEST_FAST_CHECK_EQ DOCTEST_CHECK_EQ
+#define DOCTEST_FAST_REQUIRE_EQ DOCTEST_REQUIRE_EQ
+#define DOCTEST_FAST_WARN_NE DOCTEST_WARN_NE
+#define DOCTEST_FAST_CHECK_NE DOCTEST_CHECK_NE
+#define DOCTEST_FAST_REQUIRE_NE DOCTEST_REQUIRE_NE
+#define DOCTEST_FAST_WARN_GT DOCTEST_WARN_GT
+#define DOCTEST_FAST_CHECK_GT DOCTEST_CHECK_GT
+#define DOCTEST_FAST_REQUIRE_GT DOCTEST_REQUIRE_GT
+#define DOCTEST_FAST_WARN_LT DOCTEST_WARN_LT
+#define DOCTEST_FAST_CHECK_LT DOCTEST_CHECK_LT
+#define DOCTEST_FAST_REQUIRE_LT DOCTEST_REQUIRE_LT
+#define DOCTEST_FAST_WARN_GE DOCTEST_WARN_GE
+#define DOCTEST_FAST_CHECK_GE DOCTEST_CHECK_GE
+#define DOCTEST_FAST_REQUIRE_GE DOCTEST_REQUIRE_GE
+#define DOCTEST_FAST_WARN_LE DOCTEST_WARN_LE
+#define DOCTEST_FAST_CHECK_LE DOCTEST_CHECK_LE
+#define DOCTEST_FAST_REQUIRE_LE DOCTEST_REQUIRE_LE
+
+#define DOCTEST_FAST_WARN_UNARY DOCTEST_WARN_UNARY
+#define DOCTEST_FAST_CHECK_UNARY DOCTEST_CHECK_UNARY
+#define DOCTEST_FAST_REQUIRE_UNARY DOCTEST_REQUIRE_UNARY
+#define DOCTEST_FAST_WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE
+#define DOCTEST_FAST_CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE
+#define DOCTEST_FAST_REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE
+
+#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id,__VA_ARGS__)
+// clang-format on
+
+// BDD style macros
+// clang-format off
+#define DOCTEST_SCENARIO(name) DOCTEST_TEST_CASE(" Scenario: " name)
+#define DOCTEST_SCENARIO_CLASS(name) DOCTEST_TEST_CASE_CLASS(" Scenario: " name)
+#define DOCTEST_SCENARIO_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(" Scenario: " name, T, __VA_ARGS__)
+#define DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(" Scenario: " name, T, id)
+
+#define DOCTEST_GIVEN(name) DOCTEST_SUBCASE(" Given: " name)
+#define DOCTEST_WHEN(name) DOCTEST_SUBCASE(" When: " name)
+#define DOCTEST_AND_WHEN(name) DOCTEST_SUBCASE("And when: " name)
+#define DOCTEST_THEN(name) DOCTEST_SUBCASE(" Then: " name)
+#define DOCTEST_AND_THEN(name) DOCTEST_SUBCASE(" And: " name)
+// clang-format on
+
+// == SHORT VERSIONS OF THE MACROS
+#if !defined(DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES)
+
+#define TEST_CASE(name) DOCTEST_TEST_CASE(name)
+#define TEST_CASE_CLASS(name) DOCTEST_TEST_CASE_CLASS(name)
+#define TEST_CASE_FIXTURE(x, name) DOCTEST_TEST_CASE_FIXTURE(x, name)
+#define TYPE_TO_STRING(...) DOCTEST_TYPE_TO_STRING(__VA_ARGS__)
+#define TEST_CASE_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(name, T, __VA_ARGS__)
+#define TEST_CASE_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, T, id)
+#define TEST_CASE_TEMPLATE_INVOKE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, __VA_ARGS__)
+#define TEST_CASE_TEMPLATE_APPLY(id, ...) DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, __VA_ARGS__)
+#define SUBCASE(name) DOCTEST_SUBCASE(name)
+#define TEST_SUITE(decorators) DOCTEST_TEST_SUITE(decorators)
+#define TEST_SUITE_BEGIN(name) DOCTEST_TEST_SUITE_BEGIN(name)
+#define TEST_SUITE_END DOCTEST_TEST_SUITE_END
+#define REGISTER_EXCEPTION_TRANSLATOR(signature) DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature)
+#define REGISTER_REPORTER(name, priority, reporter) DOCTEST_REGISTER_REPORTER(name, priority, reporter)
+#define REGISTER_LISTENER(name, priority, reporter) DOCTEST_REGISTER_LISTENER(name, priority, reporter)
+#define INFO(...) DOCTEST_INFO(__VA_ARGS__)
+#define CAPTURE(x) DOCTEST_CAPTURE(x)
+#define ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_MESSAGE_AT(file, line, __VA_ARGS__)
+#define ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_FAIL_CHECK_AT(file, line, __VA_ARGS__)
+#define ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_FAIL_AT(file, line, __VA_ARGS__)
+#define MESSAGE(...) DOCTEST_MESSAGE(__VA_ARGS__)
+#define FAIL_CHECK(...) DOCTEST_FAIL_CHECK(__VA_ARGS__)
+#define FAIL(...) DOCTEST_FAIL(__VA_ARGS__)
+#define TO_LVALUE(...) DOCTEST_TO_LVALUE(__VA_ARGS__)
+
+#define WARN(...) DOCTEST_WARN(__VA_ARGS__)
+#define WARN_FALSE(...) DOCTEST_WARN_FALSE(__VA_ARGS__)
+#define WARN_THROWS(...) DOCTEST_WARN_THROWS(__VA_ARGS__)
+#define WARN_THROWS_AS(expr, ...) DOCTEST_WARN_THROWS_AS(expr, __VA_ARGS__)
+#define WARN_THROWS_WITH(expr, ...) DOCTEST_WARN_THROWS_WITH(expr, __VA_ARGS__)
+#define WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_WARN_THROWS_WITH_AS(expr, with, __VA_ARGS__)
+#define WARN_NOTHROW(...) DOCTEST_WARN_NOTHROW(__VA_ARGS__)
+#define CHECK(...) DOCTEST_CHECK(__VA_ARGS__)
+#define CHECK_FALSE(...) DOCTEST_CHECK_FALSE(__VA_ARGS__)
+#define CHECK_THROWS(...) DOCTEST_CHECK_THROWS(__VA_ARGS__)
+#define CHECK_THROWS_AS(expr, ...) DOCTEST_CHECK_THROWS_AS(expr, __VA_ARGS__)
+#define CHECK_THROWS_WITH(expr, ...) DOCTEST_CHECK_THROWS_WITH(expr, __VA_ARGS__)
+#define CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_AS(expr, with, __VA_ARGS__)
+#define CHECK_NOTHROW(...) DOCTEST_CHECK_NOTHROW(__VA_ARGS__)
+#define REQUIRE(...) DOCTEST_REQUIRE(__VA_ARGS__)
+#define REQUIRE_FALSE(...) DOCTEST_REQUIRE_FALSE(__VA_ARGS__)
+#define REQUIRE_THROWS(...) DOCTEST_REQUIRE_THROWS(__VA_ARGS__)
+#define REQUIRE_THROWS_AS(expr, ...) DOCTEST_REQUIRE_THROWS_AS(expr, __VA_ARGS__)
+#define REQUIRE_THROWS_WITH(expr, ...) DOCTEST_REQUIRE_THROWS_WITH(expr, __VA_ARGS__)
+#define REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, __VA_ARGS__)
+#define REQUIRE_NOTHROW(...) DOCTEST_REQUIRE_NOTHROW(__VA_ARGS__)
+
+#define WARN_MESSAGE(cond, ...) DOCTEST_WARN_MESSAGE(cond, __VA_ARGS__)
+#define WARN_FALSE_MESSAGE(cond, ...) DOCTEST_WARN_FALSE_MESSAGE(cond, __VA_ARGS__)
+#define WARN_THROWS_MESSAGE(expr, ...) DOCTEST_WARN_THROWS_MESSAGE(expr, __VA_ARGS__)
+#define WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
+#define WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
+#define WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
+#define WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_WARN_NOTHROW_MESSAGE(expr, __VA_ARGS__)
+#define CHECK_MESSAGE(cond, ...) DOCTEST_CHECK_MESSAGE(cond, __VA_ARGS__)
+#define CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_CHECK_FALSE_MESSAGE(cond, __VA_ARGS__)
+#define CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_CHECK_THROWS_MESSAGE(expr, __VA_ARGS__)
+#define CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
+#define CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
+#define CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
+#define CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_CHECK_NOTHROW_MESSAGE(expr, __VA_ARGS__)
+#define REQUIRE_MESSAGE(cond, ...) DOCTEST_REQUIRE_MESSAGE(cond, __VA_ARGS__)
+#define REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_REQUIRE_FALSE_MESSAGE(cond, __VA_ARGS__)
+#define REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_REQUIRE_THROWS_MESSAGE(expr, __VA_ARGS__)
+#define REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
+#define REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
+#define REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
+#define REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, __VA_ARGS__)
+
+#define SCENARIO(name) DOCTEST_SCENARIO(name)
+#define SCENARIO_CLASS(name) DOCTEST_SCENARIO_CLASS(name)
+#define SCENARIO_TEMPLATE(name, T, ...) DOCTEST_SCENARIO_TEMPLATE(name, T, __VA_ARGS__)
+#define SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id)
+#define GIVEN(name) DOCTEST_GIVEN(name)
+#define WHEN(name) DOCTEST_WHEN(name)
+#define AND_WHEN(name) DOCTEST_AND_WHEN(name)
+#define THEN(name) DOCTEST_THEN(name)
+#define AND_THEN(name) DOCTEST_AND_THEN(name)
+
+#define WARN_EQ(...) DOCTEST_WARN_EQ(__VA_ARGS__)
+#define CHECK_EQ(...) DOCTEST_CHECK_EQ(__VA_ARGS__)
+#define REQUIRE_EQ(...) DOCTEST_REQUIRE_EQ(__VA_ARGS__)
+#define WARN_NE(...) DOCTEST_WARN_NE(__VA_ARGS__)
+#define CHECK_NE(...) DOCTEST_CHECK_NE(__VA_ARGS__)
+#define REQUIRE_NE(...) DOCTEST_REQUIRE_NE(__VA_ARGS__)
+#define WARN_GT(...) DOCTEST_WARN_GT(__VA_ARGS__)
+#define CHECK_GT(...) DOCTEST_CHECK_GT(__VA_ARGS__)
+#define REQUIRE_GT(...) DOCTEST_REQUIRE_GT(__VA_ARGS__)
+#define WARN_LT(...) DOCTEST_WARN_LT(__VA_ARGS__)
+#define CHECK_LT(...) DOCTEST_CHECK_LT(__VA_ARGS__)
+#define REQUIRE_LT(...) DOCTEST_REQUIRE_LT(__VA_ARGS__)
+#define WARN_GE(...) DOCTEST_WARN_GE(__VA_ARGS__)
+#define CHECK_GE(...) DOCTEST_CHECK_GE(__VA_ARGS__)
+#define REQUIRE_GE(...) DOCTEST_REQUIRE_GE(__VA_ARGS__)
+#define WARN_LE(...) DOCTEST_WARN_LE(__VA_ARGS__)
+#define CHECK_LE(...) DOCTEST_CHECK_LE(__VA_ARGS__)
+#define REQUIRE_LE(...) DOCTEST_REQUIRE_LE(__VA_ARGS__)
+#define WARN_UNARY(...) DOCTEST_WARN_UNARY(__VA_ARGS__)
+#define CHECK_UNARY(...) DOCTEST_CHECK_UNARY(__VA_ARGS__)
+#define REQUIRE_UNARY(...) DOCTEST_REQUIRE_UNARY(__VA_ARGS__)
+#define WARN_UNARY_FALSE(...) DOCTEST_WARN_UNARY_FALSE(__VA_ARGS__)
+#define CHECK_UNARY_FALSE(...) DOCTEST_CHECK_UNARY_FALSE(__VA_ARGS__)
+#define REQUIRE_UNARY_FALSE(...) DOCTEST_REQUIRE_UNARY_FALSE(__VA_ARGS__)
+
+// KEPT FOR BACKWARDS COMPATIBILITY
+#define FAST_WARN_EQ(...) DOCTEST_FAST_WARN_EQ(__VA_ARGS__)
+#define FAST_CHECK_EQ(...) DOCTEST_FAST_CHECK_EQ(__VA_ARGS__)
+#define FAST_REQUIRE_EQ(...) DOCTEST_FAST_REQUIRE_EQ(__VA_ARGS__)
+#define FAST_WARN_NE(...) DOCTEST_FAST_WARN_NE(__VA_ARGS__)
+#define FAST_CHECK_NE(...) DOCTEST_FAST_CHECK_NE(__VA_ARGS__)
+#define FAST_REQUIRE_NE(...) DOCTEST_FAST_REQUIRE_NE(__VA_ARGS__)
+#define FAST_WARN_GT(...) DOCTEST_FAST_WARN_GT(__VA_ARGS__)
+#define FAST_CHECK_GT(...) DOCTEST_FAST_CHECK_GT(__VA_ARGS__)
+#define FAST_REQUIRE_GT(...) DOCTEST_FAST_REQUIRE_GT(__VA_ARGS__)
+#define FAST_WARN_LT(...) DOCTEST_FAST_WARN_LT(__VA_ARGS__)
+#define FAST_CHECK_LT(...) DOCTEST_FAST_CHECK_LT(__VA_ARGS__)
+#define FAST_REQUIRE_LT(...) DOCTEST_FAST_REQUIRE_LT(__VA_ARGS__)
+#define FAST_WARN_GE(...) DOCTEST_FAST_WARN_GE(__VA_ARGS__)
+#define FAST_CHECK_GE(...) DOCTEST_FAST_CHECK_GE(__VA_ARGS__)
+#define FAST_REQUIRE_GE(...) DOCTEST_FAST_REQUIRE_GE(__VA_ARGS__)
+#define FAST_WARN_LE(...) DOCTEST_FAST_WARN_LE(__VA_ARGS__)
+#define FAST_CHECK_LE(...) DOCTEST_FAST_CHECK_LE(__VA_ARGS__)
+#define FAST_REQUIRE_LE(...) DOCTEST_FAST_REQUIRE_LE(__VA_ARGS__)
+
+#define FAST_WARN_UNARY(...) DOCTEST_FAST_WARN_UNARY(__VA_ARGS__)
+#define FAST_CHECK_UNARY(...) DOCTEST_FAST_CHECK_UNARY(__VA_ARGS__)
+#define FAST_REQUIRE_UNARY(...) DOCTEST_FAST_REQUIRE_UNARY(__VA_ARGS__)
+#define FAST_WARN_UNARY_FALSE(...) DOCTEST_FAST_WARN_UNARY_FALSE(__VA_ARGS__)
+#define FAST_CHECK_UNARY_FALSE(...) DOCTEST_FAST_CHECK_UNARY_FALSE(__VA_ARGS__)
+#define FAST_REQUIRE_UNARY_FALSE(...) DOCTEST_FAST_REQUIRE_UNARY_FALSE(__VA_ARGS__)
+
+#define TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, __VA_ARGS__)
+
+#endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES
+
+#if !defined(DOCTEST_CONFIG_DISABLE)
+
+// this is here to clear the 'current test suite' for the current translation unit - at the top
+DOCTEST_TEST_SUITE_END();
+
+// add stringification for primitive/fundamental types
+namespace doctest { namespace detail {
+ DOCTEST_TYPE_TO_STRING_IMPL(bool)
+ DOCTEST_TYPE_TO_STRING_IMPL(float)
+ DOCTEST_TYPE_TO_STRING_IMPL(double)
+ DOCTEST_TYPE_TO_STRING_IMPL(long double)
+ DOCTEST_TYPE_TO_STRING_IMPL(char)
+ DOCTEST_TYPE_TO_STRING_IMPL(signed char)
+ DOCTEST_TYPE_TO_STRING_IMPL(unsigned char)
+#if !DOCTEST_MSVC || defined(_NATIVE_WCHAR_T_DEFINED)
+ DOCTEST_TYPE_TO_STRING_IMPL(wchar_t)
+#endif // not MSVC or wchar_t support enabled
+ DOCTEST_TYPE_TO_STRING_IMPL(short int)
+ DOCTEST_TYPE_TO_STRING_IMPL(unsigned short int)
+ DOCTEST_TYPE_TO_STRING_IMPL(int)
+ DOCTEST_TYPE_TO_STRING_IMPL(unsigned int)
+ DOCTEST_TYPE_TO_STRING_IMPL(long int)
+ DOCTEST_TYPE_TO_STRING_IMPL(unsigned long int)
+ DOCTEST_TYPE_TO_STRING_IMPL(long long int)
+ DOCTEST_TYPE_TO_STRING_IMPL(unsigned long long int)
+}} // namespace doctest::detail
+
+#endif // DOCTEST_CONFIG_DISABLE
+
+DOCTEST_CLANG_SUPPRESS_WARNING_POP
+DOCTEST_MSVC_SUPPRESS_WARNING_POP
+DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+#endif // DOCTEST_LIBRARY_INCLUDED
+
+#ifndef DOCTEST_SINGLE_HEADER
+#define DOCTEST_SINGLE_HEADER
+#endif // DOCTEST_SINGLE_HEADER
+
+#if defined(DOCTEST_CONFIG_IMPLEMENT) || !defined(DOCTEST_SINGLE_HEADER)
+
+#ifndef DOCTEST_SINGLE_HEADER
+#include "doctest_fwd.h"
+#endif // DOCTEST_SINGLE_HEADER
+
+DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-macros")
+
+#ifndef DOCTEST_LIBRARY_IMPLEMENTATION
+#define DOCTEST_LIBRARY_IMPLEMENTATION
+
+DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wglobal-constructors")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wshorten-64-to-32")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-variable-declarations")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch-enum")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wcovered-switch-default")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-noreturn")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-member-function")
+DOCTEST_CLANG_SUPPRESS_WARNING("-Wnonportable-system-include-path")
+
+DOCTEST_GCC_SUPPRESS_WARNING_PUSH
+DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion")
+DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-field-initializers")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-braces")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-enum")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-default")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-function")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wmultiple-inheritance")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept")
+DOCTEST_GCC_SUPPRESS_WARNING("-Wsuggest-attribute")
+
+DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
+DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning
+DOCTEST_MSVC_SUPPRESS_WARNING(4619) // invalid compiler warning
+DOCTEST_MSVC_SUPPRESS_WARNING(4996) // The compiler encountered a deprecated declaration
+DOCTEST_MSVC_SUPPRESS_WARNING(4267) // 'var' : conversion from 'x' to 'y', possible loss of data
+DOCTEST_MSVC_SUPPRESS_WARNING(4706) // assignment within conditional expression
+DOCTEST_MSVC_SUPPRESS_WARNING(4512) // 'class' : assignment operator could not be generated
+DOCTEST_MSVC_SUPPRESS_WARNING(4127) // conditional expression is constant
+DOCTEST_MSVC_SUPPRESS_WARNING(4530) // C++ exception handler used, but unwind semantics not enabled
+DOCTEST_MSVC_SUPPRESS_WARNING(4577) // 'noexcept' used with no exception handling mode specified
+DOCTEST_MSVC_SUPPRESS_WARNING(4774) // format string expected in argument is not a string literal
+DOCTEST_MSVC_SUPPRESS_WARNING(4365) // conversion from 'int' to 'unsigned', signed/unsigned mismatch
+DOCTEST_MSVC_SUPPRESS_WARNING(4820) // padding in structs
+DOCTEST_MSVC_SUPPRESS_WARNING(4640) // construction of local static object is not thread-safe
+DOCTEST_MSVC_SUPPRESS_WARNING(5039) // pointer to potentially throwing function passed to extern C
+DOCTEST_MSVC_SUPPRESS_WARNING(5045) // Spectre mitigation stuff
+DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(5027) // move assignment operator was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(5026) // move constructor was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(4625) // copy constructor was implicitly defined as deleted
+DOCTEST_MSVC_SUPPRESS_WARNING(4800) // forcing value to bool 'true' or 'false' (performance warning)
+// static analysis
+DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept'
+DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable
+DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ...
+DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtor...
+DOCTEST_MSVC_SUPPRESS_WARNING(26812) // Prefer 'enum class' over 'enum'
+
+DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
+
+// required includes - will go only in one translation unit!
+#include <ctime>
+#include <cmath>
+#include <climits>
+// borland (Embarcadero) compiler requires math.h and not cmath - https://github.com/onqtam/doctest/pull/37
+#ifdef __BORLANDC__
+#include <math.h>
+#endif // __BORLANDC__
+#include <new>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <limits>
+#include <utility>
+#include <fstream>
+#include <sstream>
+#include <iostream>
+#include <algorithm>
+#include <iomanip>
+#include <vector>
+#include <atomic>
+#include <mutex>
+#include <set>
+#include <map>
+#include <exception>
+#include <stdexcept>
+#include <csignal>
+#include <cfloat>
+#include <cctype>
+#include <cstdint>
+
+#ifdef DOCTEST_PLATFORM_MAC
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/sysctl.h>
+#endif // DOCTEST_PLATFORM_MAC
+
+#ifdef DOCTEST_PLATFORM_WINDOWS
+
+// defines for a leaner windows.h
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif // WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif // NOMINMAX
+
+// not sure what AfxWin.h is for - here I do what Catch does
+#ifdef __AFXDLL
+#include <AfxWin.h>
+#else
+#include <windows.h>
+#endif
+#include <io.h>
+
+#else // DOCTEST_PLATFORM_WINDOWS
+
+#include <sys/time.h>
+#include <unistd.h>
+
+#endif // DOCTEST_PLATFORM_WINDOWS
+
+// this is a fix for https://github.com/onqtam/doctest/issues/348
+// https://mail.gnome.org/archives/xml/2012-January/msg00000.html
+#if !defined(HAVE_UNISTD_H) && !defined(STDOUT_FILENO)
+#define STDOUT_FILENO fileno(stdout)
+#endif // HAVE_UNISTD_H
+
+DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
+
+// counts the number of elements in a C array
+#define DOCTEST_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
+
+#ifdef DOCTEST_CONFIG_DISABLE
+#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_disabled
+#else // DOCTEST_CONFIG_DISABLE
+#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_not_disabled
+#endif // DOCTEST_CONFIG_DISABLE
+
+#ifndef DOCTEST_CONFIG_OPTIONS_PREFIX
+#define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-"
+#endif
+
+#ifndef DOCTEST_THREAD_LOCAL
+#define DOCTEST_THREAD_LOCAL thread_local
+#endif
+
+#ifndef DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES
+#define DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES 32
+#endif
+
+#ifndef DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE
+#define DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE 64
+#endif
+
+#ifdef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
+#define DOCTEST_OPTIONS_PREFIX_DISPLAY DOCTEST_CONFIG_OPTIONS_PREFIX
+#else
+#define DOCTEST_OPTIONS_PREFIX_DISPLAY ""
+#endif
+
+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
+#define DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS
+#endif
+
+namespace doctest {
+
+bool is_running_in_test = false;
+
+namespace {
+ using namespace detail;
+ // case insensitive strcmp
+ int stricmp(const char* a, const char* b) {
+ for(;; a++, b++) {
+ const int d = tolower(*a) - tolower(*b);
+ if(d != 0 || !*a)
+ return d;
+ }
+ }
+
+ template <typename T>
+ String fpToString(T value, int precision) {
+ std::ostringstream oss;
+ oss << std::setprecision(precision) << std::fixed << value;
+ std::string d = oss.str();
+ size_t i = d.find_last_not_of('0');
+ if(i != std::string::npos && i != d.size() - 1) {
+ if(d[i] == '.')
+ i++;
+ d = d.substr(0, i + 1);
+ }
+ return d.c_str();
+ }
+
+ struct Endianness
+ {
+ enum Arch
+ {
+ Big,
+ Little
+ };
+
+ static Arch which() {
+ int x = 1;
+ // casting any data pointer to char* is allowed
+ auto ptr = reinterpret_cast<char*>(&x);
+ if(*ptr)
+ return Little;
+ return Big;
+ }
+ };
+} // namespace
+
+namespace detail {
+ void my_memcpy(void* dest, const void* src, unsigned num) { memcpy(dest, src, num); }
+
+ String rawMemoryToString(const void* object, unsigned size) {
+ // Reverse order for little endian architectures
+ int i = 0, end = static_cast<int>(size), inc = 1;
+ if(Endianness::which() == Endianness::Little) {
+ i = end - 1;
+ end = inc = -1;
+ }
+
+ unsigned const char* bytes = static_cast<unsigned const char*>(object);
+ std::ostringstream oss;
+ oss << "0x" << std::setfill('0') << std::hex;
+ for(; i != end; i += inc)
+ oss << std::setw(2) << static_cast<unsigned>(bytes[i]);
+ return oss.str().c_str();
+ }
+
+ DOCTEST_THREAD_LOCAL std::ostringstream g_oss; // NOLINT(cert-err58-cpp)
+
+ std::ostream* getTlsOss() {
+ g_oss.clear(); // there shouldn't be anything worth clearing in the flags
+ g_oss.str(""); // the slow way of resetting a string stream
+ //g_oss.seekp(0); // optimal reset - as seen here: https://stackoverflow.com/a/624291/3162383
+ return &g_oss;
+ }
+
+ String getTlsOssResult() {
+ //g_oss << std::ends; // needed - as shown here: https://stackoverflow.com/a/624291/3162383
+ return g_oss.str().c_str();
+ }
+
+#ifndef DOCTEST_CONFIG_DISABLE
+
+namespace timer_large_integer
+{
+
+#if defined(DOCTEST_PLATFORM_WINDOWS)
+ typedef ULONGLONG type;
+#else // DOCTEST_PLATFORM_WINDOWS
+ using namespace std;
+ typedef uint64_t type;
+#endif // DOCTEST_PLATFORM_WINDOWS
+}
+
+typedef timer_large_integer::type ticks_t;
+
+#ifdef DOCTEST_CONFIG_GETCURRENTTICKS
+ ticks_t getCurrentTicks() { return DOCTEST_CONFIG_GETCURRENTTICKS(); }
+#elif defined(DOCTEST_PLATFORM_WINDOWS)
+ ticks_t getCurrentTicks() {
+ static LARGE_INTEGER hz = {0}, hzo = {0};
+ if(!hz.QuadPart) {
+ QueryPerformanceFrequency(&hz);
+ QueryPerformanceCounter(&hzo);
+ }
+ LARGE_INTEGER t;
+ QueryPerformanceCounter(&t);
+ return ((t.QuadPart - hzo.QuadPart) * LONGLONG(1000000)) / hz.QuadPart;
+ }
+#else // DOCTEST_PLATFORM_WINDOWS
+ ticks_t getCurrentTicks() {
+ timeval t;
+ gettimeofday(&t, nullptr);
+ return static_cast<ticks_t>(t.tv_sec) * 1000000 + static_cast<ticks_t>(t.tv_usec);
+ }
+#endif // DOCTEST_PLATFORM_WINDOWS
+
+ struct Timer
+ {
+ void start() { m_ticks = getCurrentTicks(); }
+ unsigned int getElapsedMicroseconds() const {
+ return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
+ }
+ //unsigned int getElapsedMilliseconds() const {
+ // return static_cast<unsigned int>(getElapsedMicroseconds() / 1000);
+ //}
+ double getElapsedSeconds() const { return static_cast<double>(getCurrentTicks() - m_ticks) / 1000000.0; }
+
+ private:
+ ticks_t m_ticks = 0;
+ };
+
+#ifdef DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS
+ template <typename T>
+ using AtomicOrMultiLaneAtomic = std::atomic<T>;
+#else // DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS
+ // Provides a multilane implementation of an atomic variable that supports add, sub, load,
+ // store. Instead of using a single atomic variable, this splits up into multiple ones,
+ // each sitting on a separate cache line. The goal is to provide a speedup when most
+ // operations are modifying. It achieves this with two properties:
+ //
+ // * Multiple atomics are used, so chance of congestion from the same atomic is reduced.
+ // * Each atomic sits on a separate cache line, so false sharing is reduced.
+ //
+ // The disadvantage is that there is a small overhead due to the use of TLS, and load/store
+ // is slower because all atomics have to be accessed.
+ template <typename T>
+ class MultiLaneAtomic
+ {
+ struct CacheLineAlignedAtomic
+ {
+ std::atomic<T> atomic{};
+ char padding[DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE - sizeof(std::atomic<T>)];
+ };
+ CacheLineAlignedAtomic m_atomics[DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES];
+
+ static_assert(sizeof(CacheLineAlignedAtomic) == DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE,
+ "guarantee one atomic takes exactly one cache line");
+
+ public:
+ T operator++() DOCTEST_NOEXCEPT { return fetch_add(1) + 1; }
+
+ T operator++(int) DOCTEST_NOEXCEPT { return fetch_add(1); }
+
+ T fetch_add(T arg, std::memory_order order = std::memory_order_seq_cst) DOCTEST_NOEXCEPT {
+ return myAtomic().fetch_add(arg, order);
+ }
+
+ T fetch_sub(T arg, std::memory_order order = std::memory_order_seq_cst) DOCTEST_NOEXCEPT {
+ return myAtomic().fetch_sub(arg, order);
+ }
+
+ operator T() const DOCTEST_NOEXCEPT { return load(); }
+
+ T load(std::memory_order order = std::memory_order_seq_cst) const DOCTEST_NOEXCEPT {
+ auto result = T();
+ for(auto const& c : m_atomics) {
+ result += c.atomic.load(order);
+ }
+ return result;
+ }
+
+ T operator=(T desired) DOCTEST_NOEXCEPT {
+ store(desired);
+ return desired;
+ }
+
+ void store(T desired, std::memory_order order = std::memory_order_seq_cst) DOCTEST_NOEXCEPT {
+ // first value becomes desired", all others become 0.
+ for(auto& c : m_atomics) {
+ c.atomic.store(desired, order);
+ desired = {};
+ }
+ }
+
+ private:
+ // Each thread has a different atomic that it operates on. If more than NumLanes threads
+ // use this, some will use the same atomic. So performance will degrate a bit, but still
+ // everything will work.
+ //
+ // The logic here is a bit tricky. The call should be as fast as possible, so that there
+ // is minimal to no overhead in determining the correct atomic for the current thread.
+ //
+ // 1. A global static counter laneCounter counts continuously up.
+ // 2. Each successive thread will use modulo operation of that counter so it gets an atomic
+ // assigned in a round-robin fashion.
+ // 3. This tlsLaneIdx is stored in the thread local data, so it is directly available with
+ // little overhead.
+ std::atomic<T>& myAtomic() DOCTEST_NOEXCEPT {
+ static std::atomic<size_t> laneCounter;
+ DOCTEST_THREAD_LOCAL size_t tlsLaneIdx =
+ laneCounter++ % DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES;
+
+ return m_atomics[tlsLaneIdx].atomic;
+ }
+ };
+
+ template <typename T>
+ using AtomicOrMultiLaneAtomic = MultiLaneAtomic<T>;
+#endif // DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS
+
+ // this holds both parameters from the command line and runtime data for tests
+ struct ContextState : ContextOptions, TestRunStats, CurrentTestCaseStats
+ {
+ AtomicOrMultiLaneAtomic<int> numAssertsCurrentTest_atomic;
+ AtomicOrMultiLaneAtomic<int> numAssertsFailedCurrentTest_atomic;
+
+ std::vector<std::vector<String>> filters = decltype(filters)(9); // 9 different filters
+
+ std::vector<IReporter*> reporters_currently_used;
+
+ assert_handler ah = nullptr;
+
+ Timer timer;
+
+ std::vector<String> stringifiedContexts; // logging from INFO() due to an exception
+
+ // stuff for subcases
+ std::vector<SubcaseSignature> subcasesStack;
+ std::set<decltype(subcasesStack)> subcasesPassed;
+ int subcasesCurrentMaxLevel;
+ bool should_reenter;
+ std::atomic<bool> shouldLogCurrentException;
+
+ void resetRunData() {
+ numTestCases = 0;
+ numTestCasesPassingFilters = 0;
+ numTestSuitesPassingFilters = 0;
+ numTestCasesFailed = 0;
+ numAsserts = 0;
+ numAssertsFailed = 0;
+ numAssertsCurrentTest = 0;
+ numAssertsFailedCurrentTest = 0;
+ }
+
+ void finalizeTestCaseData() {
+ seconds = timer.getElapsedSeconds();
+
+ // update the non-atomic counters
+ numAsserts += numAssertsCurrentTest_atomic;
+ numAssertsFailed += numAssertsFailedCurrentTest_atomic;
+ numAssertsCurrentTest = numAssertsCurrentTest_atomic;
+ numAssertsFailedCurrentTest = numAssertsFailedCurrentTest_atomic;
+
+ if(numAssertsFailedCurrentTest)
+ failure_flags |= TestCaseFailureReason::AssertFailure;
+
+ if(Approx(currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 &&
+ Approx(seconds).epsilon(DBL_EPSILON) > currentTest->m_timeout)
+ failure_flags |= TestCaseFailureReason::Timeout;
+
+ if(currentTest->m_should_fail) {
+ if(failure_flags) {
+ failure_flags |= TestCaseFailureReason::ShouldHaveFailedAndDid;
+ } else {
+ failure_flags |= TestCaseFailureReason::ShouldHaveFailedButDidnt;
+ }
+ } else if(failure_flags && currentTest->m_may_fail) {
+ failure_flags |= TestCaseFailureReason::CouldHaveFailedAndDid;
+ } else if(currentTest->m_expected_failures > 0) {
+ if(numAssertsFailedCurrentTest == currentTest->m_expected_failures) {
+ failure_flags |= TestCaseFailureReason::FailedExactlyNumTimes;
+ } else {
+ failure_flags |= TestCaseFailureReason::DidntFailExactlyNumTimes;
+ }
+ }
+
+ bool ok_to_fail = (TestCaseFailureReason::ShouldHaveFailedAndDid & failure_flags) ||
+ (TestCaseFailureReason::CouldHaveFailedAndDid & failure_flags) ||
+ (TestCaseFailureReason::FailedExactlyNumTimes & failure_flags);
+
+ // if any subcase has failed - the whole test case has failed
+ if(failure_flags && !ok_to_fail)
+ numTestCasesFailed++;
+ }
+ };
+
+ ContextState* g_cs = nullptr;
+
+ // used to avoid locks for the debug output
+ // TODO: figure out if this is indeed necessary/correct - seems like either there still
+ // could be a race or that there wouldn't be a race even if using the context directly
+ DOCTEST_THREAD_LOCAL bool g_no_colors;
+
+#endif // DOCTEST_CONFIG_DISABLE
+} // namespace detail
+
+void String::setOnHeap() { *reinterpret_cast<unsigned char*>(&buf[last]) = 128; }
+void String::setLast(unsigned in) { buf[last] = char(in); }
+
+void String::copy(const String& other) {
+ using namespace std;
+ if(other.isOnStack()) {
+ memcpy(buf, other.buf, len);
+ } else {
+ setOnHeap();
+ data.size = other.data.size;
+ data.capacity = data.size + 1;
+ data.ptr = new char[data.capacity];
+ memcpy(data.ptr, other.data.ptr, data.size + 1);
+ }
+}
+
+String::String() {
+ buf[0] = '\0';
+ setLast();
+}
+
+String::~String() {
+ if(!isOnStack())
+ delete[] data.ptr;
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+}
+
+String::String(const char* in)
+ : String(in, strlen(in)) {}
+
+String::String(const char* in, unsigned in_size) {
+ using namespace std;
+ if(in_size <= last) {
+ memcpy(buf, in, in_size);
+ buf[in_size] = '\0';
+ setLast(last - in_size);
+ } else {
+ setOnHeap();
+ data.size = in_size;
+ data.capacity = data.size + 1;
+ data.ptr = new char[data.capacity];
+ memcpy(data.ptr, in, in_size);
+ data.ptr[in_size] = '\0';
+ }
+}
+
+String::String(const String& other) { copy(other); }
+
+String& String::operator=(const String& other) {
+ if(this != &other) {
+ if(!isOnStack())
+ delete[] data.ptr;
+
+ copy(other);
+ }
+
+ return *this;
+}
+
+String& String::operator+=(const String& other) {
+ const unsigned my_old_size = size();
+ const unsigned other_size = other.size();
+ const unsigned total_size = my_old_size + other_size;
+ using namespace std;
+ if(isOnStack()) {
+ if(total_size < len) {
+ // append to the current stack space
+ memcpy(buf + my_old_size, other.c_str(), other_size + 1);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+ setLast(last - total_size);
+ } else {
+ // alloc new chunk
+ char* temp = new char[total_size + 1];
+ // copy current data to new location before writing in the union
+ memcpy(temp, buf, my_old_size); // skip the +1 ('\0') for speed
+ // update data in union
+ setOnHeap();
+ data.size = total_size;
+ data.capacity = data.size + 1;
+ data.ptr = temp;
+ // transfer the rest of the data
+ memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
+ }
+ } else {
+ if(data.capacity > total_size) {
+ // append to the current heap block
+ data.size = total_size;
+ memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
+ } else {
+ // resize
+ data.capacity *= 2;
+ if(data.capacity <= total_size)
+ data.capacity = total_size + 1;
+ // alloc new chunk
+ char* temp = new char[data.capacity];
+ // copy current data to new location before releasing it
+ memcpy(temp, data.ptr, my_old_size); // skip the +1 ('\0') for speed
+ // release old chunk
+ delete[] data.ptr;
+ // update the rest of the union members
+ data.size = total_size;
+ data.ptr = temp;
+ // transfer the rest of the data
+ memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
+ }
+ }
+
+ return *this;
+}
+
+// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+String String::operator+(const String& other) const { return String(*this) += other; }
+
+String::String(String&& other) {
+ using namespace std;
+ memcpy(buf, other.buf, len);
+ other.buf[0] = '\0';
+ other.setLast();
+}
+
+String& String::operator=(String&& other) {
+ using namespace std;
+ if(this != &other) {
+ if(!isOnStack())
+ delete[] data.ptr;
+ memcpy(buf, other.buf, len);
+ other.buf[0] = '\0';
+ other.setLast();
+ }
+ return *this;
+}
+
+char String::operator[](unsigned i) const {
+ return const_cast<String*>(this)->operator[](i); // NOLINT
+}
+
+char& String::operator[](unsigned i) {
+ if(isOnStack())
+ return reinterpret_cast<char*>(buf)[i];
+ return data.ptr[i];
+}
+
+DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmaybe-uninitialized")
+unsigned String::size() const {
+ if(isOnStack())
+ return last - (unsigned(buf[last]) & 31); // using "last" would work only if "len" is 32
+ return data.size;
+}
+DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+unsigned String::capacity() const {
+ if(isOnStack())
+ return len;
+ return data.capacity;
+}
+
+int String::compare(const char* other, bool no_case) const {
+ if(no_case)
+ return doctest::stricmp(c_str(), other);
+ return std::strcmp(c_str(), other);
+}
+
+int String::compare(const String& other, bool no_case) const {
+ return compare(other.c_str(), no_case);
+}
+
+// clang-format off
+bool operator==(const String& lhs, const String& rhs) { return lhs.compare(rhs) == 0; }
+bool operator!=(const String& lhs, const String& rhs) { return lhs.compare(rhs) != 0; }
+bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; }
+bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; }
+bool operator<=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) < 0 : true; }
+bool operator>=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) > 0 : true; }
+// clang-format on
+
+std::ostream& operator<<(std::ostream& s, const String& in) { return s << in.c_str(); }
+
+namespace {
+ void color_to_stream(std::ostream&, Color::Enum) DOCTEST_BRANCH_ON_DISABLED({}, ;)
+} // namespace
+
+namespace Color {
+ std::ostream& operator<<(std::ostream& s, Color::Enum code) {
+ color_to_stream(s, code);
+ return s;
+ }
+} // namespace Color
+
+// clang-format off
+const char* assertString(assertType::Enum at) {
+ DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4062) // enum 'x' in switch of enum 'y' is not handled
+ switch(at) { //!OCLINT missing default in switch statements
+ case assertType::DT_WARN : return "WARN";
+ case assertType::DT_CHECK : return "CHECK";
+ case assertType::DT_REQUIRE : return "REQUIRE";
+
+ case assertType::DT_WARN_FALSE : return "WARN_FALSE";
+ case assertType::DT_CHECK_FALSE : return "CHECK_FALSE";
+ case assertType::DT_REQUIRE_FALSE : return "REQUIRE_FALSE";
+
+ case assertType::DT_WARN_THROWS : return "WARN_THROWS";
+ case assertType::DT_CHECK_THROWS : return "CHECK_THROWS";
+ case assertType::DT_REQUIRE_THROWS : return "REQUIRE_THROWS";
+
+ case assertType::DT_WARN_THROWS_AS : return "WARN_THROWS_AS";
+ case assertType::DT_CHECK_THROWS_AS : return "CHECK_THROWS_AS";
+ case assertType::DT_REQUIRE_THROWS_AS : return "REQUIRE_THROWS_AS";
+
+ case assertType::DT_WARN_THROWS_WITH : return "WARN_THROWS_WITH";
+ case assertType::DT_CHECK_THROWS_WITH : return "CHECK_THROWS_WITH";
+ case assertType::DT_REQUIRE_THROWS_WITH : return "REQUIRE_THROWS_WITH";
+
+ case assertType::DT_WARN_THROWS_WITH_AS : return "WARN_THROWS_WITH_AS";
+ case assertType::DT_CHECK_THROWS_WITH_AS : return "CHECK_THROWS_WITH_AS";
+ case assertType::DT_REQUIRE_THROWS_WITH_AS : return "REQUIRE_THROWS_WITH_AS";
+
+ case assertType::DT_WARN_NOTHROW : return "WARN_NOTHROW";
+ case assertType::DT_CHECK_NOTHROW : return "CHECK_NOTHROW";
+ case assertType::DT_REQUIRE_NOTHROW : return "REQUIRE_NOTHROW";
+
+ case assertType::DT_WARN_EQ : return "WARN_EQ";
+ case assertType::DT_CHECK_EQ : return "CHECK_EQ";
+ case assertType::DT_REQUIRE_EQ : return "REQUIRE_EQ";
+ case assertType::DT_WARN_NE : return "WARN_NE";
+ case assertType::DT_CHECK_NE : return "CHECK_NE";
+ case assertType::DT_REQUIRE_NE : return "REQUIRE_NE";
+ case assertType::DT_WARN_GT : return "WARN_GT";
+ case assertType::DT_CHECK_GT : return "CHECK_GT";
+ case assertType::DT_REQUIRE_GT : return "REQUIRE_GT";
+ case assertType::DT_WARN_LT : return "WARN_LT";
+ case assertType::DT_CHECK_LT : return "CHECK_LT";
+ case assertType::DT_REQUIRE_LT : return "REQUIRE_LT";
+ case assertType::DT_WARN_GE : return "WARN_GE";
+ case assertType::DT_CHECK_GE : return "CHECK_GE";
+ case assertType::DT_REQUIRE_GE : return "REQUIRE_GE";
+ case assertType::DT_WARN_LE : return "WARN_LE";
+ case assertType::DT_CHECK_LE : return "CHECK_LE";
+ case assertType::DT_REQUIRE_LE : return "REQUIRE_LE";
+
+ case assertType::DT_WARN_UNARY : return "WARN_UNARY";
+ case assertType::DT_CHECK_UNARY : return "CHECK_UNARY";
+ case assertType::DT_REQUIRE_UNARY : return "REQUIRE_UNARY";
+ case assertType::DT_WARN_UNARY_FALSE : return "WARN_UNARY_FALSE";
+ case assertType::DT_CHECK_UNARY_FALSE : return "CHECK_UNARY_FALSE";
+ case assertType::DT_REQUIRE_UNARY_FALSE : return "REQUIRE_UNARY_FALSE";
+ }
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP
+ return "";
+}
+// clang-format on
+
+const char* failureString(assertType::Enum at) {
+ if(at & assertType::is_warn) //!OCLINT bitwise operator in conditional
+ return "WARNING";
+ if(at & assertType::is_check) //!OCLINT bitwise operator in conditional
+ return "ERROR";
+ if(at & assertType::is_require) //!OCLINT bitwise operator in conditional
+ return "FATAL ERROR";
+ return "";
+}
+
+DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference")
+DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference")
+// depending on the current options this will remove the path of filenames
+const char* skipPathFromFilename(const char* file) {
+#ifndef DOCTEST_CONFIG_DISABLE
+ if(getContextOptions()->no_path_in_filenames) {
+ auto back = std::strrchr(file, '\\');
+ auto forward = std::strrchr(file, '/');
+ if(back || forward) {
+ if(back > forward)
+ forward = back;
+ return forward + 1;
+ }
+ }
+#endif // DOCTEST_CONFIG_DISABLE
+ return file;
+}
+DOCTEST_CLANG_SUPPRESS_WARNING_POP
+DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+bool SubcaseSignature::operator<(const SubcaseSignature& other) const {
+ if(m_line != other.m_line)
+ return m_line < other.m_line;
+ if(std::strcmp(m_file, other.m_file) != 0)
+ return std::strcmp(m_file, other.m_file) < 0;
+ return m_name.compare(other.m_name) < 0;
+}
+
+IContextScope::IContextScope() = default;
+IContextScope::~IContextScope() = default;
+
+#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+String toString(char* in) { return toString(static_cast<const char*>(in)); }
+// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+String toString(const char* in) { return String("\"") + (in ? in : "{null string}") + "\""; }
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+String toString(bool in) { return in ? "true" : "false"; }
+String toString(float in) { return fpToString(in, 5) + "f"; }
+String toString(double in) { return fpToString(in, 10); }
+String toString(double long in) { return fpToString(in, 15); }
+
+#define DOCTEST_TO_STRING_OVERLOAD(type, fmt) \
+ String toString(type in) { \
+ char buf[64]; \
+ std::sprintf(buf, fmt, in); \
+ return buf; \
+ }
+
+DOCTEST_TO_STRING_OVERLOAD(char, "%d")
+DOCTEST_TO_STRING_OVERLOAD(char signed, "%d")
+DOCTEST_TO_STRING_OVERLOAD(char unsigned, "%u")
+DOCTEST_TO_STRING_OVERLOAD(int short, "%d")
+DOCTEST_TO_STRING_OVERLOAD(int short unsigned, "%u")
+DOCTEST_TO_STRING_OVERLOAD(int, "%d")
+DOCTEST_TO_STRING_OVERLOAD(unsigned, "%u")
+DOCTEST_TO_STRING_OVERLOAD(int long, "%ld")
+DOCTEST_TO_STRING_OVERLOAD(int long unsigned, "%lu")
+DOCTEST_TO_STRING_OVERLOAD(int long long, "%lld")
+DOCTEST_TO_STRING_OVERLOAD(int long long unsigned, "%llu")
+
+String toString(std::nullptr_t) { return "NULL"; }
+
+#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
+// see this issue on why this is needed: https://github.com/onqtam/doctest/issues/183
+String toString(const std::string& in) { return in.c_str(); }
+#endif // VS 2019
+
+Approx::Approx(double value)
+ : m_epsilon(static_cast<double>(std::numeric_limits<float>::epsilon()) * 100)
+ , m_scale(1.0)
+ , m_value(value) {}
+
+Approx Approx::operator()(double value) const {
+ Approx approx(value);
+ approx.epsilon(m_epsilon);
+ approx.scale(m_scale);
+ return approx;
+}
+
+Approx& Approx::epsilon(double newEpsilon) {
+ m_epsilon = newEpsilon;
+ return *this;
+}
+Approx& Approx::scale(double newScale) {
+ m_scale = newScale;
+ return *this;
+}
+
+bool operator==(double lhs, const Approx& rhs) {
+ // Thanks to Richard Harris for his help refining this formula
+ return std::fabs(lhs - rhs.m_value) <
+ rhs.m_epsilon * (rhs.m_scale + std::max<double>(std::fabs(lhs), std::fabs(rhs.m_value)));
+}
+bool operator==(const Approx& lhs, double rhs) { return operator==(rhs, lhs); }
+bool operator!=(double lhs, const Approx& rhs) { return !operator==(lhs, rhs); }
+bool operator!=(const Approx& lhs, double rhs) { return !operator==(rhs, lhs); }
+bool operator<=(double lhs, const Approx& rhs) { return lhs < rhs.m_value || lhs == rhs; }
+bool operator<=(const Approx& lhs, double rhs) { return lhs.m_value < rhs || lhs == rhs; }
+bool operator>=(double lhs, const Approx& rhs) { return lhs > rhs.m_value || lhs == rhs; }
+bool operator>=(const Approx& lhs, double rhs) { return lhs.m_value > rhs || lhs == rhs; }
+bool operator<(double lhs, const Approx& rhs) { return lhs < rhs.m_value && lhs != rhs; }
+bool operator<(const Approx& lhs, double rhs) { return lhs.m_value < rhs && lhs != rhs; }
+bool operator>(double lhs, const Approx& rhs) { return lhs > rhs.m_value && lhs != rhs; }
+bool operator>(const Approx& lhs, double rhs) { return lhs.m_value > rhs && lhs != rhs; }
+
+String toString(const Approx& in) {
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+ return String("Approx( ") + doctest::toString(in.m_value) + " )";
+}
+const ContextOptions* getContextOptions() { return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_cs); }
+
+} // namespace doctest
+
+#ifdef DOCTEST_CONFIG_DISABLE
+namespace doctest {
+Context::Context(int, const char* const*) {}
+Context::~Context() = default;
+void Context::applyCommandLine(int, const char* const*) {}
+void Context::addFilter(const char*, const char*) {}
+void Context::clearFilters() {}
+void Context::setOption(const char*, int) {}
+void Context::setOption(const char*, const char*) {}
+bool Context::shouldExit() { return false; }
+void Context::setAsDefaultForAssertsOutOfTestCases() {}
+void Context::setAssertHandler(detail::assert_handler) {}
+int Context::run() { return 0; }
+
+IReporter::~IReporter() = default;
+
+int IReporter::get_num_active_contexts() { return 0; }
+const IContextScope* const* IReporter::get_active_contexts() { return nullptr; }
+int IReporter::get_num_stringified_contexts() { return 0; }
+const String* IReporter::get_stringified_contexts() { return nullptr; }
+
+int registerReporter(const char*, int, IReporter*) { return 0; }
+
+} // namespace doctest
+#else // DOCTEST_CONFIG_DISABLE
+
+#if !defined(DOCTEST_CONFIG_COLORS_NONE)
+#if !defined(DOCTEST_CONFIG_COLORS_WINDOWS) && !defined(DOCTEST_CONFIG_COLORS_ANSI)
+#ifdef DOCTEST_PLATFORM_WINDOWS
+#define DOCTEST_CONFIG_COLORS_WINDOWS
+#else // linux
+#define DOCTEST_CONFIG_COLORS_ANSI
+#endif // platform
+#endif // DOCTEST_CONFIG_COLORS_WINDOWS && DOCTEST_CONFIG_COLORS_ANSI
+#endif // DOCTEST_CONFIG_COLORS_NONE
+
+namespace doctest_detail_test_suite_ns {
+// holds the current test suite
+doctest::detail::TestSuite& getCurrentTestSuite() {
+ static doctest::detail::TestSuite data{};
+ return data;
+}
+} // namespace doctest_detail_test_suite_ns
+
+namespace doctest {
+namespace {
+ // the int (priority) is part of the key for automatic sorting - sadly one can register a
+ // reporter with a duplicate name and a different priority but hopefully that won't happen often :|
+ typedef std::map<std::pair<int, String>, reporterCreatorFunc> reporterMap;
+
+ reporterMap& getReporters() {
+ static reporterMap data;
+ return data;
+ }
+ reporterMap& getListeners() {
+ static reporterMap data;
+ return data;
+ }
+} // namespace
+namespace detail {
+#define DOCTEST_ITERATE_THROUGH_REPORTERS(function, ...) \
+ for(auto& curr_rep : g_cs->reporters_currently_used) \
+ curr_rep->function(__VA_ARGS__)
+
+ bool checkIfShouldThrow(assertType::Enum at) {
+ if(at & assertType::is_require) //!OCLINT bitwise operator in conditional
+ return true;
+
+ if((at & assertType::is_check) //!OCLINT bitwise operator in conditional
+ && getContextOptions()->abort_after > 0 &&
+ (g_cs->numAssertsFailed + g_cs->numAssertsFailedCurrentTest_atomic) >=
+ getContextOptions()->abort_after)
+ return true;
+
+ return false;
+ }
+
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ DOCTEST_NORETURN void throwException() {
+ g_cs->shouldLogCurrentException = false;
+ throw TestFailureException();
+ } // NOLINT(cert-err60-cpp)
+#else // DOCTEST_CONFIG_NO_EXCEPTIONS
+ void throwException() {}
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+} // namespace detail
+
+namespace {
+ using namespace detail;
+ // matching of a string against a wildcard mask (case sensitivity configurable) taken from
+ // https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing
+ int wildcmp(const char* str, const char* wild, bool caseSensitive) {
+ const char* cp = str;
+ const char* mp = wild;
+
+ while((*str) && (*wild != '*')) {
+ if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) &&
+ (*wild != '?')) {
+ return 0;
+ }
+ wild++;
+ str++;
+ }
+
+ while(*str) {
+ if(*wild == '*') {
+ if(!*++wild) {
+ return 1;
+ }
+ mp = wild;
+ cp = str + 1;
+ } else if((caseSensitive ? (*wild == *str) : (tolower(*wild) == tolower(*str))) ||
+ (*wild == '?')) {
+ wild++;
+ str++;
+ } else {
+ wild = mp; //!OCLINT parameter reassignment
+ str = cp++; //!OCLINT parameter reassignment
+ }
+ }
+
+ while(*wild == '*') {
+ wild++;
+ }
+ return !*wild;
+ }
+
+ //// C string hash function (djb2) - taken from http://www.cse.yorku.ca/~oz/hash.html
+ //unsigned hashStr(unsigned const char* str) {
+ // unsigned long hash = 5381;
+ // char c;
+ // while((c = *str++))
+ // hash = ((hash << 5) + hash) + c; // hash * 33 + c
+ // return hash;
+ //}
+
+ // checks if the name matches any of the filters (and can be configured what to do when empty)
+ bool matchesAny(const char* name, const std::vector<String>& filters, bool matchEmpty,
+ bool caseSensitive) {
+ if(filters.empty() && matchEmpty)
+ return true;
+ for(auto& curr : filters)
+ if(wildcmp(name, curr.c_str(), caseSensitive))
+ return true;
+ return false;
+ }
+} // namespace
+namespace detail {
+
+ Subcase::Subcase(const String& name, const char* file, int line)
+ : m_signature({name, file, line}) {
+ auto* s = g_cs;
+
+ // check subcase filters
+ if(s->subcasesStack.size() < size_t(s->subcase_filter_levels)) {
+ if(!matchesAny(m_signature.m_name.c_str(), s->filters[6], true, s->case_sensitive))
+ return;
+ if(matchesAny(m_signature.m_name.c_str(), s->filters[7], false, s->case_sensitive))
+ return;
+ }
+
+ // if a Subcase on the same level has already been entered
+ if(s->subcasesStack.size() < size_t(s->subcasesCurrentMaxLevel)) {
+ s->should_reenter = true;
+ return;
+ }
+
+ // push the current signature to the stack so we can check if the
+ // current stack + the current new subcase have been traversed
+ s->subcasesStack.push_back(m_signature);
+ if(s->subcasesPassed.count(s->subcasesStack) != 0) {
+ // pop - revert to previous stack since we've already passed this
+ s->subcasesStack.pop_back();
+ return;
+ }
+
+ s->subcasesCurrentMaxLevel = s->subcasesStack.size();
+ m_entered = true;
+
+ DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_start, m_signature);
+ }
+
+ DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17
+ DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
+
+ Subcase::~Subcase() {
+ if(m_entered) {
+ // only mark the subcase stack as passed if no subcases have been skipped
+ if(g_cs->should_reenter == false)
+ g_cs->subcasesPassed.insert(g_cs->subcasesStack);
+ g_cs->subcasesStack.pop_back();
+
+#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
+ if(std::uncaught_exceptions() > 0
+#else
+ if(std::uncaught_exception()
+#endif
+ && g_cs->shouldLogCurrentException) {
+ DOCTEST_ITERATE_THROUGH_REPORTERS(
+ test_case_exception, {"exception thrown in subcase - will translate later "
+ "when the whole test case has been exited (cannot "
+ "translate while there is an active exception)",
+ false});
+ g_cs->shouldLogCurrentException = false;
+ }
+ DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, DOCTEST_EMPTY);
+ }
+ }
+
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ DOCTEST_GCC_SUPPRESS_WARNING_POP
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP
+
+ Subcase::operator bool() const { return m_entered; }
+
+ Result::Result(bool passed, const String& decomposition)
+ : m_passed(passed)
+ , m_decomp(decomposition) {}
+
+ ExpressionDecomposer::ExpressionDecomposer(assertType::Enum at)
+ : m_at(at) {}
+
+ TestSuite& TestSuite::operator*(const char* in) {
+ m_test_suite = in;
+ // clear state
+ m_description = nullptr;
+ m_skip = false;
+ m_no_breaks = false;
+ m_no_output = false;
+ m_may_fail = false;
+ m_should_fail = false;
+ m_expected_failures = 0;
+ m_timeout = 0;
+ return *this;
+ }
+
+ TestCase::TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite,
+ const char* type, int template_id) {
+ m_file = file;
+ m_line = line;
+ m_name = nullptr; // will be later overridden in operator*
+ m_test_suite = test_suite.m_test_suite;
+ m_description = test_suite.m_description;
+ m_skip = test_suite.m_skip;
+ m_no_breaks = test_suite.m_no_breaks;
+ m_no_output = test_suite.m_no_output;
+ m_may_fail = test_suite.m_may_fail;
+ m_should_fail = test_suite.m_should_fail;
+ m_expected_failures = test_suite.m_expected_failures;
+ m_timeout = test_suite.m_timeout;
+
+ m_test = test;
+ m_type = type;
+ m_template_id = template_id;
+ }
+
+ TestCase::TestCase(const TestCase& other)
+ : TestCaseData() {
+ *this = other;
+ }
+
+ DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function
+ DOCTEST_MSVC_SUPPRESS_WARNING(26437) // Do not slice
+ TestCase& TestCase::operator=(const TestCase& other) {
+ static_cast<TestCaseData&>(*this) = static_cast<const TestCaseData&>(other);
+
+ m_test = other.m_test;
+ m_type = other.m_type;
+ m_template_id = other.m_template_id;
+ m_full_name = other.m_full_name;
+
+ if(m_template_id != -1)
+ m_name = m_full_name.c_str();
+ return *this;
+ }
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP
+
+ TestCase& TestCase::operator*(const char* in) {
+ m_name = in;
+ // make a new name with an appended type for templated test case
+ if(m_template_id != -1) {
+ m_full_name = String(m_name) + m_type;
+ // redirect the name to point to the newly constructed full name
+ m_name = m_full_name.c_str();
+ }
+ return *this;
+ }
+
+ bool TestCase::operator<(const TestCase& other) const {
+ // this will be used only to differentiate between test cases - not relevant for sorting
+ if(m_line != other.m_line)
+ return m_line < other.m_line;
+ const int name_cmp = strcmp(m_name, other.m_name);
+ if(name_cmp != 0)
+ return name_cmp < 0;
+ const int file_cmp = m_file.compare(other.m_file);
+ if(file_cmp != 0)
+ return file_cmp < 0;
+ return m_template_id < other.m_template_id;
+ }
+
+ // all the registered tests
+ std::set<TestCase>& getRegisteredTests() {
+ static std::set<TestCase> data;
+ return data;
+ }
+} // namespace detail
+namespace {
+ using namespace detail;
+ // for sorting tests by file/line
+ bool fileOrderComparator(const TestCase* lhs, const TestCase* rhs) {
+ // this is needed because MSVC gives different case for drive letters
+ // for __FILE__ when evaluated in a header and a source file
+ const int res = lhs->m_file.compare(rhs->m_file, bool(DOCTEST_MSVC));
+ if(res != 0)
+ return res < 0;
+ if(lhs->m_line != rhs->m_line)
+ return lhs->m_line < rhs->m_line;
+ return lhs->m_template_id < rhs->m_template_id;
+ }
+
+ // for sorting tests by suite/file/line
+ bool suiteOrderComparator(const TestCase* lhs, const TestCase* rhs) {
+ const int res = std::strcmp(lhs->m_test_suite, rhs->m_test_suite);
+ if(res != 0)
+ return res < 0;
+ return fileOrderComparator(lhs, rhs);
+ }
+
+ // for sorting tests by name/suite/file/line
+ bool nameOrderComparator(const TestCase* lhs, const TestCase* rhs) {
+ const int res = std::strcmp(lhs->m_name, rhs->m_name);
+ if(res != 0)
+ return res < 0;
+ return suiteOrderComparator(lhs, rhs);
+ }
+
+#ifdef DOCTEST_CONFIG_COLORS_WINDOWS
+ HANDLE g_stdoutHandle;
+ WORD g_origFgAttrs;
+ WORD g_origBgAttrs;
+ bool g_attrsInitted = false;
+
+ int colors_init() {
+ if(!g_attrsInitted) {
+ g_stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+ g_attrsInitted = true;
+ CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+ GetConsoleScreenBufferInfo(g_stdoutHandle, &csbiInfo);
+ g_origFgAttrs = csbiInfo.wAttributes & ~(BACKGROUND_GREEN | BACKGROUND_RED |
+ BACKGROUND_BLUE | BACKGROUND_INTENSITY);
+ g_origBgAttrs = csbiInfo.wAttributes & ~(FOREGROUND_GREEN | FOREGROUND_RED |
+ FOREGROUND_BLUE | FOREGROUND_INTENSITY);
+ }
+ return 0;
+ }
+
+ int dumy_init_console_colors = colors_init();
+#endif // DOCTEST_CONFIG_COLORS_WINDOWS
+
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
+ void color_to_stream(std::ostream& s, Color::Enum code) {
+ static_cast<void>(s); // for DOCTEST_CONFIG_COLORS_NONE or DOCTEST_CONFIG_COLORS_WINDOWS
+ static_cast<void>(code); // for DOCTEST_CONFIG_COLORS_NONE
+#ifdef DOCTEST_CONFIG_COLORS_ANSI
+ if(g_no_colors ||
+ (isatty(STDOUT_FILENO) == false && getContextOptions()->force_colors == false))
+ return;
+
+ auto col = "";
+ // clang-format off
+ switch(code) { //!OCLINT missing break in switch statement / unnecessary default statement in covered switch statement
+ case Color::Red: col = "[0;31m"; break;
+ case Color::Green: col = "[0;32m"; break;
+ case Color::Blue: col = "[0;34m"; break;
+ case Color::Cyan: col = "[0;36m"; break;
+ case Color::Yellow: col = "[0;33m"; break;
+ case Color::Grey: col = "[1;30m"; break;
+ case Color::LightGrey: col = "[0;37m"; break;
+ case Color::BrightRed: col = "[1;31m"; break;
+ case Color::BrightGreen: col = "[1;32m"; break;
+ case Color::BrightWhite: col = "[1;37m"; break;
+ case Color::Bright: // invalid
+ case Color::None:
+ case Color::White:
+ default: col = "[0m";
+ }
+ // clang-format on
+ s << "\033" << col;
+#endif // DOCTEST_CONFIG_COLORS_ANSI
+
+#ifdef DOCTEST_CONFIG_COLORS_WINDOWS
+ if(g_no_colors ||
+ (isatty(fileno(stdout)) == false && getContextOptions()->force_colors == false))
+ return;
+
+#define DOCTEST_SET_ATTR(x) SetConsoleTextAttribute(g_stdoutHandle, x | g_origBgAttrs)
+
+ // clang-format off
+ switch (code) {
+ case Color::White: DOCTEST_SET_ATTR(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break;
+ case Color::Red: DOCTEST_SET_ATTR(FOREGROUND_RED); break;
+ case Color::Green: DOCTEST_SET_ATTR(FOREGROUND_GREEN); break;
+ case Color::Blue: DOCTEST_SET_ATTR(FOREGROUND_BLUE); break;
+ case Color::Cyan: DOCTEST_SET_ATTR(FOREGROUND_BLUE | FOREGROUND_GREEN); break;
+ case Color::Yellow: DOCTEST_SET_ATTR(FOREGROUND_RED | FOREGROUND_GREEN); break;
+ case Color::Grey: DOCTEST_SET_ATTR(0); break;
+ case Color::LightGrey: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY); break;
+ case Color::BrightRed: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_RED); break;
+ case Color::BrightGreen: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN); break;
+ case Color::BrightWhite: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break;
+ case Color::None:
+ case Color::Bright: // invalid
+ default: DOCTEST_SET_ATTR(g_origFgAttrs);
+ }
+ // clang-format on
+#endif // DOCTEST_CONFIG_COLORS_WINDOWS
+ }
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+
+ std::vector<const IExceptionTranslator*>& getExceptionTranslators() {
+ static std::vector<const IExceptionTranslator*> data;
+ return data;
+ }
+
+ String translateActiveException() {
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ String res;
+ auto& translators = getExceptionTranslators();
+ for(auto& curr : translators)
+ if(curr->translate(res))
+ return res;
+ // clang-format off
+ DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wcatch-value")
+ try {
+ throw;
+ } catch(std::exception& ex) {
+ return ex.what();
+ } catch(std::string& msg) {
+ return msg.c_str();
+ } catch(const char* msg) {
+ return msg;
+ } catch(...) {
+ return "unknown exception";
+ }
+ DOCTEST_GCC_SUPPRESS_WARNING_POP
+// clang-format on
+#else // DOCTEST_CONFIG_NO_EXCEPTIONS
+ return "";
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+ }
+} // namespace
+
+namespace detail {
+ // used by the macros for registering tests
+ int regTest(const TestCase& tc) {
+ getRegisteredTests().insert(tc);
+ return 0;
+ }
+
+ // sets the current test suite
+ int setTestSuite(const TestSuite& ts) {
+ doctest_detail_test_suite_ns::getCurrentTestSuite() = ts;
+ return 0;
+ }
+
+#ifdef DOCTEST_IS_DEBUGGER_ACTIVE
+ bool isDebuggerActive() { return DOCTEST_IS_DEBUGGER_ACTIVE(); }
+#else // DOCTEST_IS_DEBUGGER_ACTIVE
+#ifdef DOCTEST_PLATFORM_LINUX
+ class ErrnoGuard {
+ public:
+ ErrnoGuard() : m_oldErrno(errno) {}
+ ~ErrnoGuard() { errno = m_oldErrno; }
+ private:
+ int m_oldErrno;
+ };
+ // See the comments in Catch2 for the reasoning behind this implementation:
+ // https://github.com/catchorg/Catch2/blob/v2.13.1/include/internal/catch_debugger.cpp#L79-L102
+ bool isDebuggerActive() {
+ ErrnoGuard guard;
+ std::ifstream in("/proc/self/status");
+ for(std::string line; std::getline(in, line);) {
+ static const int PREFIX_LEN = 11;
+ if(line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0) {
+ return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0';
+ }
+ }
+ return false;
+ }
+#elif defined(DOCTEST_PLATFORM_MAC)
+ // The following function is taken directly from the following technical note:
+ // https://developer.apple.com/library/archive/qa/qa1361/_index.html
+ // Returns true if the current process is being debugged (either
+ // running under the debugger or has a debugger attached post facto).
+ bool isDebuggerActive() {
+ int mib[4];
+ kinfo_proc info;
+ size_t size;
+ // Initialize the flags so that, if sysctl fails for some bizarre
+ // reason, we get a predictable result.
+ info.kp_proc.p_flag = 0;
+ // Initialize mib, which tells sysctl the info we want, in this case
+ // we're looking for information about a specific process ID.
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PID;
+ mib[3] = getpid();
+ // Call sysctl.
+ size = sizeof(info);
+ if(sysctl(mib, DOCTEST_COUNTOF(mib), &info, &size, 0, 0) != 0) {
+ std::cerr << "\nCall to sysctl failed - unable to determine if debugger is active **\n";
+ return false;
+ }
+ // We're being debugged if the P_TRACED flag is set.
+ return ((info.kp_proc.p_flag & P_TRACED) != 0);
+ }
+#elif DOCTEST_MSVC || defined(__MINGW32__) || defined(__MINGW64__)
+ bool isDebuggerActive() { return ::IsDebuggerPresent() != 0; }
+#else
+ bool isDebuggerActive() { return false; }
+#endif // Platform
+#endif // DOCTEST_IS_DEBUGGER_ACTIVE
+
+ void registerExceptionTranslatorImpl(const IExceptionTranslator* et) {
+ if(std::find(getExceptionTranslators().begin(), getExceptionTranslators().end(), et) ==
+ getExceptionTranslators().end())
+ getExceptionTranslators().push_back(et);
+ }
+
+#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ void toStream(std::ostream* s, char* in) { *s << in; }
+ void toStream(std::ostream* s, const char* in) { *s << in; }
+#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
+ void toStream(std::ostream* s, bool in) { *s << std::boolalpha << in << std::noboolalpha; }
+ void toStream(std::ostream* s, float in) { *s << in; }
+ void toStream(std::ostream* s, double in) { *s << in; }
+ void toStream(std::ostream* s, double long in) { *s << in; }
+
+ void toStream(std::ostream* s, char in) { *s << in; }
+ void toStream(std::ostream* s, char signed in) { *s << in; }
+ void toStream(std::ostream* s, char unsigned in) { *s << in; }
+ void toStream(std::ostream* s, int short in) { *s << in; }
+ void toStream(std::ostream* s, int short unsigned in) { *s << in; }
+ void toStream(std::ostream* s, int in) { *s << in; }
+ void toStream(std::ostream* s, int unsigned in) { *s << in; }
+ void toStream(std::ostream* s, int long in) { *s << in; }
+ void toStream(std::ostream* s, int long unsigned in) { *s << in; }
+ void toStream(std::ostream* s, int long long in) { *s << in; }
+ void toStream(std::ostream* s, int long long unsigned in) { *s << in; }
+
+ DOCTEST_THREAD_LOCAL std::vector<IContextScope*> g_infoContexts; // for logging with INFO()
+
+ ContextScopeBase::ContextScopeBase() {
+ g_infoContexts.push_back(this);
+ }
+
+ DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17
+ DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
+
+ // destroy cannot be inlined into the destructor because that would mean calling stringify after
+ // ContextScope has been destroyed (base class destructors run after derived class destructors).
+ // Instead, ContextScope calls this method directly from its destructor.
+ void ContextScopeBase::destroy() {
+#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
+ if(std::uncaught_exceptions() > 0) {
+#else
+ if(std::uncaught_exception()) {
+#endif
+ std::ostringstream s;
+ this->stringify(&s);
+ g_cs->stringifiedContexts.push_back(s.str().c_str());
+ }
+ g_infoContexts.pop_back();
+ }
+
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ DOCTEST_GCC_SUPPRESS_WARNING_POP
+ DOCTEST_MSVC_SUPPRESS_WARNING_POP
+} // namespace detail
+namespace {
+ using namespace detail;
+
+#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
+ struct FatalConditionHandler
+ {
+ static void reset() {}
+ static void allocateAltStackMem() {}
+ static void freeAltStackMem() {}
+ };
+#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
+
+ void reportFatal(const std::string&);
+
+#ifdef DOCTEST_PLATFORM_WINDOWS
+
+ struct SignalDefs
+ {
+ DWORD id;
+ const char* name;
+ };
+ // There is no 1-1 mapping between signals and windows exceptions.
+ // Windows can easily distinguish between SO and SigSegV,
+ // but SigInt, SigTerm, etc are handled differently.
+ SignalDefs signalDefs[] = {
+ {static_cast<DWORD>(EXCEPTION_ILLEGAL_INSTRUCTION),
+ "SIGILL - Illegal instruction signal"},
+ {static_cast<DWORD>(EXCEPTION_STACK_OVERFLOW), "SIGSEGV - Stack overflow"},
+ {static_cast<DWORD>(EXCEPTION_ACCESS_VIOLATION),
+ "SIGSEGV - Segmentation violation signal"},
+ {static_cast<DWORD>(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error"},
+ };
+
+ struct FatalConditionHandler
+ {
+ static LONG CALLBACK handleException(PEXCEPTION_POINTERS ExceptionInfo) {
+ // Multiple threads may enter this filter/handler at once. We want the error message to be printed on the
+ // console just once no matter how many threads have crashed.
+ static std::mutex mutex;
+ static bool execute = true;
+ {
+ std::lock_guard<std::mutex> lock(mutex);
+ if(execute) {
+ bool reported = false;
+ for(size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
+ if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
+ reportFatal(signalDefs[i].name);
+ reported = true;
+ break;
+ }
+ }
+ if(reported == false)
+ reportFatal("Unhandled SEH exception caught");
+ if(isDebuggerActive() && !g_cs->no_breaks)
+ DOCTEST_BREAK_INTO_DEBUGGER();
+ }
+ execute = false;
+ }
+ std::exit(EXIT_FAILURE);
+ }
+
+ static void allocateAltStackMem() {}
+ static void freeAltStackMem() {}
+
+ FatalConditionHandler() {
+ isSet = true;
+ // 32k seems enough for doctest to handle stack overflow,
+ // but the value was found experimentally, so there is no strong guarantee
+ guaranteeSize = 32 * 1024;
+ // Register an unhandled exception filter
+ previousTop = SetUnhandledExceptionFilter(handleException);
+ // Pass in guarantee size to be filled
+ SetThreadStackGuarantee(&guaranteeSize);
+
+ // On Windows uncaught exceptions from another thread, exceptions from
+ // destructors, or calls to std::terminate are not a SEH exception
+
+ // The terminal handler gets called when:
+ // - std::terminate is called FROM THE TEST RUNNER THREAD
+ // - an exception is thrown from a destructor FROM THE TEST RUNNER THREAD
+ original_terminate_handler = std::get_terminate();
+ std::set_terminate([]() DOCTEST_NOEXCEPT {
+ reportFatal("Terminate handler called");
+ if(isDebuggerActive() && !g_cs->no_breaks)
+ DOCTEST_BREAK_INTO_DEBUGGER();
+ std::exit(EXIT_FAILURE); // explicitly exit - otherwise the SIGABRT handler may be called as well
+ });
+
+ // SIGABRT is raised when:
+ // - std::terminate is called FROM A DIFFERENT THREAD
+ // - an exception is thrown from a destructor FROM A DIFFERENT THREAD
+ // - an uncaught exception is thrown FROM A DIFFERENT THREAD
+ prev_sigabrt_handler = std::signal(SIGABRT, [](int signal) DOCTEST_NOEXCEPT {
+ if(signal == SIGABRT) {
+ reportFatal("SIGABRT - Abort (abnormal termination) signal");
+ if(isDebuggerActive() && !g_cs->no_breaks)
+ DOCTEST_BREAK_INTO_DEBUGGER();
+ std::exit(EXIT_FAILURE);
+ }
+ });
+
+ // The following settings are taken from google test, and more
+ // specifically from UnitTest::Run() inside of gtest.cc
+
+ // the user does not want to see pop-up dialogs about crashes
+ prev_error_mode_1 = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
+ SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+ // This forces the abort message to go to stderr in all circumstances.
+ prev_error_mode_2 = _set_error_mode(_OUT_TO_STDERR);
+ // In the debug version, Visual Studio pops up a separate dialog
+ // offering a choice to debug the aborted program - we want to disable that.
+ prev_abort_behavior = _set_abort_behavior(0x0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
+ // In debug mode, the Windows CRT can crash with an assertion over invalid
+ // input (e.g. passing an invalid file descriptor). The default handling
+ // for these assertions is to pop up a dialog and wait for user input.
+ // Instead ask the CRT to dump such assertions to stderr non-interactively.
+ prev_report_mode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+ prev_report_file = _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ }
+
+ static void reset() {
+ if(isSet) {
+ // Unregister handler and restore the old guarantee
+ SetUnhandledExceptionFilter(previousTop);
+ SetThreadStackGuarantee(&guaranteeSize);
+ std::set_terminate(original_terminate_handler);
+ std::signal(SIGABRT, prev_sigabrt_handler);
+ SetErrorMode(prev_error_mode_1);
+ _set_error_mode(prev_error_mode_2);
+ _set_abort_behavior(prev_abort_behavior, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
+ static_cast<void>(_CrtSetReportMode(_CRT_ASSERT, prev_report_mode));
+ static_cast<void>(_CrtSetReportFile(_CRT_ASSERT, prev_report_file));
+ isSet = false;
+ }
+ }
+
+ ~FatalConditionHandler() { reset(); }
+
+ private:
+ static UINT prev_error_mode_1;
+ static int prev_error_mode_2;
+ static unsigned int prev_abort_behavior;
+ static int prev_report_mode;
+ static _HFILE prev_report_file;
+ static void (*prev_sigabrt_handler)(int);
+ static std::terminate_handler original_terminate_handler;
+ static bool isSet;
+ static ULONG guaranteeSize;
+ static LPTOP_LEVEL_EXCEPTION_FILTER previousTop;
+ };
+
+ UINT FatalConditionHandler::prev_error_mode_1;
+ int FatalConditionHandler::prev_error_mode_2;
+ unsigned int FatalConditionHandler::prev_abort_behavior;
+ int FatalConditionHandler::prev_report_mode;
+ _HFILE FatalConditionHandler::prev_report_file;
+ void (*FatalConditionHandler::prev_sigabrt_handler)(int);
+ std::terminate_handler FatalConditionHandler::original_terminate_handler;
+ bool FatalConditionHandler::isSet = false;
+ ULONG FatalConditionHandler::guaranteeSize = 0;
+ LPTOP_LEVEL_EXCEPTION_FILTER FatalConditionHandler::previousTop = nullptr;
+
+#else // DOCTEST_PLATFORM_WINDOWS
+
+ struct SignalDefs
+ {
+ int id;
+ const char* name;
+ };
+ SignalDefs signalDefs[] = {{SIGINT, "SIGINT - Terminal interrupt signal"},
+ {SIGILL, "SIGILL - Illegal instruction signal"},
+ {SIGFPE, "SIGFPE - Floating point error signal"},
+ {SIGSEGV, "SIGSEGV - Segmentation violation signal"},
+ {SIGTERM, "SIGTERM - Termination request signal"},
+ {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}};
+
+ struct FatalConditionHandler
+ {
+ static bool isSet;
+ static struct sigaction oldSigActions[DOCTEST_COUNTOF(signalDefs)];
+ static stack_t oldSigStack;
+ static size_t altStackSize;
+ static char* altStackMem;
+
+ static void handleSignal(int sig) {
+ const char* name = "<unknown signal>";
+ for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
+ SignalDefs& def = signalDefs[i];
+ if(sig == def.id) {
+ name = def.name;
+ break;
+ }
+ }
+ reset();
+ reportFatal(name);
+ raise(sig);
+ }
+
+ static void allocateAltStackMem() {
+ altStackMem = new char[altStackSize];
+ }
+
+ static void freeAltStackMem() {
+ delete[] altStackMem;
+ }
+
+ FatalConditionHandler() {
+ isSet = true;
+ stack_t sigStack;
+ sigStack.ss_sp = altStackMem;
+ sigStack.ss_size = altStackSize;
+ sigStack.ss_flags = 0;
+ sigaltstack(&sigStack, &oldSigStack);
+ struct sigaction sa = {};
+ sa.sa_handler = handleSignal; // NOLINT
+ sa.sa_flags = SA_ONSTACK;
+ for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
+ sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
+ }
+ }
+
+ ~FatalConditionHandler() { reset(); }
+ static void reset() {
+ if(isSet) {
+ // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
+ for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
+ sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);
+ }
+ // Return the old stack
+ sigaltstack(&oldSigStack, nullptr);
+ isSet = false;
+ }
+ }
+ };
+
+ bool FatalConditionHandler::isSet = false;
+ struct sigaction FatalConditionHandler::oldSigActions[DOCTEST_COUNTOF(signalDefs)] = {};
+ stack_t FatalConditionHandler::oldSigStack = {};
+ size_t FatalConditionHandler::altStackSize = 4 * SIGSTKSZ;
+ char* FatalConditionHandler::altStackMem = nullptr;
+
+#endif // DOCTEST_PLATFORM_WINDOWS
+#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
+
+} // namespace
+
+namespace {
+ using namespace detail;
+
+#ifdef DOCTEST_PLATFORM_WINDOWS
+#define DOCTEST_OUTPUT_DEBUG_STRING(text) ::OutputDebugStringA(text)
+#else
+ // TODO: integration with XCode and other IDEs
+#define DOCTEST_OUTPUT_DEBUG_STRING(text) // NOLINT(clang-diagnostic-unused-macros)
+#endif // Platform
+
+ void addAssert(assertType::Enum at) {
+ if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional
+ g_cs->numAssertsCurrentTest_atomic++;
+ }
+
+ void addFailedAssert(assertType::Enum at) {
+ if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional
+ g_cs->numAssertsFailedCurrentTest_atomic++;
+ }
+
+#if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH)
+ void reportFatal(const std::string& message) {
+ g_cs->failure_flags |= TestCaseFailureReason::Crash;
+
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception, {message.c_str(), true});
+
+ while(g_cs->subcasesStack.size()) {
+ g_cs->subcasesStack.pop_back();
+ DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, DOCTEST_EMPTY);
+ }
+
+ g_cs->finalizeTestCaseData();
+
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
+
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
+ }
+#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
+} // namespace
+namespace detail {
+
+ ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
+ const char* exception_type, const char* exception_string) {
+ m_test_case = g_cs->currentTest;
+ m_at = at;
+ m_file = file;
+ m_line = line;
+ m_expr = expr;
+ m_failed = true;
+ m_threw = false;
+ m_threw_as = false;
+ m_exception_type = exception_type;
+ m_exception_string = exception_string;
+#if DOCTEST_MSVC
+ if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC
+ ++m_expr;
+#endif // MSVC
+ }
+
+ void ResultBuilder::setResult(const Result& res) {
+ m_decomp = res.m_decomp;
+ m_failed = !res.m_passed;
+ }
+
+ void ResultBuilder::translateException() {
+ m_threw = true;
+ m_exception = translateActiveException();
+ }
+
+ bool ResultBuilder::log() {
+ if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional
+ m_failed = !m_threw;
+ } else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) { //!OCLINT
+ m_failed = !m_threw_as || (m_exception != m_exception_string);
+ } else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional
+ m_failed = !m_threw_as;
+ } else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional
+ m_failed = m_exception != m_exception_string;
+ } else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional
+ m_failed = m_threw;
+ }
+
+ if(m_exception.size())
+ m_exception = String("\"") + m_exception + "\"";
+
+ if(is_running_in_test) {
+ addAssert(m_at);
+ DOCTEST_ITERATE_THROUGH_REPORTERS(log_assert, *this);
+
+ if(m_failed)
+ addFailedAssert(m_at);
+ } else if(m_failed) {
+ failed_out_of_a_testing_context(*this);
+ }
+
+ return m_failed && isDebuggerActive() && !getContextOptions()->no_breaks &&
+ (g_cs->currentTest == nullptr || !g_cs->currentTest->m_no_breaks); // break into debugger
+ }
+
+ void ResultBuilder::react() const {
+ if(m_failed && checkIfShouldThrow(m_at))
+ throwException();
+ }
+
+ void failed_out_of_a_testing_context(const AssertData& ad) {
+ if(g_cs->ah)
+ g_cs->ah(ad);
+ else
+ std::abort();
+ }
+
+ void decomp_assert(assertType::Enum at, const char* file, int line, const char* expr,
+ Result result) {
+ bool failed = !result.m_passed;
+
+ // ###################################################################################
+ // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
+ // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
+ // ###################################################################################
+ DOCTEST_ASSERT_OUT_OF_TESTS(result.m_decomp);
+ DOCTEST_ASSERT_IN_TESTS(result.m_decomp);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+ }
+
+ MessageBuilder::MessageBuilder(const char* file, int line, assertType::Enum severity) {
+ m_stream = getTlsOss();
+ m_file = file;
+ m_line = line;
+ m_severity = severity;
+ }
+
+ IExceptionTranslator::IExceptionTranslator() = default;
+ IExceptionTranslator::~IExceptionTranslator() = default;
+
+ bool MessageBuilder::log() {
+ m_string = getTlsOssResult();
+ DOCTEST_ITERATE_THROUGH_REPORTERS(log_message, *this);
+
+ const bool isWarn = m_severity & assertType::is_warn;
+
+ // warn is just a message in this context so we don't treat it as an assert
+ if(!isWarn) {
+ addAssert(m_severity);
+ addFailedAssert(m_severity);
+ }
+
+ return isDebuggerActive() && !getContextOptions()->no_breaks && !isWarn &&
+ (g_cs->currentTest == nullptr || !g_cs->currentTest->m_no_breaks); // break into debugger
+ }
+
+ void MessageBuilder::react() {
+ if(m_severity & assertType::is_require) //!OCLINT bitwise operator in conditional
+ throwException();
+ }
+
+ MessageBuilder::~MessageBuilder() = default;
+} // namespace detail
+namespace {
+ using namespace detail;
+
+ template <typename Ex>
+ DOCTEST_NORETURN void throw_exception(Ex const& e) {
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ throw e;
+#else // DOCTEST_CONFIG_NO_EXCEPTIONS
+ std::cerr << "doctest will terminate because it needed to throw an exception.\n"
+ << "The message was: " << e.what() << '\n';
+ std::terminate();
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+ }
+
+#ifndef DOCTEST_INTERNAL_ERROR
+#define DOCTEST_INTERNAL_ERROR(msg) \
+ throw_exception(std::logic_error( \
+ __FILE__ ":" DOCTEST_TOSTR(__LINE__) ": Internal doctest error: " msg))
+#endif // DOCTEST_INTERNAL_ERROR
+
+ // clang-format off
+
+// =================================================================================================
+// The following code has been taken verbatim from Catch2/include/internal/catch_xmlwriter.h/cpp
+// This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched.
+// =================================================================================================
+
+ class XmlEncode {
+ public:
+ enum ForWhat { ForTextNodes, ForAttributes };
+
+ XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes );
+
+ void encodeTo( std::ostream& os ) const;
+
+ friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode );
+
+ private:
+ std::string m_str;
+ ForWhat m_forWhat;
+ };
+
+ class XmlWriter {
+ public:
+
+ class ScopedElement {
+ public:
+ ScopedElement( XmlWriter* writer );
+
+ ScopedElement( ScopedElement&& other ) DOCTEST_NOEXCEPT;
+ ScopedElement& operator=( ScopedElement&& other ) DOCTEST_NOEXCEPT;
+
+ ~ScopedElement();
+
+ ScopedElement& writeText( std::string const& text, bool indent = true );
+
+ template<typename T>
+ ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
+ m_writer->writeAttribute( name, attribute );
+ return *this;
+ }
+
+ private:
+ mutable XmlWriter* m_writer = nullptr;
+ };
+
+ XmlWriter( std::ostream& os = std::cout );
+ ~XmlWriter();
+
+ XmlWriter( XmlWriter const& ) = delete;
+ XmlWriter& operator=( XmlWriter const& ) = delete;
+
+ XmlWriter& startElement( std::string const& name );
+
+ ScopedElement scopedElement( std::string const& name );
+
+ XmlWriter& endElement();
+
+ XmlWriter& writeAttribute( std::string const& name, std::string const& attribute );
+
+ XmlWriter& writeAttribute( std::string const& name, const char* attribute );
+
+ XmlWriter& writeAttribute( std::string const& name, bool attribute );
+
+ template<typename T>
+ XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
+ std::stringstream rss;
+ rss << attribute;
+ return writeAttribute( name, rss.str() );
+ }
+
+ XmlWriter& writeText( std::string const& text, bool indent = true );
+
+ //XmlWriter& writeComment( std::string const& text );
+
+ //void writeStylesheetRef( std::string const& url );
+
+ //XmlWriter& writeBlankLine();
+
+ void ensureTagClosed();
+
+ private:
+
+ void writeDeclaration();
+
+ void newlineIfNecessary();
+
+ bool m_tagIsOpen = false;
+ bool m_needsNewline = false;
+ std::vector<std::string> m_tags;
+ std::string m_indent;
+ std::ostream& m_os;
+ };
+
+// =================================================================================================
+// The following code has been taken verbatim from Catch2/include/internal/catch_xmlwriter.h/cpp
+// This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched.
+// =================================================================================================
+
+using uchar = unsigned char;
+
+namespace {
+
+ size_t trailingBytes(unsigned char c) {
+ if ((c & 0xE0) == 0xC0) {
+ return 2;
+ }
+ if ((c & 0xF0) == 0xE0) {
+ return 3;
+ }
+ if ((c & 0xF8) == 0xF0) {
+ return 4;
+ }
+ DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered");
+ }
+
+ uint32_t headerValue(unsigned char c) {
+ if ((c & 0xE0) == 0xC0) {
+ return c & 0x1F;
+ }
+ if ((c & 0xF0) == 0xE0) {
+ return c & 0x0F;
+ }
+ if ((c & 0xF8) == 0xF0) {
+ return c & 0x07;
+ }
+ DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered");
+ }
+
+ void hexEscapeChar(std::ostream& os, unsigned char c) {
+ std::ios_base::fmtflags f(os.flags());
+ os << "\\x"
+ << std::uppercase << std::hex << std::setfill('0') << std::setw(2)
+ << static_cast<int>(c);
+ os.flags(f);
+ }
+
+} // anonymous namespace
+
+ XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat )
+ : m_str( str ),
+ m_forWhat( forWhat )
+ {}
+
+ void XmlEncode::encodeTo( std::ostream& os ) const {
+ // Apostrophe escaping not necessary if we always use " to write attributes
+ // (see: https://www.w3.org/TR/xml/#syntax)
+
+ for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) {
+ uchar c = m_str[idx];
+ switch (c) {
+ case '<': os << "&lt;"; break;
+ case '&': os << "&amp;"; break;
+
+ case '>':
+ // See: https://www.w3.org/TR/xml/#syntax
+ if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']')
+ os << "&gt;";
+ else
+ os << c;
+ break;
+
+ case '\"':
+ if (m_forWhat == ForAttributes)
+ os << "&quot;";
+ else
+ os << c;
+ break;
+
+ default:
+ // Check for control characters and invalid utf-8
+
+ // Escape control characters in standard ascii
+ // see https://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
+ if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) {
+ hexEscapeChar(os, c);
+ break;
+ }
+
+ // Plain ASCII: Write it to stream
+ if (c < 0x7F) {
+ os << c;
+ break;
+ }
+
+ // UTF-8 territory
+ // Check if the encoding is valid and if it is not, hex escape bytes.
+ // Important: We do not check the exact decoded values for validity, only the encoding format
+ // First check that this bytes is a valid lead byte:
+ // This means that it is not encoded as 1111 1XXX
+ // Or as 10XX XXXX
+ if (c < 0xC0 ||
+ c >= 0xF8) {
+ hexEscapeChar(os, c);
+ break;
+ }
+
+ auto encBytes = trailingBytes(c);
+ // Are there enough bytes left to avoid accessing out-of-bounds memory?
+ if (idx + encBytes - 1 >= m_str.size()) {
+ hexEscapeChar(os, c);
+ break;
+ }
+ // The header is valid, check data
+ // The next encBytes bytes must together be a valid utf-8
+ // This means: bitpattern 10XX XXXX and the extracted value is sane (ish)
+ bool valid = true;
+ uint32_t value = headerValue(c);
+ for (std::size_t n = 1; n < encBytes; ++n) {
+ uchar nc = m_str[idx + n];
+ valid &= ((nc & 0xC0) == 0x80);
+ value = (value << 6) | (nc & 0x3F);
+ }
+
+ if (
+ // Wrong bit pattern of following bytes
+ (!valid) ||
+ // Overlong encodings
+ (value < 0x80) ||
+ ( value < 0x800 && encBytes > 2) || // removed "0x80 <= value &&" because redundant
+ (0x800 < value && value < 0x10000 && encBytes > 3) ||
+ // Encoded value out of range
+ (value >= 0x110000)
+ ) {
+ hexEscapeChar(os, c);
+ break;
+ }
+
+ // If we got here, this is in fact a valid(ish) utf-8 sequence
+ for (std::size_t n = 0; n < encBytes; ++n) {
+ os << m_str[idx + n];
+ }
+ idx += encBytes - 1;
+ break;
+ }
+ }
+ }
+
+ std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {
+ xmlEncode.encodeTo( os );
+ return os;
+ }
+
+ XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer )
+ : m_writer( writer )
+ {}
+
+ XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) DOCTEST_NOEXCEPT
+ : m_writer( other.m_writer ){
+ other.m_writer = nullptr;
+ }
+ XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) DOCTEST_NOEXCEPT {
+ if ( m_writer ) {
+ m_writer->endElement();
+ }
+ m_writer = other.m_writer;
+ other.m_writer = nullptr;
+ return *this;
+ }
+
+
+ XmlWriter::ScopedElement::~ScopedElement() {
+ if( m_writer )
+ m_writer->endElement();
+ }
+
+ XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) {
+ m_writer->writeText( text, indent );
+ return *this;
+ }
+
+ XmlWriter::XmlWriter( std::ostream& os ) : m_os( os )
+ {
+ writeDeclaration();
+ }
+
+ XmlWriter::~XmlWriter() {
+ while( !m_tags.empty() )
+ endElement();
+ }
+
+ XmlWriter& XmlWriter::startElement( std::string const& name ) {
+ ensureTagClosed();
+ newlineIfNecessary();
+ m_os << m_indent << '<' << name;
+ m_tags.push_back( name );
+ m_indent += " ";
+ m_tagIsOpen = true;
+ return *this;
+ }
+
+ XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) {
+ ScopedElement scoped( this );
+ startElement( name );
+ return scoped;
+ }
+
+ XmlWriter& XmlWriter::endElement() {
+ newlineIfNecessary();
+ m_indent = m_indent.substr( 0, m_indent.size()-2 );
+ if( m_tagIsOpen ) {
+ m_os << "/>";
+ m_tagIsOpen = false;
+ }
+ else {
+ m_os << m_indent << "</" << m_tags.back() << ">";
+ }
+ m_os << std::endl;
+ m_tags.pop_back();
+ return *this;
+ }
+
+ XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) {
+ if( !name.empty() && !attribute.empty() )
+ m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
+ return *this;
+ }
+
+ XmlWriter& XmlWriter::writeAttribute( std::string const& name, const char* attribute ) {
+ if( !name.empty() && attribute && attribute[0] != '\0' )
+ m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"';
+ return *this;
+ }
+
+ XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) {
+ m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"';
+ return *this;
+ }
+
+ XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) {
+ if( !text.empty() ){
+ bool tagWasOpen = m_tagIsOpen;
+ ensureTagClosed();
+ if( tagWasOpen && indent )
+ m_os << m_indent;
+ m_os << XmlEncode( text );
+ m_needsNewline = true;
+ }
+ return *this;
+ }
+
+ //XmlWriter& XmlWriter::writeComment( std::string const& text ) {
+ // ensureTagClosed();
+ // m_os << m_indent << "<!--" << text << "-->";
+ // m_needsNewline = true;
+ // return *this;
+ //}
+
+ //void XmlWriter::writeStylesheetRef( std::string const& url ) {
+ // m_os << "<?xml-stylesheet type=\"text/xsl\" href=\"" << url << "\"?>\n";
+ //}
+
+ //XmlWriter& XmlWriter::writeBlankLine() {
+ // ensureTagClosed();
+ // m_os << '\n';
+ // return *this;
+ //}
+
+ void XmlWriter::ensureTagClosed() {
+ if( m_tagIsOpen ) {
+ m_os << ">" << std::endl;
+ m_tagIsOpen = false;
+ }
+ }
+
+ void XmlWriter::writeDeclaration() {
+ m_os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ }
+
+ void XmlWriter::newlineIfNecessary() {
+ if( m_needsNewline ) {
+ m_os << std::endl;
+ m_needsNewline = false;
+ }
+ }
+
+// =================================================================================================
+// End of copy-pasted code from Catch
+// =================================================================================================
+
+ // clang-format on
+
+ struct XmlReporter : public IReporter
+ {
+ XmlWriter xml;
+ std::mutex mutex;
+
+ // caching pointers/references to objects of these types - safe to do
+ const ContextOptions& opt;
+ const TestCaseData* tc = nullptr;
+
+ XmlReporter(const ContextOptions& co)
+ : xml(*co.cout)
+ , opt(co) {}
+
+ void log_contexts() {
+ int num_contexts = get_num_active_contexts();
+ if(num_contexts) {
+ auto contexts = get_active_contexts();
+ std::stringstream ss;
+ for(int i = 0; i < num_contexts; ++i) {
+ contexts[i]->stringify(&ss);
+ xml.scopedElement("Info").writeText(ss.str());
+ ss.str("");
+ }
+ }
+ }
+
+ unsigned line(unsigned l) const { return opt.no_line_numbers ? 0 : l; }
+
+ void test_case_start_impl(const TestCaseData& in) {
+ bool open_ts_tag = false;
+ if(tc != nullptr) { // we have already opened a test suite
+ if(std::strcmp(tc->m_test_suite, in.m_test_suite) != 0) {
+ xml.endElement();
+ open_ts_tag = true;
+ }
+ }
+ else {
+ open_ts_tag = true; // first test case ==> first test suite
+ }
+
+ if(open_ts_tag) {
+ xml.startElement("TestSuite");
+ xml.writeAttribute("name", in.m_test_suite);
+ }
+
+ tc = &in;
+ xml.startElement("TestCase")
+ .writeAttribute("name", in.m_name)
+ .writeAttribute("filename", skipPathFromFilename(in.m_file.c_str()))
+ .writeAttribute("line", line(in.m_line))
+ .writeAttribute("description", in.m_description);
+
+ if(Approx(in.m_timeout) != 0)
+ xml.writeAttribute("timeout", in.m_timeout);
+ if(in.m_may_fail)
+ xml.writeAttribute("may_fail", true);
+ if(in.m_should_fail)
+ xml.writeAttribute("should_fail", true);
+ }
+
+ // =========================================================================================
+ // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE
+ // =========================================================================================
+
+ void report_query(const QueryData& in) override {
+ test_run_start();
+ if(opt.list_reporters) {
+ for(auto& curr : getListeners())
+ xml.scopedElement("Listener")
+ .writeAttribute("priority", curr.first.first)
+ .writeAttribute("name", curr.first.second);
+ for(auto& curr : getReporters())
+ xml.scopedElement("Reporter")
+ .writeAttribute("priority", curr.first.first)
+ .writeAttribute("name", curr.first.second);
+ } else if(opt.count || opt.list_test_cases) {
+ for(unsigned i = 0; i < in.num_data; ++i) {
+ xml.scopedElement("TestCase").writeAttribute("name", in.data[i]->m_name)
+ .writeAttribute("testsuite", in.data[i]->m_test_suite)
+ .writeAttribute("filename", skipPathFromFilename(in.data[i]->m_file.c_str()))
+ .writeAttribute("line", line(in.data[i]->m_line));
+ }
+ xml.scopedElement("OverallResultsTestCases")
+ .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters);
+ } else if(opt.list_test_suites) {
+ for(unsigned i = 0; i < in.num_data; ++i)
+ xml.scopedElement("TestSuite").writeAttribute("name", in.data[i]->m_test_suite);
+ xml.scopedElement("OverallResultsTestCases")
+ .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters);
+ xml.scopedElement("OverallResultsTestSuites")
+ .writeAttribute("unskipped", in.run_stats->numTestSuitesPassingFilters);
+ }
+ xml.endElement();
+ }
+
+ void test_run_start() override {
+ // remove .exe extension - mainly to have the same output on UNIX and Windows
+ std::string binary_name = skipPathFromFilename(opt.binary_name.c_str());
+#ifdef DOCTEST_PLATFORM_WINDOWS
+ if(binary_name.rfind(".exe") != std::string::npos)
+ binary_name = binary_name.substr(0, binary_name.length() - 4);
+#endif // DOCTEST_PLATFORM_WINDOWS
+
+ xml.startElement("doctest").writeAttribute("binary", binary_name);
+ if(opt.no_version == false)
+ xml.writeAttribute("version", DOCTEST_VERSION_STR);
+
+ // only the consequential ones (TODO: filters)
+ xml.scopedElement("Options")
+ .writeAttribute("order_by", opt.order_by.c_str())
+ .writeAttribute("rand_seed", opt.rand_seed)
+ .writeAttribute("first", opt.first)
+ .writeAttribute("last", opt.last)
+ .writeAttribute("abort_after", opt.abort_after)
+ .writeAttribute("subcase_filter_levels", opt.subcase_filter_levels)
+ .writeAttribute("case_sensitive", opt.case_sensitive)
+ .writeAttribute("no_throw", opt.no_throw)
+ .writeAttribute("no_skip", opt.no_skip);
+ }
+
+ void test_run_end(const TestRunStats& p) override {
+ if(tc) // the TestSuite tag - only if there has been at least 1 test case
+ xml.endElement();
+
+ xml.scopedElement("OverallResultsAsserts")
+ .writeAttribute("successes", p.numAsserts - p.numAssertsFailed)
+ .writeAttribute("failures", p.numAssertsFailed);
+
+ xml.startElement("OverallResultsTestCases")
+ .writeAttribute("successes",
+ p.numTestCasesPassingFilters - p.numTestCasesFailed)
+ .writeAttribute("failures", p.numTestCasesFailed);
+ if(opt.no_skipped_summary == false)
+ xml.writeAttribute("skipped", p.numTestCases - p.numTestCasesPassingFilters);
+ xml.endElement();
+
+ xml.endElement();
+ }
+
+ void test_case_start(const TestCaseData& in) override {
+ test_case_start_impl(in);
+ xml.ensureTagClosed();
+ }
+
+ void test_case_reenter(const TestCaseData&) override {}
+
+ void test_case_end(const CurrentTestCaseStats& st) override {
+ xml.startElement("OverallResultsAsserts")
+ .writeAttribute("successes",
+ st.numAssertsCurrentTest - st.numAssertsFailedCurrentTest)
+ .writeAttribute("failures", st.numAssertsFailedCurrentTest);
+ if(opt.duration)
+ xml.writeAttribute("duration", st.seconds);
+ if(tc->m_expected_failures)
+ xml.writeAttribute("expected_failures", tc->m_expected_failures);
+ xml.endElement();
+
+ xml.endElement();
+ }
+
+ void test_case_exception(const TestCaseException& e) override {
+ std::lock_guard<std::mutex> lock(mutex);
+
+ xml.scopedElement("Exception")
+ .writeAttribute("crash", e.is_crash)
+ .writeText(e.error_string.c_str());
+ }
+
+ void subcase_start(const SubcaseSignature& in) override {
+ std::lock_guard<std::mutex> lock(mutex);
+
+ xml.startElement("SubCase")
+ .writeAttribute("name", in.m_name)
+ .writeAttribute("filename", skipPathFromFilename(in.m_file))
+ .writeAttribute("line", line(in.m_line));
+ xml.ensureTagClosed();
+ }
+
+ void subcase_end() override { xml.endElement(); }
+
+ void log_assert(const AssertData& rb) override {
+ if(!rb.m_failed && !opt.success)
+ return;
+
+ std::lock_guard<std::mutex> lock(mutex);
+
+ xml.startElement("Expression")
+ .writeAttribute("success", !rb.m_failed)
+ .writeAttribute("type", assertString(rb.m_at))
+ .writeAttribute("filename", skipPathFromFilename(rb.m_file))
+ .writeAttribute("line", line(rb.m_line));
+
+ xml.scopedElement("Original").writeText(rb.m_expr);
+
+ if(rb.m_threw)
+ xml.scopedElement("Exception").writeText(rb.m_exception.c_str());
+
+ if(rb.m_at & assertType::is_throws_as)
+ xml.scopedElement("ExpectedException").writeText(rb.m_exception_type);
+ if(rb.m_at & assertType::is_throws_with)
+ xml.scopedElement("ExpectedExceptionString").writeText(rb.m_exception_string);
+ if((rb.m_at & assertType::is_normal) && !rb.m_threw)
+ xml.scopedElement("Expanded").writeText(rb.m_decomp.c_str());
+
+ log_contexts();
+
+ xml.endElement();
+ }
+
+ void log_message(const MessageData& mb) override {
+ std::lock_guard<std::mutex> lock(mutex);
+
+ xml.startElement("Message")
+ .writeAttribute("type", failureString(mb.m_severity))
+ .writeAttribute("filename", skipPathFromFilename(mb.m_file))
+ .writeAttribute("line", line(mb.m_line));
+
+ xml.scopedElement("Text").writeText(mb.m_string.c_str());
+
+ log_contexts();
+
+ xml.endElement();
+ }
+
+ void test_case_skipped(const TestCaseData& in) override {
+ if(opt.no_skipped_summary == false) {
+ test_case_start_impl(in);
+ xml.writeAttribute("skipped", "true");
+ xml.endElement();
+ }
+ }
+ };
+
+ DOCTEST_REGISTER_REPORTER("xml", 0, XmlReporter);
+
+ void fulltext_log_assert_to_stream(std::ostream& s, const AssertData& rb) {
+ if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) ==
+ 0) //!OCLINT bitwise operator in conditional
+ s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << " ) "
+ << Color::None;
+
+ if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional
+ s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n";
+ } else if((rb.m_at & assertType::is_throws_as) &&
+ (rb.m_at & assertType::is_throws_with)) { //!OCLINT
+ s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \""
+ << rb.m_exception_string << "\", " << rb.m_exception_type << " ) " << Color::None;
+ if(rb.m_threw) {
+ if(!rb.m_failed) {
+ s << "threw as expected!\n";
+ } else {
+ s << "threw a DIFFERENT exception! (contents: " << rb.m_exception << ")\n";
+ }
+ } else {
+ s << "did NOT throw at all!\n";
+ }
+ } else if(rb.m_at &
+ assertType::is_throws_as) { //!OCLINT bitwise operator in conditional
+ s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", "
+ << rb.m_exception_type << " ) " << Color::None
+ << (rb.m_threw ? (rb.m_threw_as ? "threw as expected!" :
+ "threw a DIFFERENT exception: ") :
+ "did NOT throw at all!")
+ << Color::Cyan << rb.m_exception << "\n";
+ } else if(rb.m_at &
+ assertType::is_throws_with) { //!OCLINT bitwise operator in conditional
+ s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \""
+ << rb.m_exception_string << "\" ) " << Color::None
+ << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" :
+ "threw a DIFFERENT exception: ") :
+ "did NOT throw at all!")
+ << Color::Cyan << rb.m_exception << "\n";
+ } else if(rb.m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional
+ s << (rb.m_threw ? "THREW exception: " : "didn't throw!") << Color::Cyan
+ << rb.m_exception << "\n";
+ } else {
+ s << (rb.m_threw ? "THREW exception: " :
+ (!rb.m_failed ? "is correct!\n" : "is NOT correct!\n"));
+ if(rb.m_threw)
+ s << rb.m_exception << "\n";
+ else
+ s << " values: " << assertString(rb.m_at) << "( " << rb.m_decomp << " )\n";
+ }
+ }
+
+ // TODO:
+ // - log_message()
+ // - respond to queries
+ // - honor remaining options
+ // - more attributes in tags
+ struct JUnitReporter : public IReporter
+ {
+ XmlWriter xml;
+ std::mutex mutex;
+ Timer timer;
+ std::vector<String> deepestSubcaseStackNames;
+
+ struct JUnitTestCaseData
+ {
+ static std::string getCurrentTimestamp() {
+ // Beware, this is not reentrant because of backward compatibility issues
+ // Also, UTC only, again because of backward compatibility (%z is C++11)
+ time_t rawtime;
+ std::time(&rawtime);
+ auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
+
+ std::tm timeInfo;
+#ifdef DOCTEST_PLATFORM_WINDOWS
+ gmtime_s(&timeInfo, &rawtime);
+#else // DOCTEST_PLATFORM_WINDOWS
+ gmtime_r(&rawtime, &timeInfo);
+#endif // DOCTEST_PLATFORM_WINDOWS
+
+ char timeStamp[timeStampSize];
+ const char* const fmt = "%Y-%m-%dT%H:%M:%SZ";
+
+ std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
+ return std::string(timeStamp);
+ }
+
+ struct JUnitTestMessage
+ {
+ JUnitTestMessage(const std::string& _message, const std::string& _type, const std::string& _details)
+ : message(_message), type(_type), details(_details) {}
+
+ JUnitTestMessage(const std::string& _message, const std::string& _details)
+ : message(_message), type(), details(_details) {}
+
+ std::string message, type, details;
+ };
+
+ struct JUnitTestCase
+ {
+ JUnitTestCase(const std::string& _classname, const std::string& _name)
+ : classname(_classname), name(_name), time(0), failures() {}
+
+ std::string classname, name;
+ double time;
+ std::vector<JUnitTestMessage> failures, errors;
+ };
+
+ void add(const std::string& classname, const std::string& name) {
+ testcases.emplace_back(classname, name);
+ }
+
+ void appendSubcaseNamesToLastTestcase(std::vector<String> nameStack) {
+ for(auto& curr: nameStack)
+ if(curr.size())
+ testcases.back().name += std::string("/") + curr.c_str();
+ }
+
+ void addTime(double time) {
+ if(time < 1e-4)
+ time = 0;
+ testcases.back().time = time;
+ totalSeconds += time;
+ }
+
+ void addFailure(const std::string& message, const std::string& type, const std::string& details) {
+ testcases.back().failures.emplace_back(message, type, details);
+ ++totalFailures;
+ }
+
+ void addError(const std::string& message, const std::string& details) {
+ testcases.back().errors.emplace_back(message, details);
+ ++totalErrors;
+ }
+
+ std::vector<JUnitTestCase> testcases;
+ double totalSeconds = 0;
+ int totalErrors = 0, totalFailures = 0;
+ };
+
+ JUnitTestCaseData testCaseData;
+
+ // caching pointers/references to objects of these types - safe to do
+ const ContextOptions& opt;
+ const TestCaseData* tc = nullptr;
+
+ JUnitReporter(const ContextOptions& co)
+ : xml(*co.cout)
+ , opt(co) {}
+
+ unsigned line(unsigned l) const { return opt.no_line_numbers ? 0 : l; }
+
+ // =========================================================================================
+ // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE
+ // =========================================================================================
+
+ void report_query(const QueryData&) override {}
+
+ void test_run_start() override {}
+
+ void test_run_end(const TestRunStats& p) override {
+ // remove .exe extension - mainly to have the same output on UNIX and Windows
+ std::string binary_name = skipPathFromFilename(opt.binary_name.c_str());
+#ifdef DOCTEST_PLATFORM_WINDOWS
+ if(binary_name.rfind(".exe") != std::string::npos)
+ binary_name = binary_name.substr(0, binary_name.length() - 4);
+#endif // DOCTEST_PLATFORM_WINDOWS
+ xml.startElement("testsuites");
+ xml.startElement("testsuite").writeAttribute("name", binary_name)
+ .writeAttribute("errors", testCaseData.totalErrors)
+ .writeAttribute("failures", testCaseData.totalFailures)
+ .writeAttribute("tests", p.numAsserts);
+ if(opt.no_time_in_output == false) {
+ xml.writeAttribute("time", testCaseData.totalSeconds);
+ xml.writeAttribute("timestamp", JUnitTestCaseData::getCurrentTimestamp());
+ }
+ if(opt.no_version == false)
+ xml.writeAttribute("doctest_version", DOCTEST_VERSION_STR);
+
+ for(const auto& testCase : testCaseData.testcases) {
+ xml.startElement("testcase")
+ .writeAttribute("classname", testCase.classname)
+ .writeAttribute("name", testCase.name);
+ if(opt.no_time_in_output == false)
+ xml.writeAttribute("time", testCase.time);
+ // This is not ideal, but it should be enough to mimic gtest's junit output.
+ xml.writeAttribute("status", "run");
+
+ for(const auto& failure : testCase.failures) {
+ xml.scopedElement("failure")
+ .writeAttribute("message", failure.message)
+ .writeAttribute("type", failure.type)
+ .writeText(failure.details, false);
+ }
+
+ for(const auto& error : testCase.errors) {
+ xml.scopedElement("error")
+ .writeAttribute("message", error.message)
+ .writeText(error.details);
+ }
+
+ xml.endElement();
+ }
+ xml.endElement();
+ xml.endElement();
+ }
+
+ void test_case_start(const TestCaseData& in) override {
+ testCaseData.add(skipPathFromFilename(in.m_file.c_str()), in.m_name);
+ timer.start();
+ }
+
+ void test_case_reenter(const TestCaseData& in) override {
+ testCaseData.addTime(timer.getElapsedSeconds());
+ testCaseData.appendSubcaseNamesToLastTestcase(deepestSubcaseStackNames);
+ deepestSubcaseStackNames.clear();
+
+ timer.start();
+ testCaseData.add(skipPathFromFilename(in.m_file.c_str()), in.m_name);
+ }
+
+ void test_case_end(const CurrentTestCaseStats&) override {
+ testCaseData.addTime(timer.getElapsedSeconds());
+ testCaseData.appendSubcaseNamesToLastTestcase(deepestSubcaseStackNames);
+ deepestSubcaseStackNames.clear();
+ }
+
+ void test_case_exception(const TestCaseException& e) override {
+ std::lock_guard<std::mutex> lock(mutex);
+ testCaseData.addError("exception", e.error_string.c_str());
+ }
+
+ void subcase_start(const SubcaseSignature& in) override {
+ std::lock_guard<std::mutex> lock(mutex);
+ deepestSubcaseStackNames.push_back(in.m_name);
+ }
+
+ void subcase_end() override {}
+
+ void log_assert(const AssertData& rb) override {
+ if(!rb.m_failed) // report only failures & ignore the `success` option
+ return;
+
+ std::lock_guard<std::mutex> lock(mutex);
+
+ std::ostringstream os;
+ os << skipPathFromFilename(rb.m_file) << (opt.gnu_file_line ? ":" : "(")
+ << line(rb.m_line) << (opt.gnu_file_line ? ":" : "):") << std::endl;
+
+ fulltext_log_assert_to_stream(os, rb);
+ log_contexts(os);
+ testCaseData.addFailure(rb.m_decomp.c_str(), assertString(rb.m_at), os.str());
+ }
+
+ void log_message(const MessageData&) override {}
+
+ void test_case_skipped(const TestCaseData&) override {}
+
+ void log_contexts(std::ostringstream& s) {
+ int num_contexts = get_num_active_contexts();
+ if(num_contexts) {
+ auto contexts = get_active_contexts();
+
+ s << " logged: ";
+ for(int i = 0; i < num_contexts; ++i) {
+ s << (i == 0 ? "" : " ");
+ contexts[i]->stringify(&s);
+ s << std::endl;
+ }
+ }
+ }
+ };
+
+ DOCTEST_REGISTER_REPORTER("junit", 0, JUnitReporter);
+
+ struct Whitespace
+ {
+ int nrSpaces;
+ explicit Whitespace(int nr)
+ : nrSpaces(nr) {}
+ };
+
+ std::ostream& operator<<(std::ostream& out, const Whitespace& ws) {
+ if(ws.nrSpaces != 0)
+ out << std::setw(ws.nrSpaces) << ' ';
+ return out;
+ }
+
+ struct ConsoleReporter : public IReporter
+ {
+ std::ostream& s;
+ bool hasLoggedCurrentTestStart;
+ std::vector<SubcaseSignature> subcasesStack;
+ size_t currentSubcaseLevel;
+ std::mutex mutex;
+
+ // caching pointers/references to objects of these types - safe to do
+ const ContextOptions& opt;
+ const TestCaseData* tc;
+
+ ConsoleReporter(const ContextOptions& co)
+ : s(*co.cout)
+ , opt(co) {}
+
+ ConsoleReporter(const ContextOptions& co, std::ostream& ostr)
+ : s(ostr)
+ , opt(co) {}
+
+ // =========================================================================================
+ // WHAT FOLLOWS ARE HELPERS USED BY THE OVERRIDES OF THE VIRTUAL METHODS OF THE INTERFACE
+ // =========================================================================================
+
+ void separator_to_stream() {
+ s << Color::Yellow
+ << "==============================================================================="
+ "\n";
+ }
+
+ const char* getSuccessOrFailString(bool success, assertType::Enum at,
+ const char* success_str) {
+ if(success)
+ return success_str;
+ return failureString(at);
+ }
+
+ Color::Enum getSuccessOrFailColor(bool success, assertType::Enum at) {
+ return success ? Color::BrightGreen :
+ (at & assertType::is_warn) ? Color::Yellow : Color::Red;
+ }
+
+ void successOrFailColoredStringToStream(bool success, assertType::Enum at,
+ const char* success_str = "SUCCESS") {
+ s << getSuccessOrFailColor(success, at)
+ << getSuccessOrFailString(success, at, success_str) << ": ";
+ }
+
+ void log_contexts() {
+ int num_contexts = get_num_active_contexts();
+ if(num_contexts) {
+ auto contexts = get_active_contexts();
+
+ s << Color::None << " logged: ";
+ for(int i = 0; i < num_contexts; ++i) {
+ s << (i == 0 ? "" : " ");
+ contexts[i]->stringify(&s);
+ s << "\n";
+ }
+ }
+
+ s << "\n";
+ }
+
+ // this was requested to be made virtual so users could override it
+ virtual void file_line_to_stream(const char* file, int line,
+ const char* tail = "") {
+ s << Color::LightGrey << skipPathFromFilename(file) << (opt.gnu_file_line ? ":" : "(")
+ << (opt.no_line_numbers ? 0 : line) // 0 or the real num depending on the option
+ << (opt.gnu_file_line ? ":" : "):") << tail;
+ }
+
+ void logTestStart() {
+ if(hasLoggedCurrentTestStart)
+ return;
+
+ separator_to_stream();
+ file_line_to_stream(tc->m_file.c_str(), tc->m_line, "\n");
+ if(tc->m_description)
+ s << Color::Yellow << "DESCRIPTION: " << Color::None << tc->m_description << "\n";
+ if(tc->m_test_suite && tc->m_test_suite[0] != '\0')
+ s << Color::Yellow << "TEST SUITE: " << Color::None << tc->m_test_suite << "\n";
+ if(strncmp(tc->m_name, " Scenario:", 11) != 0)
+ s << Color::Yellow << "TEST CASE: ";
+ s << Color::None << tc->m_name << "\n";
+
+ for(size_t i = 0; i < currentSubcaseLevel; ++i) {
+ if(subcasesStack[i].m_name[0] != '\0')
+ s << " " << subcasesStack[i].m_name << "\n";
+ }
+
+ if(currentSubcaseLevel != subcasesStack.size()) {
+ s << Color::Yellow << "\nDEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE):\n" << Color::None;
+ for(size_t i = 0; i < subcasesStack.size(); ++i) {
+ if(subcasesStack[i].m_name[0] != '\0')
+ s << " " << subcasesStack[i].m_name << "\n";
+ }
+ }
+
+ s << "\n";
+
+ hasLoggedCurrentTestStart = true;
+ }
+
+ void printVersion() {
+ if(opt.no_version == false)
+ s << Color::Cyan << "[doctest] " << Color::None << "doctest version is \""
+ << DOCTEST_VERSION_STR << "\"\n";
+ }
+
+ void printIntro() {
+ printVersion();
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "run with \"--" DOCTEST_OPTIONS_PREFIX_DISPLAY "help\" for options\n";
+ }
+
+ void printHelp() {
+ int sizePrefixDisplay = static_cast<int>(strlen(DOCTEST_OPTIONS_PREFIX_DISPLAY));
+ printVersion();
+ // clang-format off
+ s << Color::Cyan << "[doctest]\n" << Color::None;
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "boolean values: \"1/on/yes/true\" or \"0/off/no/false\"\n";
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "filter values: \"str1,str2,str3\" (comma separated strings)\n";
+ s << Color::Cyan << "[doctest]\n" << Color::None;
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "filters use wildcards for matching strings\n";
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "something passes a filter if any of the strings in a filter matches\n";
+#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
+ s << Color::Cyan << "[doctest]\n" << Color::None;
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A \"" DOCTEST_CONFIG_OPTIONS_PREFIX "\" PREFIX!!!\n";
+#endif
+ s << Color::Cyan << "[doctest]\n" << Color::None;
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "Query flags - the program quits after them. Available:\n\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "?, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "help, -" DOCTEST_OPTIONS_PREFIX_DISPLAY "h "
+ << Whitespace(sizePrefixDisplay*0) << "prints this message\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "v, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "version "
+ << Whitespace(sizePrefixDisplay*1) << "prints the version\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "c, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "count "
+ << Whitespace(sizePrefixDisplay*1) << "prints the number of matching tests\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ltc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-cases "
+ << Whitespace(sizePrefixDisplay*1) << "lists all matching tests by name\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-suites "
+ << Whitespace(sizePrefixDisplay*1) << "lists all matching test suites\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-reporters "
+ << Whitespace(sizePrefixDisplay*1) << "lists all registered reporters\n\n";
+ // ================================================================================== << 79
+ s << Color::Cyan << "[doctest] " << Color::None;
+ s << "The available <int>/<string> options/filters are:\n\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters tests by their name\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case-exclude=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their name\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters tests by their file\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sfe, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file-exclude=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their file\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters tests by their test suite\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tse, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite-exclude=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their test suite\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters subcases by their name\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-exclude=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "filters OUT subcases by their name\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "r, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "reporters=<filters> "
+ << Whitespace(sizePrefixDisplay*1) << "reporters to use (console is default)\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "o, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "out=<string> "
+ << Whitespace(sizePrefixDisplay*1) << "output filename\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by=<string> "
+ << Whitespace(sizePrefixDisplay*1) << "how the tests should be ordered\n";
+ s << Whitespace(sizePrefixDisplay*3) << " <string> - [file/suite/name/rand/none]\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "rand-seed=<int> "
+ << Whitespace(sizePrefixDisplay*1) << "seed for random ordering\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "first=<int> "
+ << Whitespace(sizePrefixDisplay*1) << "the first test passing the filters to\n";
+ s << Whitespace(sizePrefixDisplay*3) << " execute - for range-based execution\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "l, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "last=<int> "
+ << Whitespace(sizePrefixDisplay*1) << "the last test passing the filters to\n";
+ s << Whitespace(sizePrefixDisplay*3) << " execute - for range-based execution\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "aa, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "abort-after=<int> "
+ << Whitespace(sizePrefixDisplay*1) << "stop after <int> failed assertions\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "scfl,--" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-filter-levels=<int> "
+ << Whitespace(sizePrefixDisplay*1) << "apply filters for the first <int> levels\n";
+ s << Color::Cyan << "\n[doctest] " << Color::None;
+ s << "Bool options - can be used like flags and true is assumed. Available:\n\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "s, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "success=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "include successful assertions in output\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "cs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "case-sensitive=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "filters being treated as case sensitive\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "e, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "exit=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "exits after the tests finish\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "d, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "duration=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "prints the time duration of each test\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nt, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-throw=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "skips exceptions-related assert checks\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ne, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-exitcode=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "returns (or exits) always with success\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-run=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "skips all runtime doctest operations\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nv, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-version=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "omit the framework version in the output\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-colors=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "disables colors in output\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "fc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "force-colors=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "use colors even when not in a tty\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nb, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-breaks=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "disables breakpoints in debuggers\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ns, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-skip=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "don't skip test cases marked as skip\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "gfl, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "gnu-file-line=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << ":n: vs (n): for line numbers in output\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-path-filenames=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "only filenames and no paths in output\n";
+ s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-line-numbers=<bool> "
+ << Whitespace(sizePrefixDisplay*1) << "0 instead of real line numbers in output\n";
+ // ================================================================================== << 79
+ // clang-format on
+
+ s << Color::Cyan << "\n[doctest] " << Color::None;
+ s << "for more information visit the project documentation\n\n";
+ }
+
+ void printRegisteredReporters() {
+ printVersion();
+ auto printReporters = [this] (const reporterMap& reporters, const char* type) {
+ if(reporters.size()) {
+ s << Color::Cyan << "[doctest] " << Color::None << "listing all registered " << type << "\n";
+ for(auto& curr : reporters)
+ s << "priority: " << std::setw(5) << curr.first.first
+ << " name: " << curr.first.second << "\n";
+ }
+ };
+ printReporters(getListeners(), "listeners");
+ printReporters(getReporters(), "reporters");
+ }
+
+ void list_query_results() {
+ separator_to_stream();
+ if(opt.count || opt.list_test_cases) {
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "unskipped test cases passing the current filters: "
+ << g_cs->numTestCasesPassingFilters << "\n";
+ } else if(opt.list_test_suites) {
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "unskipped test cases passing the current filters: "
+ << g_cs->numTestCasesPassingFilters << "\n";
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "test suites with unskipped test cases passing the current filters: "
+ << g_cs->numTestSuitesPassingFilters << "\n";
+ }
+ }
+
+ // =========================================================================================
+ // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE
+ // =========================================================================================
+
+ void report_query(const QueryData& in) override {
+ if(opt.version) {
+ printVersion();
+ } else if(opt.help) {
+ printHelp();
+ } else if(opt.list_reporters) {
+ printRegisteredReporters();
+ } else if(opt.count || opt.list_test_cases) {
+ if(opt.list_test_cases) {
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "listing all test case names\n";
+ separator_to_stream();
+ }
+
+ for(unsigned i = 0; i < in.num_data; ++i)
+ s << Color::None << in.data[i]->m_name << "\n";
+
+ separator_to_stream();
+
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "unskipped test cases passing the current filters: "
+ << g_cs->numTestCasesPassingFilters << "\n";
+
+ } else if(opt.list_test_suites) {
+ s << Color::Cyan << "[doctest] " << Color::None << "listing all test suites\n";
+ separator_to_stream();
+
+ for(unsigned i = 0; i < in.num_data; ++i)
+ s << Color::None << in.data[i]->m_test_suite << "\n";
+
+ separator_to_stream();
+
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "unskipped test cases passing the current filters: "
+ << g_cs->numTestCasesPassingFilters << "\n";
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "test suites with unskipped test cases passing the current filters: "
+ << g_cs->numTestSuitesPassingFilters << "\n";
+ }
+ }
+
+ void test_run_start() override { printIntro(); }
+
+ void test_run_end(const TestRunStats& p) override {
+ separator_to_stream();
+ s << std::dec;
+
+ auto totwidth = int(std::ceil(log10((std::max(p.numTestCasesPassingFilters, static_cast<unsigned>(p.numAsserts))) + 1)));
+ auto passwidth = int(std::ceil(log10((std::max(p.numTestCasesPassingFilters - p.numTestCasesFailed, static_cast<unsigned>(p.numAsserts - p.numAssertsFailed))) + 1)));
+ auto failwidth = int(std::ceil(log10((std::max(p.numTestCasesFailed, static_cast<unsigned>(p.numAssertsFailed))) + 1)));
+ const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0;
+ s << Color::Cyan << "[doctest] " << Color::None << "test cases: " << std::setw(totwidth)
+ << p.numTestCasesPassingFilters << " | "
+ << ((p.numTestCasesPassingFilters == 0 || anythingFailed) ? Color::None :
+ Color::Green)
+ << std::setw(passwidth) << p.numTestCasesPassingFilters - p.numTestCasesFailed << " passed"
+ << Color::None << " | " << (p.numTestCasesFailed > 0 ? Color::Red : Color::None)
+ << std::setw(failwidth) << p.numTestCasesFailed << " failed" << Color::None << " |";
+ if(opt.no_skipped_summary == false) {
+ const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters;
+ s << " " << (numSkipped == 0 ? Color::None : Color::Yellow) << numSkipped
+ << " skipped" << Color::None;
+ }
+ s << "\n";
+ s << Color::Cyan << "[doctest] " << Color::None << "assertions: " << std::setw(totwidth)
+ << p.numAsserts << " | "
+ << ((p.numAsserts == 0 || anythingFailed) ? Color::None : Color::Green)
+ << std::setw(passwidth) << (p.numAsserts - p.numAssertsFailed) << " passed" << Color::None
+ << " | " << (p.numAssertsFailed > 0 ? Color::Red : Color::None) << std::setw(failwidth)
+ << p.numAssertsFailed << " failed" << Color::None << " |\n";
+ s << Color::Cyan << "[doctest] " << Color::None
+ << "Status: " << (p.numTestCasesFailed > 0 ? Color::Red : Color::Green)
+ << ((p.numTestCasesFailed > 0) ? "FAILURE!" : "SUCCESS!") << Color::None << std::endl;
+ }
+
+ void test_case_start(const TestCaseData& in) override {
+ hasLoggedCurrentTestStart = false;
+ tc = &in;
+ subcasesStack.clear();
+ currentSubcaseLevel = 0;
+ }
+
+ void test_case_reenter(const TestCaseData&) override {
+ subcasesStack.clear();
+ }
+
+ void test_case_end(const CurrentTestCaseStats& st) override {
+ if(tc->m_no_output)
+ return;
+
+ // log the preamble of the test case only if there is something
+ // else to print - something other than that an assert has failed
+ if(opt.duration ||
+ (st.failure_flags && st.failure_flags != TestCaseFailureReason::AssertFailure))
+ logTestStart();
+
+ if(opt.duration)
+ s << Color::None << std::setprecision(6) << std::fixed << st.seconds
+ << " s: " << tc->m_name << "\n";
+
+ if(st.failure_flags & TestCaseFailureReason::Timeout)
+ s << Color::Red << "Test case exceeded time limit of " << std::setprecision(6)
+ << std::fixed << tc->m_timeout << "!\n";
+
+ if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedButDidnt) {
+ s << Color::Red << "Should have failed but didn't! Marking it as failed!\n";
+ } else if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedAndDid) {
+ s << Color::Yellow << "Failed as expected so marking it as not failed\n";
+ } else if(st.failure_flags & TestCaseFailureReason::CouldHaveFailedAndDid) {
+ s << Color::Yellow << "Allowed to fail so marking it as not failed\n";
+ } else if(st.failure_flags & TestCaseFailureReason::DidntFailExactlyNumTimes) {
+ s << Color::Red << "Didn't fail exactly " << tc->m_expected_failures
+ << " times so marking it as failed!\n";
+ } else if(st.failure_flags & TestCaseFailureReason::FailedExactlyNumTimes) {
+ s << Color::Yellow << "Failed exactly " << tc->m_expected_failures
+ << " times as expected so marking it as not failed!\n";
+ }
+ if(st.failure_flags & TestCaseFailureReason::TooManyFailedAsserts) {
+ s << Color::Red << "Aborting - too many failed asserts!\n";
+ }
+ s << Color::None; // lgtm [cpp/useless-expression]
+ }
+
+ void test_case_exception(const TestCaseException& e) override {
+ if(tc->m_no_output)
+ return;
+
+ logTestStart();
+
+ file_line_to_stream(tc->m_file.c_str(), tc->m_line, " ");
+ successOrFailColoredStringToStream(false, e.is_crash ? assertType::is_require :
+ assertType::is_check);
+ s << Color::Red << (e.is_crash ? "test case CRASHED: " : "test case THREW exception: ")
+ << Color::Cyan << e.error_string << "\n";
+
+ int num_stringified_contexts = get_num_stringified_contexts();
+ if(num_stringified_contexts) {
+ auto stringified_contexts = get_stringified_contexts();
+ s << Color::None << " logged: ";
+ for(int i = num_stringified_contexts; i > 0; --i) {
+ s << (i == num_stringified_contexts ? "" : " ")
+ << stringified_contexts[i - 1] << "\n";
+ }
+ }
+ s << "\n" << Color::None;
+ }
+
+ void subcase_start(const SubcaseSignature& subc) override {
+ std::lock_guard<std::mutex> lock(mutex);
+ subcasesStack.push_back(subc);
+ ++currentSubcaseLevel;
+ hasLoggedCurrentTestStart = false;
+ }
+
+ void subcase_end() override {
+ std::lock_guard<std::mutex> lock(mutex);
+ --currentSubcaseLevel;
+ hasLoggedCurrentTestStart = false;
+ }
+
+ void log_assert(const AssertData& rb) override {
+ if((!rb.m_failed && !opt.success) || tc->m_no_output)
+ return;
+
+ std::lock_guard<std::mutex> lock(mutex);
+
+ logTestStart();
+
+ file_line_to_stream(rb.m_file, rb.m_line, " ");
+ successOrFailColoredStringToStream(!rb.m_failed, rb.m_at);
+
+ fulltext_log_assert_to_stream(s, rb);
+
+ log_contexts();
+ }
+
+ void log_message(const MessageData& mb) override {
+ if(tc->m_no_output)
+ return;
+
+ std::lock_guard<std::mutex> lock(mutex);
+
+ logTestStart();
+
+ file_line_to_stream(mb.m_file, mb.m_line, " ");
+ s << getSuccessOrFailColor(false, mb.m_severity)
+ << getSuccessOrFailString(mb.m_severity & assertType::is_warn, mb.m_severity,
+ "MESSAGE") << ": ";
+ s << Color::None << mb.m_string << "\n";
+ log_contexts();
+ }
+
+ void test_case_skipped(const TestCaseData&) override {}
+ };
+
+ DOCTEST_REGISTER_REPORTER("console", 0, ConsoleReporter);
+
+#ifdef DOCTEST_PLATFORM_WINDOWS
+ struct DebugOutputWindowReporter : public ConsoleReporter
+ {
+ DOCTEST_THREAD_LOCAL static std::ostringstream oss;
+
+ DebugOutputWindowReporter(const ContextOptions& co)
+ : ConsoleReporter(co, oss) {}
+
+#define DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(func, type, arg) \
+ void func(type arg) override { \
+ bool with_col = g_no_colors; \
+ g_no_colors = false; \
+ ConsoleReporter::func(arg); \
+ if(oss.tellp() != std::streampos{}) { \
+ DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \
+ oss.str(""); \
+ } \
+ g_no_colors = with_col; \
+ }
+
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_start, DOCTEST_EMPTY, DOCTEST_EMPTY)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_end, const TestRunStats&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_start, const TestCaseData&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_reenter, const TestCaseData&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_end, const CurrentTestCaseStats&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_exception, const TestCaseException&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_start, const SubcaseSignature&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_end, DOCTEST_EMPTY, DOCTEST_EMPTY)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_assert, const AssertData&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_message, const MessageData&, in)
+ DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_skipped, const TestCaseData&, in)
+ };
+
+ DOCTEST_THREAD_LOCAL std::ostringstream DebugOutputWindowReporter::oss;
+#endif // DOCTEST_PLATFORM_WINDOWS
+
+ // the implementation of parseOption()
+ bool parseOptionImpl(int argc, const char* const* argv, const char* pattern, String* value) {
+ // going from the end to the beginning and stopping on the first occurrence from the end
+ for(int i = argc; i > 0; --i) {
+ auto index = i - 1;
+ auto temp = std::strstr(argv[index], pattern);
+ if(temp && (value || strlen(temp) == strlen(pattern))) { //!OCLINT prefer early exits and continue
+ // eliminate matches in which the chars before the option are not '-'
+ bool noBadCharsFound = true;
+ auto curr = argv[index];
+ while(curr != temp) {
+ if(*curr++ != '-') {
+ noBadCharsFound = false;
+ break;
+ }
+ }
+ if(noBadCharsFound && argv[index][0] == '-') {
+ if(value) {
+ // parsing the value of an option
+ temp += strlen(pattern);
+ const unsigned len = strlen(temp);
+ if(len) {
+ *value = temp;
+ return true;
+ }
+ } else {
+ // just a flag - no value
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ // parses an option and returns the string after the '=' character
+ bool parseOption(int argc, const char* const* argv, const char* pattern, String* value = nullptr,
+ const String& defaultVal = String()) {
+ if(value)
+ *value = defaultVal;
+#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
+ // offset (normally 3 for "dt-") to skip prefix
+ if(parseOptionImpl(argc, argv, pattern + strlen(DOCTEST_CONFIG_OPTIONS_PREFIX), value))
+ return true;
+#endif // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
+ return parseOptionImpl(argc, argv, pattern, value);
+ }
+
+ // locates a flag on the command line
+ bool parseFlag(int argc, const char* const* argv, const char* pattern) {
+ return parseOption(argc, argv, pattern);
+ }
+
+ // parses a comma separated list of words after a pattern in one of the arguments in argv
+ bool parseCommaSepArgs(int argc, const char* const* argv, const char* pattern,
+ std::vector<String>& res) {
+ String filtersString;
+ if(parseOption(argc, argv, pattern, &filtersString)) {
+ // tokenize with "," as a separator
+ // cppcheck-suppress strtokCalled
+ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations")
+ auto pch = std::strtok(filtersString.c_str(), ","); // modifies the string
+ while(pch != nullptr) {
+ if(strlen(pch))
+ res.push_back(pch);
+ // uses the strtok() internal state to go to the next token
+ // cppcheck-suppress strtokCalled
+ pch = std::strtok(nullptr, ",");
+ }
+ DOCTEST_CLANG_SUPPRESS_WARNING_POP
+ return true;
+ }
+ return false;
+ }
+
+ enum optionType
+ {
+ option_bool,
+ option_int
+ };
+
+ // parses an int/bool option from the command line
+ bool parseIntOption(int argc, const char* const* argv, const char* pattern, optionType type,
+ int& res) {
+ String parsedValue;
+ if(!parseOption(argc, argv, pattern, &parsedValue))
+ return false;
+
+ if(type == 0) {
+ // boolean
+ const char positive[][5] = {"1", "true", "on", "yes"}; // 5 - strlen("true") + 1
+ const char negative[][6] = {"0", "false", "off", "no"}; // 6 - strlen("false") + 1
+
+ // if the value matches any of the positive/negative possibilities
+ for(unsigned i = 0; i < 4; i++) {
+ if(parsedValue.compare(positive[i], true) == 0) {
+ res = 1; //!OCLINT parameter reassignment
+ return true;
+ }
+ if(parsedValue.compare(negative[i], true) == 0) {
+ res = 0; //!OCLINT parameter reassignment
+ return true;
+ }
+ }
+ } else {
+ // integer
+ // TODO: change this to use std::stoi or something else! currently it uses undefined behavior - assumes '0' on failed parse...
+ int theInt = std::atoi(parsedValue.c_str()); // NOLINT
+ if(theInt != 0) {
+ res = theInt; //!OCLINT parameter reassignment
+ return true;
+ }
+ }
+ return false;
+ }
+} // namespace
+
+Context::Context(int argc, const char* const* argv)
+ : p(new detail::ContextState) {
+ parseArgs(argc, argv, true);
+ if(argc)
+ p->binary_name = argv[0];
+}
+
+Context::~Context() {
+ if(g_cs == p)
+ g_cs = nullptr;
+ delete p;
+}
+
+void Context::applyCommandLine(int argc, const char* const* argv) {
+ parseArgs(argc, argv);
+ if(argc)
+ p->binary_name = argv[0];
+}
+
+// parses args
+void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) {
+ using namespace detail;
+
+ // clang-format off
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file=", p->filters[0]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sf=", p->filters[0]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file-exclude=",p->filters[1]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sfe=", p->filters[1]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite=", p->filters[2]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ts=", p->filters[2]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite-exclude=", p->filters[3]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tse=", p->filters[3]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case=", p->filters[4]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tc=", p->filters[4]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case-exclude=", p->filters[5]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tce=", p->filters[5]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase=", p->filters[6]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sc=", p->filters[6]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase-exclude=", p->filters[7]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sce=", p->filters[7]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "reporters=", p->filters[8]);
+ parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "r=", p->filters[8]);
+ // clang-format on
+
+ int intRes = 0;
+ String strRes;
+
+#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \
+ if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_bool, intRes) || \
+ parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_bool, intRes)) \
+ p->var = static_cast<bool>(intRes); \
+ else if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name) || \
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname)) \
+ p->var = true; \
+ else if(withDefaults) \
+ p->var = default
+
+#define DOCTEST_PARSE_INT_OPTION(name, sname, var, default) \
+ if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_int, intRes) || \
+ parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_int, intRes)) \
+ p->var = intRes; \
+ else if(withDefaults) \
+ p->var = default
+
+#define DOCTEST_PARSE_STR_OPTION(name, sname, var, default) \
+ if(parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", &strRes, default) || \
+ parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", &strRes, default) || \
+ withDefaults) \
+ p->var = strRes
+
+ // clang-format off
+ DOCTEST_PARSE_STR_OPTION("out", "o", out, "");
+ DOCTEST_PARSE_STR_OPTION("order-by", "ob", order_by, "file");
+ DOCTEST_PARSE_INT_OPTION("rand-seed", "rs", rand_seed, 0);
+
+ DOCTEST_PARSE_INT_OPTION("first", "f", first, 0);
+ DOCTEST_PARSE_INT_OPTION("last", "l", last, UINT_MAX);
+
+ DOCTEST_PARSE_INT_OPTION("abort-after", "aa", abort_after, 0);
+ DOCTEST_PARSE_INT_OPTION("subcase-filter-levels", "scfl", subcase_filter_levels, INT_MAX);
+
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("success", "s", success, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("case-sensitive", "cs", case_sensitive, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("exit", "e", exit, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("duration", "d", duration, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-throw", "nt", no_throw, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-exitcode", "ne", no_exitcode, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-run", "nr", no_run, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-version", "nv", no_version, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-colors", "nc", no_colors, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("force-colors", "fc", force_colors, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-breaks", "nb", no_breaks, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skip", "ns", no_skip, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("gnu-file-line", "gfl", gnu_file_line, !bool(DOCTEST_MSVC));
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-path-filenames", "npf", no_path_in_filenames, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-line-numbers", "nln", no_line_numbers, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-debug-output", "ndo", no_debug_output, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skipped-summary", "nss", no_skipped_summary, false);
+ DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-time-in-output", "ntio", no_time_in_output, false);
+ // clang-format on
+
+ if(withDefaults) {
+ p->help = false;
+ p->version = false;
+ p->count = false;
+ p->list_test_cases = false;
+ p->list_test_suites = false;
+ p->list_reporters = false;
+ }
+ if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "help") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "h") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "?")) {
+ p->help = true;
+ p->exit = true;
+ }
+ if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "version") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "v")) {
+ p->version = true;
+ p->exit = true;
+ }
+ if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "count") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "c")) {
+ p->count = true;
+ p->exit = true;
+ }
+ if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-cases") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ltc")) {
+ p->list_test_cases = true;
+ p->exit = true;
+ }
+ if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-suites") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "lts")) {
+ p->list_test_suites = true;
+ p->exit = true;
+ }
+ if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-reporters") ||
+ parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "lr")) {
+ p->list_reporters = true;
+ p->exit = true;
+ }
+}
+
+// allows the user to add procedurally to the filters from the command line
+void Context::addFilter(const char* filter, const char* value) { setOption(filter, value); }
+
+// allows the user to clear all filters from the command line
+void Context::clearFilters() {
+ for(auto& curr : p->filters)
+ curr.clear();
+}
+
+// allows the user to override procedurally the int/bool options from the command line
+void Context::setOption(const char* option, int value) {
+ setOption(option, toString(value).c_str());
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
+}
+
+// allows the user to override procedurally the string options from the command line
+void Context::setOption(const char* option, const char* value) {
+ auto argv = String("-") + option + "=" + value;
+ auto lvalue = argv.c_str();
+ parseArgs(1, &lvalue);
+}
+
+// users should query this in their main() and exit the program if true
+bool Context::shouldExit() { return p->exit; }
+
+void Context::setAsDefaultForAssertsOutOfTestCases() { g_cs = p; }
+
+void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; }
+
+// the main function that does all the filtering and test running
+int Context::run() {
+ using namespace detail;
+
+ // save the old context state in case such was setup - for using asserts out of a testing context
+ auto old_cs = g_cs;
+ // this is the current contest
+ g_cs = p;
+ is_running_in_test = true;
+
+ g_no_colors = p->no_colors;
+ p->resetRunData();
+
+ // stdout by default
+ p->cout = &std::cout;
+ p->cerr = &std::cerr;
+
+ // or to a file if specified
+ std::fstream fstr;
+ if(p->out.size()) {
+ fstr.open(p->out.c_str(), std::fstream::out);
+ p->cout = &fstr;
+ }
+
+ FatalConditionHandler::allocateAltStackMem();
+
+ auto cleanup_and_return = [&]() {
+ FatalConditionHandler::freeAltStackMem();
+
+ if(fstr.is_open())
+ fstr.close();
+
+ // restore context
+ g_cs = old_cs;
+ is_running_in_test = false;
+
+ // we have to free the reporters which were allocated when the run started
+ for(auto& curr : p->reporters_currently_used)
+ delete curr;
+ p->reporters_currently_used.clear();
+
+ if(p->numTestCasesFailed && !p->no_exitcode)
+ return EXIT_FAILURE;
+ return EXIT_SUCCESS;
+ };
+
+ // setup default reporter if none is given through the command line
+ if(p->filters[8].empty())
+ p->filters[8].push_back("console");
+
+ // check to see if any of the registered reporters has been selected
+ for(auto& curr : getReporters()) {
+ if(matchesAny(curr.first.second.c_str(), p->filters[8], false, p->case_sensitive))
+ p->reporters_currently_used.push_back(curr.second(*g_cs));
+ }
+
+ // TODO: check if there is nothing in reporters_currently_used
+
+ // prepend all listeners
+ for(auto& curr : getListeners())
+ p->reporters_currently_used.insert(p->reporters_currently_used.begin(), curr.second(*g_cs));
+
+#ifdef DOCTEST_PLATFORM_WINDOWS
+ if(isDebuggerActive() && p->no_debug_output == false)
+ p->reporters_currently_used.push_back(new DebugOutputWindowReporter(*g_cs));
+#endif // DOCTEST_PLATFORM_WINDOWS
+
+ // handle version, help and no_run
+ if(p->no_run || p->version || p->help || p->list_reporters) {
+ DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, QueryData());
+
+ return cleanup_and_return();
+ }
+
+ std::vector<const TestCase*> testArray;
+ for(auto& curr : getRegisteredTests())
+ testArray.push_back(&curr);
+ p->numTestCases = testArray.size();
+
+ // sort the collected records
+ if(!testArray.empty()) {
+ if(p->order_by.compare("file", true) == 0) {
+ std::sort(testArray.begin(), testArray.end(), fileOrderComparator);
+ } else if(p->order_by.compare("suite", true) == 0) {
+ std::sort(testArray.begin(), testArray.end(), suiteOrderComparator);
+ } else if(p->order_by.compare("name", true) == 0) {
+ std::sort(testArray.begin(), testArray.end(), nameOrderComparator);
+ } else if(p->order_by.compare("rand", true) == 0) {
+ std::srand(p->rand_seed);
+
+ // random_shuffle implementation
+ const auto first = &testArray[0];
+ for(size_t i = testArray.size() - 1; i > 0; --i) {
+ int idxToSwap = std::rand() % (i + 1); // NOLINT
+
+ const auto temp = first[i];
+
+ first[i] = first[idxToSwap];
+ first[idxToSwap] = temp;
+ }
+ } else if(p->order_by.compare("none", true) == 0) {
+ // means no sorting - beneficial for death tests which call into the executable
+ // with a specific test case in mind - we don't want to slow down the startup times
+ }
+ }
+
+ std::set<String> testSuitesPassingFilt;
+
+ bool query_mode = p->count || p->list_test_cases || p->list_test_suites;
+ std::vector<const TestCaseData*> queryResults;
+
+ if(!query_mode)
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, DOCTEST_EMPTY);
+
+ // invoke the registered functions if they match the filter criteria (or just count them)
+ for(auto& curr : testArray) {
+ const auto& tc = *curr;
+
+ bool skip_me = false;
+ if(tc.m_skip && !p->no_skip)
+ skip_me = true;
+
+ if(!matchesAny(tc.m_file.c_str(), p->filters[0], true, p->case_sensitive))
+ skip_me = true;
+ if(matchesAny(tc.m_file.c_str(), p->filters[1], false, p->case_sensitive))
+ skip_me = true;
+ if(!matchesAny(tc.m_test_suite, p->filters[2], true, p->case_sensitive))
+ skip_me = true;
+ if(matchesAny(tc.m_test_suite, p->filters[3], false, p->case_sensitive))
+ skip_me = true;
+ if(!matchesAny(tc.m_name, p->filters[4], true, p->case_sensitive))
+ skip_me = true;
+ if(matchesAny(tc.m_name, p->filters[5], false, p->case_sensitive))
+ skip_me = true;
+
+ if(!skip_me)
+ p->numTestCasesPassingFilters++;
+
+ // skip the test if it is not in the execution range
+ if((p->last < p->numTestCasesPassingFilters && p->first <= p->last) ||
+ (p->first > p->numTestCasesPassingFilters))
+ skip_me = true;
+
+ if(skip_me) {
+ if(!query_mode)
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_skipped, tc);
+ continue;
+ }
+
+ // do not execute the test if we are to only count the number of filter passing tests
+ if(p->count)
+ continue;
+
+ // print the name of the test and don't execute it
+ if(p->list_test_cases) {
+ queryResults.push_back(&tc);
+ continue;
+ }
+
+ // print the name of the test suite if not done already and don't execute it
+ if(p->list_test_suites) {
+ if((testSuitesPassingFilt.count(tc.m_test_suite) == 0) && tc.m_test_suite[0] != '\0') {
+ queryResults.push_back(&tc);
+ testSuitesPassingFilt.insert(tc.m_test_suite);
+ p->numTestSuitesPassingFilters++;
+ }
+ continue;
+ }
+
+ // execute the test if it passes all the filtering
+ {
+ p->currentTest = &tc;
+
+ p->failure_flags = TestCaseFailureReason::None;
+ p->seconds = 0;
+
+ // reset atomic counters
+ p->numAssertsFailedCurrentTest_atomic = 0;
+ p->numAssertsCurrentTest_atomic = 0;
+
+ p->subcasesPassed.clear();
+
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_start, tc);
+
+ p->timer.start();
+
+ bool run_test = true;
+
+ do {
+ // reset some of the fields for subcases (except for the set of fully passed ones)
+ p->should_reenter = false;
+ p->subcasesCurrentMaxLevel = 0;
+ p->subcasesStack.clear();
+
+ p->shouldLogCurrentException = true;
+
+ // reset stuff for logging with INFO()
+ p->stringifiedContexts.clear();
+
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ try {
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+// MSVC 2015 diagnoses fatalConditionHandler as unused (because reset() is a static method)
+DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4101) // unreferenced local variable
+ FatalConditionHandler fatalConditionHandler; // Handle signals
+ // execute the test
+ tc.m_test();
+ fatalConditionHandler.reset();
+DOCTEST_MSVC_SUPPRESS_WARNING_POP
+#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
+ } catch(const TestFailureException&) {
+ p->failure_flags |= TestCaseFailureReason::AssertFailure;
+ } catch(...) {
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception,
+ {translateActiveException(), false});
+ p->failure_flags |= TestCaseFailureReason::Exception;
+ }
+#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
+
+ // exit this loop if enough assertions have failed - even if there are more subcases
+ if(p->abort_after > 0 &&
+ p->numAssertsFailed + p->numAssertsFailedCurrentTest_atomic >= p->abort_after) {
+ run_test = false;
+ p->failure_flags |= TestCaseFailureReason::TooManyFailedAsserts;
+ }
+
+ if(p->should_reenter && run_test)
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_reenter, tc);
+ if(!p->should_reenter)
+ run_test = false;
+ } while(run_test);
+
+ p->finalizeTestCaseData();
+
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
+
+ p->currentTest = nullptr;
+
+ // stop executing tests if enough assertions have failed
+ if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after)
+ break;
+ }
+ }
+
+ if(!query_mode) {
+ DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
+ } else {
+ QueryData qdata;
+ qdata.run_stats = g_cs;
+ qdata.data = queryResults.data();
+ qdata.num_data = unsigned(queryResults.size());
+ DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, qdata);
+ }
+
+ // see these issues on the reasoning for this:
+ // - https://github.com/onqtam/doctest/issues/143#issuecomment-414418903
+ // - https://github.com/onqtam/doctest/issues/126
+ auto DOCTEST_FIX_FOR_MACOS_LIBCPP_IOSFWD_STRING_LINK_ERRORS = []() DOCTEST_NOINLINE
+ { std::cout << std::string(); };
+ DOCTEST_FIX_FOR_MACOS_LIBCPP_IOSFWD_STRING_LINK_ERRORS();
+
+ return cleanup_and_return();
+}
+
+IReporter::~IReporter() = default;
+
+int IReporter::get_num_active_contexts() { return detail::g_infoContexts.size(); }
+const IContextScope* const* IReporter::get_active_contexts() {
+ return get_num_active_contexts() ? &detail::g_infoContexts[0] : nullptr;
+}
+
+int IReporter::get_num_stringified_contexts() { return detail::g_cs->stringifiedContexts.size(); }
+const String* IReporter::get_stringified_contexts() {
+ return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr;
+}
+
+namespace detail {
+ void registerReporterImpl(const char* name, int priority, reporterCreatorFunc c, bool isReporter) {
+ if(isReporter)
+ getReporters().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c));
+ else
+ getListeners().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c));
+ }
+} // namespace detail
+
+} // namespace doctest
+
+#endif // DOCTEST_CONFIG_DISABLE
+
+#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007) // 'function' : must be 'attribute' - see issue #182
+int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); }
+DOCTEST_MSVC_SUPPRESS_WARNING_POP
+#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+
+DOCTEST_CLANG_SUPPRESS_WARNING_POP
+DOCTEST_MSVC_SUPPRESS_WARNING_POP
+DOCTEST_GCC_SUPPRESS_WARNING_POP
+
+#endif // DOCTEST_LIBRARY_IMPLEMENTATION
+#endif // DOCTEST_CONFIG_IMPLEMENT
diff --git a/Client/ThirdParty/Box2D/unit-test/hello_world.cpp b/Client/ThirdParty/Box2D/unit-test/hello_world.cpp
new file mode 100644
index 0000000..eecc01a
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/hello_world.cpp
@@ -0,0 +1,112 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/box2d.h"
+#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+#include "doctest.h"
+#include <stdio.h>
+
+// This is a simple example of building and running a simulation
+// using Box2D. Here we create a large ground box and a small dynamic
+// box.
+// There are no graphics for this example. Box2D is meant to be used
+// with your rendering engine in your game engine.
+DOCTEST_TEST_CASE("hello world")
+{
+ // Define the gravity vector.
+ b2Vec2 gravity(0.0f, -10.0f);
+
+ // Construct a world object, which will hold and simulate the rigid bodies.
+ b2World world(gravity);
+
+ // Define the ground body.
+ b2BodyDef groundBodyDef;
+ groundBodyDef.position.Set(0.0f, -10.0f);
+
+ // Call the body factory which allocates memory for the ground body
+ // from a pool and creates the ground box shape (also from a pool).
+ // The body is also added to the world.
+ b2Body* groundBody = world.CreateBody(&groundBodyDef);
+
+ // Define the ground box shape.
+ b2PolygonShape groundBox;
+
+ // The extents are the half-widths of the box.
+ groundBox.SetAsBox(50.0f, 10.0f);
+
+ // Add the ground fixture to the ground body.
+ groundBody->CreateFixture(&groundBox, 0.0f);
+
+ // Define the dynamic body. We set its position and call the body factory.
+ b2BodyDef bodyDef;
+ bodyDef.type = b2_dynamicBody;
+ bodyDef.position.Set(0.0f, 4.0f);
+ b2Body* body = world.CreateBody(&bodyDef);
+
+ // Define another box shape for our dynamic body.
+ b2PolygonShape dynamicBox;
+ dynamicBox.SetAsBox(1.0f, 1.0f);
+
+ // Define the dynamic body fixture.
+ b2FixtureDef fixtureDef;
+ fixtureDef.shape = &dynamicBox;
+
+ // Set the box density to be non-zero, so it will be dynamic.
+ fixtureDef.density = 1.0f;
+
+ // Override the default friction.
+ fixtureDef.friction = 0.3f;
+
+ // Add the shape to the body.
+ body->CreateFixture(&fixtureDef);
+
+ // Prepare for simulation. Typically we use a time step of 1/60 of a
+ // second (60Hz) and 10 iterations. This provides a high quality simulation
+ // in most game scenarios.
+ float timeStep = 1.0f / 60.0f;
+ int32 velocityIterations = 6;
+ int32 positionIterations = 2;
+
+ b2Vec2 position = body->GetPosition();
+ float angle = body->GetAngle();
+
+ // This is our little game loop.
+ for (int32 i = 0; i < 60; ++i)
+ {
+ // Instruct the world to perform a single step of simulation.
+ // It is generally best to keep the time step and iterations fixed.
+ world.Step(timeStep, velocityIterations, positionIterations);
+
+ // Now print the position and angle of the body.
+ position = body->GetPosition();
+ angle = body->GetAngle();
+
+ printf("%4.2f %4.2f %4.2f\n", position.x, position.y, angle);
+ }
+
+ // When the world destructor is called, all bodies and joints are freed. This can
+ // create orphaned pointers, so be careful about your world management.
+
+ CHECK(b2Abs(position.x) < 0.01f);
+ CHECK(b2Abs(position.y - 1.01f) < 0.01f);
+ CHECK(b2Abs(angle) < 0.01f);
+}
diff --git a/Client/ThirdParty/Box2D/unit-test/joint_test.cpp b/Client/ThirdParty/Box2D/unit-test/joint_test.cpp
new file mode 100644
index 0000000..94a0880
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/joint_test.cpp
@@ -0,0 +1,106 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/box2d.h"
+#include "doctest.h"
+#include <stdio.h>
+
+DOCTEST_TEST_CASE("joint reactions")
+{
+ b2Vec2 gravity(0, -10.0f);
+ b2World world = b2World(gravity);
+
+ b2BodyDef bodyDef;
+ b2Body* ground = world.CreateBody(&bodyDef);
+
+ b2CircleShape circle;
+ circle.m_radius = 1.0f;
+
+ b2FixtureDef fixtureDef;
+
+ // Disable collision
+ fixtureDef.filter.maskBits = 0;
+ fixtureDef.density = 1.0f;
+ fixtureDef.shape = &circle;
+
+ bodyDef.type = b2_dynamicBody;
+ bodyDef.position.Set(-2.0f, 3.0f);
+
+ b2Body* bodyA = world.CreateBody(&bodyDef);
+ b2Body* bodyB = world.CreateBody(&bodyDef);
+ b2Body* bodyC = world.CreateBody(&bodyDef);
+
+ b2MassData massData;
+ circle.ComputeMass(&massData, fixtureDef.density);
+ const float mg = massData.mass * gravity.y;
+
+ bodyA->CreateFixture(&fixtureDef);
+ bodyB->CreateFixture(&fixtureDef);
+ bodyC->CreateFixture(&fixtureDef);
+
+ b2DistanceJointDef distanceJointDef;
+ distanceJointDef.Initialize(ground, bodyA, bodyDef.position + b2Vec2(0.0f, 4.0f), bodyDef.position);
+ distanceJointDef.minLength = distanceJointDef.length;
+ distanceJointDef.maxLength = distanceJointDef.length;
+
+ b2PrismaticJointDef prismaticJointDef;
+ prismaticJointDef.Initialize(ground, bodyB, bodyDef.position, b2Vec2(1.0f, 0.0f));
+
+ b2RevoluteJointDef revoluteJointDef;
+ revoluteJointDef.Initialize(ground, bodyC, bodyDef.position);
+
+ b2DistanceJoint* distanceJoint = (b2DistanceJoint*)world.CreateJoint(&distanceJointDef);
+ b2PrismaticJoint* prismaticJoint = (b2PrismaticJoint*)world.CreateJoint(&prismaticJointDef);
+ b2RevoluteJoint* revoluteJoint = (b2RevoluteJoint*)world.CreateJoint(&revoluteJointDef);
+
+ const float timeStep = 1.f / 60.f;
+ const float invTimeStep = 60.0f;
+ const int32 velocityIterations = 6;
+ const int32 positionIterations = 2;
+
+ world.Step(timeStep, velocityIterations, positionIterations);
+
+ const float tol = 1e-5f;
+ {
+ b2Vec2 F = distanceJoint->GetReactionForce(invTimeStep);
+ float T = distanceJoint->GetReactionTorque(invTimeStep);
+ CHECK(F.x == 0.0f);
+ CHECK(b2Abs(F.y + mg) < tol);
+ CHECK(T == 0.0f);
+ }
+
+ {
+ b2Vec2 F = prismaticJoint->GetReactionForce(invTimeStep);
+ float T = prismaticJoint->GetReactionTorque(invTimeStep);
+ CHECK(F.x == 0.0f);
+ CHECK(b2Abs(F.y + mg) < tol);
+ CHECK(T == 0.0f);
+ }
+
+ {
+ b2Vec2 F = revoluteJoint->GetReactionForce(invTimeStep);
+ float T = revoluteJoint->GetReactionTorque(invTimeStep);
+ CHECK(F.x == 0.0f);
+ CHECK(b2Abs(F.y + mg) < tol);
+ CHECK(T == 0.0f);
+ }
+}
diff --git a/Client/ThirdParty/Box2D/unit-test/math_test.cpp b/Client/ThirdParty/Box2D/unit-test/math_test.cpp
new file mode 100644
index 0000000..076ae58
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/math_test.cpp
@@ -0,0 +1,54 @@
+// MIT License
+
+// Copyright (c) 2020 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/box2d.h"
+#include "doctest.h"
+#include <stdio.h>
+
+DOCTEST_TEST_CASE("math test")
+{
+ SUBCASE("sweep")
+ {
+ // From issue #447
+ b2Sweep sweep;
+ sweep.localCenter.SetZero();
+ sweep.c0.Set(-2.0f, 4.0f);
+ sweep.c.Set(3.0f, 8.0f);
+ sweep.a0 = 0.5f;
+ sweep.a = 5.0f;
+ sweep.alpha0 = 0.0f;
+
+ b2Transform transform;
+
+ sweep.GetTransform(&transform, 0.0f);
+ DOCTEST_REQUIRE_EQ(transform.p.x, sweep.c0.x);
+ DOCTEST_REQUIRE_EQ(transform.p.y, sweep.c0.y);
+ DOCTEST_REQUIRE_EQ(transform.q.c, cosf(sweep.a0));
+ DOCTEST_REQUIRE_EQ(transform.q.s, sinf(sweep.a0));
+
+ sweep.GetTransform(&transform, 1.0f);
+ DOCTEST_REQUIRE_EQ(transform.p.x, sweep.c.x);
+ DOCTEST_REQUIRE_EQ(transform.p.y, sweep.c.y);
+ DOCTEST_REQUIRE_EQ(transform.q.c, cosf(sweep.a));
+ DOCTEST_REQUIRE_EQ(transform.q.s, sinf(sweep.a));
+ }
+}
diff --git a/Client/ThirdParty/Box2D/unit-test/world_test.cpp b/Client/ThirdParty/Box2D/unit-test/world_test.cpp
new file mode 100644
index 0000000..453f9f2
--- /dev/null
+++ b/Client/ThirdParty/Box2D/unit-test/world_test.cpp
@@ -0,0 +1,73 @@
+// MIT License
+
+// Copyright (c) 2019 Erin Catto
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "box2d/box2d.h"
+#include "doctest.h"
+#include <stdio.h>
+
+static bool begin_contact = false;
+
+class MyContactListener : public b2ContactListener
+{
+public:
+ void BeginContact(b2Contact* contact)
+ {
+ begin_contact = true;
+ }
+};
+
+DOCTEST_TEST_CASE("begin contact")
+{
+ b2World world = b2World(b2Vec2(0.0f, -10.0f));
+ MyContactListener listener;
+ world.SetContactListener(&listener);
+
+ b2CircleShape circle;
+ circle.m_radius = 5.f;
+
+ b2BodyDef bodyDef;
+ bodyDef.type = b2_dynamicBody;
+
+ b2Body* bodyA = world.CreateBody(&bodyDef);
+ b2Body* bodyB = world.CreateBody(&bodyDef);
+ bodyA->CreateFixture(&circle, 0.0f);
+ bodyB->CreateFixture(&circle, 0.0f);
+
+ bodyA->SetTransform(b2Vec2(0.f, 0.f), 0.f);
+ bodyB->SetTransform(b2Vec2(100.f, 0.f), 0.f);
+
+ const float timeStep = 1.f / 60.f;
+ const int32 velocityIterations = 6;
+ const int32 positionIterations = 2;
+
+ world.Step(timeStep, velocityIterations, positionIterations);
+
+ CHECK(world.GetContactList() == nullptr);
+ CHECK(begin_contact == false);
+
+ bodyB->SetTransform(b2Vec2(1.f, 0.f), 0.f);
+
+ world.Step(timeStep, velocityIterations, positionIterations);
+
+ CHECK(world.GetContactList() != nullptr);
+ CHECK(begin_contact == true);
+}