Overhaul to SDL2
This commit is contained in:
parent
240b1594b4
commit
f4c9f1ad8c
0
.cmake/api/v1/query/cache-v2
Normal file
0
.cmake/api/v1/query/cache-v2
Normal file
0
.cmake/api/v1/query/cmakeFiles-v1
Normal file
0
.cmake/api/v1/query/cmakeFiles-v1
Normal file
0
.cmake/api/v1/query/codemodel-v2
Normal file
0
.cmake/api/v1/query/codemodel-v2
Normal file
0
.cmake/api/v1/query/toolchains-v1
Normal file
0
.cmake/api/v1/query/toolchains-v1
Normal file
1263
.cmake/api/v1/reply/cache-v2-f48b714d1e4412ccc47b.json
Normal file
1263
.cmake/api/v1/reply/cache-v2-f48b714d1e4412ccc47b.json
Normal file
File diff suppressed because it is too large
Load Diff
141
.cmake/api/v1/reply/cmakeFiles-v1-13576cbc081bae598543.json
Normal file
141
.cmake/api/v1/reply/cmakeFiles-v1-13576cbc081bae598543.json
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
{
|
||||||
|
"inputs" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path" : "CMakeLists.txt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "CMakeFiles/3.26.4/CMakeSystem.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeSystemSpecificInitialize.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "CMakeFiles/3.26.4/CMakeCCompiler.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "CMakeFiles/3.26.4/CMakeCXXCompiler.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeSystemSpecificInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeGenericSystem.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeInitializeConfigs.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Platform/Linux.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Platform/UnixPaths.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeCInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeLanguageInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Compiler/GNU-C.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Compiler/GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Platform/Linux-GNU-C.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Platform/Linux-GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeCommonLanguageInclude.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeCXXInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeLanguageInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Compiler/GNU-CXX.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Compiler/GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Platform/Linux-GNU-CXX.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/Platform/Linux-GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26/Modules/CMakeCommonLanguageInclude.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config-version.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : "/media/garrett/Storage/Projects/Hydrangea",
|
||||||
|
"source" : "/media/garrett/Storage/Projects/Hydrangea"
|
||||||
|
},
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
60
.cmake/api/v1/reply/codemodel-v2-330b5f213693ec063c5e.json
Normal file
60
.cmake/api/v1/reply/codemodel-v2-330b5f213693ec063c5e.json
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
"configurations" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directories" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"build" : ".",
|
||||||
|
"jsonFile" : "directory-.-f5ebdc15457944623624.json",
|
||||||
|
"minimumCMakeVersion" :
|
||||||
|
{
|
||||||
|
"string" : "3.22.1"
|
||||||
|
},
|
||||||
|
"projectIndex" : 0,
|
||||||
|
"source" : ".",
|
||||||
|
"targetIndexes" :
|
||||||
|
[
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name" : "",
|
||||||
|
"projects" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directoryIndexes" :
|
||||||
|
[
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"name" : "Hydrangea",
|
||||||
|
"targetIndexes" :
|
||||||
|
[
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"targets" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directoryIndex" : 0,
|
||||||
|
"id" : "game::@6890427a1f51a3e7e1df",
|
||||||
|
"jsonFile" : "target-game-c928b7f21fd872f316af.json",
|
||||||
|
"name" : "game",
|
||||||
|
"projectIndex" : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : "/media/garrett/Storage/Projects/Hydrangea",
|
||||||
|
"source" : "/media/garrett/Storage/Projects/Hydrangea"
|
||||||
|
},
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 5
|
||||||
|
}
|
||||||
|
}
|
||||||
14
.cmake/api/v1/reply/directory-.-f5ebdc15457944623624.json
Normal file
14
.cmake/api/v1/reply/directory-.-f5ebdc15457944623624.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"backtraceGraph" :
|
||||||
|
{
|
||||||
|
"commands" : [],
|
||||||
|
"files" : [],
|
||||||
|
"nodes" : []
|
||||||
|
},
|
||||||
|
"installers" : [],
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : ".",
|
||||||
|
"source" : "."
|
||||||
|
}
|
||||||
|
}
|
||||||
108
.cmake/api/v1/reply/index-2023-10-03T05-15-15-0196.json
Normal file
108
.cmake/api/v1/reply/index-2023-10-03T05-15-15-0196.json
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
{
|
||||||
|
"cmake" :
|
||||||
|
{
|
||||||
|
"generator" :
|
||||||
|
{
|
||||||
|
"multiConfig" : false,
|
||||||
|
"name" : "Unix Makefiles"
|
||||||
|
},
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"cmake" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/bin/cmake",
|
||||||
|
"cpack" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/bin/cpack",
|
||||||
|
"ctest" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/bin/ctest",
|
||||||
|
"root" : "/home/garrett/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/232.9921.42/bin/cmake/linux/x64/share/cmake-3.26"
|
||||||
|
},
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"isDirty" : false,
|
||||||
|
"major" : 3,
|
||||||
|
"minor" : 26,
|
||||||
|
"patch" : 4,
|
||||||
|
"string" : "3.26.4",
|
||||||
|
"suffix" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"objects" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"jsonFile" : "codemodel-v2-330b5f213693ec063c5e.json",
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "cache-v2-f48b714d1e4412ccc47b.json",
|
||||||
|
"kind" : "cache",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "cmakeFiles-v1-13576cbc081bae598543.json",
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "toolchains-v1-99265b04de7ada3aac9e.json",
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"reply" :
|
||||||
|
{
|
||||||
|
"cache-v2" :
|
||||||
|
{
|
||||||
|
"jsonFile" : "cache-v2-f48b714d1e4412ccc47b.json",
|
||||||
|
"kind" : "cache",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cmakeFiles-v1" :
|
||||||
|
{
|
||||||
|
"jsonFile" : "cmakeFiles-v1-13576cbc081bae598543.json",
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"codemodel-v2" :
|
||||||
|
{
|
||||||
|
"jsonFile" : "codemodel-v2-330b5f213693ec063c5e.json",
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"toolchains-v1" :
|
||||||
|
{
|
||||||
|
"jsonFile" : "toolchains-v1-99265b04de7ada3aac9e.json",
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
598
.cmake/api/v1/reply/target-game-c928b7f21fd872f316af.json
Normal file
598
.cmake/api/v1/reply/target-game-c928b7f21fd872f316af.json
Normal file
|
|
@ -0,0 +1,598 @@
|
||||||
|
{
|
||||||
|
"artifacts" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path" : "game"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"backtrace" : 1,
|
||||||
|
"backtraceGraph" :
|
||||||
|
{
|
||||||
|
"commands" :
|
||||||
|
[
|
||||||
|
"add_executable",
|
||||||
|
"link_directories",
|
||||||
|
"target_link_libraries",
|
||||||
|
"include_directories"
|
||||||
|
],
|
||||||
|
"files" :
|
||||||
|
[
|
||||||
|
"CMakeLists.txt"
|
||||||
|
],
|
||||||
|
"nodes" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"file" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 0,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 24,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 1,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 14,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 2,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 30,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 2,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 31,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 3,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 10,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 3,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 18,
|
||||||
|
"parent" : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"compileGroups" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"compileCommandFragments" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"fragment" : "-std=gnu++14 -fdiagnostics-color=always"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"includes" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"backtrace" : 5,
|
||||||
|
"path" : "/usr/include/SDL2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 6,
|
||||||
|
"path" : "/media/garrett/Storage/Projects/Hydrangea/include"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"language" : "CXX",
|
||||||
|
"languageStandard" :
|
||||||
|
{
|
||||||
|
"backtraces" :
|
||||||
|
[
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"standard" : "14"
|
||||||
|
},
|
||||||
|
"sourceIndexes" :
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30,
|
||||||
|
31,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40,
|
||||||
|
41,
|
||||||
|
42,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52,
|
||||||
|
53,
|
||||||
|
54,
|
||||||
|
55
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id" : "game::@6890427a1f51a3e7e1df",
|
||||||
|
"link" :
|
||||||
|
{
|
||||||
|
"commandFragments" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"fragment" : "",
|
||||||
|
"role" : "flags"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 2,
|
||||||
|
"fragment" : "-L/src",
|
||||||
|
"role" : "libraryPath"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fragment" : "-Wl,-rpath,/src",
|
||||||
|
"role" : "libraries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 3,
|
||||||
|
"fragment" : "-L/usr/lib/x86_64-linux-gnu -lSDL2",
|
||||||
|
"role" : "libraries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 4,
|
||||||
|
"fragment" : "-lSDL2_gpu",
|
||||||
|
"role" : "libraries"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"language" : "CXX"
|
||||||
|
},
|
||||||
|
"name" : "game",
|
||||||
|
"nameOnDisk" : "game",
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : ".",
|
||||||
|
"source" : "."
|
||||||
|
},
|
||||||
|
"sourceGroups" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "Source Files",
|
||||||
|
"sourceIndexes" :
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30,
|
||||||
|
31,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40,
|
||||||
|
41,
|
||||||
|
42,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52,
|
||||||
|
53,
|
||||||
|
54,
|
||||||
|
55
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sources" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/game.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/input_manager.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/main.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/node.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/player.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/scene.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/sprite.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/static_body.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/util.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/window.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_broad_phase.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_chain_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_circle_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collide_circle.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collide_edge.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collide_polygon.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collision.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_distance.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_dynamic_tree.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_edge_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_polygon_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_time_of_impact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_block_allocator.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_draw.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_math.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_settings.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_stack_allocator.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_timer.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_body.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_chain_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_chain_polygon_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_contact_manager.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_contact_solver.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_distance_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_edge_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_edge_polygon_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_fixture.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_friction_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_gear_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_island.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_motor_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_mouse_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_polygon_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_polygon_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_prismatic_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_pulley_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_revolute_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_weld_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_wheel_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_world.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_world_callbacks.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/rope/b2_rope.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/fmt/format.cc",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type" : "EXECUTABLE"
|
||||||
|
}
|
||||||
107
.cmake/api/v1/reply/toolchains-v1-99265b04de7ada3aac9e.json
Normal file
107
.cmake/api/v1/reply/toolchains-v1-99265b04de7ada3aac9e.json
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
{
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"toolchains" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"compiler" :
|
||||||
|
{
|
||||||
|
"id" : "GNU",
|
||||||
|
"implicit" :
|
||||||
|
{
|
||||||
|
"includeDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11/include",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"/usr/include"
|
||||||
|
],
|
||||||
|
"linkDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11",
|
||||||
|
"/usr/lib/x86_64-linux-gnu",
|
||||||
|
"/usr/lib",
|
||||||
|
"/lib/x86_64-linux-gnu",
|
||||||
|
"/lib"
|
||||||
|
],
|
||||||
|
"linkFrameworkDirectories" : [],
|
||||||
|
"linkLibraries" :
|
||||||
|
[
|
||||||
|
"gcc",
|
||||||
|
"gcc_s",
|
||||||
|
"c",
|
||||||
|
"gcc",
|
||||||
|
"gcc_s"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path" : "/usr/bin/cc",
|
||||||
|
"version" : "11.4.0"
|
||||||
|
},
|
||||||
|
"language" : "C",
|
||||||
|
"sourceFileExtensions" :
|
||||||
|
[
|
||||||
|
"c",
|
||||||
|
"m"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"compiler" :
|
||||||
|
{
|
||||||
|
"id" : "GNU",
|
||||||
|
"implicit" :
|
||||||
|
{
|
||||||
|
"includeDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/include/c++/11",
|
||||||
|
"/usr/include/x86_64-linux-gnu/c++/11",
|
||||||
|
"/usr/include/c++/11/backward",
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11/include",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"/usr/include"
|
||||||
|
],
|
||||||
|
"linkDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11",
|
||||||
|
"/usr/lib/x86_64-linux-gnu",
|
||||||
|
"/usr/lib",
|
||||||
|
"/lib/x86_64-linux-gnu",
|
||||||
|
"/lib"
|
||||||
|
],
|
||||||
|
"linkFrameworkDirectories" : [],
|
||||||
|
"linkLibraries" :
|
||||||
|
[
|
||||||
|
"stdc++",
|
||||||
|
"m",
|
||||||
|
"gcc_s",
|
||||||
|
"gcc",
|
||||||
|
"c",
|
||||||
|
"gcc_s",
|
||||||
|
"gcc"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path" : "/usr/bin/c++",
|
||||||
|
"version" : "11.4.0"
|
||||||
|
},
|
||||||
|
"language" : "CXX",
|
||||||
|
"sourceFileExtensions" :
|
||||||
|
[
|
||||||
|
"C",
|
||||||
|
"M",
|
||||||
|
"c++",
|
||||||
|
"cc",
|
||||||
|
"cpp",
|
||||||
|
"cxx",
|
||||||
|
"mm",
|
||||||
|
"mpp",
|
||||||
|
"CPP",
|
||||||
|
"ixx",
|
||||||
|
"cppm"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
cmake_install.cmake
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
CMakeTmp/
|
||||||
|
Makefile
|
||||||
|
.vscode/
|
||||||
|
compile.sh
|
||||||
|
game
|
||||||
|
notes/
|
||||||
|
Testing/
|
||||||
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
2
.idea/Hydrangea.iml
Normal file
2
.idea/Hydrangea.iml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||||
10
.idea/misc.xml
Normal file
10
.idea/misc.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
<component name="CidrRootsConfiguration">
|
||||||
|
<sourceRoots>
|
||||||
|
<file path="$PROJECT_DIR$/include" />
|
||||||
|
<file path="$PROJECT_DIR$/src" />
|
||||||
|
</sourceRoots>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Hydrangea.iml" filepath="$PROJECT_DIR$/.idea/Hydrangea.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -1,16 +1,40 @@
|
||||||
cmake_minimum_required(VERSION 2.8.9)
|
cmake_minimum_required(VERSION 3.22.1)
|
||||||
|
|
||||||
project (Hydrangea)
|
project (Hydrangea)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(OUT_NAME game)
|
||||||
|
|
||||||
#Import all of the SDL2 dependencies first...
|
# Includes for SDL2
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# Includes for SDL2_gpu
|
||||||
|
include_directories (${SDL_gpu_SOURCE_DIR})
|
||||||
|
link_directories (${SDL_gpu_SOURCE_DIR}/src)
|
||||||
|
set(SDL_GPU_LIBS SDL2_gpu ${GL_LIBRARIES})
|
||||||
|
|
||||||
# Then bring in the local source files and headers into the project
|
# Then bring in the local source files and headers into the project
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
file(GLOB SOURCES "src/*.cpp")
|
|
||||||
|
|
||||||
add_executable(Hydrangea ${SOURCES})
|
file(GLOB SOURCES "src/*.cpp") # Base engine source files
|
||||||
target_link_libraries(Hydrangea ${SDL2_LIBRARIES})
|
file(GLOB BOX2D_SOURCES "src/box2d/*/*.cpp") # box2d Physics engine
|
||||||
|
file(GLOB FMT_SOURCES "src/fmt/*.cc") # fmt String formatter lib
|
||||||
|
|
||||||
|
add_executable( ${OUT_NAME}
|
||||||
|
${SOURCES}
|
||||||
|
${BOX2D_SOURCES}
|
||||||
|
${FMT_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${OUT_NAME} ${SDL2_LIBRARIES})
|
||||||
|
target_link_libraries(${OUT_NAME} ${SDL_GPU_LIBS})
|
||||||
|
#target_link_libraries(${OUT_NAME} box2d)
|
||||||
|
|
||||||
|
get_target_property(OUT ${OUT_NAME} LINK_LIBRARIES)
|
||||||
|
message(STATUS ${OUT})
|
||||||
|
|
||||||
|
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||||
|
foreach(dir ${dirs})
|
||||||
|
message(STATUS "Include dirs: '${dir}'")
|
||||||
|
endforeach()
|
||||||
9
build.sh
Executable file
9
build.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH="/usr/local/lib"
|
||||||
|
cmake CMakeLists.txt
|
||||||
|
make -j 5
|
||||||
|
|
||||||
|
if [ "$1" == "play" ]; then
|
||||||
|
./game
|
||||||
|
fi
|
||||||
1
build/.cmake/api/v1/query/client-vscode/query.json
Normal file
1
build/.cmake/api/v1/query/client-vscode/query.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{"requests":[{"kind":"cache","version":2},{"kind":"codemodel","version":2},{"kind":"toolchains","version":1},{"kind":"cmakeFiles","version":1}]}
|
||||||
1159
build/.cmake/api/v1/reply/cache-v2-5b5f3a9c60370adcf8ab.json
Normal file
1159
build/.cmake/api/v1/reply/cache-v2-5b5f3a9c60370adcf8ab.json
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,144 @@
|
||||||
|
{
|
||||||
|
"inputs" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path" : "CMakeLists.txt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isGenerated" : true,
|
||||||
|
"path" : "build/CMakeFiles/3.22.1/CMakeSystem.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isGenerated" : true,
|
||||||
|
"path" : "build/CMakeFiles/3.22.1/CMakeCCompiler.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isGenerated" : true,
|
||||||
|
"path" : "build/CMakeFiles/3.22.1/CMakeCXXCompiler.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeGenericSystem.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Platform/Linux.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Platform/UnixPaths.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeCInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Compiler/GNU-C.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Compiler/GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Platform/Linux-GNU-C.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Platform/Linux-GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeCXXInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Compiler/GNU-CXX.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Compiler/GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Platform/Linux-GNU-CXX.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/Platform/Linux-GNU.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isCMake" : true,
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config-version.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isExternal" : true,
|
||||||
|
"path" : "/usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"source" : "/media/garrett/Storage/Projects/Hydrangea"
|
||||||
|
},
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
"configurations" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directories" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"build" : ".",
|
||||||
|
"jsonFile" : "directory-.-Debug-f5ebdc15457944623624.json",
|
||||||
|
"minimumCMakeVersion" :
|
||||||
|
{
|
||||||
|
"string" : "3.22.1"
|
||||||
|
},
|
||||||
|
"projectIndex" : 0,
|
||||||
|
"source" : ".",
|
||||||
|
"targetIndexes" :
|
||||||
|
[
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name" : "Debug",
|
||||||
|
"projects" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directoryIndexes" :
|
||||||
|
[
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"name" : "Hydrangea",
|
||||||
|
"targetIndexes" :
|
||||||
|
[
|
||||||
|
0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"targets" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directoryIndex" : 0,
|
||||||
|
"id" : "game::@6890427a1f51a3e7e1df",
|
||||||
|
"jsonFile" : "target-game-Debug-9df99ffdcc4bbe325dba.json",
|
||||||
|
"name" : "game",
|
||||||
|
"projectIndex" : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"source" : "/media/garrett/Storage/Projects/Hydrangea"
|
||||||
|
},
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"backtraceGraph" :
|
||||||
|
{
|
||||||
|
"commands" : [],
|
||||||
|
"files" : [],
|
||||||
|
"nodes" : []
|
||||||
|
},
|
||||||
|
"installers" : [],
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : ".",
|
||||||
|
"source" : "."
|
||||||
|
}
|
||||||
|
}
|
||||||
132
build/.cmake/api/v1/reply/index-2023-12-09T22-09-46-0659.json
Normal file
132
build/.cmake/api/v1/reply/index-2023-12-09T22-09-46-0659.json
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
{
|
||||||
|
"cmake" :
|
||||||
|
{
|
||||||
|
"generator" :
|
||||||
|
{
|
||||||
|
"multiConfig" : false,
|
||||||
|
"name" : "Ninja"
|
||||||
|
},
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"cmake" : "/usr/bin/cmake",
|
||||||
|
"cpack" : "/usr/bin/cpack",
|
||||||
|
"ctest" : "/usr/bin/ctest",
|
||||||
|
"root" : "/usr/share/cmake-3.22"
|
||||||
|
},
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"isDirty" : false,
|
||||||
|
"major" : 3,
|
||||||
|
"minor" : 22,
|
||||||
|
"patch" : 1,
|
||||||
|
"string" : "3.22.1",
|
||||||
|
"suffix" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"objects" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"jsonFile" : "codemodel-v2-3dd0101c350a8d407562.json",
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "cache-v2-5b5f3a9c60370adcf8ab.json",
|
||||||
|
"kind" : "cache",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "cmakeFiles-v1-cef2c3de0490094bf669.json",
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "toolchains-v1-50db6e0713f69d932e1c.json",
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"reply" :
|
||||||
|
{
|
||||||
|
"client-vscode" :
|
||||||
|
{
|
||||||
|
"query.json" :
|
||||||
|
{
|
||||||
|
"requests" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"kind" : "cache",
|
||||||
|
"version" : 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"version" : 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"version" : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"jsonFile" : "cache-v2-5b5f3a9c60370adcf8ab.json",
|
||||||
|
"kind" : "cache",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "codemodel-v2-3dd0101c350a8d407562.json",
|
||||||
|
"kind" : "codemodel",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 2,
|
||||||
|
"minor" : 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "toolchains-v1-50db6e0713f69d932e1c.json",
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jsonFile" : "cmakeFiles-v1-cef2c3de0490094bf669.json",
|
||||||
|
"kind" : "cmakeFiles",
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,613 @@
|
||||||
|
{
|
||||||
|
"artifacts" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path" : "game"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"backtrace" : 1,
|
||||||
|
"backtraceGraph" :
|
||||||
|
{
|
||||||
|
"commands" :
|
||||||
|
[
|
||||||
|
"add_executable",
|
||||||
|
"link_directories",
|
||||||
|
"target_link_libraries",
|
||||||
|
"include_directories"
|
||||||
|
],
|
||||||
|
"files" :
|
||||||
|
[
|
||||||
|
"CMakeLists.txt"
|
||||||
|
],
|
||||||
|
"nodes" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"file" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 0,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 24,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 1,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 14,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 2,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 30,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 2,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 31,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 3,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 10,
|
||||||
|
"parent" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : 3,
|
||||||
|
"file" : 0,
|
||||||
|
"line" : 18,
|
||||||
|
"parent" : 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"compileGroups" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"compileCommandFragments" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"fragment" : "-g"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fragment" : "-std=gnu++14"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"includes" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"backtrace" : 5,
|
||||||
|
"path" : "/usr/include/SDL2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 6,
|
||||||
|
"path" : "/media/garrett/Storage/Projects/Hydrangea/include"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"language" : "CXX",
|
||||||
|
"languageStandard" :
|
||||||
|
{
|
||||||
|
"backtraces" :
|
||||||
|
[
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"standard" : "14"
|
||||||
|
},
|
||||||
|
"sourceIndexes" :
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30,
|
||||||
|
31,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40,
|
||||||
|
41,
|
||||||
|
42,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52,
|
||||||
|
53,
|
||||||
|
54,
|
||||||
|
55,
|
||||||
|
56
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"id" : "game::@6890427a1f51a3e7e1df",
|
||||||
|
"link" :
|
||||||
|
{
|
||||||
|
"commandFragments" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"fragment" : "-g",
|
||||||
|
"role" : "flags"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fragment" : "",
|
||||||
|
"role" : "flags"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 2,
|
||||||
|
"fragment" : "-L/src",
|
||||||
|
"role" : "libraryPath"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fragment" : "-Wl,-rpath,/src",
|
||||||
|
"role" : "libraries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 3,
|
||||||
|
"fragment" : "-L/usr/lib/x86_64-linux-gnu -lSDL2",
|
||||||
|
"role" : "libraries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 4,
|
||||||
|
"fragment" : "-lSDL2_gpu",
|
||||||
|
"role" : "libraries"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"language" : "CXX"
|
||||||
|
},
|
||||||
|
"name" : "game",
|
||||||
|
"nameOnDisk" : "game",
|
||||||
|
"paths" :
|
||||||
|
{
|
||||||
|
"build" : ".",
|
||||||
|
"source" : "."
|
||||||
|
},
|
||||||
|
"sourceGroups" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "Source Files",
|
||||||
|
"sourceIndexes" :
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
9,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
12,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
18,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
22,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
25,
|
||||||
|
26,
|
||||||
|
27,
|
||||||
|
28,
|
||||||
|
29,
|
||||||
|
30,
|
||||||
|
31,
|
||||||
|
32,
|
||||||
|
33,
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
36,
|
||||||
|
37,
|
||||||
|
38,
|
||||||
|
39,
|
||||||
|
40,
|
||||||
|
41,
|
||||||
|
42,
|
||||||
|
43,
|
||||||
|
44,
|
||||||
|
45,
|
||||||
|
46,
|
||||||
|
47,
|
||||||
|
48,
|
||||||
|
49,
|
||||||
|
50,
|
||||||
|
51,
|
||||||
|
52,
|
||||||
|
53,
|
||||||
|
54,
|
||||||
|
55,
|
||||||
|
56
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sources" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/dynamic_body.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/game.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/input_manager.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/main.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/node.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/player.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/scene.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/sprite.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/static_body.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/util.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/window.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_broad_phase.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_chain_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_circle_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collide_circle.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collide_edge.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collide_polygon.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_collision.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_distance.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_dynamic_tree.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_edge_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_polygon_shape.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/collision/b2_time_of_impact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_block_allocator.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_draw.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_math.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_settings.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_stack_allocator.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/common/b2_timer.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_body.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_chain_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_chain_polygon_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_contact_manager.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_contact_solver.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_distance_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_edge_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_edge_polygon_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_fixture.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_friction_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_gear_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_island.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_motor_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_mouse_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_polygon_circle_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_polygon_contact.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_prismatic_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_pulley_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_revolute_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_weld_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_wheel_joint.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_world.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/dynamics/b2_world_callbacks.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/box2d/rope/b2_rope.cpp",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"backtrace" : 1,
|
||||||
|
"compileGroupIndex" : 0,
|
||||||
|
"path" : "src/fmt/format.cc",
|
||||||
|
"sourceGroupIndex" : 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type" : "EXECUTABLE"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
{
|
||||||
|
"kind" : "toolchains",
|
||||||
|
"toolchains" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"compiler" :
|
||||||
|
{
|
||||||
|
"id" : "GNU",
|
||||||
|
"implicit" :
|
||||||
|
{
|
||||||
|
"includeDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11/include",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"/usr/include"
|
||||||
|
],
|
||||||
|
"linkDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11",
|
||||||
|
"/usr/lib/x86_64-linux-gnu",
|
||||||
|
"/usr/lib",
|
||||||
|
"/lib/x86_64-linux-gnu",
|
||||||
|
"/lib"
|
||||||
|
],
|
||||||
|
"linkFrameworkDirectories" : [],
|
||||||
|
"linkLibraries" :
|
||||||
|
[
|
||||||
|
"gcc",
|
||||||
|
"gcc_s",
|
||||||
|
"c",
|
||||||
|
"gcc",
|
||||||
|
"gcc_s"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path" : "/bin/x86_64-linux-gnu-gcc-11",
|
||||||
|
"version" : "11.4.0"
|
||||||
|
},
|
||||||
|
"language" : "C",
|
||||||
|
"sourceFileExtensions" :
|
||||||
|
[
|
||||||
|
"c",
|
||||||
|
"m"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"compiler" :
|
||||||
|
{
|
||||||
|
"id" : "GNU",
|
||||||
|
"implicit" :
|
||||||
|
{
|
||||||
|
"includeDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/include/c++/11",
|
||||||
|
"/usr/include/x86_64-linux-gnu/c++/11",
|
||||||
|
"/usr/include/c++/11/backward",
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11/include",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"/usr/include"
|
||||||
|
],
|
||||||
|
"linkDirectories" :
|
||||||
|
[
|
||||||
|
"/usr/lib/gcc/x86_64-linux-gnu/11",
|
||||||
|
"/usr/lib/x86_64-linux-gnu",
|
||||||
|
"/usr/lib",
|
||||||
|
"/lib/x86_64-linux-gnu",
|
||||||
|
"/lib"
|
||||||
|
],
|
||||||
|
"linkFrameworkDirectories" : [],
|
||||||
|
"linkLibraries" :
|
||||||
|
[
|
||||||
|
"stdc++",
|
||||||
|
"m",
|
||||||
|
"gcc_s",
|
||||||
|
"gcc",
|
||||||
|
"c",
|
||||||
|
"gcc_s",
|
||||||
|
"gcc"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path" : "/bin/x86_64-linux-gnu-g++-11",
|
||||||
|
"version" : "11.4.0"
|
||||||
|
},
|
||||||
|
"language" : "CXX",
|
||||||
|
"sourceFileExtensions" :
|
||||||
|
[
|
||||||
|
"C",
|
||||||
|
"M",
|
||||||
|
"c++",
|
||||||
|
"cc",
|
||||||
|
"cpp",
|
||||||
|
"cxx",
|
||||||
|
"mm",
|
||||||
|
"mpp",
|
||||||
|
"CPP",
|
||||||
|
"ixx",
|
||||||
|
"cppm"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" :
|
||||||
|
{
|
||||||
|
"major" : 1,
|
||||||
|
"minor" : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
build/.ninja_deps
Normal file
BIN
build/.ninja_deps
Normal file
Binary file not shown.
58
build/.ninja_log
Normal file
58
build/.ninja_log
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
# ninja log v5
|
||||||
|
4 247 1702159838973791840 CMakeFiles/game.dir/src/box2d/collision/b2_broad_phase.cpp.o 2584c67db79bc7f6
|
||||||
|
7 253 1702159838981791836 CMakeFiles/game.dir/src/box2d/collision/b2_circle_shape.cpp.o f0cd7e99d5f1b2f6
|
||||||
|
6 303 1702159839029791810 CMakeFiles/game.dir/src/box2d/collision/b2_chain_shape.cpp.o f16c4b982bdb0256
|
||||||
|
248 550 1702159839277791678 CMakeFiles/game.dir/src/box2d/collision/b2_collide_circle.cpp.o 5018c314eb6f805c
|
||||||
|
3 571 1702159839289791672 CMakeFiles/game.dir/src/util.cpp.o c1bdceb11ac46020
|
||||||
|
303 607 1702159839333791648 CMakeFiles/game.dir/src/box2d/collision/b2_collide_polygon.cpp.o ee45cc40c07de0d1
|
||||||
|
253 614 1702159839337791647 CMakeFiles/game.dir/src/box2d/collision/b2_collide_edge.cpp.o e62a6fcf34355c52
|
||||||
|
0 708 1702159839433791596 CMakeFiles/game.dir/src/dynamic_body.cpp.o 190c439dcd7ca4c8
|
||||||
|
550 867 1702159839593791509 CMakeFiles/game.dir/src/box2d/collision/b2_collision.cpp.o 11276083ca1c7f45
|
||||||
|
572 877 1702159839601791506 CMakeFiles/game.dir/src/box2d/collision/b2_distance.cpp.o 64b29720677838bf
|
||||||
|
614 965 1702159839693791457 CMakeFiles/game.dir/src/box2d/collision/b2_edge_shape.cpp.o f55ea97c9fc7b9c
|
||||||
|
708 1027 1702159839753791424 CMakeFiles/game.dir/src/box2d/collision/b2_polygon_shape.cpp.o 864d525ee344138f
|
||||||
|
877 1037 1702159839765791419 CMakeFiles/game.dir/src/box2d/common/b2_block_allocator.cpp.o aa2fe16437d0eab1
|
||||||
|
608 1050 1702159839777791412 CMakeFiles/game.dir/src/box2d/collision/b2_dynamic_tree.cpp.o 3190c0909911317a
|
||||||
|
966 1137 1702159839865791364 CMakeFiles/game.dir/src/box2d/common/b2_draw.cpp.o 460ab1093b305604
|
||||||
|
1037 1211 1702159839933791329 CMakeFiles/game.dir/src/box2d/common/b2_settings.cpp.o 35f60214dc2f6162
|
||||||
|
1027 1216 1702159839941791325 CMakeFiles/game.dir/src/box2d/common/b2_math.cpp.o 59e10962e30bc3b
|
||||||
|
1137 1237 1702159839953791318 CMakeFiles/game.dir/src/box2d/common/b2_timer.cpp.o e624a175973223a8
|
||||||
|
867 1276 1702159840001791292 CMakeFiles/game.dir/src/box2d/collision/b2_time_of_impact.cpp.o fb4c74b917d01306
|
||||||
|
2 1312 1702159840037791273 CMakeFiles/game.dir/src/player.cpp.o f70983e79251fd0c
|
||||||
|
1050 1349 1702159840077791251 CMakeFiles/game.dir/src/box2d/common/b2_stack_allocator.cpp.o 48c6e36f3e22d80
|
||||||
|
1 1391 1702159840117791231 CMakeFiles/game.dir/src/node.cpp.o 2d6c346af5ab59d3
|
||||||
|
1 1449 1702159840177791198 CMakeFiles/game.dir/src/input_manager.cpp.o 9679f5afa764ce3c
|
||||||
|
0 1455 1702159840173791201 CMakeFiles/game.dir/src/game.cpp.o afcd93a026538e93
|
||||||
|
1216 1492 1702159840221791175 CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_circle_contact.cpp.o deee820bad566c5
|
||||||
|
2 1506 1702159840233791168 CMakeFiles/game.dir/src/scene.cpp.o 498f0987c94048bf
|
||||||
|
1237 1523 1702159840249791160 CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_polygon_contact.cpp.o 4c1ba6cb10da1c61
|
||||||
|
1 1525 1702159840253791157 CMakeFiles/game.dir/src/main.cpp.o 8fb557ab0446f19b
|
||||||
|
1211 1541 1702159840269791149 CMakeFiles/game.dir/src/box2d/dynamics/b2_body.cpp.o f169fb3d58f132d0
|
||||||
|
2 1549 1702159840269791149 CMakeFiles/game.dir/src/static_body.cpp.o 5165020241c22f35
|
||||||
|
1276 1555 1702159840269791149 CMakeFiles/game.dir/src/box2d/dynamics/b2_circle_contact.cpp.o 99e893b9aa634d3
|
||||||
|
1313 1629 1702159840357791101 CMakeFiles/game.dir/src/box2d/dynamics/b2_contact.cpp.o 6c051ad305d37510
|
||||||
|
1349 1631 1702159840357791101 CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_manager.cpp.o c5694e44f070976a
|
||||||
|
1493 1673 1702159840401791078 CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_polygon_contact.cpp.o 16d0b786bd2dc1d9
|
||||||
|
4 1690 1702159840417791070 CMakeFiles/game.dir/src/window.cpp.o e4a06dd3638cc981
|
||||||
|
1391 1729 1702159840457791048 CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_solver.cpp.o e0b634d3fd058f04
|
||||||
|
1455 1743 1702159840461791047 CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_circle_contact.cpp.o f41b104f0d0c983
|
||||||
|
1449 1757 1702159840485791033 CMakeFiles/game.dir/src/box2d/dynamics/b2_distance_joint.cpp.o dd432ab62a7d1f2b
|
||||||
|
1507 1788 1702159840513791018 CMakeFiles/game.dir/src/box2d/dynamics/b2_fixture.cpp.o adfb8903d9117b02
|
||||||
|
1523 1809 1702159840533791007 CMakeFiles/game.dir/src/box2d/dynamics/b2_friction_joint.cpp.o c1b927d3db50eebb
|
||||||
|
1555 1828 1702159840553790998 CMakeFiles/game.dir/src/box2d/dynamics/b2_motor_joint.cpp.o 3c6d8922105990a4
|
||||||
|
1631 1850 1702159840573790987 CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_circle_contact.cpp.o d6e6909dd17c6116
|
||||||
|
2 1869 1702159840597790973 CMakeFiles/game.dir/src/sprite.cpp.o 22e50b55e4ffbce5
|
||||||
|
1526 1881 1702159840609790968 CMakeFiles/game.dir/src/box2d/dynamics/b2_gear_joint.cpp.o 8bb6a6dbe697ca52
|
||||||
|
1549 1884 1702159840613790965 CMakeFiles/game.dir/src/box2d/dynamics/b2_joint.cpp.o 13c5d3d8f7aa6391
|
||||||
|
1541 1888 1702159840617790964 CMakeFiles/game.dir/src/box2d/dynamics/b2_island.cpp.o bdc166afff2a791
|
||||||
|
1673 1918 1702159840645790949 CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_contact.cpp.o 58c5e8e6356c2b80
|
||||||
|
1629 1928 1702159840653790943 CMakeFiles/game.dir/src/box2d/dynamics/b2_mouse_joint.cpp.o f93c6bed3a465154
|
||||||
|
1690 1959 1702159840685790927 CMakeFiles/game.dir/src/box2d/dynamics/b2_prismatic_joint.cpp.o 42c5027973f19a4c
|
||||||
|
1743 1982 1702159840709790913 CMakeFiles/game.dir/src/box2d/dynamics/b2_revolute_joint.cpp.o df2e4d5aadff477d
|
||||||
|
1828 1996 1702159840725790905 CMakeFiles/game.dir/src/box2d/dynamics/b2_world_callbacks.cpp.o 35a49da1a277caec
|
||||||
|
1729 2015 1702159840741790897 CMakeFiles/game.dir/src/box2d/dynamics/b2_pulley_joint.cpp.o 2cf2b9e124e22cef
|
||||||
|
1757 2036 1702159840765790883 CMakeFiles/game.dir/src/box2d/dynamics/b2_weld_joint.cpp.o e8740d4966159ce4
|
||||||
|
1788 2050 1702159840777790878 CMakeFiles/game.dir/src/box2d/dynamics/b2_wheel_joint.cpp.o 377e9725ac313a2
|
||||||
|
1850 2094 1702159840821790855 CMakeFiles/game.dir/src/box2d/rope/b2_rope.cpp.o 2e9bc545012f9006
|
||||||
|
1809 2141 1702159840869790829 CMakeFiles/game.dir/src/box2d/dynamics/b2_world.cpp.o e01b3ad075abccc5
|
||||||
|
1869 3636 1702159842361790032 CMakeFiles/game.dir/src/fmt/format.cc.o eb44cdfe74bad47a
|
||||||
537
build/build.ninja
Normal file
537
build/build.ninja
Normal file
|
|
@ -0,0 +1,537 @@
|
||||||
|
# CMAKE generated file: DO NOT EDIT!
|
||||||
|
# Generated by "Ninja" Generator, CMake Version 3.22
|
||||||
|
|
||||||
|
# This file contains all the build statements describing the
|
||||||
|
# compilation DAG.
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Write statements declared in CMakeLists.txt:
|
||||||
|
#
|
||||||
|
# Which is the root file.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Project: Hydrangea
|
||||||
|
# Configurations: Debug
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Minimal version of Ninja required by this file
|
||||||
|
|
||||||
|
ninja_required_version = 1.5
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Set configuration variable for custom commands.
|
||||||
|
|
||||||
|
CONFIGURATION = Debug
|
||||||
|
# =============================================================================
|
||||||
|
# Include auxiliary files.
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Include rules file.
|
||||||
|
|
||||||
|
include CMakeFiles/rules.ninja
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Logical path to working directory; prefix for absolute paths.
|
||||||
|
|
||||||
|
cmake_ninja_workdir = /media/garrett/Storage/Projects/Hydrangea/build/
|
||||||
|
# =============================================================================
|
||||||
|
# Object build statements for EXECUTABLE target game
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Order-only phony target for game
|
||||||
|
|
||||||
|
build cmake_object_order_depends_target_game: phony || CMakeFiles/game.dir
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/dynamic_body.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/dynamic_body.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/dynamic_body.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/game.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/game.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/game.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/input_manager.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/input_manager.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/input_manager.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/main.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/main.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/main.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/node.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/node.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/node.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/player.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/player.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/player.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/scene.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/scene.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/scene.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/sprite.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/sprite.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/sprite.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/static_body.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/static_body.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/static_body.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/util.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/util.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/util.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/window.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/window.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/window.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_broad_phase.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_broad_phase.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_broad_phase.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_chain_shape.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_chain_shape.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_chain_shape.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_circle_shape.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_circle_shape.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_circle_shape.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_collide_circle.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_circle.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_collide_circle.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_collide_edge.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_edge.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_collide_edge.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_collide_polygon.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_polygon.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_collide_polygon.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_collision.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collision.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_collision.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_distance.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_distance.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_distance.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_dynamic_tree.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_dynamic_tree.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_dynamic_tree.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_edge_shape.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_edge_shape.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_edge_shape.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_polygon_shape.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_polygon_shape.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_polygon_shape.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/collision/b2_time_of_impact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_time_of_impact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/collision/b2_time_of_impact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/collision
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/common/b2_block_allocator.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_block_allocator.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/common/b2_block_allocator.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/common
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/common/b2_draw.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_draw.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/common/b2_draw.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/common
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/common/b2_math.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_math.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/common/b2_math.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/common
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/common/b2_settings.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_settings.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/common/b2_settings.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/common
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/common/b2_stack_allocator.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_stack_allocator.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/common/b2_stack_allocator.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/common
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/common/b2_timer.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_timer.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/common/b2_timer.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/common
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_body.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_body.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_body.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_circle_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_chain_circle_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_circle_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_polygon_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_chain_polygon_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_polygon_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_circle_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_circle_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_circle_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_manager.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact_manager.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_manager.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_solver.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact_solver.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_solver.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_distance_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_distance_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_distance_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_circle_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_edge_circle_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_circle_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_polygon_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_edge_polygon_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_polygon_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_fixture.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_fixture.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_fixture.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_friction_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_friction_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_friction_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_gear_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_gear_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_gear_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_island.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_island.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_island.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_motor_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_motor_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_motor_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_mouse_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_mouse_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_mouse_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_circle_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_polygon_circle_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_circle_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_contact.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_polygon_contact.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_contact.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_prismatic_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_prismatic_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_prismatic_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_pulley_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_pulley_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_pulley_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_revolute_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_revolute_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_revolute_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_weld_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_weld_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_weld_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_wheel_joint.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_wheel_joint.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_wheel_joint.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_world.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_world.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_world.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/dynamics/b2_world_callbacks.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_world_callbacks.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/dynamics/b2_world_callbacks.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/dynamics
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/box2d/rope/b2_rope.cpp.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/box2d/rope/b2_rope.cpp || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/box2d/rope/b2_rope.cpp.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/box2d/rope
|
||||||
|
|
||||||
|
build CMakeFiles/game.dir/src/fmt/format.cc.o: CXX_COMPILER__game_Debug /media/garrett/Storage/Projects/Hydrangea/src/fmt/format.cc || cmake_object_order_depends_target_game
|
||||||
|
DEP_FILE = CMakeFiles/game.dir/src/fmt/format.cc.o.d
|
||||||
|
FLAGS = -g -std=gnu++14
|
||||||
|
INCLUDES = -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
OBJECT_FILE_DIR = CMakeFiles/game.dir/src/fmt
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Link build statements for EXECUTABLE target game
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Link the executable game
|
||||||
|
|
||||||
|
build game: CXX_EXECUTABLE_LINKER__game_Debug CMakeFiles/game.dir/src/dynamic_body.cpp.o CMakeFiles/game.dir/src/game.cpp.o CMakeFiles/game.dir/src/input_manager.cpp.o CMakeFiles/game.dir/src/main.cpp.o CMakeFiles/game.dir/src/node.cpp.o CMakeFiles/game.dir/src/player.cpp.o CMakeFiles/game.dir/src/scene.cpp.o CMakeFiles/game.dir/src/sprite.cpp.o CMakeFiles/game.dir/src/static_body.cpp.o CMakeFiles/game.dir/src/util.cpp.o CMakeFiles/game.dir/src/window.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_broad_phase.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_chain_shape.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_circle_shape.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_collide_circle.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_collide_edge.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_collide_polygon.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_collision.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_distance.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_dynamic_tree.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_edge_shape.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_polygon_shape.cpp.o CMakeFiles/game.dir/src/box2d/collision/b2_time_of_impact.cpp.o CMakeFiles/game.dir/src/box2d/common/b2_block_allocator.cpp.o CMakeFiles/game.dir/src/box2d/common/b2_draw.cpp.o CMakeFiles/game.dir/src/box2d/common/b2_math.cpp.o CMakeFiles/game.dir/src/box2d/common/b2_settings.cpp.o CMakeFiles/game.dir/src/box2d/common/b2_stack_allocator.cpp.o CMakeFiles/game.dir/src/box2d/common/b2_timer.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_body.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_circle_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_polygon_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_circle_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_manager.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_solver.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_distance_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_circle_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_polygon_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_fixture.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_friction_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_gear_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_island.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_motor_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_mouse_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_circle_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_contact.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_prismatic_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_pulley_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_revolute_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_weld_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_wheel_joint.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_world.cpp.o CMakeFiles/game.dir/src/box2d/dynamics/b2_world_callbacks.cpp.o CMakeFiles/game.dir/src/box2d/rope/b2_rope.cpp.o CMakeFiles/game.dir/src/fmt/format.cc.o
|
||||||
|
FLAGS = -g
|
||||||
|
LINK_LIBRARIES = -Wl,-rpath,/src -L/usr/lib/x86_64-linux-gnu -lSDL2 -lSDL2_gpu
|
||||||
|
LINK_PATH = -L/src
|
||||||
|
OBJECT_DIR = CMakeFiles/game.dir
|
||||||
|
POST_BUILD = :
|
||||||
|
PRE_LINK = :
|
||||||
|
TARGET_FILE = game
|
||||||
|
TARGET_PDB = game.dbg
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Utility command for edit_cache
|
||||||
|
|
||||||
|
build CMakeFiles/edit_cache.util: CUSTOM_COMMAND
|
||||||
|
COMMAND = cd /media/garrett/Storage/Projects/Hydrangea/build && /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
|
||||||
|
DESC = No interactive CMake dialog available...
|
||||||
|
restat = 1
|
||||||
|
|
||||||
|
build edit_cache: phony CMakeFiles/edit_cache.util
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Utility command for rebuild_cache
|
||||||
|
|
||||||
|
build CMakeFiles/rebuild_cache.util: CUSTOM_COMMAND
|
||||||
|
COMMAND = cd /media/garrett/Storage/Projects/Hydrangea/build && /usr/bin/cmake --regenerate-during-build -S/media/garrett/Storage/Projects/Hydrangea -B/media/garrett/Storage/Projects/Hydrangea/build
|
||||||
|
DESC = Running CMake to regenerate build system...
|
||||||
|
pool = console
|
||||||
|
restat = 1
|
||||||
|
|
||||||
|
build rebuild_cache: phony CMakeFiles/rebuild_cache.util
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Target aliases.
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Folder targets.
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Folder: /media/garrett/Storage/Projects/Hydrangea/build
|
||||||
|
|
||||||
|
build all: phony game
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Built-in targets
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Re-run CMake if any of its inputs changed.
|
||||||
|
|
||||||
|
build build.ninja: RERUN_CMAKE | ../CMakeLists.txt /usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config-version.cmake /usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake /usr/share/cmake-3.22/Modules/CMakeCInformation.cmake /usr/share/cmake-3.22/Modules/CMakeCXXInformation.cmake /usr/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake /usr/share/cmake-3.22/Modules/CMakeGenericSystem.cmake /usr/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake /usr/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake /usr/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU-C.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU-CXX.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU-C.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU-CXX.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU.cmake /usr/share/cmake-3.22/Modules/Platform/Linux.cmake /usr/share/cmake-3.22/Modules/Platform/UnixPaths.cmake CMakeCache.txt CMakeFiles/3.22.1/CMakeCCompiler.cmake CMakeFiles/3.22.1/CMakeCXXCompiler.cmake CMakeFiles/3.22.1/CMakeSystem.cmake
|
||||||
|
pool = console
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# A missing CMake input file is not an error.
|
||||||
|
|
||||||
|
build ../CMakeLists.txt /usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config-version.cmake /usr/lib/x86_64-linux-gnu/cmake/SDL2/sdl2-config.cmake /usr/share/cmake-3.22/Modules/CMakeCInformation.cmake /usr/share/cmake-3.22/Modules/CMakeCXXInformation.cmake /usr/share/cmake-3.22/Modules/CMakeCommonLanguageInclude.cmake /usr/share/cmake-3.22/Modules/CMakeGenericSystem.cmake /usr/share/cmake-3.22/Modules/CMakeInitializeConfigs.cmake /usr/share/cmake-3.22/Modules/CMakeLanguageInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInformation.cmake /usr/share/cmake-3.22/Modules/CMakeSystemSpecificInitialize.cmake /usr/share/cmake-3.22/Modules/Compiler/CMakeCommonCompilerMacros.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU-C.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU-CXX.cmake /usr/share/cmake-3.22/Modules/Compiler/GNU.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU-C.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU-CXX.cmake /usr/share/cmake-3.22/Modules/Platform/Linux-GNU.cmake /usr/share/cmake-3.22/Modules/Platform/Linux.cmake /usr/share/cmake-3.22/Modules/Platform/UnixPaths.cmake CMakeCache.txt CMakeFiles/3.22.1/CMakeCCompiler.cmake CMakeFiles/3.22.1/CMakeCXXCompiler.cmake CMakeFiles/3.22.1/CMakeSystem.cmake: phony
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Clean all the built files.
|
||||||
|
|
||||||
|
build clean: CLEAN
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Print all primary targets available.
|
||||||
|
|
||||||
|
build help: HELP
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Make the all target the default.
|
||||||
|
|
||||||
|
default all
|
||||||
287
build/compile_commands.json
Normal file
287
build/compile_commands.json
Normal file
|
|
@ -0,0 +1,287 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/dynamic_body.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/dynamic_body.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/dynamic_body.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/game.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/game.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/game.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/input_manager.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/input_manager.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/input_manager.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/main.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/main.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/main.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/node.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/node.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/node.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/player.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/player.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/player.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/scene.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/scene.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/scene.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/sprite.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/sprite.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/sprite.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/static_body.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/static_body.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/static_body.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/util.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/util.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/util.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/window.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/window.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/window.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_broad_phase.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_broad_phase.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_broad_phase.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_chain_shape.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_chain_shape.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_chain_shape.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_circle_shape.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_circle_shape.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_circle_shape.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_collide_circle.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_circle.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_circle.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_collide_edge.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_edge.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_edge.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_collide_polygon.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_polygon.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collide_polygon.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_collision.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collision.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_collision.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_distance.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_distance.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_distance.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_dynamic_tree.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_dynamic_tree.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_dynamic_tree.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_edge_shape.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_edge_shape.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_edge_shape.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_polygon_shape.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_polygon_shape.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_polygon_shape.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/collision/b2_time_of_impact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_time_of_impact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/collision/b2_time_of_impact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/common/b2_block_allocator.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_block_allocator.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_block_allocator.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/common/b2_draw.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_draw.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_draw.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/common/b2_math.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_math.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_math.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/common/b2_settings.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_settings.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_settings.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/common/b2_stack_allocator.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_stack_allocator.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_stack_allocator.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/common/b2_timer.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_timer.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/common/b2_timer.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_body.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_body.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_body.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_circle_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_chain_circle_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_chain_circle_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_chain_polygon_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_chain_polygon_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_chain_polygon_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_circle_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_circle_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_circle_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_manager.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact_manager.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact_manager.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_contact_solver.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact_solver.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_contact_solver.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_distance_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_distance_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_distance_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_circle_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_edge_circle_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_edge_circle_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_edge_polygon_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_edge_polygon_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_edge_polygon_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_fixture.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_fixture.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_fixture.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_friction_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_friction_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_friction_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_gear_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_gear_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_gear_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_island.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_island.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_island.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_motor_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_motor_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_motor_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_mouse_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_mouse_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_mouse_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_circle_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_polygon_circle_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_polygon_circle_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_polygon_contact.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_polygon_contact.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_polygon_contact.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_prismatic_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_prismatic_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_prismatic_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_pulley_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_pulley_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_pulley_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_revolute_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_revolute_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_revolute_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_weld_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_weld_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_weld_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_wheel_joint.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_wheel_joint.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_wheel_joint.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_world.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_world.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_world.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/dynamics/b2_world_callbacks.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_world_callbacks.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/dynamics/b2_world_callbacks.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/box2d/rope/b2_rope.cpp.o -c /media/garrett/Storage/Projects/Hydrangea/src/box2d/rope/b2_rope.cpp",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/box2d/rope/b2_rope.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory": "/media/garrett/Storage/Projects/Hydrangea/build",
|
||||||
|
"command": "/bin/x86_64-linux-gnu-g++-11 -I/usr/include/SDL2 -I/media/garrett/Storage/Projects/Hydrangea/include -g -std=gnu++14 -o CMakeFiles/game.dir/src/fmt/format.cc.o -c /media/garrett/Storage/Projects/Hydrangea/src/fmt/format.cc",
|
||||||
|
"file": "/media/garrett/Storage/Projects/Hydrangea/src/fmt/format.cc"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
//
|
|
||||||
// Continue at
|
|
||||||
// https://austinmorlan.com/posts/entity_component_system/#the-entity
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Types.hpp"
|
|
||||||
#include <array>
|
|
||||||
#include <cassert>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
|
|
||||||
class IComponentArray
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IComponentArray() = default;
|
|
||||||
virtual void EntityDestroyed(Entity entity) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class ComponentArray : public IComponentArray
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::array<T, MAX_ENTITIES> mComponentArray{};
|
|
||||||
std::unordered_map<Entity, size_t> mEntityToIndexMap{};
|
|
||||||
std::unordered_map<size_t, Entity> mIndexToEntityMap{};
|
|
||||||
size_t mSize{};
|
|
||||||
public:
|
|
||||||
void InsertData(Entity entity, T component)
|
|
||||||
{
|
|
||||||
assert(mEntityToIndexMap.find(entity) == mEntityToIndexMap.end() && "Component added to same entity more than once.");
|
|
||||||
// Put new entry at end
|
|
||||||
size_t newIndex = mSize;
|
|
||||||
mEntityToIndexMap[entity] = newIndex;
|
|
||||||
mIndexToEntityMap[newIndex] = entity;
|
|
||||||
mComponentArray[newIndex] = component;
|
|
||||||
++mSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveData(Entity entity)
|
|
||||||
{
|
|
||||||
assert(mEntityToIndexMap.find(entity) != mEntityToIndexMap.end() && "Removing non-existent component.");
|
|
||||||
// Copy element at end into deleted element's place to maintain density
|
|
||||||
size_t indexOfRemovedEntity = mEntityToIndexMap[entity];
|
|
||||||
size_t indexOfLastElement = mSize - 1;
|
|
||||||
mComponentArray[indexOfRemovedEntity] = mComponentArray[indexOfLastElement];
|
|
||||||
// Update map to point to moved spot
|
|
||||||
Entity entityOfLastElement = mIndexToEntityMap[indexOfLastElement];
|
|
||||||
mEntityToIndexMap[entityOfLastElement] = indexOfRemovedEntity;
|
|
||||||
mIndexToEntityMap[indexOfRemovedEntity] = entityOfLastElement;
|
|
||||||
mEntityToIndexMap.erase(entity);
|
|
||||||
mIndexToEntityMap.erase(indexOfLastElement);
|
|
||||||
--mSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
T &GetData(Entity entity)
|
|
||||||
{
|
|
||||||
assert(mEntityToIndexMap.find(entity) != mEntityToIndexMap.end() && "Retrieving non-existent component.");
|
|
||||||
return mComponentArray[mEntityToIndexMap[entity]];
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityDestroyed(Entity entity) override
|
|
||||||
{
|
|
||||||
if (mEntityToIndexMap.find(entity) != mEntityToIndexMap.end())
|
|
||||||
{
|
|
||||||
RemoveData(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include "../Math/Vec2.hpp"
|
|
||||||
|
|
||||||
struct Transform
|
|
||||||
{
|
|
||||||
Vec2 position;
|
|
||||||
Vec2 rotation;
|
|
||||||
Vec2 scale;
|
|
||||||
};
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
#include "Types.hpp"
|
|
||||||
#include <array>
|
|
||||||
#include <cassert>
|
|
||||||
#include <queue>
|
|
||||||
|
|
||||||
#ifndef WINDOW_H
|
|
||||||
#define WINDOW_H
|
|
||||||
|
|
||||||
class EntityManager
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
// Queue of unused entity IDs
|
|
||||||
std::queue<Entity> mAvailableEntities{};
|
|
||||||
|
|
||||||
// Array of signatures where the index corresponds to the entity ID
|
|
||||||
std::array<Signature, MAX_ENTITIES> mSignatures{};
|
|
||||||
|
|
||||||
// Total living entities - used to keep limits on how many exist
|
|
||||||
uint32_t mLivingEntityCount{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
EntityManager()
|
|
||||||
{
|
|
||||||
// Initialize the queue with all possible entity IDs
|
|
||||||
for (Entity entity = 0; entity < MAX_ENTITIES; ++entity)
|
|
||||||
{
|
|
||||||
mAvailableEntities.push(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity CreateEntity()
|
|
||||||
{
|
|
||||||
assert(mLivingEntityCount < MAX_ENTITIES && "Too many entities in existence.");
|
|
||||||
|
|
||||||
// Take an ID from the front of the queue
|
|
||||||
Entity id = mAvailableEntities.front();
|
|
||||||
mAvailableEntities.pop();
|
|
||||||
++mLivingEntityCount;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DestroyEntity(Entity entity)
|
|
||||||
{
|
|
||||||
assert(entity < MAX_ENTITIES && "Entity out of range.");
|
|
||||||
|
|
||||||
// Invalidate the destroyed entity's signature
|
|
||||||
mSignatures[entity].reset();
|
|
||||||
|
|
||||||
// Put the destroyed ID at the back of the queue
|
|
||||||
mAvailableEntities.push(entity);
|
|
||||||
--mLivingEntityCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSignature(Entity entity, Signature signature)
|
|
||||||
{
|
|
||||||
assert(entity < MAX_ENTITIES && "Entity out of range.");
|
|
||||||
|
|
||||||
// Put this entity's signature into the array
|
|
||||||
mSignatures[entity] = signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
Signature GetSignature(Entity entity)
|
|
||||||
{
|
|
||||||
assert(entity < MAX_ENTITIES && "Entity out of range.");
|
|
||||||
|
|
||||||
// Get this entity's signature from the array
|
|
||||||
return mSignatures[entity];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
#ifndef HYDRANGEA_H
|
|
||||||
#define HYDRANGEA_H
|
|
||||||
|
|
||||||
class Hydrangea
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#include <bitset>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
// ECS
|
|
||||||
using Entity = std::uint32_t;
|
|
||||||
const Entity MAX_ENTITIES = 5000;
|
|
||||||
using ComponentType = std::uint8_t;
|
|
||||||
const ComponentType MAX_COMPONENTS = 32;
|
|
||||||
using Signature = std::bitset<MAX_COMPONENTS>;
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
#ifndef WINDOW_H
|
|
||||||
#define WINDOW_H
|
|
||||||
|
|
||||||
class Window
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
SDL_Window *window = NULL;
|
|
||||||
SDL_Surface *screenSurface = NULL;
|
|
||||||
int height = 480;
|
|
||||||
int width = 640;
|
|
||||||
std::string title = "Hydrangea";
|
|
||||||
|
|
||||||
public:
|
|
||||||
Window(int heightIn, int widthIn, std::string titleIn);
|
|
||||||
bool Init();
|
|
||||||
void Close();
|
|
||||||
SDL_Window *getWindow();
|
|
||||||
SDL_Surface *getSurface();
|
|
||||||
int getWidth();
|
|
||||||
int getHeight();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
52
include/box2d/b2_api.h
Normal file
52
include/box2d/b2_api.h
Normal file
|
|
@ -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
|
||||||
60
include/box2d/b2_block_allocator.h
Normal file
60
include/box2d/b2_block_allocator.h
Normal file
|
|
@ -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
|
||||||
885
include/box2d/b2_body.h
Normal file
885
include/box2d/b2_body.h
Normal file
|
|
@ -0,0 +1,885 @@
|
||||||
|
// 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.
|
||||||
|
b2MassData GetMassData() 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();
|
||||||
|
const b2BodyUserData& GetUserData() const;
|
||||||
|
|
||||||
|
/// 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 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 b2MassData b2Body::GetMassData() const
|
||||||
|
{
|
||||||
|
b2MassData data;
|
||||||
|
data.mass = m_mass;
|
||||||
|
data.I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter);
|
||||||
|
data.center = m_sweep.localCenter;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 const b2BodyUserData& b2Body::GetUserData() const
|
||||||
|
{
|
||||||
|
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
|
||||||
238
include/box2d/b2_broad_phase.h
Normal file
238
include/box2d/b2_broad_phase.h
Normal file
|
|
@ -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
|
||||||
101
include/box2d/b2_chain_shape.h
Normal file
101
include/box2d/b2_chain_shape.h
Normal file
|
|
@ -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
|
||||||
67
include/box2d/b2_circle_shape.h
Normal file
67
include/box2d/b2_circle_shape.h
Normal file
|
|
@ -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
|
||||||
306
include/box2d/b2_collision.h
Normal file
306
include/box2d/b2_collision.h
Normal file
|
|
@ -0,0 +1,306 @@
|
||||||
|
// 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* polygonB, 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);
|
||||||
|
|
||||||
|
/// Convex hull used for polygon collision
|
||||||
|
struct b2Hull
|
||||||
|
{
|
||||||
|
b2Vec2 points[b2_maxPolygonVertices];
|
||||||
|
int32 count;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Compute the convex hull of a set of points. Returns an empty hull if it fails.
|
||||||
|
/// Some failure cases:
|
||||||
|
/// - all points very close together
|
||||||
|
/// - all points on a line
|
||||||
|
/// - less than 3 points
|
||||||
|
/// - more than b2_maxPolygonVertices points
|
||||||
|
/// This welds close points and removes collinear points.
|
||||||
|
b2Hull b2ComputeHull(const b2Vec2* points, int32 count);
|
||||||
|
|
||||||
|
/// This determines if a hull is valid. Checks for:
|
||||||
|
/// - convexity
|
||||||
|
/// - collinear points
|
||||||
|
/// This is expensive and should not be called at runtime.
|
||||||
|
bool b2ValidateHull(const b2Hull& hull);
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------- 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
|
||||||
138
include/box2d/b2_common.h
Normal file
138
include/box2d/b2_common.h
Normal file
|
|
@ -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
|
||||||
386
include/box2d/b2_contact.h
Normal file
386
include/box2d/b2_contact.h
Normal file
|
|
@ -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
|
||||||
57
include/box2d/b2_contact_manager.h
Normal file
57
include/box2d/b2_contact_manager.h
Normal file
|
|
@ -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
|
||||||
171
include/box2d/b2_distance.h
Normal file
171
include/box2d/b2_distance.h
Normal file
|
|
@ -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
|
||||||
176
include/box2d/b2_distance_joint.h
Normal file
176
include/box2d/b2_distance_joint.h
Normal file
|
|
@ -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
|
||||||
102
include/box2d/b2_draw.h
Normal file
102
include/box2d/b2_draw.h
Normal file
|
|
@ -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
|
||||||
308
include/box2d/b2_dynamic_tree.h
Normal file
308
include/box2d/b2_dynamic_tree.h
Normal file
|
|
@ -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
|
||||||
86
include/box2d/b2_edge_shape.h
Normal file
86
include/box2d/b2_edge_shape.h
Normal file
|
|
@ -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
|
||||||
371
include/box2d/b2_fixture.h
Normal file
371
include/box2d/b2_fixture.h
Normal file
|
|
@ -0,0 +1,371 @@
|
||||||
|
// 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();
|
||||||
|
const b2FixtureUserData& GetUserData() const;
|
||||||
|
|
||||||
|
/// 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 const b2FixtureUserData& b2Fixture::GetUserData() const
|
||||||
|
{
|
||||||
|
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
|
||||||
124
include/box2d/b2_friction_joint.h
Normal file
124
include/box2d/b2_friction_joint.h
Normal file
|
|
@ -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
|
||||||
131
include/box2d/b2_gear_joint.h
Normal file
131
include/box2d/b2_gear_joint.h
Normal file
|
|
@ -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.
|
||||||
|
|
||||||
|
#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_tolerance;
|
||||||
|
|
||||||
|
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
|
||||||
91
include/box2d/b2_growable_stack.h
Normal file
91
include/box2d/b2_growable_stack.h
Normal file
|
|
@ -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
|
||||||
233
include/box2d/b2_joint.h
Normal file
233
include/box2d/b2_joint.h
Normal file
|
|
@ -0,0 +1,233 @@
|
||||||
|
// 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_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();
|
||||||
|
const b2JointUserData& GetUserData() const;
|
||||||
|
|
||||||
|
/// 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 const b2JointUserData& b2Joint::GetUserData() const
|
||||||
|
{
|
||||||
|
return m_userData;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool b2Joint::GetCollideConnected() const
|
||||||
|
{
|
||||||
|
return m_collideConnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
717
include/box2d/b2_math.h
Normal file
717
include/box2d/b2_math.h
Normal file
|
|
@ -0,0 +1,717 @@
|
||||||
|
// 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() = default;
|
||||||
|
|
||||||
|
/// 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() = default;
|
||||||
|
|
||||||
|
/// 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() = default;
|
||||||
|
|
||||||
|
/// 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() = default;
|
||||||
|
|
||||||
|
/// 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() = default;
|
||||||
|
|
||||||
|
/// 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() = default;
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
{
|
||||||
|
b2Sweep() = default;
|
||||||
|
|
||||||
|
/// 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
|
||||||
138
include/box2d/b2_motor_joint.h
Normal file
138
include/box2d/b2_motor_joint.h
Normal file
|
|
@ -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
|
||||||
134
include/box2d/b2_mouse_joint.h
Normal file
134
include/box2d/b2_mouse_joint.h
Normal file
|
|
@ -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
|
||||||
93
include/box2d/b2_polygon_shape.h
Normal file
93
include/box2d/b2_polygon_shape.h
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
// 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"
|
||||||
|
|
||||||
|
struct b2Hull;
|
||||||
|
|
||||||
|
/// 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 if this fails then the polygon is invalid
|
||||||
|
/// @returns true if valid
|
||||||
|
bool Set(const b2Vec2* points, int32 count);
|
||||||
|
|
||||||
|
/// Create a polygon from a given convex hull (see b2ComputeHull).
|
||||||
|
/// @warning the hull must be valid or this will crash or have unexpected behavior
|
||||||
|
void Set(const b2Hull& hull);
|
||||||
|
|
||||||
|
/// 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
205
include/box2d/b2_prismatic_joint.h
Normal file
205
include/box2d/b2_prismatic_joint.h
Normal file
|
|
@ -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
|
||||||
157
include/box2d/b2_pulley_joint.h
Normal file
157
include/box2d/b2_pulley_joint.h
Normal file
|
|
@ -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
|
||||||
211
include/box2d/b2_revolute_joint.h
Normal file
211
include/box2d/b2_revolute_joint.h
Normal file
|
|
@ -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
|
||||||
155
include/box2d/b2_rope.h
Normal file
155
include/box2d/b2_rope.h
Normal file
|
|
@ -0,0 +1,155 @@
|
||||||
|
// 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;
|
||||||
|
stretchHertz = 1.0f;
|
||||||
|
stretchDamping = 0.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
|
||||||
127
include/box2d/b2_settings.h
Normal file
127
include/box2d/b2_settings.h
Normal file
|
|
@ -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
|
||||||
110
include/box2d/b2_shape.h
Normal file
110
include/box2d/b2_shape.h
Normal file
|
|
@ -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
|
||||||
65
include/box2d/b2_stack_allocator.h
Normal file
65
include/box2d/b2_stack_allocator.h
Normal file
|
|
@ -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
|
||||||
63
include/box2d/b2_time_of_impact.h
Normal file
63
include/box2d/b2_time_of_impact.h
Normal file
|
|
@ -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
|
||||||
74
include/box2d/b2_time_step.h
Normal file
74
include/box2d/b2_time_step.h
Normal file
|
|
@ -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
|
||||||
55
include/box2d/b2_timer.h
Normal file
55
include/box2d/b2_timer.h
Normal file
|
|
@ -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
|
||||||
33
include/box2d/b2_types.h
Normal file
33
include/box2d/b2_types.h
Normal file
|
|
@ -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
|
||||||
133
include/box2d/b2_weld_joint.h
Normal file
133
include/box2d/b2_weld_joint.h
Normal file
|
|
@ -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 stiffness) { m_stiffness = stiffness; }
|
||||||
|
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
|
||||||
240
include/box2d/b2_wheel_joint.h
Normal file
240
include/box2d/b2_wheel_joint.h
Normal file
|
|
@ -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
|
||||||
348
include/box2d/b2_world.h
Normal file
348
include/box2d/b2_world.h
Normal file
|
|
@ -0,0 +1,348 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
b2World(const b2World&) = delete;
|
||||||
|
void operator=(const b2World&) = delete;
|
||||||
|
|
||||||
|
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
|
||||||
161
include/box2d/b2_world_callbacks.h
Normal file
161
include/box2d/b2_world_callbacks.h
Normal file
|
|
@ -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
|
||||||
58
include/box2d/box2d.h
Normal file
58
include/box2d/box2d.h
Normal file
|
|
@ -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
|
||||||
29
include/dynamic_body.h
Normal file
29
include/dynamic_body.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "node.h"
|
||||||
|
#include "box2d/b2_body.h"
|
||||||
|
#include "box2d/b2_polygon_shape.h"
|
||||||
|
#include "box2d/b2_fixture.h"
|
||||||
|
|
||||||
|
#ifndef HYDRANGEA_DYNAMIC_BODY_H
|
||||||
|
#define HYDRANGEA_DYNAMIC_BODY_H
|
||||||
|
|
||||||
|
class DynamicBody : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DynamicBody(float size_x = 10.0f, float size_y = 10.0f);
|
||||||
|
~DynamicBody();
|
||||||
|
|
||||||
|
void Update() override;
|
||||||
|
|
||||||
|
Vec2 size;
|
||||||
|
float friction;
|
||||||
|
float density;
|
||||||
|
|
||||||
|
private:
|
||||||
|
b2BodyDef b_body_def;
|
||||||
|
b2Body *b_body;
|
||||||
|
b2PolygonShape b_shape;
|
||||||
|
b2FixtureDef b_fixture_def;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //HYDRANGEA_DYNAMIC_BODY_H
|
||||||
2924
include/fmt/core.h
Normal file
2924
include/fmt/core.h
Normal file
File diff suppressed because it is too large
Load Diff
1662
include/fmt/format-inl.h
Normal file
1662
include/fmt/format-inl.h
Normal file
File diff suppressed because it is too large
Load Diff
4499
include/fmt/format.h
Normal file
4499
include/fmt/format.h
Normal file
File diff suppressed because it is too large
Load Diff
24
include/game.h
Normal file
24
include/game.h
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "scene.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
|
#ifndef GAME_H
|
||||||
|
#define GAME_H
|
||||||
|
|
||||||
|
class Game
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor and Destructor
|
||||||
|
Game();
|
||||||
|
~Game();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
int Init();
|
||||||
|
|
||||||
|
// Members
|
||||||
|
static Scene *scene;
|
||||||
|
Window *window = NULL;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
18
include/input_manager.h
Normal file
18
include/input_manager.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef INPUTMANAGER_H
|
||||||
|
#define INPUTMANAGER_H
|
||||||
|
|
||||||
|
class InputManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
static std::vector<SDL_Event>& GetFrameEvents();
|
||||||
|
static void WindowEscape();
|
||||||
|
|
||||||
|
static bool key_down;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
36
include/node.h
Normal file
36
include/node.h
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "math/vec2.h"
|
||||||
|
#include "scene.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#ifndef NODE_H
|
||||||
|
#define NODE_H
|
||||||
|
|
||||||
|
class Node
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Methods
|
||||||
|
void UpdateChildren();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor and Destructor
|
||||||
|
Node();
|
||||||
|
~Node();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
virtual void Update();
|
||||||
|
void AddChild(Node* child);
|
||||||
|
|
||||||
|
// Member Variables
|
||||||
|
std::string name;
|
||||||
|
Vec2 world_position = Vec2(0, 0);
|
||||||
|
Vec2 local_position = Vec2(0, 0);
|
||||||
|
Scene* scene = NULL;
|
||||||
|
Node* parent = NULL;
|
||||||
|
std::vector<Node*> children;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
20
include/player.h
Normal file
20
include/player.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "node.h"
|
||||||
|
#include "sprite.h"
|
||||||
|
|
||||||
|
#ifndef PLAYER_H
|
||||||
|
#define PLAYER_H
|
||||||
|
|
||||||
|
class Player : public Node {
|
||||||
|
private:
|
||||||
|
void Update() override;
|
||||||
|
void Move();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Player();
|
||||||
|
~Player();
|
||||||
|
|
||||||
|
Sprite *sprite;
|
||||||
|
Sprite *hammer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
32
include/scene.h
Normal file
32
include/scene.h
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "box2d/b2_math.h"
|
||||||
|
#include "box2d/b2_world.h"
|
||||||
|
|
||||||
|
#ifndef HYDRANGEA_SCENE_H
|
||||||
|
#define HYDRANGEA_SCENE_H
|
||||||
|
|
||||||
|
class Node;
|
||||||
|
class Scene
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Members
|
||||||
|
std::vector<Node*> node_tree;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor and Destructor
|
||||||
|
Scene();
|
||||||
|
~Scene();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
void Update();
|
||||||
|
void AppendNode(Node* node);
|
||||||
|
|
||||||
|
// Members
|
||||||
|
b2Vec2 b_gravity = b2Vec2(0, -10);
|
||||||
|
b2World *b_world;
|
||||||
|
int velocity_iterations = 6;
|
||||||
|
int position_iterations = 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //HYDRANGEA_SCENE_H
|
||||||
38
include/sprite.h
Normal file
38
include/sprite.h
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_gpu.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "math/vec2.h"
|
||||||
|
#include "node.h"
|
||||||
|
|
||||||
|
#ifndef SPRITE_H
|
||||||
|
#define SPRITE_H
|
||||||
|
|
||||||
|
class Sprite : public Node
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
GPU_Image* image;
|
||||||
|
GPU_Target* target;
|
||||||
|
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor and Deconstructor
|
||||||
|
explicit Sprite(std::string resource_path);
|
||||||
|
~Sprite();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
void Update() override;
|
||||||
|
|
||||||
|
void SetImage( GPU_Image img );
|
||||||
|
void SetImage( char* img_path );
|
||||||
|
GPU_Image GetImage();
|
||||||
|
|
||||||
|
// Member Variables
|
||||||
|
float angle = 0;
|
||||||
|
Vec2 scale = Vec2(1, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
24
include/static_body.h
Normal file
24
include/static_body.h
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "node.h"
|
||||||
|
#include "box2d/b2_body.h"
|
||||||
|
#include "box2d/b2_polygon_shape.h"
|
||||||
|
|
||||||
|
#ifndef HYDRANGEA_STATIC_BODY_H
|
||||||
|
#define HYDRANGEA_STATIC_BODY_H
|
||||||
|
|
||||||
|
class StaticBody : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit StaticBody(float size_x = 10.0f, float size_y = 10.0f);
|
||||||
|
~StaticBody();
|
||||||
|
|
||||||
|
void Update() override;
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
private:
|
||||||
|
b2BodyDef b_body_def;
|
||||||
|
b2Body *b_body;
|
||||||
|
b2PolygonShape b_shape;
|
||||||
|
Vec2 size;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //HYDRANGEA_STATIC_BODY_H
|
||||||
26
include/util.h
Normal file
26
include/util.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.14159265358979323846
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UTIL_H
|
||||||
|
#define UTIL_H
|
||||||
|
|
||||||
|
enum LogType {
|
||||||
|
INFO,
|
||||||
|
ERROR
|
||||||
|
};
|
||||||
|
|
||||||
|
class Util
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void Log(LogType type, std::string msg, std::string file, int line);
|
||||||
|
static std::string GenerateUUID();
|
||||||
|
static std::string LogTypeToStr(LogType type);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
32
include/window.h
Normal file
32
include/window.h
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_gpu.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
#ifndef WINDOW_H
|
||||||
|
#define WINDOW_H
|
||||||
|
|
||||||
|
class Window
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Window(int heightIn, int widthIn, std::string titleIn);
|
||||||
|
~Window();
|
||||||
|
|
||||||
|
bool Init();
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
static SDL_Window *window;
|
||||||
|
static GPU_Target *window_target;
|
||||||
|
static int window_id;
|
||||||
|
static bool is_running;
|
||||||
|
|
||||||
|
int window_height = 480;
|
||||||
|
int window_width = 640;
|
||||||
|
std::string window_title = "Window";
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
BIN
resources/img/hammer.png
Normal file
BIN
resources/img/hammer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 659 B |
BIN
resources/img/mario.png
Normal file
BIN
resources/img/mario.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 982 B |
|
|
@ -1,2 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
51
src/Main.cpp
51
src/Main.cpp
|
|
@ -1,51 +0,0 @@
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "../include/Window.hpp"
|
|
||||||
|
|
||||||
// Screen dimension constants
|
|
||||||
const int SCREEN_WIDTH = 640;
|
|
||||||
const int SCREEN_HEIGHT = 480;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::cout << "Hello, Hydrangea!\n";
|
|
||||||
|
|
||||||
Window *myWindow = new Window(SCREEN_HEIGHT,SCREEN_WIDTH, "Hello, Hydrangea!");
|
|
||||||
|
|
||||||
// Start up SDL and create window
|
|
||||||
if (!myWindow->Init())
|
|
||||||
{
|
|
||||||
printf("[Error] Failed to initialize window!\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool isRunning = true;
|
|
||||||
SDL_Event e;
|
|
||||||
|
|
||||||
while (isRunning)
|
|
||||||
{
|
|
||||||
// Handle events on queue
|
|
||||||
while (SDL_PollEvent(&e) != 0)
|
|
||||||
{
|
|
||||||
// User presses the X button
|
|
||||||
if (e.type == SDL_QUIT)
|
|
||||||
{
|
|
||||||
isRunning = false;
|
|
||||||
}
|
|
||||||
// User presses the Escape key
|
|
||||||
else if (e.type == SDL_KEYDOWN)
|
|
||||||
{
|
|
||||||
if (e.key.keysym.sym == SDLK_ESCAPE)
|
|
||||||
{
|
|
||||||
isRunning = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
myWindow->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include "../include/Window.hpp"
|
|
||||||
|
|
||||||
Window::Window(int heightIn, int widthIn, std::string titleIn)
|
|
||||||
{
|
|
||||||
height = heightIn;
|
|
||||||
width = widthIn;
|
|
||||||
title = titleIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Window::Init()
|
|
||||||
{
|
|
||||||
// Initialization flag
|
|
||||||
bool success = true;
|
|
||||||
|
|
||||||
// Initialize SDL
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
|
||||||
{
|
|
||||||
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Create window
|
|
||||||
window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
|
|
||||||
|
|
||||||
if (window == NULL)
|
|
||||||
{
|
|
||||||
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get window surface
|
|
||||||
screenSurface = SDL_GetWindowSurface(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Window::Close()
|
|
||||||
{
|
|
||||||
// Deallocate any surfaces we have
|
|
||||||
|
|
||||||
//Destroy window
|
|
||||||
SDL_DestroyWindow(window);
|
|
||||||
window = NULL;
|
|
||||||
|
|
||||||
//Quit SDL subsystems
|
|
||||||
SDL_Quit();
|
|
||||||
}
|
|
||||||
131
src/box2d/collision/b2_broad_phase.cpp
Normal file
131
src/box2d/collision/b2_broad_phase.cpp
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
185
src/box2d/collision/b2_chain_shape.cpp
Normal file
185
src/box2d/collision/b2_chain_shape.cpp
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
105
src/box2d/collision/b2_circle_shape.cpp
Normal file
105
src/box2d/collision/b2_circle_shape.cpp
Normal file
|
|
@ -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));
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user