@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.
- package/LICENSE +21 -0
- package/README.md +169 -0
- package/native/android/Cargo.lock +1848 -0
- package/native/android/Cargo.toml +20 -0
- package/native/android/src/lib.rs +1747 -0
- package/native/ios/Cargo.lock +1688 -0
- package/native/ios/Cargo.toml +19 -0
- package/native/ios/src/lib.rs +2258 -0
- package/native/linux/Cargo.lock +1719 -0
- package/native/linux/Cargo.toml +22 -0
- package/native/linux/src/lib.rs +2236 -0
- package/native/macos/Cargo.lock +3310 -0
- package/native/macos/Cargo.toml +29 -0
- package/native/macos/src/lib.rs +3444 -0
- package/native/shared/Cargo.lock +1898 -0
- package/native/shared/Cargo.toml +42 -0
- package/native/shared/assets/default_font.ttf +0 -0
- package/native/shared/build.rs +77 -0
- package/native/shared/shaders/common/fog.wgsl +16 -0
- package/native/shared/shaders/common/imposter.wgsl +112 -0
- package/native/shared/shaders/common/pbr.wgsl +186 -0
- package/native/shared/shaders/common/shadows.wgsl +77 -0
- package/native/shared/shaders/common/sky.wgsl +8 -0
- package/native/shared/shaders/common/tonemap.wgsl +25 -0
- package/native/shared/shaders/impulse_field.wgsl +53 -0
- package/native/shared/shaders/material_abi.wgsl +360 -0
- package/native/shared/shaders/materials/test_minimal.wgsl +42 -0
- package/native/shared/src/audio.rs +363 -0
- package/native/shared/src/custom_shaders.rs +104 -0
- package/native/shared/src/drs.rs +211 -0
- package/native/shared/src/engine.rs +186 -0
- package/native/shared/src/frame_callbacks.rs +88 -0
- package/native/shared/src/geometry.rs +236 -0
- package/native/shared/src/handles.rs +76 -0
- package/native/shared/src/input.rs +273 -0
- package/native/shared/src/jolt_sys.rs +822 -0
- package/native/shared/src/lib.rs +43 -0
- package/native/shared/src/models.rs +1941 -0
- package/native/shared/src/physics_jolt.rs +1528 -0
- package/native/shared/src/picking.rs +298 -0
- package/native/shared/src/postfx.rs +339 -0
- package/native/shared/src/profiler.rs +416 -0
- package/native/shared/src/renderer/atmosphere_lut.rs +573 -0
- package/native/shared/src/renderer/brdf_lut.rs +154 -0
- package/native/shared/src/renderer/formats.rs +778 -0
- package/native/shared/src/renderer/graph.rs +465 -0
- package/native/shared/src/renderer/hot_reload.rs +390 -0
- package/native/shared/src/renderer/impulse_field.rs +455 -0
- package/native/shared/src/renderer/material_pipeline.rs +604 -0
- package/native/shared/src/renderer/material_system.rs +2106 -0
- package/native/shared/src/renderer/mod.rs +13923 -0
- package/native/shared/src/renderer/planar_reflection.rs +458 -0
- package/native/shared/src/renderer/post_pass.rs +249 -0
- package/native/shared/src/renderer/shader_include.rs +205 -0
- package/native/shared/src/renderer/shader_library.rs +134 -0
- package/native/shared/src/renderer/shaders.rs +5855 -0
- package/native/shared/src/renderer/transient.rs +576 -0
- package/native/shared/src/renderer/types.rs +259 -0
- package/native/shared/src/renderer/util.rs +151 -0
- package/native/shared/src/scene.rs +1066 -0
- package/native/shared/src/sdf_cache.rs +274 -0
- package/native/shared/src/shadows.rs +551 -0
- package/native/shared/src/staging.rs +90 -0
- package/native/shared/src/string_header.rs +35 -0
- package/native/shared/src/text_renderer.rs +456 -0
- package/native/shared/src/textures.rs +154 -0
- package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.cpp +242 -0
- package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.h +121 -0
- package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeToBuffer.h +296 -0
- package/native/third_party/JoltPhysics/Jolt/AABBTree/NodeCodec/NodeCodecQuadTreeHalfFloat.h +323 -0
- package/native/third_party/JoltPhysics/Jolt/AABBTree/TriangleCodec/TriangleCodecIndexed8BitPackSOA4Flags.h +555 -0
- package/native/third_party/JoltPhysics/Jolt/ConfigurationString.h +112 -0
- package/native/third_party/JoltPhysics/Jolt/Core/ARMNeon.h +94 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Array.h +713 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Atomics.h +44 -0
- package/native/third_party/JoltPhysics/Jolt/Core/BinaryHeap.h +96 -0
- package/native/third_party/JoltPhysics/Jolt/Core/ByteBuffer.h +74 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Color.cpp +38 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Color.h +98 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Core.h +652 -0
- package/native/third_party/JoltPhysics/Jolt/Core/FPControlWord.h +143 -0
- package/native/third_party/JoltPhysics/Jolt/Core/FPException.h +96 -0
- package/native/third_party/JoltPhysics/Jolt/Core/FPFlushDenormals.h +43 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Factory.cpp +92 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Factory.h +54 -0
- package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.h +122 -0
- package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.inl +215 -0
- package/native/third_party/JoltPhysics/Jolt/Core/HashCombine.h +234 -0
- package/native/third_party/JoltPhysics/Jolt/Core/HashTable.h +876 -0
- package/native/third_party/JoltPhysics/Jolt/Core/InsertionSort.h +58 -0
- package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.cpp +27 -0
- package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.h +38 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.h +311 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.inl +56 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.cpp +65 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.h +62 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.cpp +364 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.h +101 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.cpp +230 -0
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.h +85 -0
- package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.cpp +51 -0
- package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.h +67 -0
- package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.h +182 -0
- package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.inl +351 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Memory.cpp +85 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Memory.h +85 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Mutex.h +223 -0
- package/native/third_party/JoltPhysics/Jolt/Core/MutexArray.h +98 -0
- package/native/third_party/JoltPhysics/Jolt/Core/NonCopyable.h +18 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Profiler.cpp +677 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Profiler.h +301 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Profiler.inl +90 -0
- package/native/third_party/JoltPhysics/Jolt/Core/QuickSort.h +137 -0
- package/native/third_party/JoltPhysics/Jolt/Core/RTTI.cpp +149 -0
- package/native/third_party/JoltPhysics/Jolt/Core/RTTI.h +436 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Reference.h +244 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Result.h +174 -0
- package/native/third_party/JoltPhysics/Jolt/Core/STLAlignedAllocator.h +72 -0
- package/native/third_party/JoltPhysics/Jolt/Core/STLAllocator.h +127 -0
- package/native/third_party/JoltPhysics/Jolt/Core/STLLocalAllocator.h +170 -0
- package/native/third_party/JoltPhysics/Jolt/Core/STLTempAllocator.h +80 -0
- package/native/third_party/JoltPhysics/Jolt/Core/ScopeExit.h +49 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.cpp +135 -0
- package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.h +68 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StaticArray.h +329 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StreamIn.h +120 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StreamOut.h +97 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StreamUtils.h +168 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StreamWrapper.h +53 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StridedPtr.h +63 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StringTools.cpp +101 -0
- package/native/third_party/JoltPhysics/Jolt/Core/StringTools.h +38 -0
- package/native/third_party/JoltPhysics/Jolt/Core/TempAllocator.h +209 -0
- package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.cpp +37 -0
- package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.h +58 -0
- package/native/third_party/JoltPhysics/Jolt/Core/UnorderedMap.h +80 -0
- package/native/third_party/JoltPhysics/Jolt/Core/UnorderedSet.h +32 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/AABox.h +313 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/AABox4.h +224 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ClipPoly.h +200 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ClosestPoint.h +498 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.cpp +1467 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.h +276 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.cpp +335 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.h +105 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexSupport.h +188 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/EPAConvexHullBuilder.h +845 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/EPAPenetrationDepth.h +557 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/Ellipse.h +77 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/GJKClosestPoint.h +945 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/IndexedTriangle.h +130 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.cpp +222 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.h +19 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/MortonCode.h +40 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.cpp +178 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.h +39 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/Plane.h +104 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayAABox.h +241 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayCapsule.h +37 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayCylinder.h +101 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/RaySphere.h +96 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayTriangle.h +158 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/Sphere.h +72 -0
- package/native/third_party/JoltPhysics/Jolt/Geometry/Triangle.h +34 -0
- package/native/third_party/JoltPhysics/Jolt/Jolt.cmake +703 -0
- package/native/third_party/JoltPhysics/Jolt/Jolt.h +16 -0
- package/native/third_party/JoltPhysics/Jolt/Jolt.natvis +116 -0
- package/native/third_party/JoltPhysics/Jolt/Math/BVec16.h +99 -0
- package/native/third_party/JoltPhysics/Jolt/Math/BVec16.inl +177 -0
- package/native/third_party/JoltPhysics/Jolt/Math/DMat44.h +158 -0
- package/native/third_party/JoltPhysics/Jolt/Math/DMat44.inl +310 -0
- package/native/third_party/JoltPhysics/Jolt/Math/DVec3.h +291 -0
- package/native/third_party/JoltPhysics/Jolt/Math/DVec3.inl +941 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Double3.h +48 -0
- package/native/third_party/JoltPhysics/Jolt/Math/DynMatrix.h +31 -0
- package/native/third_party/JoltPhysics/Jolt/Math/EigenValueSymmetric.h +177 -0
- package/native/third_party/JoltPhysics/Jolt/Math/FindRoot.h +42 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Float2.h +36 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Float3.h +50 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Float4.h +44 -0
- package/native/third_party/JoltPhysics/Jolt/Math/GaussianElimination.h +102 -0
- package/native/third_party/JoltPhysics/Jolt/Math/HalfFloat.h +208 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Mat44.h +243 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Mat44.inl +952 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Math.h +208 -0
- package/native/third_party/JoltPhysics/Jolt/Math/MathTypes.h +32 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Matrix.h +259 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Quat.h +268 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Quat.inl +406 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Real.h +44 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Swizzle.h +19 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Trigonometry.h +79 -0
- package/native/third_party/JoltPhysics/Jolt/Math/UVec4.h +232 -0
- package/native/third_party/JoltPhysics/Jolt/Math/UVec4.inl +636 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Vec3.cpp +71 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Vec3.h +308 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Vec3.inl +942 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Vec4.h +320 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Vec4.inl +1152 -0
- package/native/third_party/JoltPhysics/Jolt/Math/Vector.h +211 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/GetPrimitiveTypeOfType.h +54 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.cpp +38 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.h +337 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.cpp +252 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.h +57 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.cpp +165 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.h +57 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.cpp +635 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.h +148 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.cpp +166 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.h +101 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.cpp +418 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.h +55 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.cpp +255 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.h +62 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTypes.h +26 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttribute.h +111 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeEnum.h +67 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeTyped.h +60 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.cpp +15 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.h +170 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.cpp +70 -0
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.h +45 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/AllowedDOFs.h +68 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.cpp +426 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.h +452 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.inl +197 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyAccess.h +68 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyActivationListener.h +28 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.cpp +234 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.h +124 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyFilter.h +130 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyID.h +101 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.cpp +1099 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.h +324 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLock.h +111 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockInterface.h +134 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockMulti.h +120 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.cpp +1220 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.h +403 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyPair.h +36 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyType.h +19 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.cpp +185 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.h +58 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.cpp +92 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.h +308 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.inl +178 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionQuality.h +31 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionType.h +17 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.cpp +354 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.h +159 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.cpp +59 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.h +157 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterID.h +98 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.cpp +1933 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.h +752 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/AABoxCast.h +20 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdgeMode.h +17 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdges.h +114 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BackFaceMode.h +16 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.cpp +16 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.h +109 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.cpp +313 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.h +38 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h +148 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceMask.h +92 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceTable.h +64 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp +629 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.h +108 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuery.h +56 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterMask.h +35 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterTable.h +66 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.cpp +1768 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.h +389 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp +107 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.h +46 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastResult.h +37 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.cpp +223 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.h +49 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollectFacesMode.h +16 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp +155 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.h +56 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollidePointResult.h +25 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShape.h +106 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShapeVsShapePerLeaf.h +94 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVertexIterator.h +110 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVerticesVsTriangles.h +102 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp +121 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.h +50 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollector.h +109 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollectorImpl.h +219 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.cpp +107 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.h +97 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.cpp +35 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.h +97 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ContactListener.h +143 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.cpp +213 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.h +48 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.cpp +32 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.h +46 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.cpp +38 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.h +130 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/InternalEdgeRemovingCollector.h +279 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.cpp +271 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h +44 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.cpp +448 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.h +77 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.cpp +62 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.h +110 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayer.h +111 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterMask.h +52 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterTable.h +78 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.cpp +35 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.h +57 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.cpp +38 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.h +37 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/RayCast.h +87 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.cpp +318 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.h +115 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.cpp +438 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.h +129 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.cpp +433 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.h +354 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShapeVisitors.h +461 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.cpp +1311 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.h +202 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.cpp +566 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.h +150 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.cpp +418 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.h +126 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.cpp +87 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.h +80 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.cpp +64 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.h +75 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/GetTrianglesContext.h +248 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.cpp +2754 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.h +380 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.cpp +1305 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.h +228 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.cpp +596 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.h +176 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.cpp +217 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h +140 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.cpp +541 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.h +147 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PolyhedronSubmergedVolumeCalculator.h +319 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.cpp +333 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h +161 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaleHelpers.h +83 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.cpp +238 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.h +145 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.cpp +325 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.h +466 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.cpp +347 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.h +125 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp +674 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.h +139 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeID.h +138 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeIDPair.h +65 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp +453 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.gliffy +1 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.h +135 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp +691 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.h +132 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.cpp +430 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.h +143 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeCast.h +173 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeFilter.h +73 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilter.h +40 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilterWrapper.h +58 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SortReverseAndStore.h +48 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.cpp +180 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.h +194 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/CalculateSolverSteps.h +70 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.cpp +246 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.h +133 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.cpp +73 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.h +243 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.cpp +289 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.h +100 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h +257 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h +682 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/DualAxisConstraintPart.h +276 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h +195 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/HingeRotationConstraintPart.h +222 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h +246 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/PointConstraintPart.h +239 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RackAndPinionConstraintPart.h +196 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h +283 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationQuatConstraintPart.h +246 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SpringPart.h +169 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h +597 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.cpp +1804 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.h +524 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.cpp +266 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.h +120 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.cpp +215 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.h +96 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.cpp +188 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.h +116 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.cpp +443 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.h +205 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.cpp +43 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.h +66 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.cpp +458 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.h +191 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.cpp +85 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.h +76 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.cpp +308 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.h +54 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.cpp +157 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.h +94 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.cpp +253 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.h +137 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.cpp +189 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.h +118 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.cpp +900 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.h +289 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.cpp +501 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.h +198 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.cpp +35 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.h +70 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.cpp +524 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.h +197 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.cpp +56 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.h +65 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.cpp +17 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.h +159 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/EActivation.h +16 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/EPhysicsUpdateError.h +37 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.cpp +492 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.h +144 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.cpp +582 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.h +187 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsLock.h +169 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.cpp +261 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.h +104 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSettings.h +125 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsStepListener.h +37 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.cpp +2915 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.h +391 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.cpp +25 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.h +176 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.cpp +744 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.h +245 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyContactListener.h +55 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.cpp +128 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.h +75 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyManifold.h +74 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp +1501 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.h +333 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.cpp +354 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.h +73 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp +1487 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.h +390 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyUpdateContext.h +63 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyVertex.h +36 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorder.h +136 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.cpp +90 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.h +50 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.cpp +306 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.h +119 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.cpp +547 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.h +169 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.cpp +33 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.h +33 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.cpp +376 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.h +146 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.cpp +703 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.h +252 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.cpp +17 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.h +87 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.cpp +81 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.h +39 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.cpp +122 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.h +93 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.cpp +52 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.h +56 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.cpp +159 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.h +87 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.cpp +93 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.h +148 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.cpp +866 -0
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.h +205 -0
- package/native/third_party/JoltPhysics/Jolt/RegisterTypes.cpp +204 -0
- package/native/third_party/JoltPhysics/Jolt/RegisterTypes.h +29 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.cpp +1107 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.h +383 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.cpp +168 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.h +48 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.cpp +158 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.h +130 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.cpp +80 -0
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.h +88 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.cpp +165 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.h +91 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.cpp +82 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.h +72 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.cpp +237 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.h +145 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.cpp +87 -0
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.h +82 -0
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.cpp +73 -0
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.h +84 -0
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.cpp +139 -0
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.h +52 -0
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.cpp +43 -0
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.h +28 -0
- package/native/third_party/JoltPhysics/LICENSE +7 -0
- package/native/third_party/JoltPhysics/README.md +173 -0
- package/native/third_party/bloom_jolt/CMakeLists.txt +78 -0
- package/native/third_party/bloom_jolt/include/bloom_jolt.h +519 -0
- package/native/third_party/bloom_jolt/src/bloom_jolt.cpp +1780 -0
- package/native/tvos/Cargo.lock +1692 -0
- package/native/tvos/Cargo.toml +22 -0
- package/native/tvos/src/lib.rs +3179 -0
- package/native/watchos/Cargo.lock +16 -0
- package/native/watchos/Cargo.toml +19 -0
- package/native/watchos/shaders/bloom_postfx.metal +99 -0
- package/native/watchos/src/BloomWatchApp.swift +1236 -0
- package/native/watchos/src/BloomWatchAudio.swift +179 -0
- package/native/watchos/src/audio.rs +55 -0
- package/native/watchos/src/draw_list.rs +223 -0
- package/native/watchos/src/ffi_stubs.rs +454 -0
- package/native/watchos/src/lib.rs +1013 -0
- package/native/watchos/src/models.rs +746 -0
- package/native/watchos/src/postfx.rs +91 -0
- package/native/watchos/src/scene.rs +534 -0
- package/native/watchos/src/textures.rs +184 -0
- package/native/web/Cargo.lock +1656 -0
- package/native/web/Cargo.toml +38 -0
- package/native/web/bloom_glue.js +218 -0
- package/native/web/build.sh +101 -0
- package/native/web/index.html +390 -0
- package/native/web/jolt_bridge.js +1311 -0
- package/native/web/src/lib.rs +2739 -0
- package/native/windows/Cargo.lock +1813 -0
- package/native/windows/Cargo.toml +31 -0
- package/native/windows/src/lib.rs +1933 -0
- package/package.json +558 -0
- package/src/audio/index.ts +151 -0
- package/src/core/colors.ts +56 -0
- package/src/core/index.ts +903 -0
- package/src/core/keys.ts +63 -0
- package/src/core/types.ts +102 -0
- package/src/index.ts +158 -0
- package/src/math/index.ts +502 -0
- package/src/mobile/index.ts +294 -0
- package/src/models/index.ts +859 -0
- package/src/physics/index.ts +1072 -0
- package/src/scene/index.ts +570 -0
- package/src/shapes/index.ts +120 -0
- package/src/text/index.ts +48 -0
- package/src/textures/index.ts +173 -0
- package/src/world/index.ts +22 -0
- package/src/world/loader.ts +385 -0
- package/src/world/prefab.ts +205 -0
- package/src/world/saver.ts +61 -0
- package/src/world/terrain.ts +254 -0
- package/src/world/types.ts +136 -0
- package/src/world/validate.ts +202 -0
- package/src/world/version.ts +47 -0
|
@@ -0,0 +1,1311 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// jolt_bridge.js — web-side implementation of the bloom_physics_* FFI surface.
|
|
3
|
+
//
|
|
4
|
+
// The native Rust/Jolt backend is replaced on the web target by JoltPhysics.js
|
|
5
|
+
// (https://github.com/jrouwe/JoltPhysics.js). This module exports one function
|
|
6
|
+
// per `bloom_physics_*` entry so `bloom_web.wasm` can forward calls verbatim.
|
|
7
|
+
//
|
|
8
|
+
// Lifecycle:
|
|
9
|
+
// 1. Before Perry WASM boots, the host page awaits `initJolt()` below, which
|
|
10
|
+
// loads the Jolt WASM module and wires allocators + types.
|
|
11
|
+
// 2. Once ready, all bridge calls operate on live Jolt objects.
|
|
12
|
+
// 3. If a bridge call arrives before init (shouldn't happen if the host page
|
|
13
|
+
// sequences correctly), the bridge logs once and returns 0 / a no-op.
|
|
14
|
+
//
|
|
15
|
+
// Handle model mirrors the native Rust side (HandleRegistry<f64>):
|
|
16
|
+
// - 1-based numeric handles ("slots") issued sequentially per resource type.
|
|
17
|
+
// - 0 == INVALID.
|
|
18
|
+
// - Separate maps for worlds / shapes / bodies / constraints.
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
let JoltModule = null;
|
|
22
|
+
|
|
23
|
+
const state = {
|
|
24
|
+
worlds: new Map(), // handle → { system, bodyInterface, temp, jobs, contacts, rayHits, overlaps }
|
|
25
|
+
shapes: new Map(), // handle → Jolt Shape
|
|
26
|
+
bodies: new Map(), // handle → { world: number, bodyId: number }
|
|
27
|
+
constraints: new Map(), // handle → { world: number, constraint: Jolt.Constraint }
|
|
28
|
+
characters: new Map(), // handle → { world: number, character: Jolt.CharacterVirtual, layer: number }
|
|
29
|
+
nextWorld: 1, nextShape: 1, nextBody: 1, nextConstraint: 1, nextCharacter: 1,
|
|
30
|
+
// Most-recent query results (drained on read)
|
|
31
|
+
rayHits: [], // array of { body, point:[x,y,z], normal:[x,y,z], fraction, subShapeId }
|
|
32
|
+
overlapBodies: [], // array of body handles
|
|
33
|
+
contacts: [], // array of contact objects
|
|
34
|
+
// Scratch streams for variable-size shape inputs.
|
|
35
|
+
scratchF32: [],
|
|
36
|
+
scratchU32: [],
|
|
37
|
+
// Compound-shape builder state (cleared by compoundBegin).
|
|
38
|
+
compoundChildren: [],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function warnUninit(fnName) {
|
|
42
|
+
if (!JoltModule) {
|
|
43
|
+
if (!warnUninit._warned) {
|
|
44
|
+
console.warn('[jolt_bridge] Jolt not initialised; bloom_physics_* calls are no-ops until initJolt() resolves');
|
|
45
|
+
warnUninit._warned = true;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Initialisation — must be awaited before Perry calls any bloom_physics_* fn.
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {Object} joltFactory - the default export of jolt-physics (a function
|
|
58
|
+
* returning a Promise<Jolt>). Accepting it via parameter lets the host page
|
|
59
|
+
* pick how to load it (CDN script tag, bundler, etc.).
|
|
60
|
+
*/
|
|
61
|
+
export async function initJolt(joltFactory) {
|
|
62
|
+
if (JoltModule) return JoltModule;
|
|
63
|
+
if (typeof joltFactory !== 'function') {
|
|
64
|
+
throw new Error('initJolt requires a joltFactory function (Jolt.default or window.Jolt)');
|
|
65
|
+
}
|
|
66
|
+
JoltModule = await joltFactory();
|
|
67
|
+
return JoltModule;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function isJoltReady() { return !!JoltModule; }
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Helpers
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
function vec3(x, y, z) { return new JoltModule.Vec3(x, y, z); }
|
|
77
|
+
function rvec3(x, y, z) { return new JoltModule.RVec3(x, y, z); }
|
|
78
|
+
function quat(x, y, z, w) { return new JoltModule.Quat(x, y, z, w); }
|
|
79
|
+
|
|
80
|
+
const OBJECT_LAYER_NON_MOVING = 0;
|
|
81
|
+
const OBJECT_LAYER_MOVING = 1;
|
|
82
|
+
const BP_LAYER_NON_MOVING = 0;
|
|
83
|
+
const BP_LAYER_MOVING = 1;
|
|
84
|
+
|
|
85
|
+
function buildSettings(J) {
|
|
86
|
+
// Object-layer pair filter — 16 layers, mirrors the native C++ shim.
|
|
87
|
+
const pairFilter = new J.ObjectLayerPairFilterTable(16);
|
|
88
|
+
// Default: all layers collide except non-moving↔non-moving.
|
|
89
|
+
for (let a = 0; a < 16; a++) {
|
|
90
|
+
for (let b = 0; b < 16; b++) {
|
|
91
|
+
if (a === OBJECT_LAYER_NON_MOVING && b === OBJECT_LAYER_NON_MOVING) continue;
|
|
92
|
+
pairFilter.EnableCollision(a, b);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Broadphase-layer interface — 2 broadphase buckets.
|
|
96
|
+
const bpInterface = new J.BroadPhaseLayerInterfaceTable(16, 2);
|
|
97
|
+
bpInterface.MapObjectToBroadPhaseLayer(OBJECT_LAYER_NON_MOVING, new J.BroadPhaseLayer(BP_LAYER_NON_MOVING));
|
|
98
|
+
for (let i = 1; i < 16; i++) {
|
|
99
|
+
bpInterface.MapObjectToBroadPhaseLayer(i, new J.BroadPhaseLayer(BP_LAYER_MOVING));
|
|
100
|
+
}
|
|
101
|
+
const objectVsBp = new J.ObjectVsBroadPhaseLayerFilterTable(bpInterface, 2, pairFilter, 16);
|
|
102
|
+
|
|
103
|
+
const settings = new J.JoltSettings();
|
|
104
|
+
settings.mObjectLayerPairFilter = pairFilter;
|
|
105
|
+
settings.mBroadPhaseLayerInterface = bpInterface;
|
|
106
|
+
settings.mObjectVsBroadPhaseLayerFilter= objectVsBp;
|
|
107
|
+
settings.mMaxBodies = 65536;
|
|
108
|
+
settings.mMaxBodyPairs = 65536;
|
|
109
|
+
settings.mMaxContactConstraints = 10240;
|
|
110
|
+
return settings;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function motionTypeFrom(t) {
|
|
114
|
+
const J = JoltModule;
|
|
115
|
+
switch (t | 0) {
|
|
116
|
+
case 0: return J.EMotionType_Static;
|
|
117
|
+
case 1: return J.EMotionType_Kinematic;
|
|
118
|
+
default: return J.EMotionType_Dynamic;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function activationFrom(flag) {
|
|
123
|
+
const J = JoltModule;
|
|
124
|
+
return flag !== 0 ? J.EActivation_Activate : J.EActivation_DontActivate;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
// World
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
export function createWorld(gx, gy, gz, maxBodies, numThreads) {
|
|
132
|
+
if (warnUninit('createWorld')) return 0;
|
|
133
|
+
const J = JoltModule;
|
|
134
|
+
const settings = buildSettings(J);
|
|
135
|
+
if ((maxBodies | 0) > 0) settings.mMaxBodies = maxBodies | 0;
|
|
136
|
+
const jolt = new J.JoltInterface(settings);
|
|
137
|
+
const system = jolt.GetPhysicsSystem();
|
|
138
|
+
system.SetGravity(vec3(gx, gy, gz));
|
|
139
|
+
|
|
140
|
+
const handle = state.nextWorld++;
|
|
141
|
+
|
|
142
|
+
// Contact listener — bridges Jolt contact callbacks into the state.contacts queue.
|
|
143
|
+
// JoltPhysics.js provides ContactListenerJS with virtual methods exposed as JS fields.
|
|
144
|
+
const listener = new J.ContactListenerJS();
|
|
145
|
+
const pushContact = (event, body1, body2, manifold, settings_out) => {
|
|
146
|
+
const bodyIdA = body1.GetID();
|
|
147
|
+
const bodyIdB = body2.GetID();
|
|
148
|
+
const bodyAh = bodyIdToHandle(handle, bodyIdA);
|
|
149
|
+
const bodyBh = bodyIdToHandle(handle, bodyIdB);
|
|
150
|
+
let pointA = [0, 0, 0], pointB = [0, 0, 0], normal = [0, 1, 0], depth = 0;
|
|
151
|
+
if (manifold) {
|
|
152
|
+
const base = manifold.mBaseOffset;
|
|
153
|
+
const n = manifold.mWorldSpaceNormal;
|
|
154
|
+
normal = [n.GetX(), n.GetY(), n.GetZ()];
|
|
155
|
+
depth = manifold.mPenetrationDepth;
|
|
156
|
+
if (manifold.mRelativeContactPointsOn1.size() > 0) {
|
|
157
|
+
const p = manifold.mRelativeContactPointsOn1.at(0);
|
|
158
|
+
pointA = [base.GetX() + p.GetX(), base.GetY() + p.GetY(), base.GetZ() + p.GetZ()];
|
|
159
|
+
}
|
|
160
|
+
if (manifold.mRelativeContactPointsOn2.size() > 0) {
|
|
161
|
+
const p = manifold.mRelativeContactPointsOn2.at(0);
|
|
162
|
+
pointB = [base.GetX() + p.GetX(), base.GetY() + p.GetY(), base.GetZ() + p.GetZ()];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
let friction = 0, restitution = 0;
|
|
166
|
+
if (settings_out) {
|
|
167
|
+
friction = settings_out.mCombinedFriction ?? 0;
|
|
168
|
+
restitution = settings_out.mCombinedRestitution ?? 0;
|
|
169
|
+
}
|
|
170
|
+
state.contacts.push({
|
|
171
|
+
event, bodyA: bodyAh, bodyB: bodyBh,
|
|
172
|
+
pointA, pointB, normal,
|
|
173
|
+
penetrationDepth: depth,
|
|
174
|
+
combinedFriction: friction,
|
|
175
|
+
combinedRestitution: restitution,
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
listener.OnContactValidate = () => J.ValidateResult_AcceptAllContactsForThisBodyPair;
|
|
179
|
+
listener.OnContactAdded = (b1, b2, m, s) => pushContact(0, b1, b2, m, s);
|
|
180
|
+
listener.OnContactPersisted = (b1, b2, m, s) => pushContact(1, b1, b2, m, s);
|
|
181
|
+
listener.OnContactRemoved = (pair) => {
|
|
182
|
+
const b1 = pair.GetBody1ID();
|
|
183
|
+
const b2 = pair.GetBody2ID();
|
|
184
|
+
state.contacts.push({
|
|
185
|
+
event: 2,
|
|
186
|
+
bodyA: bodyIdToHandle(handle, b1),
|
|
187
|
+
bodyB: bodyIdToHandle(handle, b2),
|
|
188
|
+
pointA: [0, 0, 0], pointB: [0, 0, 0], normal: [0, 1, 0],
|
|
189
|
+
penetrationDepth: 0, combinedFriction: 0, combinedRestitution: 0,
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
system.SetContactListener(listener);
|
|
193
|
+
|
|
194
|
+
state.worlds.set(handle, {
|
|
195
|
+
jolt,
|
|
196
|
+
system,
|
|
197
|
+
bodyInterface: system.GetBodyInterface(),
|
|
198
|
+
settings,
|
|
199
|
+
listener, // hold ref so GC doesn't collect
|
|
200
|
+
});
|
|
201
|
+
return handle;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function bodyIdToHandle(worldH, bodyId) {
|
|
205
|
+
for (const [h, b] of state.bodies) {
|
|
206
|
+
if (b.world === worldH && b.bodyId.GetIndexAndSequenceNumber() === bodyId.GetIndexAndSequenceNumber()) {
|
|
207
|
+
return h;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function destroyWorld(h) {
|
|
214
|
+
const w = state.worlds.get(h);
|
|
215
|
+
if (!w) return;
|
|
216
|
+
// Remove any bodies/constraints tied to this world first.
|
|
217
|
+
for (const [bh, b] of state.bodies) {
|
|
218
|
+
if (b.world === h) { destroyBodyInternal(w, b); state.bodies.delete(bh); }
|
|
219
|
+
}
|
|
220
|
+
for (const [ch, c] of state.constraints) {
|
|
221
|
+
if (c.world === h) { w.system.RemoveConstraint(c.constraint); state.constraints.delete(ch); }
|
|
222
|
+
}
|
|
223
|
+
JoltModule.destroy(w.jolt);
|
|
224
|
+
state.worlds.delete(h);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function setGravity(h, gx, gy, gz) {
|
|
228
|
+
const w = state.worlds.get(h); if (!w) return;
|
|
229
|
+
w.system.SetGravity(vec3(gx, gy, gz));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function getGravity(h, axis) {
|
|
233
|
+
const w = state.worlds.get(h); if (!w) return 0;
|
|
234
|
+
const g = w.system.GetGravity();
|
|
235
|
+
if (axis === 0) return g.GetX();
|
|
236
|
+
if (axis === 1) return g.GetY();
|
|
237
|
+
if (axis === 2) return g.GetZ();
|
|
238
|
+
return 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function optimizeBroadphase(h) {
|
|
242
|
+
const w = state.worlds.get(h); if (!w) return;
|
|
243
|
+
w.system.OptimizeBroadPhase();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function step(h, dt, collisionSteps) {
|
|
247
|
+
const w = state.worlds.get(h); if (!w) return;
|
|
248
|
+
const steps = Math.max(1, collisionSteps | 0);
|
|
249
|
+
w.jolt.Step(dt, steps);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function setLayerCollides(h, a, b, collides) {
|
|
253
|
+
const w = state.worlds.get(h); if (!w) return;
|
|
254
|
+
// JoltSettings filter was already baked; runtime mutation isn't supported via
|
|
255
|
+
// the JS bindings. This is a no-op for now; layer setup must happen before
|
|
256
|
+
// createWorld in a future API tweak.
|
|
257
|
+
void a; void b; void collides;
|
|
258
|
+
}
|
|
259
|
+
export function getLayerCollides(h, a, b) {
|
|
260
|
+
void h; void a; void b;
|
|
261
|
+
return 1; // default permissive
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function bodyCount(h) { const w = state.worlds.get(h); return w ? w.system.GetNumBodies() : 0; }
|
|
265
|
+
export function activeBodyCount(h) { const w = state.worlds.get(h); return w ? w.system.GetNumActiveBodies() : 0; }
|
|
266
|
+
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
// Shapes
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
|
|
271
|
+
function registerShape(shape) {
|
|
272
|
+
if (!shape) return 0;
|
|
273
|
+
const h = state.nextShape++;
|
|
274
|
+
state.shapes.set(h, shape);
|
|
275
|
+
return h;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function shapeBox(hx, hy, hz, convexRadius) {
|
|
279
|
+
if (warnUninit('shapeBox')) return 0;
|
|
280
|
+
const settings = new JoltModule.BoxShapeSettings(vec3(hx, hy, hz), convexRadius);
|
|
281
|
+
const result = settings.Create();
|
|
282
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
283
|
+
}
|
|
284
|
+
export function shapeSphere(r) {
|
|
285
|
+
if (warnUninit('shapeSphere')) return 0;
|
|
286
|
+
const settings = new JoltModule.SphereShapeSettings(r);
|
|
287
|
+
const result = settings.Create();
|
|
288
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
289
|
+
}
|
|
290
|
+
export function shapeCapsule(h, r) {
|
|
291
|
+
if (warnUninit('shapeCapsule')) return 0;
|
|
292
|
+
const settings = new JoltModule.CapsuleShapeSettings(h, r);
|
|
293
|
+
const result = settings.Create();
|
|
294
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
295
|
+
}
|
|
296
|
+
export function shapeCylinder(h, r, cr) {
|
|
297
|
+
if (warnUninit('shapeCylinder')) return 0;
|
|
298
|
+
const settings = new JoltModule.CylinderShapeSettings(h, r, cr);
|
|
299
|
+
const result = settings.Create();
|
|
300
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
301
|
+
}
|
|
302
|
+
export function shapeScaled(base, sx, sy, sz) {
|
|
303
|
+
if (warnUninit('shapeScaled')) return 0;
|
|
304
|
+
const inner = state.shapes.get(base); if (!inner) return 0;
|
|
305
|
+
const settings = new JoltModule.ScaledShapeSettings(inner, vec3(sx, sy, sz));
|
|
306
|
+
const result = settings.Create();
|
|
307
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
308
|
+
}
|
|
309
|
+
export function shapeOffsetCom(base, ox, oy, oz) {
|
|
310
|
+
if (warnUninit('shapeOffsetCom')) return 0;
|
|
311
|
+
const inner = state.shapes.get(base); if (!inner) return 0;
|
|
312
|
+
const settings = new JoltModule.OffsetCenterOfMassShapeSettings(vec3(ox, oy, oz), inner);
|
|
313
|
+
const result = settings.Create();
|
|
314
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
315
|
+
}
|
|
316
|
+
export function shapeRelease(h) {
|
|
317
|
+
const s = state.shapes.get(h); if (!s) return;
|
|
318
|
+
state.shapes.delete(h);
|
|
319
|
+
// JoltPhysics.js shapes are refcounted internally; letting GC handle it is fine.
|
|
320
|
+
}
|
|
321
|
+
export function shapeBounds(h, axis) {
|
|
322
|
+
const s = state.shapes.get(h); if (!s) return 0;
|
|
323
|
+
const box = s.GetLocalBounds();
|
|
324
|
+
switch (axis | 0) {
|
|
325
|
+
case 0: return box.mMin.GetX();
|
|
326
|
+
case 1: return box.mMin.GetY();
|
|
327
|
+
case 2: return box.mMin.GetZ();
|
|
328
|
+
case 3: return box.mMax.GetX();
|
|
329
|
+
case 4: return box.mMax.GetY();
|
|
330
|
+
case 5: return box.mMax.GetZ();
|
|
331
|
+
default: return 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
export function shapeVolume(h) {
|
|
335
|
+
const s = state.shapes.get(h); if (!s) return 0;
|
|
336
|
+
return s.GetVolume ? s.GetVolume() : 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ---------------------------------------------------------------------------
|
|
340
|
+
// Bodies
|
|
341
|
+
// ---------------------------------------------------------------------------
|
|
342
|
+
|
|
343
|
+
function destroyBodyInternal(w, b) {
|
|
344
|
+
if (w.bodyInterface.IsAdded(b.bodyId)) w.bodyInterface.RemoveBody(b.bodyId);
|
|
345
|
+
w.bodyInterface.DestroyBody(b.bodyId);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function resolveBody(h) { return state.bodies.get(h); }
|
|
349
|
+
function resolveBodyInterface(b) {
|
|
350
|
+
const w = state.worlds.get(b.world); return w ? w.bodyInterface : null;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function bodyCreate(worldH, shapeH, motionType, px, py, pz, rx, ry, rz, rw, layer) {
|
|
354
|
+
if (warnUninit('bodyCreate')) return 0;
|
|
355
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
356
|
+
const s = state.shapes.get(shapeH); if (!s) return 0;
|
|
357
|
+
const J = JoltModule;
|
|
358
|
+
const settings = new J.BodyCreationSettings(
|
|
359
|
+
s,
|
|
360
|
+
rvec3(px, py, pz),
|
|
361
|
+
quat(rx, ry, rz, rw),
|
|
362
|
+
motionTypeFrom(motionType),
|
|
363
|
+
(layer | 0),
|
|
364
|
+
);
|
|
365
|
+
const bodyId = w.bodyInterface.CreateAndAddBody(settings, J.EActivation_Activate);
|
|
366
|
+
J.destroy(settings);
|
|
367
|
+
const h = state.nextBody++;
|
|
368
|
+
state.bodies.set(h, { world: worldH, bodyId });
|
|
369
|
+
return h;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export function bodyDestroy(h) {
|
|
373
|
+
const b = resolveBody(h); if (!b) return;
|
|
374
|
+
const w = state.worlds.get(b.world); if (w) destroyBodyInternal(w, b);
|
|
375
|
+
state.bodies.delete(h);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export function bodyActivate(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.ActivateBody(b.bodyId); }
|
|
379
|
+
export function bodyDeactivate(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.DeactivateBody(b.bodyId); }
|
|
380
|
+
export function bodyIsActive(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); return bi && bi.IsActive(b.bodyId) ? 1 : 0; }
|
|
381
|
+
export function bodyIsValid(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); return bi && bi.IsAdded(b.bodyId) ? 1 : 0; }
|
|
382
|
+
|
|
383
|
+
export function bodyGetPosition(h, axis) {
|
|
384
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return 0;
|
|
385
|
+
const p = bi.GetPosition(b.bodyId);
|
|
386
|
+
if (axis === 0) return p.GetX(); if (axis === 1) return p.GetY(); if (axis === 2) return p.GetZ();
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
export function bodyGetRotation(h, axis) {
|
|
390
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return 0;
|
|
391
|
+
const q = bi.GetRotation(b.bodyId);
|
|
392
|
+
if (axis === 0) return q.GetX(); if (axis === 1) return q.GetY();
|
|
393
|
+
if (axis === 2) return q.GetZ(); if (axis === 3) return q.GetW();
|
|
394
|
+
return 0;
|
|
395
|
+
}
|
|
396
|
+
export function bodySetPosition(h, x, y, z, activate) {
|
|
397
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
398
|
+
bi.SetPosition(b.bodyId, rvec3(x, y, z), activationFrom(activate));
|
|
399
|
+
}
|
|
400
|
+
export function bodySetRotation(h, x, y, z, w, activate) {
|
|
401
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
402
|
+
bi.SetRotation(b.bodyId, quat(x, y, z, w), activationFrom(activate));
|
|
403
|
+
}
|
|
404
|
+
export function bodySetTransform(h, px, py, pz, rx, ry, rz, rw, activate) {
|
|
405
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
406
|
+
bi.SetPositionAndRotation(b.bodyId, rvec3(px, py, pz), quat(rx, ry, rz, rw), activationFrom(activate));
|
|
407
|
+
}
|
|
408
|
+
export function bodyMoveKinematic(h, px, py, pz, rx, ry, rz, rw, dt) {
|
|
409
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
410
|
+
bi.MoveKinematic(b.bodyId, rvec3(px, py, pz), quat(rx, ry, rz, rw), dt);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export function bodyGetLinearVelocity(h, axis) {
|
|
414
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return 0;
|
|
415
|
+
const v = bi.GetLinearVelocity(b.bodyId);
|
|
416
|
+
if (axis === 0) return v.GetX(); if (axis === 1) return v.GetY(); if (axis === 2) return v.GetZ();
|
|
417
|
+
return 0;
|
|
418
|
+
}
|
|
419
|
+
export function bodyGetAngularVelocity(h, axis) {
|
|
420
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return 0;
|
|
421
|
+
const v = bi.GetAngularVelocity(b.bodyId);
|
|
422
|
+
if (axis === 0) return v.GetX(); if (axis === 1) return v.GetY(); if (axis === 2) return v.GetZ();
|
|
423
|
+
return 0;
|
|
424
|
+
}
|
|
425
|
+
export function bodyGetPointVelocity(h, px, py, pz, axis) {
|
|
426
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return 0;
|
|
427
|
+
const v = bi.GetPointVelocity(b.bodyId, rvec3(px, py, pz));
|
|
428
|
+
if (axis === 0) return v.GetX(); if (axis === 1) return v.GetY(); if (axis === 2) return v.GetZ();
|
|
429
|
+
return 0;
|
|
430
|
+
}
|
|
431
|
+
export function bodySetLinearVelocity(h, x, y, z) {
|
|
432
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
433
|
+
bi.SetLinearVelocity(b.bodyId, vec3(x, y, z));
|
|
434
|
+
}
|
|
435
|
+
export function bodySetAngularVelocity(h, x, y, z) {
|
|
436
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
437
|
+
bi.SetAngularVelocity(b.bodyId, vec3(x, y, z));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export function bodyAddForce(h, x, y, z) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.AddForce(b.bodyId, vec3(x, y, z)); }
|
|
441
|
+
export function bodyAddImpulse(h, x, y, z) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.AddImpulse(b.bodyId, vec3(x, y, z)); }
|
|
442
|
+
export function bodyAddTorque(h, x, y, z) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.AddTorque(b.bodyId, vec3(x, y, z)); }
|
|
443
|
+
export function bodyAddAngularImpulse(h, x, y, z) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.AddAngularImpulse(b.bodyId, vec3(x, y, z)); }
|
|
444
|
+
export function bodyAddForceAt(h, fx, fy, fz, px, py, pz) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.AddForceAt ? bi.AddForceAt(b.bodyId, vec3(fx, fy, fz), rvec3(px, py, pz)) : bi.AddForce(b.bodyId, vec3(fx, fy, fz), rvec3(px, py, pz)); }
|
|
445
|
+
export function bodyAddImpulseAt(h, ix, iy, iz, px, py, pz) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.AddImpulseAt ? bi.AddImpulseAt(b.bodyId, vec3(ix, iy, iz), rvec3(px, py, pz)) : bi.AddImpulse(b.bodyId, vec3(ix, iy, iz), rvec3(px, py, pz)); }
|
|
446
|
+
|
|
447
|
+
export function bodySetFriction(h, v) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.SetFriction(b.bodyId, v); }
|
|
448
|
+
export function bodySetRestitution(h, v) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi) bi.SetRestitution(b.bodyId, v); }
|
|
449
|
+
export function bodySetLinearDamping(h, v) {
|
|
450
|
+
const b = resolveBody(h); if (!b) return;
|
|
451
|
+
const w = state.worlds.get(b.world); if (!w) return;
|
|
452
|
+
const J = JoltModule;
|
|
453
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), b.bodyId);
|
|
454
|
+
if (lock.SucceededAndIsInBroadPhase()) {
|
|
455
|
+
const mp = lock.GetBody().GetMotionPropertiesUnchecked();
|
|
456
|
+
if (mp) mp.SetLinearDamping(v);
|
|
457
|
+
}
|
|
458
|
+
lock.ReleaseLock();
|
|
459
|
+
}
|
|
460
|
+
export function bodySetAngularDamping(h, v) {
|
|
461
|
+
const b = resolveBody(h); if (!b) return;
|
|
462
|
+
const w = state.worlds.get(b.world); if (!w) return;
|
|
463
|
+
const J = JoltModule;
|
|
464
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), b.bodyId);
|
|
465
|
+
if (lock.SucceededAndIsInBroadPhase()) {
|
|
466
|
+
const mp = lock.GetBody().GetMotionPropertiesUnchecked();
|
|
467
|
+
if (mp) mp.SetAngularDamping(v);
|
|
468
|
+
}
|
|
469
|
+
lock.ReleaseLock();
|
|
470
|
+
}
|
|
471
|
+
export function bodySetGravityFactor(h, v) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi && bi.SetGravityFactor) bi.SetGravityFactor(b.bodyId, v); }
|
|
472
|
+
export function bodySetCcd(h, enabled) {
|
|
473
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
474
|
+
const J = JoltModule;
|
|
475
|
+
bi.SetMotionQuality(b.bodyId, enabled ? J.EMotionQuality_LinearCast : J.EMotionQuality_Discrete);
|
|
476
|
+
}
|
|
477
|
+
export function bodySetMotionType(h, t, activate) {
|
|
478
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
479
|
+
bi.SetMotionType(b.bodyId, motionTypeFrom(t), activationFrom(activate));
|
|
480
|
+
}
|
|
481
|
+
export function bodySetObjectLayer(h, layer) {
|
|
482
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (bi && bi.SetObjectLayer) bi.SetObjectLayer(b.bodyId, layer | 0);
|
|
483
|
+
}
|
|
484
|
+
export function bodySetIsSensor(h, enabled) {
|
|
485
|
+
const b = resolveBody(h); if (!b) return;
|
|
486
|
+
const w = state.worlds.get(b.world); if (!w) return;
|
|
487
|
+
const J = JoltModule;
|
|
488
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), b.bodyId);
|
|
489
|
+
if (lock.SucceededAndIsInBroadPhase()) lock.GetBody().SetIsSensor(enabled !== 0);
|
|
490
|
+
lock.ReleaseLock();
|
|
491
|
+
}
|
|
492
|
+
export function bodySetAllowSleeping(h, enabled) {
|
|
493
|
+
const b = resolveBody(h); if (!b) return;
|
|
494
|
+
const w = state.worlds.get(b.world); if (!w) return;
|
|
495
|
+
const J = JoltModule;
|
|
496
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), b.bodyId);
|
|
497
|
+
if (lock.SucceededAndIsInBroadPhase()) lock.GetBody().SetAllowSleeping(enabled !== 0);
|
|
498
|
+
lock.ReleaseLock();
|
|
499
|
+
}
|
|
500
|
+
export function bodySetShape(h, shapeH, updateMass, activate) {
|
|
501
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return;
|
|
502
|
+
const s = state.shapes.get(shapeH); if (!s) return;
|
|
503
|
+
bi.SetShape(b.bodyId, s, updateMass !== 0, activationFrom(activate));
|
|
504
|
+
}
|
|
505
|
+
export function bodyLockRotationAxes(h, x, y, z) {
|
|
506
|
+
void h; void x; void y; void z; // stub — requires recreating the body on JS side
|
|
507
|
+
}
|
|
508
|
+
export function bodyLockTranslationAxes(h, x, y, z) {
|
|
509
|
+
void h; void x; void y; void z;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export function bodyGetMass(h) {
|
|
513
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi) return 0;
|
|
514
|
+
const inv = bi.GetInverseMass ? bi.GetInverseMass(b.bodyId) : 0;
|
|
515
|
+
return inv > 0 ? 1 / inv : 0;
|
|
516
|
+
}
|
|
517
|
+
export function bodyGetFriction(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); return bi ? bi.GetFriction(b.bodyId) : 0; }
|
|
518
|
+
export function bodyGetRestitution(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); return bi ? bi.GetRestitution(b.bodyId) : 0; }
|
|
519
|
+
export function bodyGetObjectLayer(h) { const b = resolveBody(h); const bi = b && resolveBodyInterface(b); return bi && bi.GetObjectLayer ? bi.GetObjectLayer(b.bodyId) : 0; }
|
|
520
|
+
export function bodySetUserData(h, lo, hi) {
|
|
521
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi || !bi.SetUserData) return;
|
|
522
|
+
// JS BigInt path: pack lo (uint32) + hi (uint32) into uint64.
|
|
523
|
+
// Most call sites use just `lo`; `hi` stays 0.
|
|
524
|
+
bi.SetUserData(b.bodyId, BigInt(lo >>> 0) | (BigInt(hi >>> 0) << 32n));
|
|
525
|
+
}
|
|
526
|
+
export function bodyGetUserData(h, part) {
|
|
527
|
+
const b = resolveBody(h); const bi = b && resolveBodyInterface(b); if (!bi || !bi.GetUserData) return 0;
|
|
528
|
+
const u = bi.GetUserData(b.bodyId);
|
|
529
|
+
if (typeof u === 'bigint') {
|
|
530
|
+
return part === 1 ? Number(u >> 32n) : Number(u & 0xFFFFFFFFn);
|
|
531
|
+
}
|
|
532
|
+
return Number(u);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// ---------------------------------------------------------------------------
|
|
536
|
+
// Queries (Tier 1 — closest-hit only; all-hits/overlap = stubs for Tier 2)
|
|
537
|
+
// ---------------------------------------------------------------------------
|
|
538
|
+
|
|
539
|
+
export function raycast(worldH, ox, oy, oz, dx, dy, dz, maxDist, layerMask) {
|
|
540
|
+
state.rayHits.length = 0;
|
|
541
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
542
|
+
const J = JoltModule;
|
|
543
|
+
const dir = vec3(dx, dy, dz);
|
|
544
|
+
if (dir.LengthSq() === 0) return 0;
|
|
545
|
+
const scaled = dir.Mul ? dir.Mul(maxDist / Math.sqrt(dir.LengthSq())) : dir;
|
|
546
|
+
const ray = new J.RRayCast(rvec3(ox, oy, oz), scaled);
|
|
547
|
+
const result = new J.RayCastResult();
|
|
548
|
+
const hit = w.system.GetNarrowPhaseQuery().CastRay(ray, result, new J.BroadPhaseLayerFilter(), new J.ObjectLayerFilter(), new J.BodyFilter());
|
|
549
|
+
void layerMask; // layer filtering is handled by ObjectLayerFilter; Tier 2 adds mask support
|
|
550
|
+
if (hit) {
|
|
551
|
+
// Resolve body handle from BodyID.
|
|
552
|
+
const bodyId = result.mBodyID;
|
|
553
|
+
let bodyHandle = 0;
|
|
554
|
+
for (const [h, b] of state.bodies) { if (b.world === worldH && b.bodyId.GetIndexAndSequenceNumber() === bodyId.GetIndexAndSequenceNumber()) { bodyHandle = h; break; } }
|
|
555
|
+
const fraction = result.mFraction;
|
|
556
|
+
state.rayHits.push({
|
|
557
|
+
body: bodyHandle,
|
|
558
|
+
point: [ox + (dx * maxDist) * fraction, oy + (dy * maxDist) * fraction, oz + (dz * maxDist) * fraction],
|
|
559
|
+
normal: [0, 1, 0], // TODO: world-space surface normal — needs a BodyLock
|
|
560
|
+
fraction,
|
|
561
|
+
subShapeId: 0,
|
|
562
|
+
});
|
|
563
|
+
return 1;
|
|
564
|
+
}
|
|
565
|
+
return 0;
|
|
566
|
+
}
|
|
567
|
+
export function raycastAll(worldH, ox, oy, oz, dx, dy, dz, maxDist, layerMask, maxHits) {
|
|
568
|
+
state.rayHits.length = 0;
|
|
569
|
+
void layerMask;
|
|
570
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
571
|
+
const J = JoltModule;
|
|
572
|
+
const dir = vec3(dx, dy, dz);
|
|
573
|
+
if (dir.LengthSq() === 0) return 0;
|
|
574
|
+
const scaled = vec3(dx * maxDist, dy * maxDist, dz * maxDist);
|
|
575
|
+
const ray = new J.RRayCast(rvec3(ox, oy, oz), scaled);
|
|
576
|
+
const settings = new J.RayCastSettings();
|
|
577
|
+
const collector = new J.CastRayAllHitCollisionCollectorJS();
|
|
578
|
+
w.system.GetNarrowPhaseQuery().CastRay(
|
|
579
|
+
ray, settings, collector,
|
|
580
|
+
new J.BroadPhaseLayerFilter(), new J.ObjectLayerFilter(), new J.BodyFilter(), new J.ShapeFilter(),
|
|
581
|
+
);
|
|
582
|
+
collector.Sort();
|
|
583
|
+
const count = Math.min(maxHits | 0, collector.mHits.size());
|
|
584
|
+
for (let i = 0; i < count; i++) {
|
|
585
|
+
const hit = collector.mHits.at(i);
|
|
586
|
+
const frac = hit.mFraction;
|
|
587
|
+
let bodyHandle = 0;
|
|
588
|
+
for (const [h, b] of state.bodies) {
|
|
589
|
+
if (b.world === worldH && b.bodyId.GetIndexAndSequenceNumber() === hit.mBodyID.GetIndexAndSequenceNumber()) {
|
|
590
|
+
bodyHandle = h; break;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
state.rayHits.push({
|
|
594
|
+
body: bodyHandle,
|
|
595
|
+
point: [ox + dx * maxDist * frac, oy + dy * maxDist * frac, oz + dz * maxDist * frac],
|
|
596
|
+
normal: [0, 1, 0], // world-space normal requires a BodyLock; skipped for now
|
|
597
|
+
fraction: frac,
|
|
598
|
+
subShapeId: hit.mSubShapeID2 ? hit.mSubShapeID2.GetValue() : 0,
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
return state.rayHits.length;
|
|
602
|
+
}
|
|
603
|
+
export function rayHitCount() { return state.rayHits.length; }
|
|
604
|
+
export function rayHitBody(i) { return state.rayHits[i|0]?.body ?? 0; }
|
|
605
|
+
export function rayHitAxis(i, f) {
|
|
606
|
+
const h = state.rayHits[i|0]; if (!h) return 0;
|
|
607
|
+
return f < 3 ? h.point[f|0] : h.normal[(f|0)-3];
|
|
608
|
+
}
|
|
609
|
+
export function rayHitFraction(i) { return state.rayHits[i|0]?.fraction ?? 0; }
|
|
610
|
+
export function rayHitSubShape(i) { return state.rayHits[i|0]?.subShapeId ?? 0; }
|
|
611
|
+
|
|
612
|
+
function collectOverlapBodies(w, shapeCollider, maxResults) {
|
|
613
|
+
// JoltPhysics.js exposes broadphase query collectors via *_JS suffixed classes.
|
|
614
|
+
const J = JoltModule;
|
|
615
|
+
const collector = new J.CollideShapeBodyCollectorJS();
|
|
616
|
+
shapeCollider(collector);
|
|
617
|
+
const count = Math.min(maxResults | 0, collector.mHits.size());
|
|
618
|
+
const out = [];
|
|
619
|
+
for (let i = 0; i < count; i++) {
|
|
620
|
+
const bodyId = collector.mHits.at(i);
|
|
621
|
+
for (const [h, b] of state.bodies) {
|
|
622
|
+
if (b.world === w && b.bodyId.GetIndexAndSequenceNumber() === bodyId.GetIndexAndSequenceNumber()) {
|
|
623
|
+
out.push(h); break;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return out;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export function overlapSphere(worldH, cx, cy, cz, r, layerMask, maxResults) {
|
|
631
|
+
state.overlapBodies.length = 0;
|
|
632
|
+
void layerMask;
|
|
633
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
634
|
+
const J = JoltModule;
|
|
635
|
+
state.overlapBodies = collectOverlapBodies(worldH, collector => {
|
|
636
|
+
w.system.GetBroadPhaseQuery().CollideSphere(
|
|
637
|
+
vec3(cx, cy, cz), r, collector,
|
|
638
|
+
new J.BroadPhaseLayerFilter(), new J.ObjectLayerFilter(),
|
|
639
|
+
);
|
|
640
|
+
}, maxResults);
|
|
641
|
+
return state.overlapBodies.length;
|
|
642
|
+
}
|
|
643
|
+
export function overlapPoint(worldH, px, py, pz, layerMask, maxResults) {
|
|
644
|
+
state.overlapBodies.length = 0;
|
|
645
|
+
void layerMask;
|
|
646
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
647
|
+
const J = JoltModule;
|
|
648
|
+
state.overlapBodies = collectOverlapBodies(worldH, collector => {
|
|
649
|
+
w.system.GetBroadPhaseQuery().CollidePoint(
|
|
650
|
+
vec3(px, py, pz), collector,
|
|
651
|
+
new J.BroadPhaseLayerFilter(), new J.ObjectLayerFilter(),
|
|
652
|
+
);
|
|
653
|
+
}, maxResults);
|
|
654
|
+
return state.overlapBodies.length;
|
|
655
|
+
}
|
|
656
|
+
export function overlapBox(worldH, px, py, pz, rx, ry, rz, rw, hx, hy, hz, layerMask, maxResults) {
|
|
657
|
+
state.overlapBodies.length = 0;
|
|
658
|
+
void layerMask;
|
|
659
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
660
|
+
const J = JoltModule;
|
|
661
|
+
// Conservative AABB around the rotated box (matches native C++ shim behavior).
|
|
662
|
+
const q = quat(rx, ry, rz, rw);
|
|
663
|
+
const rotMat = q.GetRotation ? q.GetRotation() : null;
|
|
664
|
+
// Jolt.js may not expose Quat.GetRotation; fall back to axis-aligned extents.
|
|
665
|
+
const ex = Math.abs(hx) + Math.abs(hy) * 0.001 + Math.abs(hz) * 0.001;
|
|
666
|
+
const ey = Math.abs(hy) + Math.abs(hx) * 0.001 + Math.abs(hz) * 0.001;
|
|
667
|
+
const ez = Math.abs(hz) + Math.abs(hx) * 0.001 + Math.abs(hy) * 0.001;
|
|
668
|
+
const box = new J.AABox(vec3(px - ex, py - ey, pz - ez), vec3(px + ex, py + ey, pz + ez));
|
|
669
|
+
state.overlapBodies = collectOverlapBodies(worldH, collector => {
|
|
670
|
+
w.system.GetBroadPhaseQuery().CollideAABox(
|
|
671
|
+
box, collector,
|
|
672
|
+
new J.BroadPhaseLayerFilter(), new J.ObjectLayerFilter(),
|
|
673
|
+
);
|
|
674
|
+
}, maxResults);
|
|
675
|
+
void rotMat;
|
|
676
|
+
return state.overlapBodies.length;
|
|
677
|
+
}
|
|
678
|
+
export function overlapBody(i) { return state.overlapBodies[i|0] ?? 0; }
|
|
679
|
+
|
|
680
|
+
// ---------------------------------------------------------------------------
|
|
681
|
+
// Constraints
|
|
682
|
+
// ---------------------------------------------------------------------------
|
|
683
|
+
|
|
684
|
+
function resolveConstraintBodies(bodyAh, bodyBh) {
|
|
685
|
+
const J = JoltModule;
|
|
686
|
+
const ba = state.bodies.get(bodyAh); if (!ba) return null;
|
|
687
|
+
const w = state.worlds.get(ba.world); if (!w) return null;
|
|
688
|
+
// Retrieve the actual Body refs via the lock interface.
|
|
689
|
+
const lockA = new J.BodyLockRead(w.system.GetBodyLockInterface(), ba.bodyId);
|
|
690
|
+
if (!lockA.SucceededAndIsInBroadPhase()) { lockA.ReleaseLock(); return null; }
|
|
691
|
+
const body1 = lockA.GetBody();
|
|
692
|
+
let body2 = J.Body.prototype.sFixedToWorld ?? null;
|
|
693
|
+
let lockB = null;
|
|
694
|
+
if (bodyBh !== 0) {
|
|
695
|
+
const bb = state.bodies.get(bodyBh); if (!bb) { lockA.ReleaseLock(); return null; }
|
|
696
|
+
lockB = new J.BodyLockRead(w.system.GetBodyLockInterface(), bb.bodyId);
|
|
697
|
+
if (!lockB.SucceededAndIsInBroadPhase()) { lockA.ReleaseLock(); lockB.ReleaseLock(); return null; }
|
|
698
|
+
body2 = lockB.GetBody();
|
|
699
|
+
}
|
|
700
|
+
return {
|
|
701
|
+
w, body1, body2,
|
|
702
|
+
release: () => { lockA.ReleaseLock(); if (lockB) lockB.ReleaseLock(); },
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function registerConstraint(worldId, constraint) {
|
|
707
|
+
state.worlds.get(worldId).system.AddConstraint(constraint);
|
|
708
|
+
const h = state.nextConstraint++;
|
|
709
|
+
state.constraints.set(h, { world: worldId, constraint });
|
|
710
|
+
return h;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export function constraintFixed(bodyA, bodyB, ax, ay, az, bx, by, bz, worldSpace) {
|
|
714
|
+
if (warnUninit('constraintFixed')) return 0;
|
|
715
|
+
const ctx = resolveConstraintBodies(bodyA, bodyB); if (!ctx) return 0;
|
|
716
|
+
const J = JoltModule;
|
|
717
|
+
const settings = new J.FixedConstraintSettings();
|
|
718
|
+
settings.mSpace = worldSpace ? J.EConstraintSpace_WorldSpace : J.EConstraintSpace_LocalToBodyCOM;
|
|
719
|
+
settings.mPoint1 = rvec3(ax, ay, az);
|
|
720
|
+
settings.mPoint2 = rvec3(bx, by, bz);
|
|
721
|
+
settings.mAutoDetectPoint = false;
|
|
722
|
+
const c = settings.Create(ctx.body1, ctx.body2);
|
|
723
|
+
ctx.release();
|
|
724
|
+
return registerConstraint(ctx.w === state.worlds.get(state.bodies.get(bodyA).world) ? state.bodies.get(bodyA).world : 0, c);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
export function constraintPoint(bodyA, bodyB, ax, ay, az, bx, by, bz, worldSpace) {
|
|
728
|
+
if (warnUninit('constraintPoint')) return 0;
|
|
729
|
+
const ctx = resolveConstraintBodies(bodyA, bodyB); if (!ctx) return 0;
|
|
730
|
+
const J = JoltModule;
|
|
731
|
+
const settings = new J.PointConstraintSettings();
|
|
732
|
+
settings.mSpace = worldSpace ? J.EConstraintSpace_WorldSpace : J.EConstraintSpace_LocalToBodyCOM;
|
|
733
|
+
settings.mPoint1 = rvec3(ax, ay, az);
|
|
734
|
+
settings.mPoint2 = rvec3(bx, by, bz);
|
|
735
|
+
const c = settings.Create(ctx.body1, ctx.body2);
|
|
736
|
+
ctx.release();
|
|
737
|
+
return registerConstraint(state.bodies.get(bodyA).world, c);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
export function constraintHinge(bodyA, bodyB, ax, ay, az, bx, by, bz, axX, axY, axZ, lmin, lmax, worldSpace) {
|
|
741
|
+
if (warnUninit('constraintHinge')) return 0;
|
|
742
|
+
const ctx = resolveConstraintBodies(bodyA, bodyB); if (!ctx) return 0;
|
|
743
|
+
const J = JoltModule;
|
|
744
|
+
const settings = new J.HingeConstraintSettings();
|
|
745
|
+
settings.mSpace = worldSpace ? J.EConstraintSpace_WorldSpace : J.EConstraintSpace_LocalToBodyCOM;
|
|
746
|
+
settings.mPoint1 = rvec3(ax, ay, az);
|
|
747
|
+
settings.mPoint2 = rvec3(bx, by, bz);
|
|
748
|
+
const axis = vec3(axX, axY, axZ);
|
|
749
|
+
settings.mHingeAxis1 = axis;
|
|
750
|
+
settings.mHingeAxis2 = axis;
|
|
751
|
+
const perp = axis.GetNormalizedPerpendicular ? axis.GetNormalizedPerpendicular() : vec3(1, 0, 0);
|
|
752
|
+
settings.mNormalAxis1 = perp;
|
|
753
|
+
settings.mNormalAxis2 = perp;
|
|
754
|
+
if (lmin < lmax) { settings.mLimitsMin = lmin; settings.mLimitsMax = lmax; }
|
|
755
|
+
const c = settings.Create(ctx.body1, ctx.body2);
|
|
756
|
+
ctx.release();
|
|
757
|
+
return registerConstraint(state.bodies.get(bodyA).world, c);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export function constraintSlider(bodyA, bodyB, ax, ay, az, bx, by, bz, axX, axY, axZ, lmin, lmax, worldSpace) {
|
|
761
|
+
if (warnUninit('constraintSlider')) return 0;
|
|
762
|
+
const ctx = resolveConstraintBodies(bodyA, bodyB); if (!ctx) return 0;
|
|
763
|
+
const J = JoltModule;
|
|
764
|
+
const settings = new J.SliderConstraintSettings();
|
|
765
|
+
settings.mSpace = worldSpace ? J.EConstraintSpace_WorldSpace : J.EConstraintSpace_LocalToBodyCOM;
|
|
766
|
+
settings.mPoint1 = rvec3(ax, ay, az);
|
|
767
|
+
settings.mPoint2 = rvec3(bx, by, bz);
|
|
768
|
+
// Normalize axis.
|
|
769
|
+
const len = Math.hypot(axX, axY, axZ) || 1;
|
|
770
|
+
const axis = vec3(axX / len, axY / len, axZ / len);
|
|
771
|
+
settings.mSliderAxis1 = axis;
|
|
772
|
+
settings.mSliderAxis2 = axis;
|
|
773
|
+
const perp = axis.GetNormalizedPerpendicular ? axis.GetNormalizedPerpendicular() : vec3(1, 0, 0);
|
|
774
|
+
settings.mNormalAxis1 = perp;
|
|
775
|
+
settings.mNormalAxis2 = perp;
|
|
776
|
+
if (lmin < lmax) { settings.mLimitsMin = lmin; settings.mLimitsMax = lmax; }
|
|
777
|
+
const c = settings.Create(ctx.body1, ctx.body2);
|
|
778
|
+
ctx.release();
|
|
779
|
+
return registerConstraint(state.bodies.get(bodyA).world, c);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
export function constraintDistance(bodyA, bodyB, ax, ay, az, bx, by, bz, minD, maxD, worldSpace) {
|
|
783
|
+
if (warnUninit('constraintDistance')) return 0;
|
|
784
|
+
const ctx = resolveConstraintBodies(bodyA, bodyB); if (!ctx) return 0;
|
|
785
|
+
const J = JoltModule;
|
|
786
|
+
const settings = new J.DistanceConstraintSettings();
|
|
787
|
+
settings.mSpace = worldSpace ? J.EConstraintSpace_WorldSpace : J.EConstraintSpace_LocalToBodyCOM;
|
|
788
|
+
settings.mPoint1 = rvec3(ax, ay, az);
|
|
789
|
+
settings.mPoint2 = rvec3(bx, by, bz);
|
|
790
|
+
settings.mMinDistance = minD;
|
|
791
|
+
settings.mMaxDistance = maxD;
|
|
792
|
+
const c = settings.Create(ctx.body1, ctx.body2);
|
|
793
|
+
ctx.release();
|
|
794
|
+
return registerConstraint(state.bodies.get(bodyA).world, c);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
export function constraintDestroy(h) {
|
|
798
|
+
const c = state.constraints.get(h); if (!c) return;
|
|
799
|
+
const w = state.worlds.get(c.world); if (w) w.system.RemoveConstraint(c.constraint);
|
|
800
|
+
state.constraints.delete(h);
|
|
801
|
+
}
|
|
802
|
+
export function constraintSetEnabled(h, enabled) {
|
|
803
|
+
const c = state.constraints.get(h); if (!c) return;
|
|
804
|
+
if (c.constraint.SetEnabled) c.constraint.SetEnabled(enabled !== 0);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// ---------------------------------------------------------------------------
|
|
808
|
+
// Contact events (Tier 2 — listener wiring not yet ported to JS)
|
|
809
|
+
// ---------------------------------------------------------------------------
|
|
810
|
+
|
|
811
|
+
export function contactCount() { return state.contacts.length; }
|
|
812
|
+
export function contactField(i, field) {
|
|
813
|
+
const c = state.contacts[i|0]; if (!c) return 0;
|
|
814
|
+
switch (field|0) {
|
|
815
|
+
case 0: return c.event;
|
|
816
|
+
case 1: return c.bodyA;
|
|
817
|
+
case 2: return c.bodyB;
|
|
818
|
+
case 3: return c.pointA[0]; case 4: return c.pointA[1]; case 5: return c.pointA[2];
|
|
819
|
+
case 6: return c.pointB[0]; case 7: return c.pointB[1]; case 8: return c.pointB[2];
|
|
820
|
+
case 9: return c.normal[0]; case 10: return c.normal[1]; case 11: return c.normal[2];
|
|
821
|
+
case 12: return c.penetrationDepth;
|
|
822
|
+
case 13: return c.combinedFriction;
|
|
823
|
+
case 14: return c.combinedRestitution;
|
|
824
|
+
default: return 0;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
export function clearContacts(worldH) { void worldH; state.contacts.length = 0; }
|
|
828
|
+
|
|
829
|
+
// ============================================================================
|
|
830
|
+
// Phase 5 additions — complex shapes + character controller
|
|
831
|
+
// ============================================================================
|
|
832
|
+
|
|
833
|
+
// --- Scratch streams ---
|
|
834
|
+
export function scratchReset() { state.scratchF32.length = 0; state.scratchU32.length = 0; }
|
|
835
|
+
export function scratchPushF32(v) { state.scratchF32.push(v); }
|
|
836
|
+
export function scratchPushU32(v) { state.scratchU32.push(v >>> 0); }
|
|
837
|
+
|
|
838
|
+
// --- Complex shape factories ---
|
|
839
|
+
|
|
840
|
+
export function shapeConvexHull(numPoints, convexRadius) {
|
|
841
|
+
if (warnUninit('shapeConvexHull')) return 0;
|
|
842
|
+
const J = JoltModule;
|
|
843
|
+
if (state.scratchF32.length < numPoints * 3 || numPoints < 3) return 0;
|
|
844
|
+
const settings = new J.ConvexHullShapeSettings();
|
|
845
|
+
// JoltPhysics.js exposes mPoints as a JS-friendly Array<Vec3>.
|
|
846
|
+
for (let i = 0; i < numPoints; i++) {
|
|
847
|
+
const p = vec3(state.scratchF32[i*3], state.scratchF32[i*3+1], state.scratchF32[i*3+2]);
|
|
848
|
+
settings.mPoints.push_back(p);
|
|
849
|
+
}
|
|
850
|
+
settings.mConvexRadius = convexRadius;
|
|
851
|
+
const result = settings.Create();
|
|
852
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
export function shapeMesh(vertexCount, triangleCount) {
|
|
856
|
+
if (warnUninit('shapeMesh')) return 0;
|
|
857
|
+
const J = JoltModule;
|
|
858
|
+
if (state.scratchF32.length < vertexCount * 3 || state.scratchU32.length < triangleCount * 3) return 0;
|
|
859
|
+
if (vertexCount === 0 || triangleCount === 0) return 0;
|
|
860
|
+
const settings = new J.MeshShapeSettings();
|
|
861
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
862
|
+
settings.mTriangleVertices.push_back(new J.Float3(
|
|
863
|
+
state.scratchF32[i*3], state.scratchF32[i*3+1], state.scratchF32[i*3+2]
|
|
864
|
+
));
|
|
865
|
+
}
|
|
866
|
+
for (let t = 0; t < triangleCount; t++) {
|
|
867
|
+
const idx = new J.IndexedTriangle(
|
|
868
|
+
state.scratchU32[t*3], state.scratchU32[t*3+1], state.scratchU32[t*3+2], 0
|
|
869
|
+
);
|
|
870
|
+
settings.mIndexedTriangles.push_back(idx);
|
|
871
|
+
}
|
|
872
|
+
settings.Sanitize();
|
|
873
|
+
const result = settings.Create();
|
|
874
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export function shapeHeightfield(sampleCount, ox, oy, oz, sx, sy, sz, blockSize) {
|
|
878
|
+
if (warnUninit('shapeHeightfield')) return 0;
|
|
879
|
+
const J = JoltModule;
|
|
880
|
+
const need = sampleCount * sampleCount;
|
|
881
|
+
if (state.scratchF32.length < need || sampleCount < 2) return 0;
|
|
882
|
+
// JoltPhysics.js expects a flat Float32Array for heightfield samples.
|
|
883
|
+
const samples = new Float32Array(need);
|
|
884
|
+
for (let i = 0; i < need; i++) samples[i] = state.scratchF32[i];
|
|
885
|
+
const settings = new J.HeightFieldShapeSettings(
|
|
886
|
+
samples, vec3(ox, oy, oz), vec3(sx, sy, sz), sampleCount
|
|
887
|
+
);
|
|
888
|
+
settings.mBlockSize = blockSize || 4;
|
|
889
|
+
const result = settings.Create();
|
|
890
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// --- Compound builder ---
|
|
894
|
+
|
|
895
|
+
export function compoundBegin() { state.compoundChildren.length = 0; }
|
|
896
|
+
export function compoundAddChild(shape, px, py, pz, rx, ry, rz, rw) {
|
|
897
|
+
const s = state.shapes.get(shape); if (!s) return;
|
|
898
|
+
state.compoundChildren.push({ shape: s, px, py, pz, rx, ry, rz, rw });
|
|
899
|
+
}
|
|
900
|
+
export function compoundEnd() {
|
|
901
|
+
if (warnUninit('compoundEnd')) return 0;
|
|
902
|
+
const J = JoltModule;
|
|
903
|
+
if (state.compoundChildren.length === 0) return 0;
|
|
904
|
+
const settings = new J.StaticCompoundShapeSettings();
|
|
905
|
+
for (const c of state.compoundChildren) {
|
|
906
|
+
settings.AddShape(vec3(c.px, c.py, c.pz), quat(c.rx, c.ry, c.rz, c.rw), c.shape, 0);
|
|
907
|
+
}
|
|
908
|
+
state.compoundChildren.length = 0;
|
|
909
|
+
const result = settings.Create();
|
|
910
|
+
return result.IsValid() ? registerShape(result.Get()) : 0;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// --- Character controller (CharacterVirtual) ---
|
|
914
|
+
|
|
915
|
+
export function characterCreate(
|
|
916
|
+
worldH, shapeH,
|
|
917
|
+
upX, upY, upZ,
|
|
918
|
+
maxSlopeAngle, characterPadding,
|
|
919
|
+
penetrationRecoverySpeed, predictiveContactDistance,
|
|
920
|
+
maxStrength, mass, objectLayer,
|
|
921
|
+
px, py, pz, rx, ry, rz, rw,
|
|
922
|
+
) {
|
|
923
|
+
if (warnUninit('characterCreate')) return 0;
|
|
924
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
925
|
+
const shape = state.shapes.get(shapeH); if (!shape) return 0;
|
|
926
|
+
const J = JoltModule;
|
|
927
|
+
const settings = new J.CharacterVirtualSettings();
|
|
928
|
+
settings.mShape = shape;
|
|
929
|
+
settings.mUp = vec3(upX, upY, upZ);
|
|
930
|
+
settings.mMaxSlopeAngle = maxSlopeAngle;
|
|
931
|
+
settings.mCharacterPadding = characterPadding;
|
|
932
|
+
settings.mPenetrationRecoverySpeed = penetrationRecoverySpeed;
|
|
933
|
+
settings.mPredictiveContactDistance = predictiveContactDistance;
|
|
934
|
+
settings.mMaxStrength = maxStrength;
|
|
935
|
+
settings.mMass = mass;
|
|
936
|
+
const character = new J.CharacterVirtual(
|
|
937
|
+
settings, rvec3(px, py, pz), quat(rx, ry, rz, rw), 0n, w.system
|
|
938
|
+
);
|
|
939
|
+
const h = state.nextCharacter++;
|
|
940
|
+
state.characters.set(h, { world: worldH, character, layer: objectLayer | 0 });
|
|
941
|
+
return h;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
export function characterDestroy(h) {
|
|
945
|
+
const e = state.characters.get(h); if (!e) return;
|
|
946
|
+
JoltModule.destroy(e.character);
|
|
947
|
+
state.characters.delete(h);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
export function characterUpdate(h, dt, gx, gy, gz) {
|
|
951
|
+
const e = state.characters.get(h); if (!e) return;
|
|
952
|
+
const w = state.worlds.get(e.world); if (!w) return;
|
|
953
|
+
const J = JoltModule;
|
|
954
|
+
// Integrate gravity into velocity (match native C shim behaviour).
|
|
955
|
+
const v = e.character.GetLinearVelocity();
|
|
956
|
+
const newV = vec3(v.GetX() + gx * dt, v.GetY() + gy * dt, v.GetZ() + gz * dt);
|
|
957
|
+
e.character.SetLinearVelocity(newV);
|
|
958
|
+
const settings = new J.ExtendedUpdateSettings();
|
|
959
|
+
e.character.ExtendedUpdate(
|
|
960
|
+
dt, vec3(gx, gy, gz),
|
|
961
|
+
settings,
|
|
962
|
+
w.system.GetDefaultBroadPhaseLayerFilter(e.layer),
|
|
963
|
+
w.system.GetDefaultLayerFilter(e.layer),
|
|
964
|
+
new J.BodyFilter(),
|
|
965
|
+
new J.ShapeFilter(),
|
|
966
|
+
w.jolt.GetTempAllocator()
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
export function characterGetPosition(h, axis) {
|
|
971
|
+
const e = state.characters.get(h); if (!e) return 0;
|
|
972
|
+
const p = e.character.GetPosition();
|
|
973
|
+
if (axis === 0) return p.GetX(); if (axis === 1) return p.GetY(); if (axis === 2) return p.GetZ();
|
|
974
|
+
return 0;
|
|
975
|
+
}
|
|
976
|
+
export function characterGetRotation(h, axis) {
|
|
977
|
+
const e = state.characters.get(h); if (!e) return axis === 3 ? 1 : 0;
|
|
978
|
+
const q = e.character.GetRotation();
|
|
979
|
+
if (axis === 0) return q.GetX(); if (axis === 1) return q.GetY();
|
|
980
|
+
if (axis === 2) return q.GetZ(); if (axis === 3) return q.GetW();
|
|
981
|
+
return 0;
|
|
982
|
+
}
|
|
983
|
+
export function characterSetPosition(h, x, y, z) {
|
|
984
|
+
const e = state.characters.get(h); if (!e) return;
|
|
985
|
+
e.character.SetPosition(rvec3(x, y, z));
|
|
986
|
+
}
|
|
987
|
+
export function characterSetRotation(h, x, y, z, w) {
|
|
988
|
+
const e = state.characters.get(h); if (!e) return;
|
|
989
|
+
e.character.SetRotation(quat(x, y, z, w));
|
|
990
|
+
}
|
|
991
|
+
export function characterGetLinearVelocity(h, axis) {
|
|
992
|
+
const e = state.characters.get(h); if (!e) return 0;
|
|
993
|
+
const v = e.character.GetLinearVelocity();
|
|
994
|
+
if (axis === 0) return v.GetX(); if (axis === 1) return v.GetY(); if (axis === 2) return v.GetZ();
|
|
995
|
+
return 0;
|
|
996
|
+
}
|
|
997
|
+
export function characterSetLinearVelocity(h, x, y, z) {
|
|
998
|
+
const e = state.characters.get(h); if (!e) return;
|
|
999
|
+
e.character.SetLinearVelocity(vec3(x, y, z));
|
|
1000
|
+
}
|
|
1001
|
+
export function characterGetGroundState(h) {
|
|
1002
|
+
const e = state.characters.get(h); if (!e) return 3;
|
|
1003
|
+
const J = JoltModule;
|
|
1004
|
+
const s = e.character.GetGroundState();
|
|
1005
|
+
// Map Jolt enum → bj_ground_state.
|
|
1006
|
+
if (s === J.EGroundState_OnGround) return 0;
|
|
1007
|
+
if (s === J.EGroundState_OnSteepGround) return 1;
|
|
1008
|
+
if (s === J.EGroundState_NotSupported) return 2;
|
|
1009
|
+
return 3;
|
|
1010
|
+
}
|
|
1011
|
+
export function characterGetGroundNormal(h, axis) {
|
|
1012
|
+
const e = state.characters.get(h); if (!e) return axis === 1 ? 1 : 0;
|
|
1013
|
+
const n = e.character.GetGroundNormal();
|
|
1014
|
+
if (axis === 0) return n.GetX(); if (axis === 1) return n.GetY(); if (axis === 2) return n.GetZ();
|
|
1015
|
+
return 0;
|
|
1016
|
+
}
|
|
1017
|
+
export function characterGetGroundPosition(h, axis) {
|
|
1018
|
+
const e = state.characters.get(h); if (!e) return 0;
|
|
1019
|
+
const p = e.character.GetGroundPosition();
|
|
1020
|
+
if (axis === 0) return p.GetX(); if (axis === 1) return p.GetY(); if (axis === 2) return p.GetZ();
|
|
1021
|
+
return 0;
|
|
1022
|
+
}
|
|
1023
|
+
export function characterGetGroundBody(h) {
|
|
1024
|
+
const e = state.characters.get(h); if (!e) return 0;
|
|
1025
|
+
const bodyId = e.character.GetGroundBodyID();
|
|
1026
|
+
for (const [bh, b] of state.bodies) {
|
|
1027
|
+
if (b.world === e.world && b.bodyId.GetIndexAndSequenceNumber() === bodyId.GetIndexAndSequenceNumber()) {
|
|
1028
|
+
return bh;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return 0;
|
|
1032
|
+
}
|
|
1033
|
+
export function characterSetShape(h, shapeH) {
|
|
1034
|
+
const e = state.characters.get(h); if (!e) return;
|
|
1035
|
+
const w = state.worlds.get(e.world); if (!w) return;
|
|
1036
|
+
const s = state.shapes.get(shapeH); if (!s) return;
|
|
1037
|
+
const J = JoltModule;
|
|
1038
|
+
e.character.SetShape(
|
|
1039
|
+
s, Number.MAX_VALUE,
|
|
1040
|
+
w.system.GetDefaultBroadPhaseLayerFilter(e.layer),
|
|
1041
|
+
w.system.GetDefaultLayerFilter(e.layer),
|
|
1042
|
+
new J.BodyFilter(),
|
|
1043
|
+
new J.ShapeFilter(),
|
|
1044
|
+
w.jolt.GetTempAllocator()
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// ---------------------------------------------------------------------------
|
|
1049
|
+
// Soft bodies (Tier 2 — cloth / rope / jelly)
|
|
1050
|
+
// ---------------------------------------------------------------------------
|
|
1051
|
+
|
|
1052
|
+
export function softBodyCreate(
|
|
1053
|
+
worldH, vertexCount, triangleCount,
|
|
1054
|
+
px, py, pz, rx, ry, rz, rw,
|
|
1055
|
+
objectLayer, edgeCompliance, gravityFactor, linearDamping, pressure,
|
|
1056
|
+
) {
|
|
1057
|
+
if (warnUninit('softBodyCreate')) return 0;
|
|
1058
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
1059
|
+
const needF = vertexCount * 4, needU = triangleCount * 3;
|
|
1060
|
+
if (state.scratchF32.length < needF || state.scratchU32.length < needU) return 0;
|
|
1061
|
+
if (vertexCount < 3 || triangleCount === 0) return 0;
|
|
1062
|
+
|
|
1063
|
+
const J = JoltModule;
|
|
1064
|
+
const shared = new J.SoftBodySharedSettings();
|
|
1065
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
1066
|
+
const v = new J.SoftBodySharedSettingsVertex();
|
|
1067
|
+
v.mPosition = new J.Float3(state.scratchF32[i*4], state.scratchF32[i*4+1], state.scratchF32[i*4+2]);
|
|
1068
|
+
v.mVelocity = new J.Float3(0, 0, 0);
|
|
1069
|
+
v.mInvMass = state.scratchF32[i*4+3];
|
|
1070
|
+
shared.mVertices.push_back(v);
|
|
1071
|
+
}
|
|
1072
|
+
for (let t = 0; t < triangleCount; t++) {
|
|
1073
|
+
const f = new J.SoftBodySharedSettingsFace(
|
|
1074
|
+
state.scratchU32[t*3], state.scratchU32[t*3+1], state.scratchU32[t*3+2], 0
|
|
1075
|
+
);
|
|
1076
|
+
shared.AddFace(f);
|
|
1077
|
+
}
|
|
1078
|
+
const attrs = new J.SoftBodySharedSettingsVertexAttributes();
|
|
1079
|
+
attrs.mCompliance = edgeCompliance;
|
|
1080
|
+
attrs.mShearCompliance = edgeCompliance;
|
|
1081
|
+
attrs.mBendCompliance = edgeCompliance;
|
|
1082
|
+
shared.CreateConstraints(attrs, 1, J.EBendType_Distance ?? 0);
|
|
1083
|
+
shared.Optimize();
|
|
1084
|
+
|
|
1085
|
+
const bcs = new J.SoftBodyCreationSettings(shared, rvec3(px, py, pz), quat(rx, ry, rz, rw), objectLayer | 0);
|
|
1086
|
+
bcs.mGravityFactor = gravityFactor;
|
|
1087
|
+
bcs.mLinearDamping = linearDamping;
|
|
1088
|
+
bcs.mPressure = pressure;
|
|
1089
|
+
bcs.mUpdatePosition = true;
|
|
1090
|
+
|
|
1091
|
+
const bodyId = w.bodyInterface.CreateAndAddSoftBody(bcs, J.EActivation_Activate);
|
|
1092
|
+
const h = state.nextBody++;
|
|
1093
|
+
state.bodies.set(h, { world: worldH, bodyId, isSoftBody: true });
|
|
1094
|
+
return h;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
function softMotionProperties(h) {
|
|
1098
|
+
const b = state.bodies.get(h); if (!b) return null;
|
|
1099
|
+
const w = state.worlds.get(b.world); if (!w) return null;
|
|
1100
|
+
const J = JoltModule;
|
|
1101
|
+
// Use read-locking to safely access SoftBodyMotionProperties.
|
|
1102
|
+
const lock = new J.BodyLockRead(w.system.GetBodyLockInterface(), b.bodyId);
|
|
1103
|
+
if (!lock.SucceededAndIsInBroadPhase()) { lock.ReleaseLock(); return null; }
|
|
1104
|
+
const body = lock.GetBody();
|
|
1105
|
+
if (!body.IsSoftBody()) { lock.ReleaseLock(); return null; }
|
|
1106
|
+
const mp = J.castObject ? J.castObject(body.GetMotionPropertiesUnchecked(), J.SoftBodyMotionProperties)
|
|
1107
|
+
: body.GetMotionPropertiesUnchecked();
|
|
1108
|
+
return { lock, body, mp };
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
export function softBodyVertexCount(h) {
|
|
1112
|
+
const ctx = softMotionProperties(h); if (!ctx) return 0;
|
|
1113
|
+
const n = ctx.mp.GetVertices ? ctx.mp.GetVertices().size() : 0;
|
|
1114
|
+
ctx.lock.ReleaseLock();
|
|
1115
|
+
return n;
|
|
1116
|
+
}
|
|
1117
|
+
export function softBodyGetVertex(h, idx, axis) {
|
|
1118
|
+
const ctx = softMotionProperties(h); if (!ctx) return 0;
|
|
1119
|
+
const verts = ctx.mp.GetVertices ? ctx.mp.GetVertices() : null;
|
|
1120
|
+
if (!verts || idx >= verts.size()) { ctx.lock.ReleaseLock(); return 0; }
|
|
1121
|
+
const v = verts.at(idx);
|
|
1122
|
+
const local = v.mPosition; // Vec3 in body-local space
|
|
1123
|
+
const xform = ctx.body.GetWorldTransform();
|
|
1124
|
+
const worldPos = xform.Multiply3x4(local);
|
|
1125
|
+
ctx.lock.ReleaseLock();
|
|
1126
|
+
if (axis === 0) return worldPos.GetX();
|
|
1127
|
+
if (axis === 1) return worldPos.GetY();
|
|
1128
|
+
if (axis === 2) return worldPos.GetZ();
|
|
1129
|
+
return 0;
|
|
1130
|
+
}
|
|
1131
|
+
export function softBodySetVertex(h, idx, x, y, z) {
|
|
1132
|
+
const b = state.bodies.get(h); if (!b) return;
|
|
1133
|
+
const w = state.worlds.get(b.world); if (!w) return;
|
|
1134
|
+
const J = JoltModule;
|
|
1135
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), b.bodyId);
|
|
1136
|
+
if (lock.SucceededAndIsInBroadPhase()) {
|
|
1137
|
+
const body = lock.GetBody();
|
|
1138
|
+
if (body.IsSoftBody()) {
|
|
1139
|
+
const mp = J.castObject ? J.castObject(body.GetMotionPropertiesUnchecked(), J.SoftBodyMotionProperties)
|
|
1140
|
+
: body.GetMotionPropertiesUnchecked();
|
|
1141
|
+
const verts = mp.GetVertices();
|
|
1142
|
+
if (idx < verts.size()) {
|
|
1143
|
+
const xform = body.GetWorldTransform();
|
|
1144
|
+
const inv = xform.Inversed();
|
|
1145
|
+
const local = inv.Multiply3x4(vec3(x, y, z));
|
|
1146
|
+
verts.at(idx).mPosition = local;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
lock.ReleaseLock();
|
|
1151
|
+
}
|
|
1152
|
+
export function softBodySetVertexInvMass(h, idx, invMass) {
|
|
1153
|
+
const b = state.bodies.get(h); if (!b) return;
|
|
1154
|
+
const w = state.worlds.get(b.world); if (!w) return;
|
|
1155
|
+
const J = JoltModule;
|
|
1156
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), b.bodyId);
|
|
1157
|
+
if (lock.SucceededAndIsInBroadPhase()) {
|
|
1158
|
+
const body = lock.GetBody();
|
|
1159
|
+
if (body.IsSoftBody()) {
|
|
1160
|
+
const mp = J.castObject ? J.castObject(body.GetMotionPropertiesUnchecked(), J.SoftBodyMotionProperties)
|
|
1161
|
+
: body.GetMotionPropertiesUnchecked();
|
|
1162
|
+
const verts = mp.GetVertices();
|
|
1163
|
+
if (idx < verts.size()) verts.at(idx).mInvMass = invMass;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
lock.ReleaseLock();
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// ---------------------------------------------------------------------------
|
|
1170
|
+
// Wheeled vehicles (Tier 2 — 4-wheel car)
|
|
1171
|
+
// ---------------------------------------------------------------------------
|
|
1172
|
+
|
|
1173
|
+
export function vehicleCreate(
|
|
1174
|
+
worldH, chassisShapeH,
|
|
1175
|
+
upX, upY, upZ, fwX, fwY, fwZ,
|
|
1176
|
+
w0x, w0y, w0z, w1x, w1y, w1z, w2x, w2y, w2z, w3x, w3y, w3z,
|
|
1177
|
+
wheelRadius, wheelWidth, suspensionMin, suspensionMax,
|
|
1178
|
+
maxSteerAngle, maxBrakeTorque, maxHandbrakeTorque,
|
|
1179
|
+
engineMaxTorque, maxPitchRollAngle, objectLayer,
|
|
1180
|
+
px, py, pz, rx, ry, rz, rw,
|
|
1181
|
+
) {
|
|
1182
|
+
if (warnUninit('vehicleCreate')) return 0;
|
|
1183
|
+
const w = state.worlds.get(worldH); if (!w) return 0;
|
|
1184
|
+
const shape = state.shapes.get(chassisShapeH); if (!shape) return 0;
|
|
1185
|
+
const J = JoltModule;
|
|
1186
|
+
|
|
1187
|
+
// Chassis body.
|
|
1188
|
+
const chassisSettings = new J.BodyCreationSettings(
|
|
1189
|
+
shape, rvec3(px, py, pz), quat(rx, ry, rz, rw),
|
|
1190
|
+
J.EMotionType_Dynamic, objectLayer | 0,
|
|
1191
|
+
);
|
|
1192
|
+
chassisSettings.mOverrideMassProperties = J.EOverrideMassProperties_CalculateInertia;
|
|
1193
|
+
chassisSettings.mMassPropertiesOverride.mMass = 1500.0;
|
|
1194
|
+
const chassisId = w.bodyInterface.CreateAndAddBody(chassisSettings, J.EActivation_Activate);
|
|
1195
|
+
const chassisHandle = state.nextBody++;
|
|
1196
|
+
state.bodies.set(chassisHandle, { world: worldH, bodyId: chassisId });
|
|
1197
|
+
|
|
1198
|
+
// VehicleConstraintSettings.
|
|
1199
|
+
const vcs = new J.VehicleConstraintSettings();
|
|
1200
|
+
vcs.mUp = vec3(upX, upY, upZ);
|
|
1201
|
+
vcs.mForward = vec3(fwX, fwY, fwZ);
|
|
1202
|
+
vcs.mMaxPitchRollAngle = maxPitchRollAngle;
|
|
1203
|
+
|
|
1204
|
+
// 4 wheels — FL/FR steer, RL/RR drive + handbrake.
|
|
1205
|
+
const wheelPositions = [
|
|
1206
|
+
[w0x, w0y, w0z], [w1x, w1y, w1z], [w2x, w2y, w2z], [w3x, w3y, w3z],
|
|
1207
|
+
];
|
|
1208
|
+
for (let i = 0; i < 4; i++) {
|
|
1209
|
+
const wheel = new J.WheelSettingsWV();
|
|
1210
|
+
wheel.mPosition = vec3(wheelPositions[i][0], wheelPositions[i][1], wheelPositions[i][2]);
|
|
1211
|
+
wheel.mRadius = wheelRadius;
|
|
1212
|
+
wheel.mWidth = wheelWidth;
|
|
1213
|
+
wheel.mSuspensionMinLength = suspensionMin;
|
|
1214
|
+
wheel.mSuspensionMaxLength = suspensionMax;
|
|
1215
|
+
wheel.mMaxSteerAngle = (i < 2) ? maxSteerAngle : 0.0;
|
|
1216
|
+
wheel.mMaxBrakeTorque = maxBrakeTorque;
|
|
1217
|
+
wheel.mMaxHandBrakeTorque = (i >= 2) ? maxHandbrakeTorque : 0.0;
|
|
1218
|
+
vcs.mWheels.push_back(wheel);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// WheeledVehicleController with a single rear-axle differential.
|
|
1222
|
+
const controller = new J.WheeledVehicleControllerSettings();
|
|
1223
|
+
controller.mEngine.mMaxTorque = engineMaxTorque;
|
|
1224
|
+
const diff = new J.VehicleDifferentialSettings();
|
|
1225
|
+
diff.mLeftWheel = 2;
|
|
1226
|
+
diff.mRightWheel = 3;
|
|
1227
|
+
controller.mDifferentials.push_back(diff);
|
|
1228
|
+
vcs.mController = controller;
|
|
1229
|
+
|
|
1230
|
+
// Lock chassis to construct the constraint.
|
|
1231
|
+
const lock = new J.BodyLockWrite(w.system.GetBodyLockInterface(), chassisId);
|
|
1232
|
+
if (!lock.SucceededAndIsInBroadPhase()) { lock.ReleaseLock(); return 0; }
|
|
1233
|
+
const constraint = new J.VehicleConstraint(lock.GetBody(), vcs);
|
|
1234
|
+
lock.ReleaseLock();
|
|
1235
|
+
|
|
1236
|
+
const tester = new J.VehicleCollisionTesterRay(OBJECT_LAYER_NON_MOVING, vec3(upX, upY, upZ));
|
|
1237
|
+
constraint.SetVehicleCollisionTester(tester);
|
|
1238
|
+
w.system.AddConstraint(constraint);
|
|
1239
|
+
w.system.AddStepListener(constraint);
|
|
1240
|
+
|
|
1241
|
+
const vh = state.nextConstraint++;
|
|
1242
|
+
state.constraints.set(vh, {
|
|
1243
|
+
world: worldH, constraint, tester,
|
|
1244
|
+
isVehicle: true, chassisHandle, chassisId,
|
|
1245
|
+
});
|
|
1246
|
+
return vh;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
export function vehicleDestroy(h) {
|
|
1250
|
+
const v = state.constraints.get(h); if (!v || !v.isVehicle) return;
|
|
1251
|
+
const w = state.worlds.get(v.world); if (!w) return;
|
|
1252
|
+
w.system.RemoveStepListener(v.constraint);
|
|
1253
|
+
w.system.RemoveConstraint(v.constraint);
|
|
1254
|
+
if (w.bodyInterface.IsAdded(v.chassisId)) w.bodyInterface.RemoveBody(v.chassisId);
|
|
1255
|
+
w.bodyInterface.DestroyBody(v.chassisId);
|
|
1256
|
+
state.bodies.delete(v.chassisHandle);
|
|
1257
|
+
state.constraints.delete(h);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
export function vehicleGetChassis(h) {
|
|
1261
|
+
const v = state.constraints.get(h); return (v && v.isVehicle) ? v.chassisHandle : 0;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
export function vehicleSetInput(h, forward, right, brake, handbrake) {
|
|
1265
|
+
const v = state.constraints.get(h); if (!v || !v.isVehicle) return;
|
|
1266
|
+
const J = JoltModule;
|
|
1267
|
+
const ctrl = J.castObject ? J.castObject(v.constraint.GetController(), J.WheeledVehicleController)
|
|
1268
|
+
: v.constraint.GetController();
|
|
1269
|
+
ctrl.SetDriverInput(forward, right, brake, handbrake);
|
|
1270
|
+
if (forward !== 0 || brake !== 0 || handbrake !== 0 || right !== 0) {
|
|
1271
|
+
const w = state.worlds.get(v.world);
|
|
1272
|
+
if (w) w.bodyInterface.ActivateBody(v.chassisId);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
export function vehicleGetWheelTransform(h, wheelIndex, axis) {
|
|
1277
|
+
const v = state.constraints.get(h); if (!v || !v.isVehicle) return 0;
|
|
1278
|
+
const J = JoltModule;
|
|
1279
|
+
const xform = v.constraint.GetWheelWorldTransform(wheelIndex, J.Vec3.prototype.sAxisY(), J.Vec3.prototype.sAxisX());
|
|
1280
|
+
if (axis < 3) {
|
|
1281
|
+
const p = xform.GetTranslation();
|
|
1282
|
+
if (axis === 0) return p.GetX();
|
|
1283
|
+
if (axis === 1) return p.GetY();
|
|
1284
|
+
return p.GetZ();
|
|
1285
|
+
}
|
|
1286
|
+
if (axis < 7) {
|
|
1287
|
+
const q = xform.GetQuaternion();
|
|
1288
|
+
if (axis === 3) return q.GetX();
|
|
1289
|
+
if (axis === 4) return q.GetY();
|
|
1290
|
+
if (axis === 5) return q.GetZ();
|
|
1291
|
+
return q.GetW();
|
|
1292
|
+
}
|
|
1293
|
+
return 0;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
export function vehicleGetEngineRpm(h) {
|
|
1297
|
+
const v = state.constraints.get(h); if (!v || !v.isVehicle) return 0;
|
|
1298
|
+
const J = JoltModule;
|
|
1299
|
+
const ctrl = J.castObject ? J.castObject(v.constraint.GetController(), J.WheeledVehicleController)
|
|
1300
|
+
: v.constraint.GetController();
|
|
1301
|
+
return ctrl.GetEngine().GetCurrentRPM();
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
export function vehicleGetWheelAngularVelocity(h, wheelIndex) {
|
|
1305
|
+
const v = state.constraints.get(h); if (!v || !v.isVehicle) return 0;
|
|
1306
|
+
const J = JoltModule;
|
|
1307
|
+
const wheel = v.constraint.GetWheel(wheelIndex);
|
|
1308
|
+
if (!wheel) return 0;
|
|
1309
|
+
const wv = J.castObject ? J.castObject(wheel, J.WheelWV) : wheel;
|
|
1310
|
+
return wv.GetAngularVelocity ? wv.GetAngularVelocity() : 0;
|
|
1311
|
+
}
|