@bloomengine/engine 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (562) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/native/android/Cargo.lock +1848 -0
  4. package/native/android/Cargo.toml +20 -0
  5. package/native/android/src/lib.rs +1747 -0
  6. package/native/ios/Cargo.lock +1688 -0
  7. package/native/ios/Cargo.toml +19 -0
  8. package/native/ios/src/lib.rs +2258 -0
  9. package/native/linux/Cargo.lock +1719 -0
  10. package/native/linux/Cargo.toml +22 -0
  11. package/native/linux/src/lib.rs +2236 -0
  12. package/native/macos/Cargo.lock +3310 -0
  13. package/native/macos/Cargo.toml +29 -0
  14. package/native/macos/src/lib.rs +3444 -0
  15. package/native/shared/Cargo.lock +1898 -0
  16. package/native/shared/Cargo.toml +42 -0
  17. package/native/shared/assets/default_font.ttf +0 -0
  18. package/native/shared/build.rs +77 -0
  19. package/native/shared/shaders/common/fog.wgsl +16 -0
  20. package/native/shared/shaders/common/imposter.wgsl +112 -0
  21. package/native/shared/shaders/common/pbr.wgsl +186 -0
  22. package/native/shared/shaders/common/shadows.wgsl +77 -0
  23. package/native/shared/shaders/common/sky.wgsl +8 -0
  24. package/native/shared/shaders/common/tonemap.wgsl +25 -0
  25. package/native/shared/shaders/impulse_field.wgsl +53 -0
  26. package/native/shared/shaders/material_abi.wgsl +360 -0
  27. package/native/shared/shaders/materials/test_minimal.wgsl +42 -0
  28. package/native/shared/src/audio.rs +363 -0
  29. package/native/shared/src/custom_shaders.rs +104 -0
  30. package/native/shared/src/drs.rs +211 -0
  31. package/native/shared/src/engine.rs +186 -0
  32. package/native/shared/src/frame_callbacks.rs +88 -0
  33. package/native/shared/src/geometry.rs +236 -0
  34. package/native/shared/src/handles.rs +76 -0
  35. package/native/shared/src/input.rs +273 -0
  36. package/native/shared/src/jolt_sys.rs +822 -0
  37. package/native/shared/src/lib.rs +43 -0
  38. package/native/shared/src/models.rs +1941 -0
  39. package/native/shared/src/physics_jolt.rs +1528 -0
  40. package/native/shared/src/picking.rs +298 -0
  41. package/native/shared/src/postfx.rs +339 -0
  42. package/native/shared/src/profiler.rs +416 -0
  43. package/native/shared/src/renderer/atmosphere_lut.rs +573 -0
  44. package/native/shared/src/renderer/brdf_lut.rs +154 -0
  45. package/native/shared/src/renderer/formats.rs +778 -0
  46. package/native/shared/src/renderer/graph.rs +465 -0
  47. package/native/shared/src/renderer/hot_reload.rs +390 -0
  48. package/native/shared/src/renderer/impulse_field.rs +455 -0
  49. package/native/shared/src/renderer/material_pipeline.rs +604 -0
  50. package/native/shared/src/renderer/material_system.rs +2106 -0
  51. package/native/shared/src/renderer/mod.rs +13923 -0
  52. package/native/shared/src/renderer/planar_reflection.rs +458 -0
  53. package/native/shared/src/renderer/post_pass.rs +249 -0
  54. package/native/shared/src/renderer/shader_include.rs +205 -0
  55. package/native/shared/src/renderer/shader_library.rs +134 -0
  56. package/native/shared/src/renderer/shaders.rs +5855 -0
  57. package/native/shared/src/renderer/transient.rs +576 -0
  58. package/native/shared/src/renderer/types.rs +259 -0
  59. package/native/shared/src/renderer/util.rs +151 -0
  60. package/native/shared/src/scene.rs +1066 -0
  61. package/native/shared/src/sdf_cache.rs +274 -0
  62. package/native/shared/src/shadows.rs +551 -0
  63. package/native/shared/src/staging.rs +90 -0
  64. package/native/shared/src/string_header.rs +35 -0
  65. package/native/shared/src/text_renderer.rs +456 -0
  66. package/native/shared/src/textures.rs +154 -0
  67. package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.cpp +242 -0
  68. package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.h +121 -0
  69. package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeToBuffer.h +296 -0
  70. package/native/third_party/JoltPhysics/Jolt/AABBTree/NodeCodec/NodeCodecQuadTreeHalfFloat.h +323 -0
  71. package/native/third_party/JoltPhysics/Jolt/AABBTree/TriangleCodec/TriangleCodecIndexed8BitPackSOA4Flags.h +555 -0
  72. package/native/third_party/JoltPhysics/Jolt/ConfigurationString.h +112 -0
  73. package/native/third_party/JoltPhysics/Jolt/Core/ARMNeon.h +94 -0
  74. package/native/third_party/JoltPhysics/Jolt/Core/Array.h +713 -0
  75. package/native/third_party/JoltPhysics/Jolt/Core/Atomics.h +44 -0
  76. package/native/third_party/JoltPhysics/Jolt/Core/BinaryHeap.h +96 -0
  77. package/native/third_party/JoltPhysics/Jolt/Core/ByteBuffer.h +74 -0
  78. package/native/third_party/JoltPhysics/Jolt/Core/Color.cpp +38 -0
  79. package/native/third_party/JoltPhysics/Jolt/Core/Color.h +98 -0
  80. package/native/third_party/JoltPhysics/Jolt/Core/Core.h +652 -0
  81. package/native/third_party/JoltPhysics/Jolt/Core/FPControlWord.h +143 -0
  82. package/native/third_party/JoltPhysics/Jolt/Core/FPException.h +96 -0
  83. package/native/third_party/JoltPhysics/Jolt/Core/FPFlushDenormals.h +43 -0
  84. package/native/third_party/JoltPhysics/Jolt/Core/Factory.cpp +92 -0
  85. package/native/third_party/JoltPhysics/Jolt/Core/Factory.h +54 -0
  86. package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.h +122 -0
  87. package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.inl +215 -0
  88. package/native/third_party/JoltPhysics/Jolt/Core/HashCombine.h +234 -0
  89. package/native/third_party/JoltPhysics/Jolt/Core/HashTable.h +876 -0
  90. package/native/third_party/JoltPhysics/Jolt/Core/InsertionSort.h +58 -0
  91. package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.cpp +27 -0
  92. package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.h +38 -0
  93. package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.h +311 -0
  94. package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.inl +56 -0
  95. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.cpp +65 -0
  96. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.h +62 -0
  97. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.cpp +364 -0
  98. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.h +101 -0
  99. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.cpp +230 -0
  100. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.h +85 -0
  101. package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.cpp +51 -0
  102. package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.h +67 -0
  103. package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.h +182 -0
  104. package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.inl +351 -0
  105. package/native/third_party/JoltPhysics/Jolt/Core/Memory.cpp +85 -0
  106. package/native/third_party/JoltPhysics/Jolt/Core/Memory.h +85 -0
  107. package/native/third_party/JoltPhysics/Jolt/Core/Mutex.h +223 -0
  108. package/native/third_party/JoltPhysics/Jolt/Core/MutexArray.h +98 -0
  109. package/native/third_party/JoltPhysics/Jolt/Core/NonCopyable.h +18 -0
  110. package/native/third_party/JoltPhysics/Jolt/Core/Profiler.cpp +677 -0
  111. package/native/third_party/JoltPhysics/Jolt/Core/Profiler.h +301 -0
  112. package/native/third_party/JoltPhysics/Jolt/Core/Profiler.inl +90 -0
  113. package/native/third_party/JoltPhysics/Jolt/Core/QuickSort.h +137 -0
  114. package/native/third_party/JoltPhysics/Jolt/Core/RTTI.cpp +149 -0
  115. package/native/third_party/JoltPhysics/Jolt/Core/RTTI.h +436 -0
  116. package/native/third_party/JoltPhysics/Jolt/Core/Reference.h +244 -0
  117. package/native/third_party/JoltPhysics/Jolt/Core/Result.h +174 -0
  118. package/native/third_party/JoltPhysics/Jolt/Core/STLAlignedAllocator.h +72 -0
  119. package/native/third_party/JoltPhysics/Jolt/Core/STLAllocator.h +127 -0
  120. package/native/third_party/JoltPhysics/Jolt/Core/STLLocalAllocator.h +170 -0
  121. package/native/third_party/JoltPhysics/Jolt/Core/STLTempAllocator.h +80 -0
  122. package/native/third_party/JoltPhysics/Jolt/Core/ScopeExit.h +49 -0
  123. package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.cpp +135 -0
  124. package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.h +68 -0
  125. package/native/third_party/JoltPhysics/Jolt/Core/StaticArray.h +329 -0
  126. package/native/third_party/JoltPhysics/Jolt/Core/StreamIn.h +120 -0
  127. package/native/third_party/JoltPhysics/Jolt/Core/StreamOut.h +97 -0
  128. package/native/third_party/JoltPhysics/Jolt/Core/StreamUtils.h +168 -0
  129. package/native/third_party/JoltPhysics/Jolt/Core/StreamWrapper.h +53 -0
  130. package/native/third_party/JoltPhysics/Jolt/Core/StridedPtr.h +63 -0
  131. package/native/third_party/JoltPhysics/Jolt/Core/StringTools.cpp +101 -0
  132. package/native/third_party/JoltPhysics/Jolt/Core/StringTools.h +38 -0
  133. package/native/third_party/JoltPhysics/Jolt/Core/TempAllocator.h +209 -0
  134. package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.cpp +37 -0
  135. package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.h +58 -0
  136. package/native/third_party/JoltPhysics/Jolt/Core/UnorderedMap.h +80 -0
  137. package/native/third_party/JoltPhysics/Jolt/Core/UnorderedSet.h +32 -0
  138. package/native/third_party/JoltPhysics/Jolt/Geometry/AABox.h +313 -0
  139. package/native/third_party/JoltPhysics/Jolt/Geometry/AABox4.h +224 -0
  140. package/native/third_party/JoltPhysics/Jolt/Geometry/ClipPoly.h +200 -0
  141. package/native/third_party/JoltPhysics/Jolt/Geometry/ClosestPoint.h +498 -0
  142. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.cpp +1467 -0
  143. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.h +276 -0
  144. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.cpp +335 -0
  145. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.h +105 -0
  146. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexSupport.h +188 -0
  147. package/native/third_party/JoltPhysics/Jolt/Geometry/EPAConvexHullBuilder.h +845 -0
  148. package/native/third_party/JoltPhysics/Jolt/Geometry/EPAPenetrationDepth.h +557 -0
  149. package/native/third_party/JoltPhysics/Jolt/Geometry/Ellipse.h +77 -0
  150. package/native/third_party/JoltPhysics/Jolt/Geometry/GJKClosestPoint.h +945 -0
  151. package/native/third_party/JoltPhysics/Jolt/Geometry/IndexedTriangle.h +130 -0
  152. package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.cpp +222 -0
  153. package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.h +19 -0
  154. package/native/third_party/JoltPhysics/Jolt/Geometry/MortonCode.h +40 -0
  155. package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.cpp +178 -0
  156. package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.h +39 -0
  157. package/native/third_party/JoltPhysics/Jolt/Geometry/Plane.h +104 -0
  158. package/native/third_party/JoltPhysics/Jolt/Geometry/RayAABox.h +241 -0
  159. package/native/third_party/JoltPhysics/Jolt/Geometry/RayCapsule.h +37 -0
  160. package/native/third_party/JoltPhysics/Jolt/Geometry/RayCylinder.h +101 -0
  161. package/native/third_party/JoltPhysics/Jolt/Geometry/RaySphere.h +96 -0
  162. package/native/third_party/JoltPhysics/Jolt/Geometry/RayTriangle.h +158 -0
  163. package/native/third_party/JoltPhysics/Jolt/Geometry/Sphere.h +72 -0
  164. package/native/third_party/JoltPhysics/Jolt/Geometry/Triangle.h +34 -0
  165. package/native/third_party/JoltPhysics/Jolt/Jolt.cmake +703 -0
  166. package/native/third_party/JoltPhysics/Jolt/Jolt.h +16 -0
  167. package/native/third_party/JoltPhysics/Jolt/Jolt.natvis +116 -0
  168. package/native/third_party/JoltPhysics/Jolt/Math/BVec16.h +99 -0
  169. package/native/third_party/JoltPhysics/Jolt/Math/BVec16.inl +177 -0
  170. package/native/third_party/JoltPhysics/Jolt/Math/DMat44.h +158 -0
  171. package/native/third_party/JoltPhysics/Jolt/Math/DMat44.inl +310 -0
  172. package/native/third_party/JoltPhysics/Jolt/Math/DVec3.h +291 -0
  173. package/native/third_party/JoltPhysics/Jolt/Math/DVec3.inl +941 -0
  174. package/native/third_party/JoltPhysics/Jolt/Math/Double3.h +48 -0
  175. package/native/third_party/JoltPhysics/Jolt/Math/DynMatrix.h +31 -0
  176. package/native/third_party/JoltPhysics/Jolt/Math/EigenValueSymmetric.h +177 -0
  177. package/native/third_party/JoltPhysics/Jolt/Math/FindRoot.h +42 -0
  178. package/native/third_party/JoltPhysics/Jolt/Math/Float2.h +36 -0
  179. package/native/third_party/JoltPhysics/Jolt/Math/Float3.h +50 -0
  180. package/native/third_party/JoltPhysics/Jolt/Math/Float4.h +44 -0
  181. package/native/third_party/JoltPhysics/Jolt/Math/GaussianElimination.h +102 -0
  182. package/native/third_party/JoltPhysics/Jolt/Math/HalfFloat.h +208 -0
  183. package/native/third_party/JoltPhysics/Jolt/Math/Mat44.h +243 -0
  184. package/native/third_party/JoltPhysics/Jolt/Math/Mat44.inl +952 -0
  185. package/native/third_party/JoltPhysics/Jolt/Math/Math.h +208 -0
  186. package/native/third_party/JoltPhysics/Jolt/Math/MathTypes.h +32 -0
  187. package/native/third_party/JoltPhysics/Jolt/Math/Matrix.h +259 -0
  188. package/native/third_party/JoltPhysics/Jolt/Math/Quat.h +268 -0
  189. package/native/third_party/JoltPhysics/Jolt/Math/Quat.inl +406 -0
  190. package/native/third_party/JoltPhysics/Jolt/Math/Real.h +44 -0
  191. package/native/third_party/JoltPhysics/Jolt/Math/Swizzle.h +19 -0
  192. package/native/third_party/JoltPhysics/Jolt/Math/Trigonometry.h +79 -0
  193. package/native/third_party/JoltPhysics/Jolt/Math/UVec4.h +232 -0
  194. package/native/third_party/JoltPhysics/Jolt/Math/UVec4.inl +636 -0
  195. package/native/third_party/JoltPhysics/Jolt/Math/Vec3.cpp +71 -0
  196. package/native/third_party/JoltPhysics/Jolt/Math/Vec3.h +308 -0
  197. package/native/third_party/JoltPhysics/Jolt/Math/Vec3.inl +942 -0
  198. package/native/third_party/JoltPhysics/Jolt/Math/Vec4.h +320 -0
  199. package/native/third_party/JoltPhysics/Jolt/Math/Vec4.inl +1152 -0
  200. package/native/third_party/JoltPhysics/Jolt/Math/Vector.h +211 -0
  201. package/native/third_party/JoltPhysics/Jolt/ObjectStream/GetPrimitiveTypeOfType.h +54 -0
  202. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.cpp +38 -0
  203. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.h +337 -0
  204. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.cpp +252 -0
  205. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.h +57 -0
  206. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.cpp +165 -0
  207. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.h +57 -0
  208. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.cpp +635 -0
  209. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.h +148 -0
  210. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.cpp +166 -0
  211. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.h +101 -0
  212. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.cpp +418 -0
  213. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.h +55 -0
  214. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.cpp +255 -0
  215. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.h +62 -0
  216. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTypes.h +26 -0
  217. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttribute.h +111 -0
  218. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeEnum.h +67 -0
  219. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeTyped.h +60 -0
  220. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.cpp +15 -0
  221. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.h +170 -0
  222. package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.cpp +70 -0
  223. package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.h +45 -0
  224. package/native/third_party/JoltPhysics/Jolt/Physics/Body/AllowedDOFs.h +68 -0
  225. package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.cpp +426 -0
  226. package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.h +452 -0
  227. package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.inl +197 -0
  228. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyAccess.h +68 -0
  229. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyActivationListener.h +28 -0
  230. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.cpp +234 -0
  231. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.h +124 -0
  232. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyFilter.h +130 -0
  233. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyID.h +101 -0
  234. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.cpp +1099 -0
  235. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.h +324 -0
  236. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLock.h +111 -0
  237. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockInterface.h +134 -0
  238. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockMulti.h +120 -0
  239. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.cpp +1220 -0
  240. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.h +403 -0
  241. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyPair.h +36 -0
  242. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyType.h +19 -0
  243. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.cpp +185 -0
  244. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.h +58 -0
  245. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.cpp +92 -0
  246. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.h +308 -0
  247. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.inl +178 -0
  248. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionQuality.h +31 -0
  249. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionType.h +17 -0
  250. package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.cpp +354 -0
  251. package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.h +159 -0
  252. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.cpp +59 -0
  253. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.h +157 -0
  254. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterID.h +98 -0
  255. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.cpp +1933 -0
  256. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.h +752 -0
  257. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/AABoxCast.h +20 -0
  258. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdgeMode.h +17 -0
  259. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdges.h +114 -0
  260. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BackFaceMode.h +16 -0
  261. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.cpp +16 -0
  262. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.h +109 -0
  263. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.cpp +313 -0
  264. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.h +38 -0
  265. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h +148 -0
  266. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceMask.h +92 -0
  267. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceTable.h +64 -0
  268. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp +629 -0
  269. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.h +108 -0
  270. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuery.h +56 -0
  271. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterMask.h +35 -0
  272. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterTable.h +66 -0
  273. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.cpp +1768 -0
  274. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.h +389 -0
  275. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp +107 -0
  276. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.h +46 -0
  277. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastResult.h +37 -0
  278. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.cpp +223 -0
  279. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.h +49 -0
  280. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollectFacesMode.h +16 -0
  281. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp +155 -0
  282. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.h +56 -0
  283. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollidePointResult.h +25 -0
  284. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShape.h +106 -0
  285. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShapeVsShapePerLeaf.h +94 -0
  286. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVertexIterator.h +110 -0
  287. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVerticesVsTriangles.h +102 -0
  288. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp +121 -0
  289. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.h +50 -0
  290. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollector.h +109 -0
  291. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollectorImpl.h +219 -0
  292. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.cpp +107 -0
  293. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.h +97 -0
  294. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.cpp +35 -0
  295. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.h +97 -0
  296. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ContactListener.h +143 -0
  297. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.cpp +213 -0
  298. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.h +48 -0
  299. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.cpp +32 -0
  300. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.h +46 -0
  301. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.cpp +38 -0
  302. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.h +130 -0
  303. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/InternalEdgeRemovingCollector.h +279 -0
  304. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.cpp +271 -0
  305. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h +44 -0
  306. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.cpp +448 -0
  307. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.h +77 -0
  308. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.cpp +62 -0
  309. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.h +110 -0
  310. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayer.h +111 -0
  311. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterMask.h +52 -0
  312. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterTable.h +78 -0
  313. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.cpp +35 -0
  314. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.h +57 -0
  315. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.cpp +38 -0
  316. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.h +37 -0
  317. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/RayCast.h +87 -0
  318. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.cpp +318 -0
  319. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.h +115 -0
  320. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.cpp +438 -0
  321. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.h +129 -0
  322. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.cpp +433 -0
  323. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.h +354 -0
  324. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShapeVisitors.h +461 -0
  325. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.cpp +1311 -0
  326. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.h +202 -0
  327. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.cpp +566 -0
  328. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.h +150 -0
  329. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.cpp +418 -0
  330. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.h +126 -0
  331. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.cpp +87 -0
  332. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.h +80 -0
  333. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.cpp +64 -0
  334. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.h +75 -0
  335. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/GetTrianglesContext.h +248 -0
  336. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.cpp +2754 -0
  337. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.h +380 -0
  338. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.cpp +1305 -0
  339. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.h +228 -0
  340. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.cpp +596 -0
  341. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.h +176 -0
  342. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.cpp +217 -0
  343. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h +140 -0
  344. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.cpp +541 -0
  345. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.h +147 -0
  346. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PolyhedronSubmergedVolumeCalculator.h +319 -0
  347. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.cpp +333 -0
  348. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h +161 -0
  349. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaleHelpers.h +83 -0
  350. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.cpp +238 -0
  351. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.h +145 -0
  352. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.cpp +325 -0
  353. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.h +466 -0
  354. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.cpp +347 -0
  355. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.h +125 -0
  356. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp +674 -0
  357. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.h +139 -0
  358. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeID.h +138 -0
  359. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeIDPair.h +65 -0
  360. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp +453 -0
  361. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.gliffy +1 -0
  362. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.h +135 -0
  363. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp +691 -0
  364. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.h +132 -0
  365. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.cpp +430 -0
  366. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.h +143 -0
  367. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeCast.h +173 -0
  368. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeFilter.h +73 -0
  369. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilter.h +40 -0
  370. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilterWrapper.h +58 -0
  371. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SortReverseAndStore.h +48 -0
  372. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.cpp +180 -0
  373. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.h +194 -0
  374. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/CalculateSolverSteps.h +70 -0
  375. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.cpp +246 -0
  376. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.h +133 -0
  377. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.cpp +73 -0
  378. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.h +243 -0
  379. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.cpp +289 -0
  380. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.h +100 -0
  381. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h +257 -0
  382. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h +682 -0
  383. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/DualAxisConstraintPart.h +276 -0
  384. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h +195 -0
  385. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/HingeRotationConstraintPart.h +222 -0
  386. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h +246 -0
  387. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/PointConstraintPart.h +239 -0
  388. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RackAndPinionConstraintPart.h +196 -0
  389. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h +283 -0
  390. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationQuatConstraintPart.h +246 -0
  391. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SpringPart.h +169 -0
  392. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h +597 -0
  393. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.cpp +1804 -0
  394. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.h +524 -0
  395. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.cpp +266 -0
  396. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.h +120 -0
  397. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.cpp +215 -0
  398. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.h +96 -0
  399. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.cpp +188 -0
  400. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.h +116 -0
  401. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.cpp +443 -0
  402. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.h +205 -0
  403. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.cpp +43 -0
  404. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.h +66 -0
  405. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.cpp +458 -0
  406. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.h +191 -0
  407. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.cpp +85 -0
  408. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.h +76 -0
  409. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.cpp +308 -0
  410. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.h +54 -0
  411. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.cpp +157 -0
  412. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.h +94 -0
  413. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.cpp +253 -0
  414. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.h +137 -0
  415. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.cpp +189 -0
  416. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.h +118 -0
  417. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.cpp +900 -0
  418. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.h +289 -0
  419. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.cpp +501 -0
  420. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.h +198 -0
  421. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.cpp +35 -0
  422. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.h +70 -0
  423. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.cpp +524 -0
  424. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.h +197 -0
  425. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.cpp +56 -0
  426. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.h +65 -0
  427. package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.cpp +17 -0
  428. package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.h +159 -0
  429. package/native/third_party/JoltPhysics/Jolt/Physics/EActivation.h +16 -0
  430. package/native/third_party/JoltPhysics/Jolt/Physics/EPhysicsUpdateError.h +37 -0
  431. package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.cpp +492 -0
  432. package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.h +144 -0
  433. package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.cpp +582 -0
  434. package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.h +187 -0
  435. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsLock.h +169 -0
  436. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.cpp +261 -0
  437. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.h +104 -0
  438. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSettings.h +125 -0
  439. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsStepListener.h +37 -0
  440. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.cpp +2915 -0
  441. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.h +391 -0
  442. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.cpp +25 -0
  443. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.h +176 -0
  444. package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.cpp +744 -0
  445. package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.h +245 -0
  446. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyContactListener.h +55 -0
  447. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.cpp +128 -0
  448. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.h +75 -0
  449. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyManifold.h +74 -0
  450. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp +1501 -0
  451. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.h +333 -0
  452. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.cpp +354 -0
  453. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.h +73 -0
  454. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp +1487 -0
  455. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.h +390 -0
  456. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyUpdateContext.h +63 -0
  457. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyVertex.h +36 -0
  458. package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorder.h +136 -0
  459. package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.cpp +90 -0
  460. package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.h +50 -0
  461. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.cpp +306 -0
  462. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.h +119 -0
  463. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.cpp +547 -0
  464. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.h +169 -0
  465. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.cpp +33 -0
  466. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.h +33 -0
  467. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.cpp +376 -0
  468. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.h +146 -0
  469. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.cpp +703 -0
  470. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.h +252 -0
  471. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.cpp +17 -0
  472. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.h +87 -0
  473. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.cpp +81 -0
  474. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.h +39 -0
  475. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.cpp +122 -0
  476. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.h +93 -0
  477. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.cpp +52 -0
  478. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.h +56 -0
  479. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.cpp +159 -0
  480. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.h +87 -0
  481. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.cpp +93 -0
  482. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.h +148 -0
  483. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.cpp +866 -0
  484. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.h +205 -0
  485. package/native/third_party/JoltPhysics/Jolt/RegisterTypes.cpp +204 -0
  486. package/native/third_party/JoltPhysics/Jolt/RegisterTypes.h +29 -0
  487. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.cpp +1107 -0
  488. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.h +383 -0
  489. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.cpp +168 -0
  490. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.h +48 -0
  491. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.cpp +158 -0
  492. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.h +130 -0
  493. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.cpp +80 -0
  494. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.h +88 -0
  495. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.cpp +165 -0
  496. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.h +91 -0
  497. package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.cpp +82 -0
  498. package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.h +72 -0
  499. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.cpp +237 -0
  500. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.h +145 -0
  501. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.cpp +87 -0
  502. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.h +82 -0
  503. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.cpp +73 -0
  504. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.h +84 -0
  505. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.cpp +139 -0
  506. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.h +52 -0
  507. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.cpp +43 -0
  508. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.h +28 -0
  509. package/native/third_party/JoltPhysics/LICENSE +7 -0
  510. package/native/third_party/JoltPhysics/README.md +173 -0
  511. package/native/third_party/bloom_jolt/CMakeLists.txt +78 -0
  512. package/native/third_party/bloom_jolt/include/bloom_jolt.h +519 -0
  513. package/native/third_party/bloom_jolt/src/bloom_jolt.cpp +1780 -0
  514. package/native/tvos/Cargo.lock +1692 -0
  515. package/native/tvos/Cargo.toml +22 -0
  516. package/native/tvos/src/lib.rs +3179 -0
  517. package/native/watchos/Cargo.lock +16 -0
  518. package/native/watchos/Cargo.toml +19 -0
  519. package/native/watchos/shaders/bloom_postfx.metal +99 -0
  520. package/native/watchos/src/BloomWatchApp.swift +1236 -0
  521. package/native/watchos/src/BloomWatchAudio.swift +179 -0
  522. package/native/watchos/src/audio.rs +55 -0
  523. package/native/watchos/src/draw_list.rs +223 -0
  524. package/native/watchos/src/ffi_stubs.rs +454 -0
  525. package/native/watchos/src/lib.rs +1013 -0
  526. package/native/watchos/src/models.rs +746 -0
  527. package/native/watchos/src/postfx.rs +91 -0
  528. package/native/watchos/src/scene.rs +534 -0
  529. package/native/watchos/src/textures.rs +184 -0
  530. package/native/web/Cargo.lock +1656 -0
  531. package/native/web/Cargo.toml +38 -0
  532. package/native/web/bloom_glue.js +218 -0
  533. package/native/web/build.sh +101 -0
  534. package/native/web/index.html +390 -0
  535. package/native/web/jolt_bridge.js +1311 -0
  536. package/native/web/src/lib.rs +2739 -0
  537. package/native/windows/Cargo.lock +1813 -0
  538. package/native/windows/Cargo.toml +31 -0
  539. package/native/windows/src/lib.rs +1933 -0
  540. package/package.json +558 -0
  541. package/src/audio/index.ts +151 -0
  542. package/src/core/colors.ts +56 -0
  543. package/src/core/index.ts +903 -0
  544. package/src/core/keys.ts +63 -0
  545. package/src/core/types.ts +102 -0
  546. package/src/index.ts +158 -0
  547. package/src/math/index.ts +502 -0
  548. package/src/mobile/index.ts +294 -0
  549. package/src/models/index.ts +859 -0
  550. package/src/physics/index.ts +1072 -0
  551. package/src/scene/index.ts +570 -0
  552. package/src/shapes/index.ts +120 -0
  553. package/src/text/index.ts +48 -0
  554. package/src/textures/index.ts +173 -0
  555. package/src/world/index.ts +22 -0
  556. package/src/world/loader.ts +385 -0
  557. package/src/world/prefab.ts +205 -0
  558. package/src/world/saver.ts +61 -0
  559. package/src/world/terrain.ts +254 -0
  560. package/src/world/types.ts +136 -0
  561. package/src/world/validate.ts +202 -0
  562. package/src/world/version.ts +47 -0
@@ -0,0 +1,1107 @@
1
+ // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2
+ // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3
+ // SPDX-License-Identifier: MIT
4
+
5
+ #include <Jolt/Jolt.h>
6
+
7
+ #ifdef JPH_DEBUG_RENDERER
8
+
9
+ #include <Jolt/Renderer/DebugRenderer.h>
10
+ #include <Jolt/Core/Profiler.h>
11
+ #include <Jolt/Geometry/OrientedBox.h>
12
+
13
+ JPH_NAMESPACE_BEGIN
14
+
15
+ DebugRenderer *DebugRenderer::sInstance = nullptr;
16
+
17
+ // Number of LOD levels to create
18
+ static const int sMaxLevel = 4;
19
+
20
+ // Distance for each LOD level, these are tweaked for an object of approx. size 1. Use the lod scale to scale these distances.
21
+ static const float sLODDistanceForLevel[] = { 5.0f, 10.0f, 40.0f, cLargeFloat };
22
+
23
+ DebugRenderer::Triangle::Triangle(Vec3Arg inV1, Vec3Arg inV2, Vec3Arg inV3, ColorArg inColor)
24
+ {
25
+ // Set position
26
+ inV1.StoreFloat3(&mV[0].mPosition);
27
+ inV2.StoreFloat3(&mV[1].mPosition);
28
+ inV3.StoreFloat3(&mV[2].mPosition);
29
+
30
+ // Set color
31
+ mV[0].mColor = mV[1].mColor = mV[2].mColor = inColor;
32
+
33
+ // Calculate normal
34
+ Vec3 normal = (inV2 - inV1).Cross(inV3 - inV1);
35
+ float normal_len = normal.Length();
36
+ if (normal_len > 0.0f)
37
+ normal /= normal_len;
38
+ Float3 normal3;
39
+ normal.StoreFloat3(&normal3);
40
+ mV[0].mNormal = mV[1].mNormal = mV[2].mNormal = normal3;
41
+
42
+ // Reset UV's
43
+ mV[0].mUV = mV[1].mUV = mV[2].mUV = { 0, 0 };
44
+ }
45
+
46
+ DebugRenderer::Triangle::Triangle(Vec3Arg inV1, Vec3Arg inV2, Vec3Arg inV3, ColorArg inColor, Vec3Arg inUVOrigin, Vec3Arg inUVDirection)
47
+ {
48
+ // Set position
49
+ inV1.StoreFloat3(&mV[0].mPosition);
50
+ inV2.StoreFloat3(&mV[1].mPosition);
51
+ inV3.StoreFloat3(&mV[2].mPosition);
52
+
53
+ // Set color
54
+ mV[0].mColor = mV[1].mColor = mV[2].mColor = inColor;
55
+
56
+ // Calculate normal
57
+ Vec3 normal = (inV2 - inV1).Cross(inV3 - inV1).Normalized();
58
+ Float3 normal3;
59
+ normal.StoreFloat3(&normal3);
60
+ mV[0].mNormal = mV[1].mNormal = mV[2].mNormal = normal3;
61
+
62
+ // Set UV's
63
+ Vec3 uv1 = inV1 - inUVOrigin;
64
+ Vec3 uv2 = inV2 - inUVOrigin;
65
+ Vec3 uv3 = inV3 - inUVOrigin;
66
+ Vec3 axis2 = normal.Cross(inUVDirection);
67
+ mV[0].mUV = { inUVDirection.Dot(uv1), axis2.Dot(uv1) };
68
+ mV[1].mUV = { inUVDirection.Dot(uv2), axis2.Dot(uv2) };
69
+ mV[2].mUV = { inUVDirection.Dot(uv3), axis2.Dot(uv3) };
70
+ }
71
+
72
+ DebugRenderer::DebugRenderer()
73
+ {
74
+ // Store singleton
75
+ JPH_ASSERT(sInstance == nullptr);
76
+ sInstance = this;
77
+ }
78
+
79
+ DebugRenderer::~DebugRenderer()
80
+ {
81
+ JPH_ASSERT(sInstance == this);
82
+ sInstance = nullptr;
83
+ }
84
+
85
+ void DebugRenderer::DrawWireBox(const AABox &inBox, ColorArg inColor)
86
+ {
87
+ JPH_PROFILE_FUNCTION();
88
+
89
+ // 8 vertices
90
+ RVec3 v1(Real(inBox.mMin.GetX()), Real(inBox.mMin.GetY()), Real(inBox.mMin.GetZ()));
91
+ RVec3 v2(Real(inBox.mMin.GetX()), Real(inBox.mMin.GetY()), Real(inBox.mMax.GetZ()));
92
+ RVec3 v3(Real(inBox.mMin.GetX()), Real(inBox.mMax.GetY()), Real(inBox.mMin.GetZ()));
93
+ RVec3 v4(Real(inBox.mMin.GetX()), Real(inBox.mMax.GetY()), Real(inBox.mMax.GetZ()));
94
+ RVec3 v5(Real(inBox.mMax.GetX()), Real(inBox.mMin.GetY()), Real(inBox.mMin.GetZ()));
95
+ RVec3 v6(Real(inBox.mMax.GetX()), Real(inBox.mMin.GetY()), Real(inBox.mMax.GetZ()));
96
+ RVec3 v7(Real(inBox.mMax.GetX()), Real(inBox.mMax.GetY()), Real(inBox.mMin.GetZ()));
97
+ RVec3 v8(Real(inBox.mMax.GetX()), Real(inBox.mMax.GetY()), Real(inBox.mMax.GetZ()));
98
+
99
+ // 12 edges
100
+ DrawLine(v1, v2, inColor);
101
+ DrawLine(v1, v3, inColor);
102
+ DrawLine(v1, v5, inColor);
103
+ DrawLine(v2, v4, inColor);
104
+ DrawLine(v2, v6, inColor);
105
+ DrawLine(v3, v4, inColor);
106
+ DrawLine(v3, v7, inColor);
107
+ DrawLine(v4, v8, inColor);
108
+ DrawLine(v5, v6, inColor);
109
+ DrawLine(v5, v7, inColor);
110
+ DrawLine(v6, v8, inColor);
111
+ DrawLine(v7, v8, inColor);
112
+ }
113
+
114
+ void DebugRenderer::DrawWireBox(const OrientedBox &inBox, ColorArg inColor)
115
+ {
116
+ JPH_PROFILE_FUNCTION();
117
+
118
+ // 8 vertices
119
+ RVec3 v1(inBox.mOrientation * Vec3(-inBox.mHalfExtents.GetX(), -inBox.mHalfExtents.GetY(), -inBox.mHalfExtents.GetZ()));
120
+ RVec3 v2(inBox.mOrientation * Vec3(-inBox.mHalfExtents.GetX(), -inBox.mHalfExtents.GetY(), inBox.mHalfExtents.GetZ()));
121
+ RVec3 v3(inBox.mOrientation * Vec3(-inBox.mHalfExtents.GetX(), inBox.mHalfExtents.GetY(), -inBox.mHalfExtents.GetZ()));
122
+ RVec3 v4(inBox.mOrientation * Vec3(-inBox.mHalfExtents.GetX(), inBox.mHalfExtents.GetY(), inBox.mHalfExtents.GetZ()));
123
+ RVec3 v5(inBox.mOrientation * Vec3(inBox.mHalfExtents.GetX(), -inBox.mHalfExtents.GetY(), -inBox.mHalfExtents.GetZ()));
124
+ RVec3 v6(inBox.mOrientation * Vec3(inBox.mHalfExtents.GetX(), -inBox.mHalfExtents.GetY(), inBox.mHalfExtents.GetZ()));
125
+ RVec3 v7(inBox.mOrientation * Vec3(inBox.mHalfExtents.GetX(), inBox.mHalfExtents.GetY(), -inBox.mHalfExtents.GetZ()));
126
+ RVec3 v8(inBox.mOrientation * Vec3(inBox.mHalfExtents.GetX(), inBox.mHalfExtents.GetY(), inBox.mHalfExtents.GetZ()));
127
+
128
+ // 12 edges
129
+ DrawLine(v1, v2, inColor);
130
+ DrawLine(v1, v3, inColor);
131
+ DrawLine(v1, v5, inColor);
132
+ DrawLine(v2, v4, inColor);
133
+ DrawLine(v2, v6, inColor);
134
+ DrawLine(v3, v4, inColor);
135
+ DrawLine(v3, v7, inColor);
136
+ DrawLine(v4, v8, inColor);
137
+ DrawLine(v5, v6, inColor);
138
+ DrawLine(v5, v7, inColor);
139
+ DrawLine(v6, v8, inColor);
140
+ DrawLine(v7, v8, inColor);
141
+ }
142
+
143
+ void DebugRenderer::DrawWireBox(RMat44Arg inMatrix, const AABox &inBox, ColorArg inColor)
144
+ {
145
+ JPH_PROFILE_FUNCTION();
146
+
147
+ // 8 vertices
148
+ RVec3 v1 = inMatrix * Vec3(inBox.mMin.GetX(), inBox.mMin.GetY(), inBox.mMin.GetZ());
149
+ RVec3 v2 = inMatrix * Vec3(inBox.mMin.GetX(), inBox.mMin.GetY(), inBox.mMax.GetZ());
150
+ RVec3 v3 = inMatrix * Vec3(inBox.mMin.GetX(), inBox.mMax.GetY(), inBox.mMin.GetZ());
151
+ RVec3 v4 = inMatrix * Vec3(inBox.mMin.GetX(), inBox.mMax.GetY(), inBox.mMax.GetZ());
152
+ RVec3 v5 = inMatrix * Vec3(inBox.mMax.GetX(), inBox.mMin.GetY(), inBox.mMin.GetZ());
153
+ RVec3 v6 = inMatrix * Vec3(inBox.mMax.GetX(), inBox.mMin.GetY(), inBox.mMax.GetZ());
154
+ RVec3 v7 = inMatrix * Vec3(inBox.mMax.GetX(), inBox.mMax.GetY(), inBox.mMin.GetZ());
155
+ RVec3 v8 = inMatrix * Vec3(inBox.mMax.GetX(), inBox.mMax.GetY(), inBox.mMax.GetZ());
156
+
157
+ // 12 edges
158
+ DrawLine(v1, v2, inColor);
159
+ DrawLine(v1, v3, inColor);
160
+ DrawLine(v1, v5, inColor);
161
+ DrawLine(v2, v4, inColor);
162
+ DrawLine(v2, v6, inColor);
163
+ DrawLine(v3, v4, inColor);
164
+ DrawLine(v3, v7, inColor);
165
+ DrawLine(v4, v8, inColor);
166
+ DrawLine(v5, v6, inColor);
167
+ DrawLine(v5, v7, inColor);
168
+ DrawLine(v6, v8, inColor);
169
+ DrawLine(v7, v8, inColor);
170
+ }
171
+
172
+ void DebugRenderer::DrawMarker(RVec3Arg inPosition, ColorArg inColor, float inSize)
173
+ {
174
+ JPH_PROFILE_FUNCTION();
175
+
176
+ Vec3 dx(inSize, 0, 0);
177
+ Vec3 dy(0, inSize, 0);
178
+ Vec3 dz(0, 0, inSize);
179
+ DrawLine(inPosition - dy, inPosition + dy, inColor);
180
+ DrawLine(inPosition - dx, inPosition + dx, inColor);
181
+ DrawLine(inPosition - dz, inPosition + dz, inColor);
182
+ }
183
+
184
+ void DebugRenderer::DrawArrow(RVec3Arg inFrom, RVec3Arg inTo, ColorArg inColor, float inSize)
185
+ {
186
+ JPH_PROFILE_FUNCTION();
187
+
188
+ // Draw base line
189
+ DrawLine(inFrom, inTo, inColor);
190
+
191
+ if (inSize > 0.0f)
192
+ {
193
+ // Draw arrow head
194
+ Vec3 dir = Vec3(inTo - inFrom);
195
+ float len = dir.Length();
196
+ if (len != 0.0f)
197
+ dir = dir * (inSize / len);
198
+ else
199
+ dir = Vec3(inSize, 0, 0);
200
+ Vec3 perp = inSize * dir.GetNormalizedPerpendicular();
201
+ DrawLine(inTo - dir + perp, inTo, inColor);
202
+ DrawLine(inTo - dir - perp, inTo, inColor);
203
+ }
204
+ }
205
+
206
+ void DebugRenderer::DrawCoordinateSystem(RMat44Arg inTransform, float inSize)
207
+ {
208
+ JPH_PROFILE_FUNCTION();
209
+
210
+ DrawArrow(inTransform.GetTranslation(), inTransform * Vec3(inSize, 0, 0), Color::sRed, 0.1f * inSize);
211
+ DrawArrow(inTransform.GetTranslation(), inTransform * Vec3(0, inSize, 0), Color::sGreen, 0.1f * inSize);
212
+ DrawArrow(inTransform.GetTranslation(), inTransform * Vec3(0, 0, inSize), Color::sBlue, 0.1f * inSize);
213
+ }
214
+
215
+ void DebugRenderer::DrawPlane(RVec3Arg inPoint, Vec3Arg inNormal, ColorArg inColor, float inSize)
216
+ {
217
+ // Create orthogonal basis
218
+ Vec3 perp1 = inNormal.Cross(Vec3::sAxisY()).NormalizedOr(Vec3::sAxisX());
219
+ Vec3 perp2 = perp1.Cross(inNormal).Normalized();
220
+ perp1 = inNormal.Cross(perp2);
221
+
222
+ // Calculate corners
223
+ RVec3 corner1 = inPoint + inSize * (perp1 + perp2);
224
+ RVec3 corner2 = inPoint + inSize * (perp1 - perp2);
225
+ RVec3 corner3 = inPoint + inSize * (-perp1 - perp2);
226
+ RVec3 corner4 = inPoint + inSize * (-perp1 + perp2);
227
+
228
+ // Draw cross
229
+ DrawLine(corner1, corner3, inColor);
230
+ DrawLine(corner2, corner4, inColor);
231
+
232
+ // Draw square
233
+ DrawLine(corner1, corner2, inColor);
234
+ DrawLine(corner2, corner3, inColor);
235
+ DrawLine(corner3, corner4, inColor);
236
+ DrawLine(corner4, corner1, inColor);
237
+
238
+ // Draw normal
239
+ DrawArrow(inPoint, inPoint + inSize * inNormal, inColor, 0.1f * inSize);
240
+ }
241
+
242
+ void DebugRenderer::DrawWireTriangle(RVec3Arg inV1, RVec3Arg inV2, RVec3Arg inV3, ColorArg inColor)
243
+ {
244
+ JPH_PROFILE_FUNCTION();
245
+
246
+ DrawLine(inV1, inV2, inColor);
247
+ DrawLine(inV2, inV3, inColor);
248
+ DrawLine(inV3, inV1, inColor);
249
+ }
250
+
251
+ void DebugRenderer::DrawWireSphere(RVec3Arg inCenter, float inRadius, ColorArg inColor, int inLevel)
252
+ {
253
+ RMat44 matrix = RMat44::sTranslation(inCenter) * Mat44::sScale(inRadius);
254
+
255
+ DrawWireUnitSphere(matrix, inColor, inLevel);
256
+ }
257
+
258
+ void DebugRenderer::DrawWireUnitSphere(RMat44Arg inMatrix, ColorArg inColor, int inLevel)
259
+ {
260
+ JPH_PROFILE_FUNCTION();
261
+
262
+ DrawWireUnitSphereRecursive(inMatrix, inColor, Vec3::sAxisX(), Vec3::sAxisY(), Vec3::sAxisZ(), inLevel);
263
+ DrawWireUnitSphereRecursive(inMatrix, inColor, -Vec3::sAxisX(), Vec3::sAxisY(), Vec3::sAxisZ(), inLevel);
264
+ DrawWireUnitSphereRecursive(inMatrix, inColor, Vec3::sAxisX(), -Vec3::sAxisY(), Vec3::sAxisZ(), inLevel);
265
+ DrawWireUnitSphereRecursive(inMatrix, inColor, -Vec3::sAxisX(), -Vec3::sAxisY(), Vec3::sAxisZ(), inLevel);
266
+ DrawWireUnitSphereRecursive(inMatrix, inColor, Vec3::sAxisX(), Vec3::sAxisY(), -Vec3::sAxisZ(), inLevel);
267
+ DrawWireUnitSphereRecursive(inMatrix, inColor, -Vec3::sAxisX(), Vec3::sAxisY(), -Vec3::sAxisZ(), inLevel);
268
+ DrawWireUnitSphereRecursive(inMatrix, inColor, Vec3::sAxisX(), -Vec3::sAxisY(), -Vec3::sAxisZ(), inLevel);
269
+ DrawWireUnitSphereRecursive(inMatrix, inColor, -Vec3::sAxisX(), -Vec3::sAxisY(), -Vec3::sAxisZ(), inLevel);
270
+ }
271
+
272
+ void DebugRenderer::DrawWireUnitSphereRecursive(RMat44Arg inMatrix, ColorArg inColor, Vec3Arg inDir1, Vec3Arg inDir2, Vec3Arg inDir3, int inLevel)
273
+ {
274
+ if (inLevel == 0)
275
+ {
276
+ RVec3 d1 = inMatrix * inDir1;
277
+ RVec3 d2 = inMatrix * inDir2;
278
+ RVec3 d3 = inMatrix * inDir3;
279
+
280
+ DrawLine(d1, d2, inColor);
281
+ DrawLine(d2, d3, inColor);
282
+ DrawLine(d3, d1, inColor);
283
+ }
284
+ else
285
+ {
286
+ Vec3 center1 = (inDir1 + inDir2).Normalized();
287
+ Vec3 center2 = (inDir2 + inDir3).Normalized();
288
+ Vec3 center3 = (inDir3 + inDir1).Normalized();
289
+
290
+ DrawWireUnitSphereRecursive(inMatrix, inColor, inDir1, center1, center3, inLevel - 1);
291
+ DrawWireUnitSphereRecursive(inMatrix, inColor, center1, center2, center3, inLevel - 1);
292
+ DrawWireUnitSphereRecursive(inMatrix, inColor, center1, inDir2, center2, inLevel - 1);
293
+ DrawWireUnitSphereRecursive(inMatrix, inColor, center3, center2, inDir3, inLevel - 1);
294
+ }
295
+ }
296
+
297
+ void DebugRenderer::Create8thSphereRecursive(Array<uint32> &ioIndices, Array<Vertex> &ioVertices, Vec3Arg inDir1, uint32 &ioIdx1, Vec3Arg inDir2, uint32 &ioIdx2, Vec3Arg inDir3, uint32 &ioIdx3, const Float2 &inUV, SupportFunction inGetSupport, int inLevel)
298
+ {
299
+ if (inLevel == 0)
300
+ {
301
+ if (ioIdx1 == 0xffffffff)
302
+ {
303
+ ioIdx1 = (uint32)ioVertices.size();
304
+ Float3 position, normal;
305
+ inGetSupport(inDir1).StoreFloat3(&position);
306
+ inDir1.StoreFloat3(&normal);
307
+ ioVertices.push_back({ position, normal, inUV, Color::sWhite });
308
+ }
309
+
310
+ if (ioIdx2 == 0xffffffff)
311
+ {
312
+ ioIdx2 = (uint32)ioVertices.size();
313
+ Float3 position, normal;
314
+ inGetSupport(inDir2).StoreFloat3(&position);
315
+ inDir2.StoreFloat3(&normal);
316
+ ioVertices.push_back({ position, normal, inUV, Color::sWhite });
317
+ }
318
+
319
+ if (ioIdx3 == 0xffffffff)
320
+ {
321
+ ioIdx3 = (uint32)ioVertices.size();
322
+ Float3 position, normal;
323
+ inGetSupport(inDir3).StoreFloat3(&position);
324
+ inDir3.StoreFloat3(&normal);
325
+ ioVertices.push_back({ position, normal, inUV, Color::sWhite });
326
+ }
327
+
328
+ ioIndices.push_back(ioIdx1);
329
+ ioIndices.push_back(ioIdx2);
330
+ ioIndices.push_back(ioIdx3);
331
+ }
332
+ else
333
+ {
334
+ Vec3 center1 = (inDir1 + inDir2).Normalized();
335
+ Vec3 center2 = (inDir2 + inDir3).Normalized();
336
+ Vec3 center3 = (inDir3 + inDir1).Normalized();
337
+
338
+ uint32 idx1 = 0xffffffff;
339
+ uint32 idx2 = 0xffffffff;
340
+ uint32 idx3 = 0xffffffff;
341
+
342
+ Create8thSphereRecursive(ioIndices, ioVertices, inDir1, ioIdx1, center1, idx1, center3, idx3, inUV, inGetSupport, inLevel - 1);
343
+ Create8thSphereRecursive(ioIndices, ioVertices, center1, idx1, center2, idx2, center3, idx3, inUV, inGetSupport, inLevel - 1);
344
+ Create8thSphereRecursive(ioIndices, ioVertices, center1, idx1, inDir2, ioIdx2, center2, idx2, inUV, inGetSupport, inLevel - 1);
345
+ Create8thSphereRecursive(ioIndices, ioVertices, center3, idx3, center2, idx2, inDir3, ioIdx3, inUV, inGetSupport, inLevel - 1);
346
+ }
347
+ }
348
+
349
+ void DebugRenderer::Create8thSphere(Array<uint32> &ioIndices, Array<Vertex> &ioVertices, Vec3Arg inDir1, Vec3Arg inDir2, Vec3Arg inDir3, const Float2 &inUV, SupportFunction inGetSupport, int inLevel)
350
+ {
351
+ uint32 idx1 = 0xffffffff;
352
+ uint32 idx2 = 0xffffffff;
353
+ uint32 idx3 = 0xffffffff;
354
+
355
+ Create8thSphereRecursive(ioIndices, ioVertices, inDir1, idx1, inDir2, idx2, inDir3, idx3, inUV, inGetSupport, inLevel);
356
+ }
357
+
358
+ DebugRenderer::Batch DebugRenderer::CreateCylinder(float inTop, float inBottom, float inTopRadius, float inBottomRadius, int inLevel)
359
+ {
360
+ Array<Vertex> cylinder_vertices;
361
+ Array<uint32> cylinder_indices;
362
+
363
+ for (int q = 0; q < 4; ++q)
364
+ {
365
+ Float2 uv = (q & 1) == 0? Float2(0.25f, 0.75f) : Float2(0.25f, 0.25f);
366
+
367
+ uint32 center_start_idx = (uint32)cylinder_vertices.size();
368
+
369
+ Float3 nt(0.0f, 1.0f, 0.0f);
370
+ Float3 nb(0.0f, -1.0f, 0.0f);
371
+ cylinder_vertices.push_back({ Float3(0.0f, inTop, 0.0f), nt, uv, Color::sWhite });
372
+ cylinder_vertices.push_back({ Float3(0.0f, inBottom, 0.0f), nb, uv, Color::sWhite });
373
+
374
+ uint32 vtx_start_idx = (uint32)cylinder_vertices.size();
375
+
376
+ int num_parts = 1 << inLevel;
377
+ for (int i = 0; i <= num_parts; ++i)
378
+ {
379
+ // Calculate top and bottom vertex
380
+ float angle = 0.5f * JPH_PI * (float(q) + float(i) / num_parts);
381
+ float s = Sin(angle);
382
+ float c = Cos(angle);
383
+ Float3 vt(inTopRadius * s, inTop, inTopRadius * c);
384
+ Float3 vb(inBottomRadius * s, inBottom, inBottomRadius * c);
385
+
386
+ // Calculate normal
387
+ Vec3 edge = Vec3(vt) - Vec3(vb);
388
+ Float3 n;
389
+ edge.Cross(Vec3(s, 0, c).Cross(edge)).Normalized().StoreFloat3(&n);
390
+
391
+ cylinder_vertices.push_back({ vt, nt, uv, Color::sWhite });
392
+ cylinder_vertices.push_back({ vb, nb, uv, Color::sWhite });
393
+ cylinder_vertices.push_back({ vt, n, uv, Color::sWhite });
394
+ cylinder_vertices.push_back({ vb, n, uv, Color::sWhite });
395
+ }
396
+
397
+ for (int i = 0; i < num_parts; ++i)
398
+ {
399
+ uint32 start = vtx_start_idx + 4 * i;
400
+
401
+ // Top
402
+ cylinder_indices.push_back(center_start_idx);
403
+ cylinder_indices.push_back(start);
404
+ cylinder_indices.push_back(start + 4);
405
+
406
+ // Bottom
407
+ cylinder_indices.push_back(center_start_idx + 1);
408
+ cylinder_indices.push_back(start + 5);
409
+ cylinder_indices.push_back(start + 1);
410
+
411
+ // Side
412
+ cylinder_indices.push_back(start + 2);
413
+ cylinder_indices.push_back(start + 3);
414
+ cylinder_indices.push_back(start + 7);
415
+
416
+ cylinder_indices.push_back(start + 2);
417
+ cylinder_indices.push_back(start + 7);
418
+ cylinder_indices.push_back(start + 6);
419
+ }
420
+ }
421
+
422
+ return CreateTriangleBatch(cylinder_vertices, cylinder_indices);
423
+ }
424
+
425
+ void DebugRenderer::CreateQuad(Array<uint32> &ioIndices, Array<Vertex> &ioVertices, Vec3Arg inV1, Vec3Arg inV2, Vec3Arg inV3, Vec3Arg inV4)
426
+ {
427
+ // Make room
428
+ uint32 start_idx = uint32(ioVertices.size());
429
+ ioVertices.resize(start_idx + 4);
430
+ Vertex *vertices = &ioVertices[start_idx];
431
+
432
+ // Set position
433
+ inV1.StoreFloat3(&vertices[0].mPosition);
434
+ inV2.StoreFloat3(&vertices[1].mPosition);
435
+ inV3.StoreFloat3(&vertices[2].mPosition);
436
+ inV4.StoreFloat3(&vertices[3].mPosition);
437
+
438
+ // Set color
439
+ vertices[0].mColor = vertices[1].mColor = vertices[2].mColor = vertices[3].mColor = Color::sWhite;
440
+
441
+ // Calculate normal
442
+ Vec3 normal = (inV2 - inV1).Cross(inV3 - inV1).Normalized();
443
+ Float3 normal3;
444
+ normal.StoreFloat3(&normal3);
445
+ vertices[0].mNormal = vertices[1].mNormal = vertices[2].mNormal = vertices[3].mNormal = normal3;
446
+
447
+ // Set UV's
448
+ vertices[0].mUV = { 0, 0 };
449
+ vertices[1].mUV = { 2, 0 };
450
+ vertices[2].mUV = { 2, 2 };
451
+ vertices[3].mUV = { 0, 2 };
452
+
453
+ // Set indices
454
+ ioIndices.push_back(start_idx);
455
+ ioIndices.push_back(start_idx + 1);
456
+ ioIndices.push_back(start_idx + 2);
457
+
458
+ ioIndices.push_back(start_idx);
459
+ ioIndices.push_back(start_idx + 2);
460
+ ioIndices.push_back(start_idx + 3);
461
+ }
462
+
463
+ void DebugRenderer::Initialize()
464
+ {
465
+ // Box
466
+ {
467
+ Array<Vertex> box_vertices;
468
+ Array<uint32> box_indices;
469
+
470
+ // Get corner points
471
+ Vec3 v0 = Vec3(-1, 1, -1);
472
+ Vec3 v1 = Vec3( 1, 1, -1);
473
+ Vec3 v2 = Vec3( 1, 1, 1);
474
+ Vec3 v3 = Vec3(-1, 1, 1);
475
+ Vec3 v4 = Vec3(-1, -1, -1);
476
+ Vec3 v5 = Vec3( 1, -1, -1);
477
+ Vec3 v6 = Vec3( 1, -1, 1);
478
+ Vec3 v7 = Vec3(-1, -1, 1);
479
+
480
+ // Top
481
+ CreateQuad(box_indices, box_vertices, v0, v3, v2, v1);
482
+
483
+ // Bottom
484
+ CreateQuad(box_indices, box_vertices, v4, v5, v6, v7);
485
+
486
+ // Left
487
+ CreateQuad(box_indices, box_vertices, v0, v4, v7, v3);
488
+
489
+ // Right
490
+ CreateQuad(box_indices, box_vertices, v2, v6, v5, v1);
491
+
492
+ // Front
493
+ CreateQuad(box_indices, box_vertices, v3, v7, v6, v2);
494
+
495
+ // Back
496
+ CreateQuad(box_indices, box_vertices, v0, v1, v5, v4);
497
+
498
+ mBox = new Geometry(CreateTriangleBatch(box_vertices, box_indices), AABox(Vec3(-1, -1, -1), Vec3(1, 1, 1)));
499
+ }
500
+
501
+ // Support function that returns a unit sphere
502
+ auto sphere_support = [](Vec3Arg inDirection) { return inDirection; };
503
+
504
+ // Construct geometries
505
+ mSphere = new Geometry(AABox(Vec3(-1, -1, -1), Vec3(1, 1, 1)));
506
+ mCapsuleBottom = new Geometry(AABox(Vec3(-1, -1, -1), Vec3(1, 0, 1)));
507
+ mCapsuleTop = new Geometry(AABox(Vec3(-1, 0, -1), Vec3(1, 1, 1)));
508
+ mCapsuleMid = new Geometry(AABox(Vec3(-1, -1, -1), Vec3(1, 1, 1)));
509
+ mOpenCone = new Geometry(AABox(Vec3(-1, 0, -1), Vec3(1, 1, 1)));
510
+ mCylinder = new Geometry(AABox(Vec3(-1, -1, -1), Vec3(1, 1, 1)));
511
+
512
+ // Iterate over levels
513
+ for (int level = sMaxLevel; level >= 1; --level)
514
+ {
515
+ // Determine at which distance this level should be active
516
+ float distance = sLODDistanceForLevel[sMaxLevel - level];
517
+
518
+ // Sphere
519
+ mSphere->mLODs.push_back({ CreateTriangleBatchForConvex(sphere_support, level), distance });
520
+
521
+ // Capsule bottom half sphere
522
+ {
523
+ Array<Vertex> capsule_bottom_vertices;
524
+ Array<uint32> capsule_bottom_indices;
525
+ Create8thSphere(capsule_bottom_indices, capsule_bottom_vertices, -Vec3::sAxisX(), -Vec3::sAxisY(), Vec3::sAxisZ(), Float2(0.25f, 0.25f), sphere_support, level);
526
+ Create8thSphere(capsule_bottom_indices, capsule_bottom_vertices, -Vec3::sAxisY(), Vec3::sAxisX(), Vec3::sAxisZ(), Float2(0.25f, 0.75f), sphere_support, level);
527
+ Create8thSphere(capsule_bottom_indices, capsule_bottom_vertices, Vec3::sAxisX(), -Vec3::sAxisY(), -Vec3::sAxisZ(), Float2(0.25f, 0.25f), sphere_support, level);
528
+ Create8thSphere(capsule_bottom_indices, capsule_bottom_vertices, -Vec3::sAxisY(), -Vec3::sAxisX(), -Vec3::sAxisZ(), Float2(0.25f, 0.75f), sphere_support, level);
529
+ mCapsuleBottom->mLODs.push_back({ CreateTriangleBatch(capsule_bottom_vertices, capsule_bottom_indices), distance });
530
+ }
531
+
532
+ // Capsule top half sphere
533
+ {
534
+ Array<Vertex> capsule_top_vertices;
535
+ Array<uint32> capsule_top_indices;
536
+ Create8thSphere(capsule_top_indices, capsule_top_vertices, Vec3::sAxisX(), Vec3::sAxisY(), Vec3::sAxisZ(), Float2(0.25f, 0.75f), sphere_support, level);
537
+ Create8thSphere(capsule_top_indices, capsule_top_vertices, Vec3::sAxisY(), -Vec3::sAxisX(), Vec3::sAxisZ(), Float2(0.25f, 0.25f), sphere_support, level);
538
+ Create8thSphere(capsule_top_indices, capsule_top_vertices, Vec3::sAxisY(), Vec3::sAxisX(), -Vec3::sAxisZ(), Float2(0.25f, 0.25f), sphere_support, level);
539
+ Create8thSphere(capsule_top_indices, capsule_top_vertices, -Vec3::sAxisX(), Vec3::sAxisY(), -Vec3::sAxisZ(), Float2(0.25f, 0.75f), sphere_support, level);
540
+ mCapsuleTop->mLODs.push_back({ CreateTriangleBatch(capsule_top_vertices, capsule_top_indices), distance });
541
+ }
542
+
543
+ // Capsule middle part
544
+ {
545
+ Array<Vertex> capsule_mid_vertices;
546
+ Array<uint32> capsule_mid_indices;
547
+ for (int q = 0; q < 4; ++q)
548
+ {
549
+ Float2 uv = (q & 1) == 0? Float2(0.25f, 0.25f) : Float2(0.25f, 0.75f);
550
+
551
+ uint32 start_idx = (uint32)capsule_mid_vertices.size();
552
+
553
+ int num_parts = 1 << level;
554
+ for (int i = 0; i <= num_parts; ++i)
555
+ {
556
+ float angle = 0.5f * JPH_PI * (float(q) + float(i) / num_parts);
557
+ float s = Sin(angle);
558
+ float c = Cos(angle);
559
+ Float3 vt(s, 1.0f, c);
560
+ Float3 vb(s, -1.0f, c);
561
+ Float3 n(s, 0, c);
562
+
563
+ capsule_mid_vertices.push_back({ vt, n, uv, Color::sWhite });
564
+ capsule_mid_vertices.push_back({ vb, n, uv, Color::sWhite });
565
+ }
566
+
567
+ for (int i = 0; i < num_parts; ++i)
568
+ {
569
+ uint32 start = start_idx + 2 * i;
570
+
571
+ capsule_mid_indices.push_back(start);
572
+ capsule_mid_indices.push_back(start + 1);
573
+ capsule_mid_indices.push_back(start + 3);
574
+
575
+ capsule_mid_indices.push_back(start);
576
+ capsule_mid_indices.push_back(start + 3);
577
+ capsule_mid_indices.push_back(start + 2);
578
+ }
579
+ }
580
+ mCapsuleMid->mLODs.push_back({ CreateTriangleBatch(capsule_mid_vertices, capsule_mid_indices), distance });
581
+ }
582
+
583
+ // Open cone
584
+ {
585
+ Array<Vertex> open_cone_vertices;
586
+ Array<uint32> open_cone_indices;
587
+ for (int q = 0; q < 4; ++q)
588
+ {
589
+ Float2 uv = (q & 1) == 0? Float2(0.25f, 0.25f) : Float2(0.25f, 0.75f);
590
+
591
+ uint32 start_idx = (uint32)open_cone_vertices.size();
592
+
593
+ int num_parts = 2 << level;
594
+ Float3 vt(0, 0, 0);
595
+ for (int i = 0; i <= num_parts; ++i)
596
+ {
597
+ // Calculate bottom vertex
598
+ float angle = 0.5f * JPH_PI * (float(q) + float(i) / num_parts);
599
+ float s = Sin(angle);
600
+ float c = Cos(angle);
601
+ Float3 vb(s, 1.0f, c);
602
+
603
+ // Calculate normal
604
+ // perpendicular = Y cross vb (perpendicular to the plane in which 0, y and vb exists)
605
+ // normal = perpendicular cross vb (normal to the edge 0 vb)
606
+ Vec3 normal = Vec3(s, -Square(s) - Square(c), c).Normalized();
607
+ Float3 n; normal.StoreFloat3(&n);
608
+
609
+ open_cone_vertices.push_back({ vt, n, uv, Color::sWhite });
610
+ open_cone_vertices.push_back({ vb, n, uv, Color::sWhite });
611
+ }
612
+
613
+ for (int i = 0; i < num_parts; ++i)
614
+ {
615
+ uint32 start = start_idx + 2 * i;
616
+
617
+ open_cone_indices.push_back(start);
618
+ open_cone_indices.push_back(start + 1);
619
+ open_cone_indices.push_back(start + 3);
620
+ }
621
+ }
622
+ mOpenCone->mLODs.push_back({ CreateTriangleBatch(open_cone_vertices, open_cone_indices), distance });
623
+ }
624
+
625
+ // Cylinder
626
+ mCylinder->mLODs.push_back({ CreateCylinder(1.0f, -1.0f, 1.0f, 1.0f, level), distance });
627
+ }
628
+ }
629
+
630
+ AABox DebugRenderer::sCalculateBounds(const Vertex *inVertices, int inVertexCount)
631
+ {
632
+ AABox bounds;
633
+ for (const Vertex *v = inVertices, *v_end = inVertices + inVertexCount; v < v_end; ++v)
634
+ bounds.Encapsulate(Vec3(v->mPosition));
635
+ return bounds;
636
+ }
637
+
638
+ DebugRenderer::Batch DebugRenderer::CreateTriangleBatch(const VertexList &inVertices, const IndexedTriangleNoMaterialList &inTriangles)
639
+ {
640
+ JPH_PROFILE_FUNCTION();
641
+
642
+ Array<Vertex> vertices;
643
+
644
+ // Create render vertices
645
+ vertices.resize(inVertices.size());
646
+ for (size_t v = 0; v < inVertices.size(); ++v)
647
+ {
648
+ vertices[v].mPosition = inVertices[v];
649
+ vertices[v].mNormal = Float3(0, 0, 0);
650
+ vertices[v].mUV = Float2(0, 0);
651
+ vertices[v].mColor = Color::sWhite;
652
+ }
653
+
654
+ // Calculate normals
655
+ for (size_t i = 0; i < inTriangles.size(); ++i)
656
+ {
657
+ const IndexedTriangleNoMaterial &tri = inTriangles[i];
658
+
659
+ // Calculate normal of face
660
+ Vec3 vtx[3];
661
+ for (int j = 0; j < 3; ++j)
662
+ vtx[j] = Vec3::sLoadFloat3Unsafe(vertices[tri.mIdx[j]].mPosition);
663
+ Vec3 normal = ((vtx[1] - vtx[0]).Cross(vtx[2] - vtx[0])).Normalized();
664
+
665
+ // Add normal to all vertices in face
666
+ for (int j = 0; j < 3; ++j)
667
+ (Vec3::sLoadFloat3Unsafe(vertices[tri.mIdx[j]].mNormal) + normal).StoreFloat3(&vertices[tri.mIdx[j]].mNormal);
668
+ }
669
+
670
+ // Renormalize vertex normals
671
+ for (size_t i = 0; i < vertices.size(); ++i)
672
+ Vec3::sLoadFloat3Unsafe(vertices[i].mNormal).Normalized().StoreFloat3(&vertices[i].mNormal);
673
+
674
+ return CreateTriangleBatch(&vertices[0], (int)vertices.size(), &inTriangles[0].mIdx[0], (int)(3 * inTriangles.size()));
675
+ }
676
+
677
+ DebugRenderer::Batch DebugRenderer::CreateTriangleBatchForConvex(SupportFunction inGetSupport, int inLevel, AABox *outBounds)
678
+ {
679
+ JPH_PROFILE_FUNCTION();
680
+
681
+ Array<Vertex> vertices;
682
+ Array<uint32> indices;
683
+ Create8thSphere(indices, vertices, Vec3::sAxisX(), Vec3::sAxisY(), Vec3::sAxisZ(), Float2(0.25f, 0.25f), inGetSupport, inLevel);
684
+ Create8thSphere(indices, vertices, Vec3::sAxisY(), -Vec3::sAxisX(), Vec3::sAxisZ(), Float2(0.25f, 0.75f), inGetSupport, inLevel);
685
+ Create8thSphere(indices, vertices, -Vec3::sAxisY(), Vec3::sAxisX(), Vec3::sAxisZ(), Float2(0.25f, 0.75f), inGetSupport, inLevel);
686
+ Create8thSphere(indices, vertices, -Vec3::sAxisX(), -Vec3::sAxisY(), Vec3::sAxisZ(), Float2(0.25f, 0.25f), inGetSupport, inLevel);
687
+ Create8thSphere(indices, vertices, Vec3::sAxisY(), Vec3::sAxisX(), -Vec3::sAxisZ(), Float2(0.25f, 0.75f), inGetSupport, inLevel);
688
+ Create8thSphere(indices, vertices, -Vec3::sAxisX(), Vec3::sAxisY(), -Vec3::sAxisZ(), Float2(0.25f, 0.25f), inGetSupport, inLevel);
689
+ Create8thSphere(indices, vertices, Vec3::sAxisX(), -Vec3::sAxisY(), -Vec3::sAxisZ(), Float2(0.25f, 0.25f), inGetSupport, inLevel);
690
+ Create8thSphere(indices, vertices, -Vec3::sAxisY(), -Vec3::sAxisX(), -Vec3::sAxisZ(), Float2(0.25f, 0.75f), inGetSupport, inLevel);
691
+
692
+ if (outBounds != nullptr)
693
+ *outBounds = sCalculateBounds(&vertices[0], (int)vertices.size());
694
+
695
+ return CreateTriangleBatch(vertices, indices);
696
+ }
697
+
698
+ DebugRenderer::GeometryRef DebugRenderer::CreateTriangleGeometryForConvex(SupportFunction inGetSupport)
699
+ {
700
+ GeometryRef geometry;
701
+
702
+ // Iterate over levels
703
+ for (int level = sMaxLevel; level >= 1; --level)
704
+ {
705
+ // Determine at which distance this level should be active
706
+ float distance = sLODDistanceForLevel[sMaxLevel - level];
707
+
708
+ // Create triangle batch and only calculate bounds for highest LOD level
709
+ AABox bounds;
710
+ Batch batch = CreateTriangleBatchForConvex(inGetSupport, level, geometry == nullptr? &bounds : nullptr);
711
+
712
+ // Construct geometry in the first iteration
713
+ if (geometry == nullptr)
714
+ geometry = new Geometry(bounds);
715
+
716
+ // Add the LOD
717
+ geometry->mLODs.push_back({ batch, distance });
718
+ }
719
+
720
+ return geometry;
721
+ }
722
+
723
+ void DebugRenderer::DrawBox(const AABox &inBox, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
724
+ {
725
+ JPH_PROFILE_FUNCTION();
726
+
727
+ RMat44 m = RMat44::sScale(Vec3::sMax(inBox.GetExtent(), Vec3::sReplicate(1.0e-6f))); // Prevent div by zero when one of the edges has length 0
728
+ m.SetTranslation(RVec3(inBox.GetCenter()));
729
+ DrawGeometry(m, inColor, mBox, ECullMode::CullBackFace, inCastShadow, inDrawMode);
730
+ }
731
+
732
+ void DebugRenderer::DrawBox(RMat44Arg inMatrix, const AABox &inBox, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
733
+ {
734
+ JPH_PROFILE_FUNCTION();
735
+
736
+ Mat44 m = Mat44::sScale(Vec3::sMax(inBox.GetExtent(), Vec3::sReplicate(1.0e-6f))); // Prevent div by zero when one of the edges has length 0
737
+ m.SetTranslation(inBox.GetCenter());
738
+ DrawGeometry(inMatrix * m, inColor, mBox, ECullMode::CullBackFace, inCastShadow, inDrawMode);
739
+ }
740
+
741
+ void DebugRenderer::DrawSphere(RVec3Arg inCenter, float inRadius, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
742
+ {
743
+ JPH_PROFILE_FUNCTION();
744
+
745
+ RMat44 matrix = RMat44::sTranslation(inCenter) * Mat44::sScale(inRadius);
746
+
747
+ DrawUnitSphere(matrix, inColor, inCastShadow, inDrawMode);
748
+ }
749
+
750
+ void DebugRenderer::DrawUnitSphere(RMat44Arg inMatrix, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
751
+ {
752
+ JPH_PROFILE_FUNCTION();
753
+
754
+ DrawGeometry(inMatrix, inColor, mSphere, ECullMode::CullBackFace, inCastShadow, inDrawMode);
755
+ }
756
+
757
+ void DebugRenderer::DrawCapsule(RMat44Arg inMatrix, float inHalfHeightOfCylinder, float inRadius, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
758
+ {
759
+ JPH_PROFILE_FUNCTION();
760
+
761
+ Mat44 scale_matrix = Mat44::sScale(inRadius);
762
+
763
+ // Calculate world space bounding box
764
+ AABox local_bounds(Vec3(-inRadius, -inHalfHeightOfCylinder - inRadius, -inRadius), Vec3(inRadius, inHalfHeightOfCylinder + inRadius, inRadius));
765
+ AABox world_bounds = local_bounds.Transformed(inMatrix);
766
+
767
+ float radius_sq = Square(inRadius);
768
+
769
+ // Draw bottom half sphere
770
+ RMat44 bottom_matrix = inMatrix * Mat44::sTranslation(Vec3(0, -inHalfHeightOfCylinder, 0)) * scale_matrix;
771
+ DrawGeometry(bottom_matrix, world_bounds, radius_sq, inColor, mCapsuleBottom, ECullMode::CullBackFace, inCastShadow, inDrawMode);
772
+
773
+ // Draw top half sphere
774
+ RMat44 top_matrix = inMatrix * Mat44::sTranslation(Vec3(0, inHalfHeightOfCylinder, 0)) * scale_matrix;
775
+ DrawGeometry(top_matrix, world_bounds, radius_sq, inColor, mCapsuleTop, ECullMode::CullBackFace, inCastShadow, inDrawMode);
776
+
777
+ // Draw middle part
778
+ DrawGeometry(inMatrix * Mat44::sScale(Vec3(inRadius, inHalfHeightOfCylinder, inRadius)), world_bounds, radius_sq, inColor, mCapsuleMid, ECullMode::CullBackFace, inCastShadow, inDrawMode);
779
+ }
780
+
781
+ void DebugRenderer::DrawCylinder(RMat44Arg inMatrix, float inHalfHeight, float inRadius, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
782
+ {
783
+ JPH_PROFILE_FUNCTION();
784
+
785
+ Mat44 local_transform(Vec4(inRadius, 0, 0, 0), Vec4(0, inHalfHeight, 0, 0), Vec4(0, 0, inRadius, 0), Vec4(0, 0, 0, 1));
786
+ RMat44 transform = inMatrix * local_transform;
787
+
788
+ DrawGeometry(transform, mCylinder->mBounds.Transformed(transform), Square(inRadius), inColor, mCylinder, ECullMode::CullBackFace, inCastShadow, inDrawMode);
789
+ }
790
+
791
+ void DebugRenderer::DrawOpenCone(RVec3Arg inTop, Vec3Arg inAxis, Vec3Arg inPerpendicular, float inHalfAngle, float inLength, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
792
+ {
793
+ JPH_PROFILE_FUNCTION();
794
+
795
+ JPH_ASSERT(inAxis.IsNormalized(1.0e-4f));
796
+ JPH_ASSERT(inPerpendicular.IsNormalized(1.0e-4f));
797
+ JPH_ASSERT(abs(inPerpendicular.Dot(inAxis)) < 1.0e-4f);
798
+
799
+ Vec3 axis = Sign(inHalfAngle) * inLength * inAxis;
800
+ float scale = inLength * Tan(abs(inHalfAngle));
801
+ if (scale != 0.0f)
802
+ {
803
+ Vec3 perp1 = scale * inPerpendicular;
804
+ Vec3 perp2 = scale * inAxis.Cross(inPerpendicular);
805
+ RMat44 transform(Vec4(perp1, 0), Vec4(axis, 0), Vec4(perp2, 0), inTop);
806
+ DrawGeometry(transform, inColor, mOpenCone, ECullMode::Off, inCastShadow, inDrawMode);
807
+ }
808
+ }
809
+
810
+ DebugRenderer::Geometry *DebugRenderer::CreateSwingLimitGeometry(int inNumSegments, const Vec3 *inVertices)
811
+ {
812
+ // Allocate space for vertices
813
+ int num_vertices = 2 * inNumSegments;
814
+ Vertex *vertices_start = (Vertex *)JPH_STACK_ALLOC(num_vertices * sizeof(Vertex));
815
+ Vertex *vertices = vertices_start;
816
+
817
+ for (int i = 0; i < inNumSegments; ++i)
818
+ {
819
+ // Get output vertices
820
+ Vertex &top = *(vertices++);
821
+ Vertex &bottom = *(vertices++);
822
+
823
+ // Get local position
824
+ const Vec3 &pos = inVertices[i];
825
+
826
+ // Get local normal
827
+ const Vec3 &prev_pos = inVertices[(i + inNumSegments - 1) % inNumSegments];
828
+ const Vec3 &next_pos = inVertices[(i + 1) % inNumSegments];
829
+ Vec3 normal = 0.5f * (next_pos.Cross(pos).NormalizedOr(Vec3::sZero()) + pos.Cross(prev_pos).NormalizedOr(Vec3::sZero()));
830
+
831
+ // Store top vertex
832
+ top.mPosition = { 0, 0, 0 };
833
+ normal.StoreFloat3(&top.mNormal);
834
+ top.mColor = Color::sWhite;
835
+ top.mUV = { 0, 0 };
836
+
837
+ // Store bottom vertex
838
+ pos.StoreFloat3(&bottom.mPosition);
839
+ normal.StoreFloat3(&bottom.mNormal);
840
+ bottom.mColor = Color::sWhite;
841
+ bottom.mUV = { 0, 0 };
842
+ }
843
+
844
+ // Allocate space for indices
845
+ int num_indices = 3 * inNumSegments;
846
+ uint32 *indices_start = (uint32 *)JPH_STACK_ALLOC(num_indices * sizeof(uint32));
847
+ uint32 *indices = indices_start;
848
+
849
+ // Calculate indices
850
+ for (int i = 0; i < inNumSegments; ++i)
851
+ {
852
+ int first = 2 * i;
853
+ int second = (first + 3) % num_vertices;
854
+ int third = first + 1;
855
+
856
+ // Triangle
857
+ *indices++ = first;
858
+ *indices++ = second;
859
+ *indices++ = third;
860
+ }
861
+
862
+ // Convert to triangle batch
863
+ return new Geometry(CreateTriangleBatch(vertices_start, num_vertices, indices_start, num_indices), sCalculateBounds(vertices_start, num_vertices));
864
+ }
865
+
866
+ void DebugRenderer::DrawSwingConeLimits(RMat44Arg inMatrix, float inSwingYHalfAngle, float inSwingZHalfAngle, float inEdgeLength, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
867
+ {
868
+ JPH_PROFILE_FUNCTION();
869
+
870
+ // Assert sane input
871
+ JPH_ASSERT(inSwingYHalfAngle >= 0.0f && inSwingYHalfAngle <= JPH_PI);
872
+ JPH_ASSERT(inSwingZHalfAngle >= 0.0f && inSwingZHalfAngle <= JPH_PI);
873
+ JPH_ASSERT(inEdgeLength > 0.0f);
874
+
875
+ // Check cache
876
+ SwingConeLimits limits { inSwingYHalfAngle, inSwingZHalfAngle };
877
+ GeometryRef &geometry = mSwingConeLimits[limits];
878
+ if (geometry == nullptr)
879
+ {
880
+ SwingConeBatches::iterator it = mPrevSwingConeLimits.find(limits);
881
+ if (it != mPrevSwingConeLimits.end())
882
+ geometry = it->second;
883
+ }
884
+ if (geometry == nullptr)
885
+ {
886
+ // Number of segments to draw the cone with
887
+ const int num_segments = 64;
888
+ int half_num_segments = num_segments / 2;
889
+
890
+ // The y and z values of the quaternion are limited to an ellipse, e1 and e2 are the radii of this ellipse
891
+ float e1 = Sin(0.5f * inSwingZHalfAngle);
892
+ float e2 = Sin(0.5f * inSwingYHalfAngle);
893
+
894
+ // Check if the limits will draw something
895
+ if ((e1 <= 0.0f && e2 <= 0.0f) || (e2 >= 1.0f && e1 >= 1.0f))
896
+ return;
897
+
898
+ // Calculate squared values
899
+ float e1_sq = Square(e1);
900
+ float e2_sq = Square(e2);
901
+
902
+ // Calculate local space vertices for shape
903
+ Vec3 ls_vertices[num_segments];
904
+ int tgt_vertex = 0;
905
+ for (int side_iter = 0; side_iter < 2; ++side_iter)
906
+ for (int segment_iter = 0; segment_iter < half_num_segments; ++segment_iter)
907
+ {
908
+ float y, z;
909
+ if (e2_sq > e1_sq)
910
+ {
911
+ // Trace the y value of the quaternion
912
+ y = e2 - 2.0f * segment_iter * e2 / half_num_segments;
913
+
914
+ // Calculate the corresponding z value of the quaternion
915
+ float z_sq = e1_sq - e1_sq / e2_sq * Square(y);
916
+ z = z_sq <= 0.0f? 0.0f : sqrt(z_sq);
917
+ }
918
+ else
919
+ {
920
+ // Trace the z value of the quaternion
921
+ z = -e1 + 2.0f * segment_iter * e1 / half_num_segments;
922
+
923
+ // Calculate the corresponding y value of the quaternion
924
+ float y_sq = e2_sq - e2_sq / e1_sq * Square(z);
925
+ y = y_sq <= 0.0f? 0.0f : sqrt(y_sq);
926
+ }
927
+
928
+ // If we're tracing the opposite side, flip the values
929
+ if (side_iter == 1)
930
+ {
931
+ z = -z;
932
+ y = -y;
933
+ }
934
+
935
+ // Create quaternion
936
+ Vec3 q_xyz(0, y, z);
937
+ float w = sqrt(1.0f - q_xyz.LengthSq());
938
+ Quat q(Vec4(q_xyz, w));
939
+
940
+ // Store vertex
941
+ ls_vertices[tgt_vertex++] = q.RotateAxisX();
942
+ }
943
+
944
+ geometry = CreateSwingLimitGeometry(num_segments, ls_vertices);
945
+ }
946
+
947
+ DrawGeometry(inMatrix * Mat44::sScale(inEdgeLength), inColor, geometry, ECullMode::Off, inCastShadow, inDrawMode);
948
+ }
949
+
950
+ void DebugRenderer::DrawSwingPyramidLimits(RMat44Arg inMatrix, float inMinSwingYAngle, float inMaxSwingYAngle, float inMinSwingZAngle, float inMaxSwingZAngle, float inEdgeLength, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
951
+ {
952
+ JPH_PROFILE_FUNCTION();
953
+
954
+ // Assert sane input
955
+ JPH_ASSERT(inMinSwingYAngle <= inMaxSwingYAngle && inMinSwingZAngle <= inMaxSwingZAngle);
956
+ JPH_ASSERT(inEdgeLength > 0.0f);
957
+
958
+ // Check cache
959
+ SwingPyramidLimits limits { inMinSwingYAngle, inMaxSwingYAngle, inMinSwingZAngle, inMaxSwingZAngle };
960
+ GeometryRef &geometry = mSwingPyramidLimits[limits];
961
+ if (geometry == nullptr)
962
+ {
963
+ SwingPyramidBatches::iterator it = mPrevSwingPyramidLimits.find(limits);
964
+ if (it != mPrevSwingPyramidLimits.end())
965
+ geometry = it->second;
966
+ }
967
+ if (geometry == nullptr)
968
+ {
969
+ // Number of segments to draw the cone with
970
+ const int num_segments = 64;
971
+ int quarter_num_segments = num_segments / 4;
972
+
973
+ // Note that this is q = Quat::sRotation(Vec3::sAxisZ(), z) * Quat::sRotation(Vec3::sAxisY(), y) with q.x set to zero so we don't introduce twist
974
+ // This matches the calculation in SwingTwistConstraintPart::ClampSwingTwist
975
+ auto get_axis = [](float inY, float inZ) {
976
+ float hy = 0.5f * inY;
977
+ float hz = 0.5f * inZ;
978
+ float cos_hy = Cos(hy);
979
+ float cos_hz = Cos(hz);
980
+ return Quat(0, Sin(hy) * cos_hz, cos_hy * Sin(hz), cos_hy * cos_hz).Normalized().RotateAxisX();
981
+ };
982
+
983
+ // Calculate local space vertices for shape
984
+ Vec3 ls_vertices[num_segments];
985
+ int tgt_vertex = 0;
986
+ for (int segment_iter = 0; segment_iter < quarter_num_segments; ++segment_iter)
987
+ ls_vertices[tgt_vertex++] = get_axis(inMinSwingYAngle, inMaxSwingZAngle - (inMaxSwingZAngle - inMinSwingZAngle) * segment_iter / quarter_num_segments);
988
+ for (int segment_iter = 0; segment_iter < quarter_num_segments; ++segment_iter)
989
+ ls_vertices[tgt_vertex++] = get_axis(inMinSwingYAngle + (inMaxSwingYAngle - inMinSwingYAngle) * segment_iter / quarter_num_segments, inMinSwingZAngle);
990
+ for (int segment_iter = 0; segment_iter < quarter_num_segments; ++segment_iter)
991
+ ls_vertices[tgt_vertex++] = get_axis(inMaxSwingYAngle, inMinSwingZAngle + (inMaxSwingZAngle - inMinSwingZAngle) * segment_iter / quarter_num_segments);
992
+ for (int segment_iter = 0; segment_iter < quarter_num_segments; ++segment_iter)
993
+ ls_vertices[tgt_vertex++] = get_axis(inMaxSwingYAngle - (inMaxSwingYAngle - inMinSwingYAngle) * segment_iter / quarter_num_segments, inMaxSwingZAngle);
994
+
995
+ geometry = CreateSwingLimitGeometry(num_segments, ls_vertices);
996
+ }
997
+
998
+ DrawGeometry(inMatrix * Mat44::sScale(inEdgeLength), inColor, geometry, ECullMode::Off, inCastShadow, inDrawMode);
999
+ }
1000
+
1001
+ void DebugRenderer::DrawPie(RVec3Arg inCenter, float inRadius, Vec3Arg inNormal, Vec3Arg inAxis, float inMinAngle, float inMaxAngle, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
1002
+ {
1003
+ if (inMinAngle >= inMaxAngle)
1004
+ return;
1005
+
1006
+ JPH_PROFILE_FUNCTION();
1007
+
1008
+ JPH_ASSERT(inAxis.IsNormalized(1.0e-4f));
1009
+ JPH_ASSERT(inNormal.IsNormalized(1.0e-4f));
1010
+ JPH_ASSERT(abs(inNormal.Dot(inAxis)) < 1.0e-4f);
1011
+
1012
+ // Pies have a unique batch based on the difference between min and max angle
1013
+ float delta_angle = inMaxAngle - inMinAngle;
1014
+ GeometryRef &geometry = mPieLimits[delta_angle];
1015
+ if (geometry == nullptr)
1016
+ {
1017
+ PieBatces::iterator it = mPrevPieLimits.find(delta_angle);
1018
+ if (it != mPrevPieLimits.end())
1019
+ geometry = it->second;
1020
+ }
1021
+ if (geometry == nullptr)
1022
+ {
1023
+ int num_parts = (int)ceil(64.0f * delta_angle / (2.0f * JPH_PI));
1024
+
1025
+ Float3 normal = { 0, 1, 0 };
1026
+ Float3 center = { 0, 0, 0 };
1027
+
1028
+ // Allocate space for vertices
1029
+ int num_vertices = num_parts + 2;
1030
+ Vertex *vertices_start = (Vertex *)JPH_STACK_ALLOC(num_vertices * sizeof(Vertex));
1031
+ Vertex *vertices = vertices_start;
1032
+
1033
+ // Center of circle
1034
+ *vertices++ = { center, normal, { 0, 0 }, Color::sWhite };
1035
+
1036
+ // Outer edge of pie
1037
+ for (int i = 0; i <= num_parts; ++i)
1038
+ {
1039
+ float angle = float(i) / float(num_parts) * delta_angle;
1040
+
1041
+ Float3 pos = { Cos(angle), 0, Sin(angle) };
1042
+ *vertices++ = { pos, normal, { 0, 0 }, Color::sWhite };
1043
+ }
1044
+
1045
+ // Allocate space for indices
1046
+ int num_indices = num_parts * 3;
1047
+ uint32 *indices_start = (uint32 *)JPH_STACK_ALLOC(num_indices * sizeof(uint32));
1048
+ uint32 *indices = indices_start;
1049
+
1050
+ for (int i = 0; i < num_parts; ++i)
1051
+ {
1052
+ *indices++ = 0;
1053
+ *indices++ = i + 1;
1054
+ *indices++ = i + 2;
1055
+ }
1056
+
1057
+ // Convert to triangle batch
1058
+ geometry = new Geometry(CreateTriangleBatch(vertices_start, num_vertices, indices_start, num_indices), sCalculateBounds(vertices_start, num_vertices));
1059
+ }
1060
+
1061
+ // Construct matrix that transforms pie into world space
1062
+ RMat44 matrix = RMat44(Vec4(inRadius * inAxis, 0), Vec4(inRadius * inNormal, 0), Vec4(inRadius * inNormal.Cross(inAxis), 0), inCenter) * Mat44::sRotationY(-inMinAngle);
1063
+
1064
+ DrawGeometry(matrix, inColor, geometry, ECullMode::Off, inCastShadow, inDrawMode);
1065
+ }
1066
+
1067
+ void DebugRenderer::DrawTaperedCylinder(RMat44Arg inMatrix, float inTop, float inBottom, float inTopRadius, float inBottomRadius, ColorArg inColor, ECastShadow inCastShadow, EDrawMode inDrawMode)
1068
+ {
1069
+ TaperedCylinder tapered_cylinder { inTop, inBottom, inTopRadius, inBottomRadius };
1070
+
1071
+ GeometryRef &geometry = mTaperedCylinders[tapered_cylinder];
1072
+ if (geometry == nullptr)
1073
+ {
1074
+ TaperedCylinderBatces::iterator it = mPrevTaperedCylinders.find(tapered_cylinder);
1075
+ if (it != mPrevTaperedCylinders.end())
1076
+ geometry = it->second;
1077
+ }
1078
+ if (geometry == nullptr)
1079
+ {
1080
+ float max_radius = max(inTopRadius, inBottomRadius);
1081
+ geometry = new Geometry(AABox(Vec3(-max_radius, inBottom, -max_radius), Vec3(max_radius, inTop, max_radius)));
1082
+
1083
+ for (int level = sMaxLevel; level >= 1; --level)
1084
+ geometry->mLODs.push_back({ CreateCylinder(inTop, inBottom, inTopRadius, inBottomRadius, level), sLODDistanceForLevel[sMaxLevel - level] });
1085
+ }
1086
+
1087
+ DrawGeometry(inMatrix, inColor, geometry, ECullMode::CullBackFace, inCastShadow, inDrawMode);
1088
+ }
1089
+
1090
+ void DebugRenderer::NextFrame()
1091
+ {
1092
+ mPrevSwingConeLimits.clear();
1093
+ std::swap(mSwingConeLimits, mPrevSwingConeLimits);
1094
+
1095
+ mPrevSwingPyramidLimits.clear();
1096
+ std::swap(mSwingPyramidLimits, mPrevSwingPyramidLimits);
1097
+
1098
+ mPrevPieLimits.clear();
1099
+ std::swap(mPieLimits, mPrevPieLimits);
1100
+
1101
+ mPrevTaperedCylinders.clear();
1102
+ std::swap(mTaperedCylinders, mPrevTaperedCylinders);
1103
+ }
1104
+
1105
+ JPH_NAMESPACE_END
1106
+
1107
+ #endif // JPH_DEBUG_RENDERER