@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,1013 @@
1
+ //! bloom-watchos: Canvas + (future) SceneKit backend for watchOS.
2
+ //!
3
+ //! The Swift shell (`BloomWatchApp.swift`, compiled by Perry via
4
+ //! `--features watchos-swift-app`) owns `@main`. During init it spawns the
5
+ //! game thread calling `_perry_user_main`. The root view is a SwiftUI
6
+ //! `Canvas` that drains this crate's draw list each frame. Digital Crown
7
+ //! rotation, taps, and layout dimensions come back in through the
8
+ //! `bloom_watchos_*` inbound functions.
9
+
10
+ #![allow(non_upper_case_globals)]
11
+
12
+ mod ffi_stubs;
13
+ mod draw_list;
14
+ mod textures;
15
+ mod audio;
16
+ mod scene;
17
+ mod models;
18
+ mod postfx;
19
+
20
+ /// Perry StringHeader layout — mirrors bloom-shared's copy. Inlined here
21
+ /// because we don't depend on bloom-shared (keeps the watchos crate
22
+ /// wgpu-free).
23
+ #[repr(C)]
24
+ struct StringHeader {
25
+ utf16_len: u32,
26
+ byte_len: u32,
27
+ capacity: u32,
28
+ refcount: u32,
29
+ }
30
+
31
+ /// Decode a Perry-side string pointer (i64 on this ABI) into a borrowed &str.
32
+ /// Returns "" for null / too-small pointers to keep the FFI boundary robust.
33
+ fn perry_str<'a>(ptr: i64) -> &'a str {
34
+ if ptr == 0 { return ""; }
35
+ let p = ptr as *const u8;
36
+ if (p as usize) < 0x1000 { return ""; }
37
+ unsafe {
38
+ let header = p as *const StringHeader;
39
+ let len = (*header).byte_len as usize;
40
+ let data = p.add(std::mem::size_of::<StringHeader>());
41
+ std::str::from_utf8_unchecked(std::slice::from_raw_parts(data, len))
42
+ }
43
+ }
44
+
45
+ use std::ffi::{c_char, c_void};
46
+ use std::sync::atomic::{AtomicI64, AtomicU64, AtomicUsize, Ordering};
47
+ use std::sync::OnceLock;
48
+ use std::time::Instant;
49
+
50
+ use draw_list::{kind, DrawCmd};
51
+
52
+ // ============================================================
53
+ // Minimal engine state (input + timing). Rendering state lives
54
+ // in the draw_list and textures modules.
55
+ // ============================================================
56
+
57
+ const MAX_TOUCH: usize = 4;
58
+
59
+ struct WatchState {
60
+ crown_bits: AtomicU64, // f64 bits
61
+ touch_x: [AtomicU64; MAX_TOUCH],
62
+ touch_y: [AtomicU64; MAX_TOUCH],
63
+ touch_active: [AtomicU64; MAX_TOUCH],
64
+ screen_w: AtomicU64, // f64 bits
65
+ screen_h: AtomicU64, // f64 bits
66
+ target_fps: AtomicI64,
67
+ start: OnceLock<Instant>,
68
+ last_frame_ns: AtomicU64,
69
+ frame_count: AtomicUsize,
70
+ }
71
+
72
+ fn state() -> &'static WatchState {
73
+ static S: OnceLock<WatchState> = OnceLock::new();
74
+ S.get_or_init(|| WatchState {
75
+ crown_bits: AtomicU64::new(0),
76
+ touch_x: std::array::from_fn(|_| AtomicU64::new(0)),
77
+ touch_y: std::array::from_fn(|_| AtomicU64::new(0)),
78
+ touch_active: std::array::from_fn(|_| AtomicU64::new(0)),
79
+ screen_w: AtomicU64::new(198f64.to_bits()),
80
+ screen_h: AtomicU64::new(242f64.to_bits()),
81
+ target_fps: AtomicI64::new(30),
82
+ start: OnceLock::new(),
83
+ last_frame_ns: AtomicU64::new(0),
84
+ frame_count: AtomicUsize::new(0),
85
+ })
86
+ }
87
+
88
+ fn now_nanos() -> u64 {
89
+ let s = state();
90
+ let start = s.start.get_or_init(Instant::now);
91
+ start.elapsed().as_nanos() as u64
92
+ }
93
+
94
+ fn add_crown(delta: f64) {
95
+ let s = state();
96
+ loop {
97
+ let cur = s.crown_bits.load(Ordering::Acquire);
98
+ let new = (f64::from_bits(cur) + delta).to_bits();
99
+ if s.crown_bits
100
+ .compare_exchange_weak(cur, new, Ordering::AcqRel, Ordering::Acquire)
101
+ .is_ok()
102
+ {
103
+ break;
104
+ }
105
+ }
106
+ }
107
+
108
+ fn consume_crown() -> f64 {
109
+ let s = state();
110
+ let bits = s.crown_bits.swap(0, Ordering::AcqRel);
111
+ f64::from_bits(bits)
112
+ }
113
+
114
+ // ============================================================
115
+ // Swift → Rust inbound hooks. Called from BloomWatchApp.swift.
116
+ // ============================================================
117
+
118
+ #[no_mangle]
119
+ pub extern "C" fn bloom_watchos_crown_delta(delta: f64) { add_crown(delta); }
120
+
121
+ #[no_mangle]
122
+ pub extern "C" fn bloom_watchos_touch(index: i64, x: f64, y: f64, active: i64) {
123
+ let s = state();
124
+ let i = index as usize;
125
+ if i < MAX_TOUCH {
126
+ s.touch_x[i].store(x.to_bits(), Ordering::Release);
127
+ s.touch_y[i].store(y.to_bits(), Ordering::Release);
128
+ s.touch_active[i].store(active as u64, Ordering::Release);
129
+ }
130
+ }
131
+
132
+ #[no_mangle]
133
+ pub extern "C" fn bloom_watchos_set_screen(w: f64, h: f64) {
134
+ let s = state();
135
+ s.screen_w.store(w.to_bits(), Ordering::Release);
136
+ s.screen_h.store(h.to_bits(), Ordering::Release);
137
+ }
138
+
139
+ #[no_mangle]
140
+ pub extern "C" fn bloom_watchos_set_bundle_path(path: *const c_char) {
141
+ if path.is_null() { return; }
142
+ let s = unsafe { std::ffi::CStr::from_ptr(path) };
143
+ if let Ok(str) = s.to_str() {
144
+ textures::set_bundle_path(str);
145
+ }
146
+ }
147
+
148
+ // Draw-list snapshot accessors for Swift Canvas.
149
+
150
+ #[no_mangle]
151
+ pub extern "C" fn bloom_watchos_frame_count() -> u64 { draw_list::frame() }
152
+
153
+ #[no_mangle]
154
+ pub extern "C" fn bloom_watchos_copy_draw_list(dst: *mut DrawCmd, max: i64) -> i64 {
155
+ draw_list::copy_into(dst, max)
156
+ }
157
+
158
+ /// Returns [r,g,b,a] of the current clear color, 0-255 per channel, into a
159
+ /// Swift-supplied 4-element f64 buffer.
160
+ #[no_mangle]
161
+ pub extern "C" fn bloom_watchos_clear_color(out: *mut f64) {
162
+ if out.is_null() { return; }
163
+ let c = draw_list::clear_rgba();
164
+ unsafe { std::ptr::copy_nonoverlapping(c.as_ptr(), out, 4); }
165
+ }
166
+
167
+ #[no_mangle]
168
+ pub extern "C" fn bloom_watchos_texture_path(handle: u32) -> *const c_char {
169
+ textures::path_ptr(handle)
170
+ }
171
+
172
+ /// Copy camera state [px,py,pz, tx,ty,tz, ux,uy,uz, fovy, proj] into a
173
+ /// Swift-supplied 11-element f64 buffer. Called by the Swift SceneView.
174
+ #[no_mangle]
175
+ pub extern "C" fn bloom_watchos_camera_state(out: *mut f64) {
176
+ draw_list::camera_snapshot(out);
177
+ }
178
+
179
+ /// 1 if the game has ever opened a 3D mode section — hints to the Swift
180
+ /// shell that it should host a SceneView layer underneath the Canvas.
181
+ #[no_mangle]
182
+ pub extern "C" fn bloom_watchos_has_3d() -> f64 {
183
+ if draw_list::has_3d() { 1.0 } else { 0.0 }
184
+ }
185
+
186
+ // ============================================================
187
+ // Perry game-loop handshake.
188
+ // ============================================================
189
+ //
190
+ // With --features watchos-swift-app, Perry doesn't generate its own main() —
191
+ // BloomWatchApp.swift is @main. Perry's watchos runtime still provides the
192
+ // `perry_main_init` C symbol which does global TS init; the Swift App calls
193
+ // it before spawning the game thread. We don't need to register any ObjC
194
+ // classes from this crate.
195
+
196
+ #[no_mangle]
197
+ pub extern "C" fn perry_register_native_classes() {}
198
+
199
+ #[no_mangle]
200
+ pub extern "C" fn perry_scene_will_connect(_scene: *const c_void) {}
201
+
202
+ // ============================================================
203
+ // Platform / timing / input overrides
204
+ // ============================================================
205
+
206
+ #[no_mangle]
207
+ pub extern "C" fn bloom_get_platform() -> f64 { 8.0 }
208
+
209
+ #[no_mangle]
210
+ pub extern "C" fn bloom_get_crown_rotation() -> f64 { consume_crown() }
211
+
212
+ #[no_mangle]
213
+ pub extern "C" fn bloom_get_screen_width() -> f64 {
214
+ f64::from_bits(state().screen_w.load(Ordering::Acquire))
215
+ }
216
+
217
+ #[no_mangle]
218
+ pub extern "C" fn bloom_get_screen_height() -> f64 {
219
+ f64::from_bits(state().screen_h.load(Ordering::Acquire))
220
+ }
221
+
222
+ #[no_mangle]
223
+ pub extern "C" fn bloom_get_touch_x(index: f64) -> f64 {
224
+ let s = state();
225
+ let i = index as usize;
226
+ if i < MAX_TOUCH { f64::from_bits(s.touch_x[i].load(Ordering::Acquire)) } else { 0.0 }
227
+ }
228
+
229
+ #[no_mangle]
230
+ pub extern "C" fn bloom_get_touch_y(index: f64) -> f64 {
231
+ let s = state();
232
+ let i = index as usize;
233
+ if i < MAX_TOUCH { f64::from_bits(s.touch_y[i].load(Ordering::Acquire)) } else { 0.0 }
234
+ }
235
+
236
+ #[no_mangle]
237
+ pub extern "C" fn bloom_get_touch_count() -> f64 {
238
+ let s = state();
239
+ let mut n = 0.0;
240
+ for i in 0..MAX_TOUCH {
241
+ if s.touch_active[i].load(Ordering::Acquire) != 0 { n += 1.0; }
242
+ }
243
+ n
244
+ }
245
+
246
+ #[no_mangle]
247
+ pub extern "C" fn bloom_get_delta_time() -> f64 {
248
+ let s = state();
249
+ let now = now_nanos();
250
+ let last = s.last_frame_ns.swap(now, Ordering::AcqRel);
251
+ if last == 0 { 1.0 / 30.0 } else { (now - last) as f64 / 1_000_000_000.0 }
252
+ }
253
+
254
+ #[no_mangle]
255
+ pub extern "C" fn bloom_get_time() -> f64 {
256
+ now_nanos() as f64 / 1_000_000_000.0
257
+ }
258
+
259
+ #[no_mangle]
260
+ pub extern "C" fn bloom_get_fps() -> f64 {
261
+ state().target_fps.load(Ordering::Acquire) as f64
262
+ }
263
+
264
+ #[no_mangle]
265
+ pub extern "C" fn bloom_set_target_fps(fps: f64) {
266
+ state().target_fps.store(fps as i64, Ordering::Release);
267
+ }
268
+
269
+ // No-op on watchOS (no deferred 3D pipeline); kept to satisfy the FFI
270
+ // surface so cross-platform game code can call setDirect2DMode() freely.
271
+ #[no_mangle]
272
+ pub extern "C" fn bloom_set_direct_2d_mode(_on: f64) {}
273
+
274
+ #[no_mangle]
275
+ pub extern "C" fn bloom_init_window(_w: f64, _h: f64, _title: i64, _fullscreen: f64) {}
276
+
277
+ #[no_mangle]
278
+ pub extern "C" fn bloom_close_window() {}
279
+
280
+ #[no_mangle]
281
+ pub extern "C" fn bloom_window_should_close() -> f64 { 0.0 }
282
+
283
+ // ============================================================
284
+ // Drawing lifecycle
285
+ // ============================================================
286
+
287
+ #[no_mangle]
288
+ pub extern "C" fn bloom_begin_drawing() {
289
+ // Pace the game thread to target fps. Canvas refresh is driven by the
290
+ // frame counter change on the Swift side, so this sleep also controls
291
+ // apparent frame rate in the view.
292
+ let fps = state().target_fps.load(Ordering::Acquire);
293
+ if fps > 0 {
294
+ let frame_ns = 1_000_000_000u64 / fps as u64;
295
+ std::thread::sleep(std::time::Duration::from_nanos(frame_ns));
296
+ }
297
+ draw_list::begin();
298
+ }
299
+
300
+ #[no_mangle]
301
+ pub extern "C" fn bloom_end_drawing() {
302
+ draw_list::end();
303
+ state().frame_count.fetch_add(1, Ordering::Relaxed);
304
+ }
305
+
306
+ #[no_mangle]
307
+ pub extern "C" fn bloom_clear_background(r: f64, g: f64, b: f64, a: f64) {
308
+ draw_list::set_clear(r, g, b, a);
309
+ }
310
+
311
+ #[no_mangle]
312
+ pub extern "C" fn bloom_run_game(_callback: f64) {}
313
+
314
+ #[no_mangle]
315
+ pub extern "C" fn bloom_is_any_input_pressed() -> f64 {
316
+ let s = state();
317
+ for i in 0..MAX_TOUCH {
318
+ if s.touch_active[i].load(Ordering::Acquire) != 0 { return 1.0; }
319
+ }
320
+ if f64::from_bits(s.crown_bits.load(Ordering::Acquire)).abs() > 0.0 { return 1.0; }
321
+ 0.0
322
+ }
323
+
324
+ #[no_mangle] pub extern "C" fn bloom_is_key_pressed(_k: f64) -> f64 { 0.0 }
325
+ #[no_mangle] pub extern "C" fn bloom_is_key_down(_k: f64) -> f64 { 0.0 }
326
+ #[no_mangle] pub extern "C" fn bloom_is_key_released(_k: f64) -> f64 { 0.0 }
327
+
328
+ #[no_mangle] pub extern "C" fn bloom_inject_key_down(_k: f64) {}
329
+ #[no_mangle] pub extern "C" fn bloom_inject_key_up(_k: f64) {}
330
+ #[no_mangle] pub extern "C" fn bloom_inject_gamepad_axis(_a: f64, _v: f64) {}
331
+ #[no_mangle] pub extern "C" fn bloom_inject_gamepad_button_down(_b: f64) {}
332
+ #[no_mangle] pub extern "C" fn bloom_inject_gamepad_button_up(_b: f64) {}
333
+
334
+ #[no_mangle] pub extern "C" fn bloom_is_gamepad_available() -> f64 { 0.0 }
335
+ #[no_mangle] pub extern "C" fn bloom_get_gamepad_axis(_a: f64) -> f64 { 0.0 }
336
+ #[no_mangle] pub extern "C" fn bloom_is_gamepad_button_pressed(_b: f64) -> f64 { 0.0 }
337
+ #[no_mangle] pub extern "C" fn bloom_is_gamepad_button_down(_b: f64) -> f64 { 0.0 }
338
+ #[no_mangle] pub extern "C" fn bloom_is_gamepad_button_released(_b: f64) -> f64 { 0.0 }
339
+ #[no_mangle] pub extern "C" fn bloom_get_gamepad_axis_count() -> f64 { 0.0 }
340
+
341
+ // ============================================================
342
+ // 2D shape commands → draw list
343
+ // ============================================================
344
+
345
+ #[no_mangle]
346
+ pub extern "C" fn bloom_draw_rect(x: f64, y: f64, w: f64, h: f64, r: f64, g: f64, b: f64, a: f64) {
347
+ let mut c = DrawCmd::zero();
348
+ c.kind = kind::RECT;
349
+ c.x = x; c.y = y; c.w = w; c.h = h;
350
+ c.r = r; c.g = g; c.b = b; c.a = a;
351
+ draw_list::push(c);
352
+ }
353
+
354
+ #[no_mangle]
355
+ pub extern "C" fn bloom_draw_rect_lines(x: f64, y: f64, w: f64, h: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64) {
356
+ let mut c = DrawCmd::zero();
357
+ c.kind = kind::RECT_LINES;
358
+ c.x = x; c.y = y; c.w = w; c.h = h;
359
+ c.thickness = thickness;
360
+ c.r = r; c.g = g; c.b = b; c.a = a;
361
+ draw_list::push(c);
362
+ }
363
+
364
+ #[no_mangle]
365
+ pub extern "C" fn bloom_draw_circle(cx: f64, cy: f64, rad: f64, r: f64, g: f64, b: f64, a: f64) {
366
+ let mut c = DrawCmd::zero();
367
+ c.kind = kind::CIRCLE;
368
+ c.x = cx; c.y = cy; c.w = rad; c.h = rad;
369
+ c.r = r; c.g = g; c.b = b; c.a = a;
370
+ draw_list::push(c);
371
+ }
372
+
373
+ #[no_mangle]
374
+ pub extern "C" fn bloom_draw_circle_lines(cx: f64, cy: f64, rad: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64) {
375
+ let mut c = DrawCmd::zero();
376
+ c.kind = kind::CIRCLE_LINES;
377
+ c.x = cx; c.y = cy; c.w = rad; c.h = rad;
378
+ c.thickness = thickness;
379
+ c.r = r; c.g = g; c.b = b; c.a = a;
380
+ draw_list::push(c);
381
+ }
382
+
383
+ #[no_mangle]
384
+ pub extern "C" fn bloom_draw_line(x1: f64, y1: f64, x2: f64, y2: f64, thickness: f64, r: f64, g: f64, b: f64, a: f64) {
385
+ let mut c = DrawCmd::zero();
386
+ c.kind = kind::LINE;
387
+ c.x = x1; c.y = y1;
388
+ c.src_x = x2; c.src_y = y2;
389
+ c.thickness = thickness;
390
+ c.r = r; c.g = g; c.b = b; c.a = a;
391
+ draw_list::push(c);
392
+ }
393
+
394
+ #[no_mangle]
395
+ pub extern "C" fn bloom_draw_triangle(x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64, r: f64, g: f64, b: f64, a: f64) {
396
+ let mut c = DrawCmd::zero();
397
+ c.kind = kind::TRIANGLE;
398
+ c.x = x1; c.y = y1;
399
+ c.src_x = x2; c.src_y = y2;
400
+ c.src_w = x3; c.src_h = y3;
401
+ c.r = r; c.g = g; c.b = b; c.a = a;
402
+ draw_list::push(c);
403
+ }
404
+
405
+ #[no_mangle]
406
+ pub extern "C" fn bloom_draw_poly(_cx: f64, _cy: f64, _sides: f64, _radius: f64, _rot: f64, _r: f64, _g: f64, _b: f64, _a: f64) {
407
+ // Polygon fill — defer; Canvas handles via context.fill(Path.addArc).
408
+ // Will land with the rest of the Canvas geometry work.
409
+ }
410
+
411
+ // ============================================================
412
+ // Texture commands
413
+ // ============================================================
414
+
415
+ #[no_mangle]
416
+ pub extern "C" fn bloom_load_texture(path: i64) -> f64 {
417
+ textures::load(perry_str(path)) as f64
418
+ }
419
+
420
+ #[no_mangle]
421
+ pub extern "C" fn bloom_unload_texture(_handle: f64) {
422
+ // Retain by handle — unload is a no-op on watch (reloading isn't common
423
+ // in Jump-class games; we keep cached CGImages on the Swift side for
424
+ // the life of the process).
425
+ }
426
+
427
+ #[no_mangle]
428
+ pub extern "C" fn bloom_get_texture_width(handle: f64) -> f64 {
429
+ textures::width(handle as u32) as f64
430
+ }
431
+
432
+ #[no_mangle]
433
+ pub extern "C" fn bloom_get_texture_height(handle: f64) -> f64 {
434
+ textures::height(handle as u32) as f64
435
+ }
436
+
437
+ #[no_mangle]
438
+ pub extern "C" fn bloom_draw_texture(handle: f64, x: f64, y: f64, r: f64, g: f64, b: f64, a: f64) {
439
+ let h = handle as u32;
440
+ if h == 0 { return; }
441
+ let mut c = DrawCmd::zero();
442
+ c.kind = kind::TEXTURE;
443
+ c.tex = h;
444
+ c.x = x; c.y = y;
445
+ c.w = textures::width(h) as f64;
446
+ c.h = textures::height(h) as f64;
447
+ c.r = r; c.g = g; c.b = b; c.a = a;
448
+ draw_list::push(c);
449
+ }
450
+
451
+ #[no_mangle]
452
+ pub extern "C" fn bloom_draw_texture_rec(handle: f64,
453
+ src_x: f64, src_y: f64, src_w: f64, src_h: f64,
454
+ dst_x: f64, dst_y: f64,
455
+ r: f64, g: f64, b: f64, a: f64,
456
+ ) {
457
+ let h = handle as u32;
458
+ if h == 0 { return; }
459
+ let mut c = DrawCmd::zero();
460
+ c.kind = kind::TEXTURE_REC;
461
+ c.tex = h;
462
+ c.x = dst_x; c.y = dst_y;
463
+ c.w = src_w; c.h = src_h;
464
+ c.src_x = src_x; c.src_y = src_y; c.src_w = src_w; c.src_h = src_h;
465
+ c.r = r; c.g = g; c.b = b; c.a = a;
466
+ draw_list::push(c);
467
+ }
468
+
469
+ #[no_mangle]
470
+ pub extern "C" fn bloom_draw_texture_pro(handle: f64,
471
+ src_x: f64, src_y: f64, src_w: f64, src_h: f64,
472
+ dst_x: f64, dst_y: f64, dst_w: f64, dst_h: f64,
473
+ ox: f64, oy: f64, rot: f64,
474
+ r: f64, g: f64, b: f64, a: f64,
475
+ ) {
476
+ let h = handle as u32;
477
+ if h == 0 { return; }
478
+ let mut c = DrawCmd::zero();
479
+ c.kind = kind::TEXTURE_PRO;
480
+ c.tex = h;
481
+ c.x = dst_x; c.y = dst_y; c.w = dst_w; c.h = dst_h;
482
+ c.src_x = src_x; c.src_y = src_y; c.src_w = src_w; c.src_h = src_h;
483
+ c.ox = ox; c.oy = oy; c.rot = rot;
484
+ c.r = r; c.g = g; c.b = b; c.a = a;
485
+ draw_list::push(c);
486
+ }
487
+
488
+ #[no_mangle]
489
+ pub extern "C" fn bloom_set_texture_filter(_handle: f64, _mode: f64) {}
490
+
491
+ // ============================================================
492
+ // Text
493
+ // ============================================================
494
+
495
+ #[no_mangle]
496
+ pub extern "C" fn bloom_draw_text(text: i64, x: f64, y: f64, size: f64,
497
+ r: f64, g: f64, b: f64, a: f64,
498
+ ) {
499
+ push_text(perry_str(text), x, y, size, r, g, b, a);
500
+ }
501
+
502
+ #[no_mangle]
503
+ pub extern "C" fn bloom_draw_text_ex(_font: f64, text: i64,
504
+ x: f64, y: f64, size: f64, _spacing: f64,
505
+ r: f64, g: f64, b: f64, a: f64,
506
+ ) {
507
+ push_text(perry_str(text), x, y, size, r, g, b, a);
508
+ }
509
+
510
+ fn push_text(s: &str, x: f64, y: f64, size: f64,
511
+ r: f64, g: f64, b: f64, a: f64,
512
+ ) {
513
+ if s.is_empty() { return; }
514
+ let mut c = DrawCmd::zero();
515
+ c.kind = kind::TEXT;
516
+ c.x = x; c.y = y;
517
+ c.size = size;
518
+ c.r = r; c.g = g; c.b = b; c.a = a;
519
+ c.set_text(s);
520
+ draw_list::push(c);
521
+ }
522
+
523
+ /// Crude text width estimate — fontSize * 0.55 * char_count. Good enough for
524
+ /// HUD layout; real glyph metrics would require calling back into Swift
525
+ /// (CoreText) or bundling a font parser.
526
+ #[no_mangle]
527
+ pub extern "C" fn bloom_measure_text(text: i64, size: f64) -> f64 {
528
+ perry_str(text).chars().count() as f64 * size * 0.55
529
+ }
530
+
531
+ #[no_mangle]
532
+ pub extern "C" fn bloom_measure_text_ex(_font: f64, text: i64, size: f64, _spacing: f64) -> f64 {
533
+ bloom_measure_text(text, size)
534
+ }
535
+
536
+ #[no_mangle]
537
+ pub extern "C" fn bloom_load_font(_path: i64, _size: f64) -> f64 {
538
+ 1.0 // All text uses the system font on watch; single sentinel handle.
539
+ }
540
+
541
+ #[no_mangle]
542
+ pub extern "C" fn bloom_unload_font(_handle: f64) {}
543
+
544
+ // ============================================================
545
+ // File I/O — minimal std::fs-backed implementations
546
+ // ============================================================
547
+
548
+ #[no_mangle]
549
+ pub extern "C" fn bloom_file_exists(path: i64) -> f64 {
550
+ let p = perry_str(path);
551
+ if p.is_empty() { return 0.0; }
552
+ // Resolve bundle-relative paths the same way textures does.
553
+ let full = if p.starts_with('/') { p.to_string() } else { textures::resolve_bundle_path(p) };
554
+ if std::path::Path::new(&full).exists() { 1.0 } else { 0.0 }
555
+ }
556
+
557
+ #[no_mangle]
558
+ pub extern "C" fn bloom_read_file(path: i64) -> i64 {
559
+ // Perry's native FFI wraps string returns — returning 0 signals null
560
+ // from the watchOS side. Jump reads level files via this path; a later
561
+ // pass will resolve bundle-relative paths and hand back a StringHeader.
562
+ let _ = path;
563
+ 0
564
+ }
565
+
566
+ #[no_mangle]
567
+ pub extern "C" fn bloom_write_file(_path: i64, _data: i64) -> f64 {
568
+ 0.0 // watchOS app sandbox — defer real write support.
569
+ }
570
+
571
+ // ============================================================
572
+ // 3D immediate-mode primitives
573
+ // ============================================================
574
+
575
+ #[no_mangle]
576
+ pub extern "C" fn bloom_begin_mode_3d(
577
+ px: f64, py: f64, pz: f64,
578
+ tx: f64, ty: f64, tz: f64,
579
+ ux: f64, uy: f64, uz: f64,
580
+ fovy: f64, proj: f64,
581
+ ) {
582
+ draw_list::set_camera(px, py, pz, tx, ty, tz, ux, uy, uz, fovy, proj);
583
+ }
584
+
585
+ #[no_mangle]
586
+ pub extern "C" fn bloom_end_mode_3d() {
587
+ // No-op: 3D commands are already in the list; the camera stays set until
588
+ // the next begin_mode_3d. Swift's SceneView draws 3D cmds under the
589
+ // Canvas layer each frame.
590
+ }
591
+
592
+ #[no_mangle]
593
+ pub extern "C" fn bloom_draw_cube(x: f64, y: f64, z: f64, w: f64, h: f64, d: f64,
594
+ r: f64, g: f64, b: f64, a: f64,
595
+ ) {
596
+ let mut c = DrawCmd::zero();
597
+ c.kind = kind::CUBE;
598
+ c.x = x; c.y = y; c.src_x = z; // src_x doubles as z on 3D cmds
599
+ c.w = w; c.h = h; c.size = d;
600
+ c.r = r; c.g = g; c.b = b; c.a = a;
601
+ draw_list::push(c);
602
+ }
603
+
604
+ #[no_mangle]
605
+ pub extern "C" fn bloom_draw_cube_wires(x: f64, y: f64, z: f64, w: f64, h: f64, d: f64,
606
+ r: f64, g: f64, b: f64, a: f64,
607
+ ) {
608
+ let mut c = DrawCmd::zero();
609
+ c.kind = kind::CUBE_WIRES;
610
+ c.x = x; c.y = y; c.src_x = z; // src_x doubles as z on 3D cmds
611
+ c.w = w; c.h = h; c.size = d;
612
+ c.r = r; c.g = g; c.b = b; c.a = a;
613
+ draw_list::push(c);
614
+ }
615
+
616
+ #[no_mangle]
617
+ pub extern "C" fn bloom_draw_sphere(x: f64, y: f64, z: f64, radius: f64,
618
+ r: f64, g: f64, b: f64, a: f64,
619
+ ) {
620
+ let mut c = DrawCmd::zero();
621
+ c.kind = kind::SPHERE;
622
+ c.x = x; c.y = y; c.src_x = z; // src_x doubles as z on 3D cmds
623
+ c.w = radius;
624
+ c.r = r; c.g = g; c.b = b; c.a = a;
625
+ draw_list::push(c);
626
+ }
627
+
628
+ #[no_mangle]
629
+ pub extern "C" fn bloom_draw_sphere_wires(x: f64, y: f64, z: f64, radius: f64,
630
+ r: f64, g: f64, b: f64, a: f64,
631
+ ) {
632
+ let mut c = DrawCmd::zero();
633
+ c.kind = kind::SPHERE_WIRES;
634
+ c.x = x; c.y = y; c.src_x = z; // src_x doubles as z on 3D cmds
635
+ c.w = radius;
636
+ c.r = r; c.g = g; c.b = b; c.a = a;
637
+ draw_list::push(c);
638
+ }
639
+
640
+ #[no_mangle]
641
+ pub extern "C" fn bloom_draw_cylinder(x: f64, y: f64, z: f64,
642
+ radius_top: f64, _radius_bottom: f64, height: f64, _slices: f64,
643
+ r: f64, g: f64, b: f64, a: f64,
644
+ ) {
645
+ let mut c = DrawCmd::zero();
646
+ c.kind = kind::CYLINDER;
647
+ c.x = x; c.y = y; c.src_x = z; // src_x doubles as z on 3D cmds
648
+ c.w = radius_top; c.h = height;
649
+ c.r = r; c.g = g; c.b = b; c.a = a;
650
+ draw_list::push(c);
651
+ }
652
+
653
+ #[no_mangle]
654
+ pub extern "C" fn bloom_draw_plane(x: f64, y: f64, z: f64, w: f64, h: f64,
655
+ r: f64, g: f64, b: f64, a: f64,
656
+ ) {
657
+ let mut c = DrawCmd::zero();
658
+ c.kind = kind::PLANE;
659
+ c.x = x; c.y = y; c.src_x = z; // src_x doubles as z on 3D cmds
660
+ c.w = w; c.h = h;
661
+ c.r = r; c.g = g; c.b = b; c.a = a;
662
+ draw_list::push(c);
663
+ }
664
+
665
+ // ============================================================
666
+ // Audio (forwards to Swift BloomAudioManager)
667
+ // ============================================================
668
+
669
+ #[no_mangle] pub extern "C" fn bloom_init_audio() { audio::init_audio(); }
670
+ #[no_mangle] pub extern "C" fn bloom_close_audio() { audio::close_audio(); }
671
+
672
+ #[no_mangle]
673
+ pub extern "C" fn bloom_load_sound(path: i64) -> f64 {
674
+ audio::load_sound(perry_str(path)) as f64
675
+ }
676
+ #[no_mangle] pub extern "C" fn bloom_play_sound(handle: f64) { audio::play_sound(handle as u32); }
677
+ #[no_mangle] pub extern "C" fn bloom_stop_sound(handle: f64) { audio::stop_sound(handle as u32); }
678
+ #[no_mangle] pub extern "C" fn bloom_set_sound_volume(handle: f64, v: f64) {
679
+ audio::set_sound_volume(handle as u32, v as f32);
680
+ }
681
+ #[no_mangle] pub extern "C" fn bloom_set_master_volume(v: f64) {
682
+ audio::set_master_volume(v as f32);
683
+ }
684
+ #[no_mangle] pub extern "C" fn bloom_play_sound_3d(handle: f64, _x: f64, _y: f64, _z: f64) {
685
+ // No spatial audio on watch — play at full 2D volume.
686
+ audio::play_sound(handle as u32);
687
+ }
688
+
689
+ #[no_mangle]
690
+ pub extern "C" fn bloom_load_music(path: i64) -> f64 {
691
+ audio::load_music(perry_str(path)) as f64
692
+ }
693
+ #[no_mangle] pub extern "C" fn bloom_play_music(handle: f64) { audio::play_music(handle as u32); }
694
+ #[no_mangle] pub extern "C" fn bloom_stop_music(handle: f64) { audio::stop_music(handle as u32); }
695
+ #[no_mangle] pub extern "C" fn bloom_set_music_volume(handle: f64, v: f64) {
696
+ audio::set_music_volume(handle as u32, v as f32);
697
+ }
698
+ #[no_mangle] pub extern "C" fn bloom_is_music_playing(handle: f64) -> f64 {
699
+ if audio::is_music_playing(handle as u32) { 1.0 } else { 0.0 }
700
+ }
701
+ #[no_mangle] pub extern "C" fn bloom_update_music_stream(_handle: f64) {
702
+ // AVAudioPlayer owns stream pumping internally — no per-frame poke needed.
703
+ }
704
+
705
+ // ============================================================
706
+ // Retained scene graph (bloom_scene_*) — synced to SCNNodes in Swift
707
+ // ============================================================
708
+
709
+ #[no_mangle] pub extern "C" fn bloom_scene_create_node() -> f64 { scene::create() as f64 }
710
+ #[no_mangle] pub extern "C" fn bloom_scene_destroy_node(h: f64) { scene::destroy(h as u32); }
711
+ #[no_mangle] pub extern "C" fn bloom_scene_set_visible(h: f64, v: f64) {
712
+ scene::set_visible(h as u32, v > 0.5);
713
+ }
714
+ #[no_mangle] pub extern "C" fn bloom_scene_set_cast_shadow(_h: f64, _v: f64) {
715
+ // SceneKit manages shadow casting via per-node + light config; deferred.
716
+ }
717
+ #[no_mangle] pub extern "C" fn bloom_scene_set_receive_shadow(_h: f64, _v: f64) {}
718
+ #[no_mangle] pub extern "C" fn bloom_scene_set_parent(h: f64, parent: f64) {
719
+ scene::set_parent(h as u32, parent as u32);
720
+ }
721
+
722
+ /// Transform is a raw pointer to 16 column-major f64s (128 bytes). No
723
+ /// StringHeader wrapping — bloom's TS side passes a `number[]` which Perry
724
+ /// forwards as a pointer to the Float64 data.
725
+ #[no_mangle]
726
+ pub extern "C" fn bloom_scene_set_transform(handle: f64, matrix_ptr: i64) {
727
+ if matrix_ptr == 0 { return; }
728
+ let src = unsafe { std::slice::from_raw_parts(matrix_ptr as *const f64, 16) };
729
+ let mut arr = [0.0f32; 16];
730
+ for i in 0..16 { arr[i] = src[i] as f32; }
731
+ scene::set_transform(handle as u32, arr);
732
+ }
733
+
734
+ /// Geometry: vert_ptr points to `vertex_count * 12` f64s (12 floats per
735
+ /// vertex: xyz, nx ny nz, rgba, uv). idx_ptr points to `index_count` f64s
736
+ /// (each integer index boxed as f64 — matches bloom's TS `number[]` calls).
737
+ #[no_mangle]
738
+ pub extern "C" fn bloom_scene_update_geometry(
739
+ handle: f64, verts_ptr: i64, vertex_count: f64,
740
+ idx_ptr: i64, index_count: f64,
741
+ ) {
742
+ if verts_ptr == 0 || idx_ptr == 0 { return; }
743
+ let vcount = vertex_count as usize;
744
+ let icount = index_count as usize;
745
+ let verts = unsafe { std::slice::from_raw_parts(verts_ptr as *const f64, vcount * 12) };
746
+ let idx_f64 = unsafe { std::slice::from_raw_parts(idx_ptr as *const f64, icount) };
747
+ scene::update_geometry_f64(handle as u32, verts, idx_f64);
748
+ }
749
+
750
+ #[no_mangle]
751
+ pub extern "C" fn bloom_scene_set_material_color(h: f64, r: f64, g: f64, b: f64, a: f64) {
752
+ scene::set_color(h as u32, [r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, a as f32 / 255.0]);
753
+ }
754
+ #[no_mangle]
755
+ pub extern "C" fn bloom_scene_set_material_pbr(h: f64, roughness: f64, metalness: f64) {
756
+ scene::set_pbr(h as u32, roughness as f32, metalness as f32);
757
+ }
758
+ #[no_mangle]
759
+ pub extern "C" fn bloom_scene_set_material_texture(h: f64, tex: f64) {
760
+ scene::set_texture(h as u32, tex as u32);
761
+ }
762
+ #[no_mangle] pub extern "C" fn bloom_scene_node_count() -> f64 { scene::node_count() as f64 }
763
+
764
+ #[no_mangle]
765
+ pub extern "C" fn bloom_scene_get_transform(handle: f64, out: f64) -> f64 {
766
+ // `out` is a pointer to 16 f32s the caller has allocated. Write them.
767
+ if out == 0.0 { return 0.0; }
768
+ let t = scene::get_transform(handle as u32);
769
+ unsafe {
770
+ std::ptr::copy_nonoverlapping(t.as_ptr(), out as usize as *mut f32, 16);
771
+ }
772
+ 1.0
773
+ }
774
+
775
+ // ============================================================
776
+ // Models — glTF (.glb) loading + scene attachment
777
+ // ============================================================
778
+
779
+ #[no_mangle]
780
+ pub extern "C" fn bloom_load_model(path: i64) -> f64 {
781
+ let p = perry_str(path);
782
+ if p.is_empty() { return 0.0; }
783
+ let full = if p.starts_with('/') { p.to_string() } else { textures::resolve_bundle_path(p) };
784
+ models::load(&full) as f64
785
+ }
786
+
787
+ #[no_mangle]
788
+ pub extern "C" fn bloom_gen_mesh_cube(w: f64, h: f64, d: f64) -> f64 {
789
+ models::gen_cube_mesh(w as f32, h as f32, d as f32) as f64
790
+ }
791
+
792
+ /// Attach a loaded model to a scene node. If the model has a glTF scene
793
+ /// hierarchy, the full subtree is spawned as bloom scene-node descendants of
794
+ /// `node_handle` with each glTF node's TRS transform baked in. For
795
+ /// single-node models this collapses to the pre-#15 behavior (the target
796
+ /// node gets the one mesh's first primitive, sibling primitives become its
797
+ /// children).
798
+ ///
799
+ /// The `mesh_idx` parameter is only honored when the model has no scene
800
+ /// hierarchy — it picks which mesh to instantiate into `node_handle`.
801
+ #[no_mangle]
802
+ pub extern "C" fn bloom_scene_attach_model(node_handle: f64, model_handle: f64, mesh_idx: f64) {
803
+ let Some(model) = models::get(model_handle as u32) else { return; };
804
+ let root = node_handle as u32;
805
+
806
+ // If the model has a scene graph with non-trivial hierarchy (>1 node or a
807
+ // transform on the root), walk it. Otherwise fall back to single-mesh
808
+ // mode so mesh_idx still picks which mesh to attach.
809
+ let single_mesh = model.nodes.len() <= 1
810
+ && model.scene_roots.len() <= 1
811
+ && model.nodes.first().map(|n| n.matrix.is_none()
812
+ && n.translation == [0.0; 3]
813
+ && n.rotation == [0.0, 0.0, 0.0, 1.0]
814
+ && n.scale == [1.0; 3]).unwrap_or(true);
815
+
816
+ if single_mesh {
817
+ let mesh_i = mesh_idx as usize;
818
+ let Some(mesh) = model.meshes.get(mesh_i) else { return; };
819
+ attach_mesh(root, mesh);
820
+ return;
821
+ }
822
+
823
+ // Scene-hierarchy path: one bloom scene node per glTF node. The attach
824
+ // target `root` itself doesn't gain geometry — it's the hierarchy's
825
+ // anchor. Children materialize via scene::create + scene::set_parent.
826
+ // We build a gltf_node_idx → bloom_handle map during the walk, then
827
+ // resolve skin joint references once everyone's in place.
828
+ let mut gltf_to_bloom: std::collections::HashMap<usize, u32> = std::collections::HashMap::new();
829
+ let mut skinned_nodes: Vec<(u32, usize)> = Vec::new(); // (bloom_handle, gltf_node_idx)
830
+ for scene_root in &model.scene_roots {
831
+ spawn_node_subtree(&model, *scene_root, root, &mut gltf_to_bloom, &mut skinned_nodes);
832
+ }
833
+ // Second pass: attach skin data to each skinned mesh-node. Joints are
834
+ // resolved to the bloom handles we just created.
835
+ for (bloom_handle, gltf_idx) in skinned_nodes {
836
+ let gltf_node = &model.nodes[gltf_idx];
837
+ let Some(skin_idx) = gltf_node.skin else { continue };
838
+ let Some(skin) = model.skins.get(skin_idx) else { continue };
839
+ let Some(mesh_idx) = gltf_node.mesh else { continue };
840
+ let Some(mesh) = model.meshes.get(mesh_idx) else { continue };
841
+ let Some(prim) = mesh.primitives.first() else { continue };
842
+
843
+ let joint_handles: Vec<u32> = skin.joints.iter()
844
+ .map(|&gi| *gltf_to_bloom.get(&gi).unwrap_or(&0))
845
+ .collect();
846
+ scene::set_skin(bloom_handle,
847
+ joint_handles,
848
+ skin.inverse_bind_matrices.clone(),
849
+ prim.joint_indices.clone(),
850
+ prim.weights.clone(),
851
+ );
852
+
853
+ // Animation tracks — resolve channel targets to bloom handles.
854
+ // Auto-select animation 0 for now (typically the idle/survey clip).
855
+ // Follow-up: bloom_update_model_animation to switch between them.
856
+ if let Some(anim) = model.animations.first() {
857
+ let mut tracks: Vec<scene::AnimTrack> = Vec::new();
858
+ for ch in &anim.channels {
859
+ let Some(&bone_h) = gltf_to_bloom.get(&ch.target_node) else { continue };
860
+ if bone_h == 0 { continue; }
861
+ tracks.push(scene::AnimTrack {
862
+ bone_handle: bone_h,
863
+ path: ch.path as u32,
864
+ times: ch.times.clone(),
865
+ values: ch.values.clone(),
866
+ });
867
+ }
868
+ if !tracks.is_empty() {
869
+ scene::set_anim_tracks(bloom_handle, tracks);
870
+ }
871
+ }
872
+ }
873
+ }
874
+
875
+ fn attach_mesh(handle: u32, mesh: &models::Mesh) {
876
+ if mesh.primitives.is_empty() { return; }
877
+ apply_primitive(handle, &mesh.primitives[0]);
878
+ for prim in mesh.primitives.iter().skip(1) {
879
+ let child = scene::create();
880
+ scene::set_parent(child, handle);
881
+ apply_primitive(child, prim);
882
+ }
883
+ }
884
+
885
+ fn spawn_node_subtree(
886
+ model: &models::Model, node_idx: usize, parent: u32,
887
+ gltf_to_bloom: &mut std::collections::HashMap<usize, u32>,
888
+ skinned_nodes: &mut Vec<(u32, usize)>,
889
+ ) {
890
+ let Some(gltf_node) = model.nodes.get(node_idx) else { return; };
891
+ let bloom_node = scene::create();
892
+ gltf_to_bloom.insert(node_idx, bloom_node);
893
+ scene::set_parent(bloom_node, parent);
894
+ scene::set_transform(bloom_node, gltf_node.local_transform());
895
+ if let Some(mi) = gltf_node.mesh {
896
+ if let Some(mesh) = model.meshes.get(mi) {
897
+ attach_mesh(bloom_node, mesh);
898
+ if gltf_node.skin.is_some() {
899
+ skinned_nodes.push((bloom_node, node_idx));
900
+ }
901
+ }
902
+ }
903
+ for &child_idx in &gltf_node.children {
904
+ spawn_node_subtree(model, child_idx, bloom_node, gltf_to_bloom, skinned_nodes);
905
+ }
906
+ }
907
+
908
+ fn apply_primitive(handle: u32, prim: &models::Primitive) {
909
+ scene::set_geometry(handle,
910
+ prim.positions.clone(), prim.normals.clone(),
911
+ prim.uvs.clone(), prim.indices.clone());
912
+ scene::set_color(handle, prim.color);
913
+ scene::set_pbr(handle, prim.roughness, prim.metallic);
914
+ scene::set_pbr_textures(handle,
915
+ prim.tex_base_color, prim.tex_normal,
916
+ prim.tex_metallic_roughness, prim.tex_emissive, prim.tex_occlusion);
917
+ }
918
+
919
+ // ============================================================
920
+ // Post-processing — stored for Swift to translate into SwiftUI modifiers
921
+ // ============================================================
922
+
923
+ #[no_mangle] pub extern "C" fn bloom_enable_postfx() { postfx::set_enabled(true); }
924
+ #[no_mangle] pub extern "C" fn bloom_disable_postfx() { postfx::set_enabled(false); }
925
+ #[no_mangle] pub extern "C" fn bloom_set_vignette(strength: f64, softness: f64) {
926
+ postfx::set_vignette(strength, softness);
927
+ }
928
+ #[no_mangle] pub extern "C" fn bloom_set_chromatic_aberration(strength: f64) {
929
+ postfx::set_chromatic_aberration(strength);
930
+ }
931
+ #[no_mangle] pub extern "C" fn bloom_set_film_grain(strength: f64) {
932
+ postfx::set_film_grain(strength);
933
+ }
934
+ #[no_mangle] pub extern "C" fn bloom_set_manual_exposure(v: f64) { postfx::set_exposure(v); }
935
+ #[no_mangle] pub extern "C" fn bloom_set_auto_exposure(on: f64) {
936
+ postfx::set_auto_exposure(on > 0.5);
937
+ }
938
+ #[no_mangle] pub extern "C" fn bloom_set_sun_shafts(
939
+ strength: f64, decay: f64, r: f64, g: f64, b: f64,
940
+ ) {
941
+ postfx::set_sun_shafts(strength, decay, r, g, b);
942
+ }
943
+
944
+ #[no_mangle]
945
+ pub extern "C" fn bloom_watchos_postfx_state(out: *mut postfx::PostFxState) {
946
+ postfx::snapshot(out);
947
+ }
948
+
949
+ #[no_mangle] pub extern "C" fn bloom_add_directional_light(
950
+ dx: f64, dy: f64, dz: f64, r: f64, g: f64, b: f64, intensity: f64,
951
+ ) {
952
+ scene::add_directional_light(dx as f32, dy as f32, dz as f32,
953
+ r as f32, g as f32, b as f32, intensity as f32);
954
+ }
955
+
956
+ #[no_mangle] pub extern "C" fn bloom_add_point_light(
957
+ x: f64, y: f64, z: f64, range: f64, r: f64, g: f64, b: f64, intensity: f64,
958
+ ) {
959
+ scene::add_point_light(x as f32, y as f32, z as f32, range as f32,
960
+ r as f32, g as f32, b as f32, intensity as f32);
961
+ }
962
+
963
+ // ============================================================
964
+ // Scene snapshot accessors for Swift
965
+ // ============================================================
966
+
967
+ #[no_mangle]
968
+ pub extern "C" fn bloom_watchos_scene_drain_dirty(dst: *mut scene::SceneNodeInfo, max: i64) -> i64 {
969
+ scene::drain_dirty(dst, max)
970
+ }
971
+
972
+ #[no_mangle]
973
+ pub extern "C" fn bloom_watchos_scene_drain_destroyed(dst: *mut u32, max: i64) -> i64 {
974
+ scene::drain_destroyed(dst, max)
975
+ }
976
+
977
+ #[no_mangle]
978
+ pub extern "C" fn bloom_watchos_scene_copy_lights(dst: *mut scene::Light, max: i64) -> i64 {
979
+ scene::copy_lights(dst, max)
980
+ }
981
+
982
+ #[no_mangle]
983
+ pub extern "C" fn bloom_watchos_scene_geometry(handle: u32, out: *mut scene::GeometryPtrs) {
984
+ if out.is_null() { return; }
985
+ unsafe { *out = scene::geometry_ptrs(handle); }
986
+ }
987
+
988
+ #[no_mangle]
989
+ pub extern "C" fn bloom_watchos_scene_skin(handle: u32, out: *mut scene::SkinPtrs) {
990
+ if out.is_null() { return; }
991
+ unsafe { *out = scene::skin_ptrs(handle); }
992
+ }
993
+
994
+ #[no_mangle]
995
+ pub extern "C" fn bloom_watchos_scene_anim_track_count(handle: u32) -> i64 {
996
+ scene::anim_track_count(handle)
997
+ }
998
+
999
+ #[no_mangle]
1000
+ pub extern "C" fn bloom_watchos_scene_anim_track_info(handle: u32, idx: i64, out: *mut scene::AnimTrackInfo) {
1001
+ scene::anim_track_info(handle, idx, out);
1002
+ }
1003
+
1004
+ #[no_mangle]
1005
+ pub extern "C" fn bloom_draw_grid(slices: f64, spacing: f64) {
1006
+ let mut c = DrawCmd::zero();
1007
+ c.kind = kind::GRID;
1008
+ c.w = slices;
1009
+ c.h = spacing;
1010
+ // Grid color — light gray, matches bloom's default.
1011
+ c.r = 200.0; c.g = 200.0; c.b = 200.0; c.a = 255.0;
1012
+ draw_list::push(c);
1013
+ }