@bloomengine/engine 0.4.0 → 0.4.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/package.json +4 -11
- package/native/third_party/JoltPhysics/Build/Android/PerformanceTest/build.gradle +0 -51
- package/native/third_party/JoltPhysics/Build/Android/PerformanceTest/src/main/AndroidManifest.xml +0 -20
- package/native/third_party/JoltPhysics/Build/Android/PerformanceTest/src/main/cpp/CMakeLists.txt +0 -20
- package/native/third_party/JoltPhysics/Build/Android/UnitTests/build.gradle +0 -51
- package/native/third_party/JoltPhysics/Build/Android/UnitTests/src/main/AndroidManifest.xml +0 -20
- package/native/third_party/JoltPhysics/Build/Android/UnitTests/src/main/cpp/CMakeLists.txt +0 -20
- package/native/third_party/JoltPhysics/Build/Android/build.gradle +0 -17
- package/native/third_party/JoltPhysics/Build/Android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/native/third_party/JoltPhysics/Build/Android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/native/third_party/JoltPhysics/Build/Android/gradle.properties +0 -21
- package/native/third_party/JoltPhysics/Build/Android/gradlew +0 -185
- package/native/third_party/JoltPhysics/Build/Android/gradlew.bat +0 -89
- package/native/third_party/JoltPhysics/Build/Android/settings.gradle +0 -10
- package/native/third_party/JoltPhysics/Build/CMakeLists.txt +0 -449
- package/native/third_party/JoltPhysics/Build/README.md +0 -250
- package/native/third_party/JoltPhysics/Build/cmake_linux_clang_gcc.sh +0 -28
- package/native/third_party/JoltPhysics/Build/cmake_linux_emscripten.sh +0 -19
- package/native/third_party/JoltPhysics/Build/cmake_linux_mingw.sh +0 -19
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_32bit.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_arm.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_arm_32bit.bat +0 -4
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_cross_platform_deterministic.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_double.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_no_object_stream.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_clang.bat +0 -10
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_clang_cross_platform_deterministic.bat +0 -10
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_clang_double.bat +0 -10
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_uwp.bat +0 -5
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_uwp_arm.bat +0 -5
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_cl.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_cl_cross_platform_deterministic.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_cl_double.bat +0 -3
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_clang.bat +0 -10
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_clang_cross_platform_deterministic.bat +0 -10
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_clang_double.bat +0 -10
- package/native/third_party/JoltPhysics/Build/cmake_windows_mingw.sh +0 -19
- package/native/third_party/JoltPhysics/Build/cmake_xcode_ios.sh +0 -4
- package/native/third_party/JoltPhysics/Build/cmake_xcode_macos.sh +0 -4
- package/native/third_party/JoltPhysics/Build/iOS/JoltViewerInfo.plist +0 -34
- package/native/third_party/JoltPhysics/Build/iOS/SamplesInfo.plist +0 -34
- package/native/third_party/JoltPhysics/Build/iOS/UnitTestsInfo.plist +0 -34
- package/native/third_party/JoltPhysics/Build/macOS/icon.icns +0 -0
- package/native/third_party/JoltPhysics/Build/macos_install_vulkan_sdk.sh +0 -13
- package/native/third_party/JoltPhysics/Build/ubuntu24_install_vulkan_sdk.sh +0 -4
- package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.cpp +0 -242
- package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.h +0 -121
- package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeToBuffer.h +0 -296
- package/native/third_party/JoltPhysics/Jolt/AABBTree/NodeCodec/NodeCodecQuadTreeHalfFloat.h +0 -323
- package/native/third_party/JoltPhysics/Jolt/AABBTree/TriangleCodec/TriangleCodecIndexed8BitPackSOA4Flags.h +0 -555
- package/native/third_party/JoltPhysics/Jolt/ConfigurationString.h +0 -112
- package/native/third_party/JoltPhysics/Jolt/Core/ARMNeon.h +0 -94
- package/native/third_party/JoltPhysics/Jolt/Core/Array.h +0 -713
- package/native/third_party/JoltPhysics/Jolt/Core/Atomics.h +0 -44
- package/native/third_party/JoltPhysics/Jolt/Core/BinaryHeap.h +0 -96
- package/native/third_party/JoltPhysics/Jolt/Core/ByteBuffer.h +0 -74
- package/native/third_party/JoltPhysics/Jolt/Core/Color.cpp +0 -38
- package/native/third_party/JoltPhysics/Jolt/Core/Color.h +0 -98
- package/native/third_party/JoltPhysics/Jolt/Core/Core.h +0 -652
- package/native/third_party/JoltPhysics/Jolt/Core/FPControlWord.h +0 -143
- package/native/third_party/JoltPhysics/Jolt/Core/FPException.h +0 -96
- package/native/third_party/JoltPhysics/Jolt/Core/FPFlushDenormals.h +0 -43
- package/native/third_party/JoltPhysics/Jolt/Core/Factory.cpp +0 -92
- package/native/third_party/JoltPhysics/Jolt/Core/Factory.h +0 -54
- package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.h +0 -122
- package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.inl +0 -215
- package/native/third_party/JoltPhysics/Jolt/Core/HashCombine.h +0 -234
- package/native/third_party/JoltPhysics/Jolt/Core/HashTable.h +0 -876
- package/native/third_party/JoltPhysics/Jolt/Core/InsertionSort.h +0 -58
- package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.cpp +0 -27
- package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.h +0 -38
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.h +0 -311
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.inl +0 -56
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.cpp +0 -65
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.h +0 -62
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.cpp +0 -364
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.h +0 -101
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.cpp +0 -230
- package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.h +0 -85
- package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.cpp +0 -51
- package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.h +0 -67
- package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.h +0 -182
- package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.inl +0 -351
- package/native/third_party/JoltPhysics/Jolt/Core/Memory.cpp +0 -85
- package/native/third_party/JoltPhysics/Jolt/Core/Memory.h +0 -85
- package/native/third_party/JoltPhysics/Jolt/Core/Mutex.h +0 -223
- package/native/third_party/JoltPhysics/Jolt/Core/MutexArray.h +0 -98
- package/native/third_party/JoltPhysics/Jolt/Core/NonCopyable.h +0 -18
- package/native/third_party/JoltPhysics/Jolt/Core/Profiler.cpp +0 -677
- package/native/third_party/JoltPhysics/Jolt/Core/Profiler.h +0 -301
- package/native/third_party/JoltPhysics/Jolt/Core/Profiler.inl +0 -90
- package/native/third_party/JoltPhysics/Jolt/Core/QuickSort.h +0 -137
- package/native/third_party/JoltPhysics/Jolt/Core/RTTI.cpp +0 -149
- package/native/third_party/JoltPhysics/Jolt/Core/RTTI.h +0 -436
- package/native/third_party/JoltPhysics/Jolt/Core/Reference.h +0 -244
- package/native/third_party/JoltPhysics/Jolt/Core/Result.h +0 -174
- package/native/third_party/JoltPhysics/Jolt/Core/STLAlignedAllocator.h +0 -72
- package/native/third_party/JoltPhysics/Jolt/Core/STLAllocator.h +0 -127
- package/native/third_party/JoltPhysics/Jolt/Core/STLLocalAllocator.h +0 -170
- package/native/third_party/JoltPhysics/Jolt/Core/STLTempAllocator.h +0 -80
- package/native/third_party/JoltPhysics/Jolt/Core/ScopeExit.h +0 -49
- package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.cpp +0 -135
- package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.h +0 -68
- package/native/third_party/JoltPhysics/Jolt/Core/StaticArray.h +0 -329
- package/native/third_party/JoltPhysics/Jolt/Core/StreamIn.h +0 -120
- package/native/third_party/JoltPhysics/Jolt/Core/StreamOut.h +0 -97
- package/native/third_party/JoltPhysics/Jolt/Core/StreamUtils.h +0 -168
- package/native/third_party/JoltPhysics/Jolt/Core/StreamWrapper.h +0 -53
- package/native/third_party/JoltPhysics/Jolt/Core/StridedPtr.h +0 -63
- package/native/third_party/JoltPhysics/Jolt/Core/StringTools.cpp +0 -101
- package/native/third_party/JoltPhysics/Jolt/Core/StringTools.h +0 -38
- package/native/third_party/JoltPhysics/Jolt/Core/TempAllocator.h +0 -209
- package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.cpp +0 -37
- package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.h +0 -58
- package/native/third_party/JoltPhysics/Jolt/Core/UnorderedMap.h +0 -80
- package/native/third_party/JoltPhysics/Jolt/Core/UnorderedSet.h +0 -32
- package/native/third_party/JoltPhysics/Jolt/Geometry/AABox.h +0 -313
- package/native/third_party/JoltPhysics/Jolt/Geometry/AABox4.h +0 -224
- package/native/third_party/JoltPhysics/Jolt/Geometry/ClipPoly.h +0 -200
- package/native/third_party/JoltPhysics/Jolt/Geometry/ClosestPoint.h +0 -498
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.cpp +0 -1467
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.h +0 -276
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.cpp +0 -335
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.h +0 -105
- package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexSupport.h +0 -188
- package/native/third_party/JoltPhysics/Jolt/Geometry/EPAConvexHullBuilder.h +0 -845
- package/native/third_party/JoltPhysics/Jolt/Geometry/EPAPenetrationDepth.h +0 -557
- package/native/third_party/JoltPhysics/Jolt/Geometry/Ellipse.h +0 -77
- package/native/third_party/JoltPhysics/Jolt/Geometry/GJKClosestPoint.h +0 -945
- package/native/third_party/JoltPhysics/Jolt/Geometry/IndexedTriangle.h +0 -130
- package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.cpp +0 -222
- package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.h +0 -19
- package/native/third_party/JoltPhysics/Jolt/Geometry/MortonCode.h +0 -40
- package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.cpp +0 -178
- package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.h +0 -39
- package/native/third_party/JoltPhysics/Jolt/Geometry/Plane.h +0 -104
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayAABox.h +0 -241
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayCapsule.h +0 -37
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayCylinder.h +0 -101
- package/native/third_party/JoltPhysics/Jolt/Geometry/RaySphere.h +0 -96
- package/native/third_party/JoltPhysics/Jolt/Geometry/RayTriangle.h +0 -158
- package/native/third_party/JoltPhysics/Jolt/Geometry/Sphere.h +0 -72
- package/native/third_party/JoltPhysics/Jolt/Geometry/Triangle.h +0 -34
- package/native/third_party/JoltPhysics/Jolt/Jolt.cmake +0 -703
- package/native/third_party/JoltPhysics/Jolt/Jolt.h +0 -16
- package/native/third_party/JoltPhysics/Jolt/Jolt.natvis +0 -116
- package/native/third_party/JoltPhysics/Jolt/Math/BVec16.h +0 -99
- package/native/third_party/JoltPhysics/Jolt/Math/BVec16.inl +0 -177
- package/native/third_party/JoltPhysics/Jolt/Math/DMat44.h +0 -158
- package/native/third_party/JoltPhysics/Jolt/Math/DMat44.inl +0 -310
- package/native/third_party/JoltPhysics/Jolt/Math/DVec3.h +0 -291
- package/native/third_party/JoltPhysics/Jolt/Math/DVec3.inl +0 -941
- package/native/third_party/JoltPhysics/Jolt/Math/Double3.h +0 -48
- package/native/third_party/JoltPhysics/Jolt/Math/DynMatrix.h +0 -31
- package/native/third_party/JoltPhysics/Jolt/Math/EigenValueSymmetric.h +0 -177
- package/native/third_party/JoltPhysics/Jolt/Math/FindRoot.h +0 -42
- package/native/third_party/JoltPhysics/Jolt/Math/Float2.h +0 -36
- package/native/third_party/JoltPhysics/Jolt/Math/Float3.h +0 -50
- package/native/third_party/JoltPhysics/Jolt/Math/Float4.h +0 -44
- package/native/third_party/JoltPhysics/Jolt/Math/GaussianElimination.h +0 -102
- package/native/third_party/JoltPhysics/Jolt/Math/HalfFloat.h +0 -208
- package/native/third_party/JoltPhysics/Jolt/Math/Mat44.h +0 -243
- package/native/third_party/JoltPhysics/Jolt/Math/Mat44.inl +0 -952
- package/native/third_party/JoltPhysics/Jolt/Math/Math.h +0 -208
- package/native/third_party/JoltPhysics/Jolt/Math/MathTypes.h +0 -32
- package/native/third_party/JoltPhysics/Jolt/Math/Matrix.h +0 -259
- package/native/third_party/JoltPhysics/Jolt/Math/Quat.h +0 -268
- package/native/third_party/JoltPhysics/Jolt/Math/Quat.inl +0 -406
- package/native/third_party/JoltPhysics/Jolt/Math/Real.h +0 -44
- package/native/third_party/JoltPhysics/Jolt/Math/Swizzle.h +0 -19
- package/native/third_party/JoltPhysics/Jolt/Math/Trigonometry.h +0 -79
- package/native/third_party/JoltPhysics/Jolt/Math/UVec4.h +0 -232
- package/native/third_party/JoltPhysics/Jolt/Math/UVec4.inl +0 -636
- package/native/third_party/JoltPhysics/Jolt/Math/Vec3.cpp +0 -71
- package/native/third_party/JoltPhysics/Jolt/Math/Vec3.h +0 -308
- package/native/third_party/JoltPhysics/Jolt/Math/Vec3.inl +0 -942
- package/native/third_party/JoltPhysics/Jolt/Math/Vec4.h +0 -320
- package/native/third_party/JoltPhysics/Jolt/Math/Vec4.inl +0 -1152
- package/native/third_party/JoltPhysics/Jolt/Math/Vector.h +0 -211
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/GetPrimitiveTypeOfType.h +0 -54
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.cpp +0 -38
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.h +0 -337
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.cpp +0 -252
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.h +0 -57
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.cpp +0 -165
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.h +0 -57
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.cpp +0 -635
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.h +0 -148
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.cpp +0 -166
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.h +0 -101
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.cpp +0 -418
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.h +0 -55
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.cpp +0 -255
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.h +0 -62
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTypes.h +0 -26
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttribute.h +0 -111
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeEnum.h +0 -67
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeTyped.h +0 -60
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.cpp +0 -15
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.h +0 -170
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.cpp +0 -70
- package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.h +0 -45
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/AllowedDOFs.h +0 -68
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.cpp +0 -426
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.h +0 -452
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.inl +0 -197
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyAccess.h +0 -68
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyActivationListener.h +0 -28
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.cpp +0 -234
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.h +0 -124
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyFilter.h +0 -130
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyID.h +0 -101
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.cpp +0 -1099
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.h +0 -324
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLock.h +0 -111
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockInterface.h +0 -134
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockMulti.h +0 -120
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.cpp +0 -1220
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.h +0 -403
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyPair.h +0 -36
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyType.h +0 -19
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.cpp +0 -185
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.h +0 -58
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.cpp +0 -92
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.h +0 -308
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.inl +0 -178
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionQuality.h +0 -31
- package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionType.h +0 -17
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.cpp +0 -354
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.h +0 -159
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.cpp +0 -59
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.h +0 -157
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterID.h +0 -98
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.cpp +0 -1933
- package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.h +0 -752
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/AABoxCast.h +0 -20
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdgeMode.h +0 -17
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdges.h +0 -114
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BackFaceMode.h +0 -16
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.cpp +0 -16
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.h +0 -109
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.cpp +0 -313
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.h +0 -38
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h +0 -148
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceMask.h +0 -92
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceTable.h +0 -64
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp +0 -629
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.h +0 -108
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuery.h +0 -56
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterMask.h +0 -35
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterTable.h +0 -66
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.cpp +0 -1768
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.h +0 -389
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp +0 -107
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.h +0 -46
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastResult.h +0 -37
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.cpp +0 -223
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.h +0 -49
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollectFacesMode.h +0 -16
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp +0 -155
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.h +0 -56
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollidePointResult.h +0 -25
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShape.h +0 -106
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShapeVsShapePerLeaf.h +0 -94
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVertexIterator.h +0 -110
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVerticesVsTriangles.h +0 -102
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp +0 -121
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.h +0 -50
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollector.h +0 -109
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollectorImpl.h +0 -219
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.cpp +0 -107
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.h +0 -97
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.cpp +0 -35
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.h +0 -97
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ContactListener.h +0 -143
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.cpp +0 -213
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.h +0 -48
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.cpp +0 -32
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.h +0 -46
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.cpp +0 -38
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.h +0 -130
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/InternalEdgeRemovingCollector.h +0 -279
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.cpp +0 -271
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h +0 -44
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.cpp +0 -448
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.h +0 -77
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.cpp +0 -62
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.h +0 -110
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayer.h +0 -111
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterMask.h +0 -52
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterTable.h +0 -78
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.cpp +0 -35
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.h +0 -57
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.cpp +0 -38
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.h +0 -37
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/RayCast.h +0 -87
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.cpp +0 -318
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.h +0 -115
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.cpp +0 -438
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.h +0 -129
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.cpp +0 -433
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.h +0 -354
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShapeVisitors.h +0 -461
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.cpp +0 -1311
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.h +0 -202
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.cpp +0 -566
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.h +0 -150
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.cpp +0 -418
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.h +0 -126
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.cpp +0 -87
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.h +0 -80
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.cpp +0 -64
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.h +0 -75
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/GetTrianglesContext.h +0 -248
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.cpp +0 -2754
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.h +0 -380
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.cpp +0 -1305
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.h +0 -228
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.cpp +0 -596
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.h +0 -176
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.cpp +0 -217
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h +0 -140
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.cpp +0 -541
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.h +0 -147
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PolyhedronSubmergedVolumeCalculator.h +0 -319
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.cpp +0 -333
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h +0 -161
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaleHelpers.h +0 -83
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.cpp +0 -238
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.h +0 -145
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.cpp +0 -325
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.h +0 -466
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.cpp +0 -347
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.h +0 -125
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp +0 -674
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.h +0 -139
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeID.h +0 -138
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeIDPair.h +0 -65
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp +0 -453
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.gliffy +0 -1
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.h +0 -135
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp +0 -691
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.h +0 -132
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.cpp +0 -430
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.h +0 -143
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeCast.h +0 -173
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeFilter.h +0 -73
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilter.h +0 -40
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilterWrapper.h +0 -58
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SortReverseAndStore.h +0 -48
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.cpp +0 -180
- package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.h +0 -194
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/CalculateSolverSteps.h +0 -70
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.cpp +0 -246
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.h +0 -133
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.cpp +0 -73
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.h +0 -243
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.cpp +0 -289
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.h +0 -100
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h +0 -257
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h +0 -682
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/DualAxisConstraintPart.h +0 -276
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h +0 -195
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/HingeRotationConstraintPart.h +0 -222
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h +0 -246
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/PointConstraintPart.h +0 -239
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RackAndPinionConstraintPart.h +0 -196
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h +0 -283
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationQuatConstraintPart.h +0 -246
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SpringPart.h +0 -169
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h +0 -597
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.cpp +0 -1804
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.h +0 -524
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.cpp +0 -266
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.h +0 -120
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.cpp +0 -215
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.h +0 -96
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.cpp +0 -188
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.h +0 -116
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.cpp +0 -443
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.h +0 -205
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.cpp +0 -43
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.h +0 -66
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.cpp +0 -458
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.h +0 -191
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.cpp +0 -85
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.h +0 -76
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.cpp +0 -308
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.h +0 -54
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.cpp +0 -157
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.h +0 -94
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.cpp +0 -253
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.h +0 -137
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.cpp +0 -189
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.h +0 -118
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.cpp +0 -900
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.h +0 -289
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.cpp +0 -501
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.h +0 -198
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.cpp +0 -35
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.h +0 -70
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.cpp +0 -524
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.h +0 -197
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.cpp +0 -56
- package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.h +0 -65
- package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.cpp +0 -17
- package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.h +0 -159
- package/native/third_party/JoltPhysics/Jolt/Physics/EActivation.h +0 -16
- package/native/third_party/JoltPhysics/Jolt/Physics/EPhysicsUpdateError.h +0 -37
- package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.cpp +0 -492
- package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.h +0 -144
- package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.cpp +0 -582
- package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.h +0 -187
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsLock.h +0 -169
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.cpp +0 -261
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.h +0 -104
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSettings.h +0 -125
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsStepListener.h +0 -37
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.cpp +0 -2915
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.h +0 -391
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.cpp +0 -25
- package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.h +0 -176
- package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.cpp +0 -744
- package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.h +0 -245
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyContactListener.h +0 -55
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.cpp +0 -128
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.h +0 -75
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyManifold.h +0 -74
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp +0 -1501
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.h +0 -333
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.cpp +0 -354
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.h +0 -73
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp +0 -1487
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.h +0 -390
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyUpdateContext.h +0 -63
- package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyVertex.h +0 -36
- package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorder.h +0 -136
- package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.cpp +0 -90
- package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.h +0 -50
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.cpp +0 -306
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.h +0 -119
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.cpp +0 -547
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.h +0 -169
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.cpp +0 -33
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.h +0 -33
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.cpp +0 -376
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.h +0 -146
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.cpp +0 -703
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.h +0 -252
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.cpp +0 -17
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.h +0 -87
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.cpp +0 -81
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.h +0 -39
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.cpp +0 -122
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.h +0 -93
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.cpp +0 -52
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.h +0 -56
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.cpp +0 -159
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.h +0 -87
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.cpp +0 -93
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.h +0 -148
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.cpp +0 -866
- package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.h +0 -205
- package/native/third_party/JoltPhysics/Jolt/RegisterTypes.cpp +0 -204
- package/native/third_party/JoltPhysics/Jolt/RegisterTypes.h +0 -29
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.cpp +0 -1107
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.h +0 -383
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.cpp +0 -168
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.h +0 -48
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.cpp +0 -158
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.h +0 -130
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.cpp +0 -80
- package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.h +0 -88
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.cpp +0 -165
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.h +0 -91
- package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.cpp +0 -82
- package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.h +0 -72
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.cpp +0 -237
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.h +0 -145
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.cpp +0 -87
- package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.h +0 -82
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.cpp +0 -73
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.h +0 -84
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.cpp +0 -139
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.h +0 -52
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.cpp +0 -43
- package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.h +0 -28
- package/native/third_party/JoltPhysics/LICENSE +0 -7
- package/native/third_party/JoltPhysics/README.md +0 -173
- package/native/third_party/bloom_jolt/CMakeLists.txt +0 -87
- package/native/third_party/bloom_jolt/include/bloom_jolt.h +0 -519
- package/native/third_party/bloom_jolt/src/bloom_jolt.cpp +0 -1780
package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.cpp
DELETED
|
@@ -1,1804 +0,0 @@
|
|
|
1
|
-
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
|
2
|
-
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
|
|
5
|
-
#include <Jolt/Jolt.h>
|
|
6
|
-
|
|
7
|
-
#include <Jolt/Physics/Constraints/ContactConstraintManager.h>
|
|
8
|
-
#include <Jolt/Physics/Constraints/CalculateSolverSteps.h>
|
|
9
|
-
#include <Jolt/Physics/Body/Body.h>
|
|
10
|
-
#include <Jolt/Physics/PhysicsUpdateContext.h>
|
|
11
|
-
#include <Jolt/Physics/PhysicsSettings.h>
|
|
12
|
-
#include <Jolt/Physics/PhysicsSystem.h>
|
|
13
|
-
#include <Jolt/Physics/IslandBuilder.h>
|
|
14
|
-
#include <Jolt/Physics/DeterminismLog.h>
|
|
15
|
-
#include <Jolt/Core/TempAllocator.h>
|
|
16
|
-
#include <Jolt/Core/QuickSort.h>
|
|
17
|
-
#ifdef JPH_DEBUG_RENDERER
|
|
18
|
-
#include <Jolt/Renderer/DebugRenderer.h>
|
|
19
|
-
#endif // JPH_DEBUG_RENDERER
|
|
20
|
-
|
|
21
|
-
JPH_NAMESPACE_BEGIN
|
|
22
|
-
|
|
23
|
-
using namespace literals;
|
|
24
|
-
|
|
25
|
-
#ifdef JPH_DEBUG_RENDERER
|
|
26
|
-
bool ContactConstraintManager::sDrawContactPoint = false;
|
|
27
|
-
bool ContactConstraintManager::sDrawSupportingFaces = false;
|
|
28
|
-
bool ContactConstraintManager::sDrawContactPointReduction = false;
|
|
29
|
-
bool ContactConstraintManager::sDrawContactManifolds = false;
|
|
30
|
-
#endif // JPH_DEBUG_RENDERER
|
|
31
|
-
|
|
32
|
-
//#define JPH_MANIFOLD_CACHE_DEBUG
|
|
33
|
-
|
|
34
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
35
|
-
// ContactConstraintManager::WorldContactPoint
|
|
36
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
37
|
-
|
|
38
|
-
void ContactConstraintManager::WorldContactPoint::CalculateNonPenetrationConstraintProperties(const Body &inBody1, float inInvMass1, float inInvInertiaScale1, const Body &inBody2, float inInvMass2, float inInvInertiaScale2, RVec3Arg inWorldSpacePosition1, RVec3Arg inWorldSpacePosition2, Vec3Arg inWorldSpaceNormal)
|
|
39
|
-
{
|
|
40
|
-
// Calculate collision points relative to body
|
|
41
|
-
RVec3 p = 0.5_r * (inWorldSpacePosition1 + inWorldSpacePosition2);
|
|
42
|
-
Vec3 r1 = Vec3(p - inBody1.GetCenterOfMassPosition());
|
|
43
|
-
Vec3 r2 = Vec3(p - inBody2.GetCenterOfMassPosition());
|
|
44
|
-
|
|
45
|
-
mNonPenetrationConstraint.CalculateConstraintPropertiesWithMassOverride(inBody1, inInvMass1, inInvInertiaScale1, r1, inBody2, inInvMass2, inInvInertiaScale2, r2, inWorldSpaceNormal);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
template <EMotionType Type1, EMotionType Type2>
|
|
49
|
-
JPH_INLINE void ContactConstraintManager::WorldContactPoint::TemplatedCalculateFrictionAndNonPenetrationConstraintProperties(float inDeltaTime, float inGravityDeltaTimeDotNormal, const Body &inBody1, const Body &inBody2, float inInvM1, float inInvM2, Mat44Arg inInvI1, Mat44Arg inInvI2, RVec3Arg inWorldSpacePosition1, RVec3Arg inWorldSpacePosition2, Vec3Arg inWorldSpaceNormal, Vec3Arg inWorldSpaceTangent1, Vec3Arg inWorldSpaceTangent2, const ContactSettings &inSettings, float inMinVelocityForRestitution)
|
|
50
|
-
{
|
|
51
|
-
JPH_DET_LOG("TemplatedCalculateFrictionAndNonPenetrationConstraintProperties: p1: " << inWorldSpacePosition1 << " p2: " << inWorldSpacePosition2
|
|
52
|
-
<< " normal: " << inWorldSpaceNormal << " tangent1: " << inWorldSpaceTangent1 << " tangent2: " << inWorldSpaceTangent2
|
|
53
|
-
<< " restitution: " << inSettings.mCombinedRestitution << " friction: " << inSettings.mCombinedFriction << " minv: " << inMinVelocityForRestitution
|
|
54
|
-
<< " surface_vel: " << inSettings.mRelativeLinearSurfaceVelocity << " surface_ang: " << inSettings.mRelativeAngularSurfaceVelocity);
|
|
55
|
-
|
|
56
|
-
// Calculate collision points relative to body
|
|
57
|
-
RVec3 p = 0.5_r * (inWorldSpacePosition1 + inWorldSpacePosition2);
|
|
58
|
-
Vec3 r1 = Vec3(p - inBody1.GetCenterOfMassPosition());
|
|
59
|
-
Vec3 r2 = Vec3(p - inBody2.GetCenterOfMassPosition());
|
|
60
|
-
|
|
61
|
-
// The gravity is applied in the beginning of the time step. If we get here, there was a collision
|
|
62
|
-
// at the beginning of the time step, so we've applied too much gravity. This means that our
|
|
63
|
-
// calculated restitution can be too high, so when we apply restitution, we cancel the added
|
|
64
|
-
// velocity due to gravity.
|
|
65
|
-
float gravity_dt_dot_normal;
|
|
66
|
-
|
|
67
|
-
// Calculate velocity of collision points
|
|
68
|
-
Vec3 relative_velocity;
|
|
69
|
-
if constexpr (Type1 != EMotionType::Static && Type2 != EMotionType::Static)
|
|
70
|
-
{
|
|
71
|
-
const MotionProperties *mp1 = inBody1.GetMotionPropertiesUnchecked();
|
|
72
|
-
const MotionProperties *mp2 = inBody2.GetMotionPropertiesUnchecked();
|
|
73
|
-
relative_velocity = mp2->GetPointVelocityCOM(r2) - mp1->GetPointVelocityCOM(r1);
|
|
74
|
-
gravity_dt_dot_normal = inGravityDeltaTimeDotNormal * (mp2->GetGravityFactor() - mp1->GetGravityFactor());
|
|
75
|
-
}
|
|
76
|
-
else if constexpr (Type1 != EMotionType::Static)
|
|
77
|
-
{
|
|
78
|
-
const MotionProperties *mp1 = inBody1.GetMotionPropertiesUnchecked();
|
|
79
|
-
relative_velocity = -mp1->GetPointVelocityCOM(r1);
|
|
80
|
-
gravity_dt_dot_normal = inGravityDeltaTimeDotNormal * mp1->GetGravityFactor();
|
|
81
|
-
}
|
|
82
|
-
else if constexpr (Type2 != EMotionType::Static)
|
|
83
|
-
{
|
|
84
|
-
const MotionProperties *mp2 = inBody2.GetMotionPropertiesUnchecked();
|
|
85
|
-
relative_velocity = mp2->GetPointVelocityCOM(r2);
|
|
86
|
-
gravity_dt_dot_normal = inGravityDeltaTimeDotNormal * mp2->GetGravityFactor();
|
|
87
|
-
}
|
|
88
|
-
else
|
|
89
|
-
{
|
|
90
|
-
JPH_ASSERT(false); // Static vs static makes no sense
|
|
91
|
-
relative_velocity = Vec3::sZero();
|
|
92
|
-
gravity_dt_dot_normal = 0.0f;
|
|
93
|
-
}
|
|
94
|
-
float normal_velocity = relative_velocity.Dot(inWorldSpaceNormal);
|
|
95
|
-
|
|
96
|
-
// How much the shapes are penetrating (> 0 if penetrating, < 0 if separated)
|
|
97
|
-
float penetration = Vec3(inWorldSpacePosition1 - inWorldSpacePosition2).Dot(inWorldSpaceNormal);
|
|
98
|
-
|
|
99
|
-
// If there is no penetration, this is a speculative contact and we will apply a bias to the contact constraint
|
|
100
|
-
// so that the constraint becomes relative_velocity . contact normal > -penetration / delta_time
|
|
101
|
-
// instead of relative_velocity . contact normal > 0
|
|
102
|
-
// See: GDC 2013: "Physics for Game Programmers; Continuous Collision" - Erin Catto
|
|
103
|
-
float speculative_contact_velocity_bias = max(0.0f, -penetration / inDeltaTime);
|
|
104
|
-
|
|
105
|
-
// Determine if the velocity is big enough for restitution
|
|
106
|
-
float normal_velocity_bias;
|
|
107
|
-
if (inSettings.mCombinedRestitution > 0.0f && normal_velocity < -inMinVelocityForRestitution)
|
|
108
|
-
{
|
|
109
|
-
// We have a velocity that is big enough for restitution. This is where speculative contacts don't work
|
|
110
|
-
// great as we have to decide now if we're going to apply the restitution or not. If the relative
|
|
111
|
-
// velocity is big enough for a hit, we apply the restitution (in the end, due to other constraints,
|
|
112
|
-
// the objects may actually not collide and we will have applied restitution incorrectly). Another
|
|
113
|
-
// artifact that occurs because of this approximation is that the object will bounce from its current
|
|
114
|
-
// position rather than from a position where it is touching the other object. This causes the object
|
|
115
|
-
// to appear to move faster for 1 frame (the opposite of time stealing).
|
|
116
|
-
if (normal_velocity < -speculative_contact_velocity_bias)
|
|
117
|
-
normal_velocity_bias = inSettings.mCombinedRestitution * (normal_velocity - gravity_dt_dot_normal);
|
|
118
|
-
else
|
|
119
|
-
// In this case we have predicted that we don't hit the other object, but if we do (due to other constraints changing velocities)
|
|
120
|
-
// the speculative contact will prevent penetration but will not apply restitution leading to another artifact.
|
|
121
|
-
normal_velocity_bias = speculative_contact_velocity_bias;
|
|
122
|
-
}
|
|
123
|
-
else
|
|
124
|
-
{
|
|
125
|
-
// No restitution. We can safely apply our contact velocity bias.
|
|
126
|
-
normal_velocity_bias = speculative_contact_velocity_bias;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
mNonPenetrationConstraint.TemplatedCalculateConstraintProperties<Type1, Type2>(inInvM1, inInvI1, r1, inInvM2, inInvI2, r2, inWorldSpaceNormal, normal_velocity_bias);
|
|
130
|
-
|
|
131
|
-
// Calculate friction part
|
|
132
|
-
if (inSettings.mCombinedFriction > 0.0f)
|
|
133
|
-
{
|
|
134
|
-
// Get surface velocity relative to tangents
|
|
135
|
-
Vec3 ws_surface_velocity = inSettings.mRelativeLinearSurfaceVelocity + inSettings.mRelativeAngularSurfaceVelocity.Cross(r1);
|
|
136
|
-
float surface_velocity1 = inWorldSpaceTangent1.Dot(ws_surface_velocity);
|
|
137
|
-
float surface_velocity2 = inWorldSpaceTangent2.Dot(ws_surface_velocity);
|
|
138
|
-
|
|
139
|
-
// Implement friction as 2 AxisConstraintParts
|
|
140
|
-
mFrictionConstraint1.TemplatedCalculateConstraintProperties<Type1, Type2>(inInvM1, inInvI1, r1, inInvM2, inInvI2, r2, inWorldSpaceTangent1, surface_velocity1);
|
|
141
|
-
mFrictionConstraint2.TemplatedCalculateConstraintProperties<Type1, Type2>(inInvM1, inInvI1, r1, inInvM2, inInvI2, r2, inWorldSpaceTangent2, surface_velocity2);
|
|
142
|
-
}
|
|
143
|
-
else
|
|
144
|
-
{
|
|
145
|
-
// Turn off friction constraint
|
|
146
|
-
mFrictionConstraint1.Deactivate();
|
|
147
|
-
mFrictionConstraint2.Deactivate();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
152
|
-
// ContactConstraintManager::ContactConstraint
|
|
153
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
154
|
-
|
|
155
|
-
#ifdef JPH_DEBUG_RENDERER
|
|
156
|
-
void ContactConstraintManager::ContactConstraint::Draw(DebugRenderer *inRenderer, ColorArg inManifoldColor) const
|
|
157
|
-
{
|
|
158
|
-
if (mContactPoints.empty())
|
|
159
|
-
return;
|
|
160
|
-
|
|
161
|
-
// Get body transforms
|
|
162
|
-
RMat44 transform_body1 = mBody1->GetCenterOfMassTransform();
|
|
163
|
-
RMat44 transform_body2 = mBody2->GetCenterOfMassTransform();
|
|
164
|
-
|
|
165
|
-
RVec3 prev_point = transform_body1 * Vec3::sLoadFloat3Unsafe(mContactPoints.back().mContactPoint->mPosition1);
|
|
166
|
-
for (const WorldContactPoint &wcp : mContactPoints)
|
|
167
|
-
{
|
|
168
|
-
// Test if any lambda from the previous frame was transferred
|
|
169
|
-
float radius = wcp.mNonPenetrationConstraint.GetTotalLambda() == 0.0f
|
|
170
|
-
&& wcp.mFrictionConstraint1.GetTotalLambda() == 0.0f
|
|
171
|
-
&& wcp.mFrictionConstraint2.GetTotalLambda() == 0.0f? 0.1f : 0.2f;
|
|
172
|
-
|
|
173
|
-
RVec3 next_point = transform_body1 * Vec3::sLoadFloat3Unsafe(wcp.mContactPoint->mPosition1);
|
|
174
|
-
inRenderer->DrawMarker(next_point, Color::sCyan, radius);
|
|
175
|
-
inRenderer->DrawMarker(transform_body2 * Vec3::sLoadFloat3Unsafe(wcp.mContactPoint->mPosition2), Color::sPurple, radius);
|
|
176
|
-
|
|
177
|
-
// Draw edge
|
|
178
|
-
inRenderer->DrawArrow(prev_point, next_point, inManifoldColor, 0.05f);
|
|
179
|
-
prev_point = next_point;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Draw normal
|
|
183
|
-
RVec3 wp = transform_body1 * Vec3::sLoadFloat3Unsafe(mContactPoints[0].mContactPoint->mPosition1);
|
|
184
|
-
inRenderer->DrawArrow(wp, wp + GetWorldSpaceNormal(), Color::sRed, 0.05f);
|
|
185
|
-
|
|
186
|
-
// Get tangents
|
|
187
|
-
Vec3 t1, t2;
|
|
188
|
-
GetTangents(t1, t2);
|
|
189
|
-
|
|
190
|
-
// Draw tangents
|
|
191
|
-
inRenderer->DrawLine(wp, wp + t1, Color::sGreen);
|
|
192
|
-
inRenderer->DrawLine(wp, wp + t2, Color::sBlue);
|
|
193
|
-
}
|
|
194
|
-
#endif // JPH_DEBUG_RENDERER
|
|
195
|
-
|
|
196
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
197
|
-
// ContactConstraintManager::CachedContactPoint
|
|
198
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
199
|
-
|
|
200
|
-
void ContactConstraintManager::CachedContactPoint::SaveState(StateRecorder &inStream) const
|
|
201
|
-
{
|
|
202
|
-
inStream.Write(mPosition1);
|
|
203
|
-
inStream.Write(mPosition2);
|
|
204
|
-
inStream.Write(mNonPenetrationLambda);
|
|
205
|
-
inStream.Write(mFrictionLambda);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
void ContactConstraintManager::CachedContactPoint::RestoreState(StateRecorder &inStream)
|
|
209
|
-
{
|
|
210
|
-
inStream.Read(mPosition1);
|
|
211
|
-
inStream.Read(mPosition2);
|
|
212
|
-
inStream.Read(mNonPenetrationLambda);
|
|
213
|
-
inStream.Read(mFrictionLambda);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
217
|
-
// ContactConstraintManager::CachedManifold
|
|
218
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
219
|
-
|
|
220
|
-
void ContactConstraintManager::CachedManifold::SaveState(StateRecorder &inStream) const
|
|
221
|
-
{
|
|
222
|
-
inStream.Write(mContactNormal);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
void ContactConstraintManager::CachedManifold::RestoreState(StateRecorder &inStream)
|
|
226
|
-
{
|
|
227
|
-
inStream.Read(mContactNormal);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
231
|
-
// ContactConstraintManager::CachedBodyPair
|
|
232
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
233
|
-
|
|
234
|
-
void ContactConstraintManager::CachedBodyPair::SaveState(StateRecorder &inStream) const
|
|
235
|
-
{
|
|
236
|
-
inStream.Write(mDeltaPosition);
|
|
237
|
-
inStream.Write(mDeltaRotation);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
void ContactConstraintManager::CachedBodyPair::RestoreState(StateRecorder &inStream)
|
|
241
|
-
{
|
|
242
|
-
inStream.Read(mDeltaPosition);
|
|
243
|
-
inStream.Read(mDeltaRotation);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
247
|
-
// ContactConstraintManager::ManifoldCache
|
|
248
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
249
|
-
|
|
250
|
-
void ContactConstraintManager::ManifoldCache::Init(uint inMaxBodyPairs, uint inMaxContactConstraints, uint inCachedManifoldsSize)
|
|
251
|
-
{
|
|
252
|
-
uint max_body_pairs = min(inMaxBodyPairs, cMaxBodyPairsLimit);
|
|
253
|
-
JPH_ASSERT(max_body_pairs == inMaxBodyPairs, "Cannot support this many body pairs!");
|
|
254
|
-
JPH_ASSERT(inMaxContactConstraints <= cMaxContactConstraintsLimit); // Should have been enforced by caller
|
|
255
|
-
|
|
256
|
-
mAllocator.Init(uint(min(uint64(max_body_pairs) * sizeof(BodyPairMap::KeyValue) + inCachedManifoldsSize, uint64(~uint(0)))));
|
|
257
|
-
|
|
258
|
-
mCachedManifolds.Init(GetNextPowerOf2(inMaxContactConstraints));
|
|
259
|
-
mCachedBodyPairs.Init(GetNextPowerOf2(max_body_pairs));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
void ContactConstraintManager::ManifoldCache::Clear()
|
|
263
|
-
{
|
|
264
|
-
JPH_PROFILE_FUNCTION();
|
|
265
|
-
|
|
266
|
-
mCachedManifolds.Clear();
|
|
267
|
-
mCachedBodyPairs.Clear();
|
|
268
|
-
mAllocator.Clear();
|
|
269
|
-
|
|
270
|
-
#ifdef JPH_ENABLE_ASSERTS
|
|
271
|
-
// Mark as incomplete
|
|
272
|
-
mIsFinalized = false;
|
|
273
|
-
#endif
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
void ContactConstraintManager::ManifoldCache::Prepare(uint inExpectedNumBodyPairs, uint inExpectedNumManifolds)
|
|
277
|
-
{
|
|
278
|
-
// Minimum amount of buckets to use in the hash map
|
|
279
|
-
constexpr uint32 cMinBuckets = 1024;
|
|
280
|
-
|
|
281
|
-
// Use the next higher power of 2 of amount of objects in the cache from last frame to determine the amount of buckets in this frame
|
|
282
|
-
mCachedManifolds.SetNumBuckets(min(max(cMinBuckets, GetNextPowerOf2(inExpectedNumManifolds)), mCachedManifolds.GetMaxBuckets()));
|
|
283
|
-
mCachedBodyPairs.SetNumBuckets(min(max(cMinBuckets, GetNextPowerOf2(inExpectedNumBodyPairs)), mCachedBodyPairs.GetMaxBuckets()));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const ContactConstraintManager::MKeyValue *ContactConstraintManager::ManifoldCache::Find(const SubShapeIDPair &inKey, uint64 inKeyHash) const
|
|
287
|
-
{
|
|
288
|
-
JPH_ASSERT(mIsFinalized);
|
|
289
|
-
return mCachedManifolds.Find(inKey, inKeyHash);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
ContactConstraintManager::MKeyValue *ContactConstraintManager::ManifoldCache::Create(ContactAllocator &ioContactAllocator, const SubShapeIDPair &inKey, uint64 inKeyHash, int inNumContactPoints)
|
|
293
|
-
{
|
|
294
|
-
JPH_ASSERT(!mIsFinalized);
|
|
295
|
-
MKeyValue *kv = mCachedManifolds.Create(ioContactAllocator, inKey, inKeyHash, CachedManifold::sGetRequiredExtraSize(inNumContactPoints));
|
|
296
|
-
if (kv == nullptr)
|
|
297
|
-
{
|
|
298
|
-
ioContactAllocator.mErrors |= EPhysicsUpdateError::ManifoldCacheFull;
|
|
299
|
-
return nullptr;
|
|
300
|
-
}
|
|
301
|
-
kv->GetValue().mNumContactPoints = uint16(inNumContactPoints);
|
|
302
|
-
++ioContactAllocator.mNumManifolds;
|
|
303
|
-
return kv;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
ContactConstraintManager::MKVAndCreated ContactConstraintManager::ManifoldCache::FindOrCreate(ContactAllocator &ioContactAllocator, const SubShapeIDPair &inKey, uint64 inKeyHash, int inNumContactPoints)
|
|
307
|
-
{
|
|
308
|
-
MKeyValue *kv = const_cast<MKeyValue *>(mCachedManifolds.Find(inKey, inKeyHash));
|
|
309
|
-
if (kv != nullptr)
|
|
310
|
-
return { kv, false };
|
|
311
|
-
|
|
312
|
-
return { Create(ioContactAllocator, inKey, inKeyHash, inNumContactPoints), true };
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
uint32 ContactConstraintManager::ManifoldCache::ToHandle(const MKeyValue *inKeyValue) const
|
|
316
|
-
{
|
|
317
|
-
JPH_ASSERT(!mIsFinalized);
|
|
318
|
-
return mCachedManifolds.ToHandle(inKeyValue);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const ContactConstraintManager::MKeyValue *ContactConstraintManager::ManifoldCache::FromHandle(uint32 inHandle) const
|
|
322
|
-
{
|
|
323
|
-
JPH_ASSERT(mIsFinalized);
|
|
324
|
-
return mCachedManifolds.FromHandle(inHandle);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
const ContactConstraintManager::BPKeyValue *ContactConstraintManager::ManifoldCache::Find(const BodyPair &inKey, uint64 inKeyHash) const
|
|
328
|
-
{
|
|
329
|
-
JPH_ASSERT(mIsFinalized);
|
|
330
|
-
return mCachedBodyPairs.Find(inKey, inKeyHash);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
ContactConstraintManager::BPKeyValue *ContactConstraintManager::ManifoldCache::Create(ContactAllocator &ioContactAllocator, const BodyPair &inKey, uint64 inKeyHash)
|
|
334
|
-
{
|
|
335
|
-
JPH_ASSERT(!mIsFinalized);
|
|
336
|
-
BPKeyValue *kv = mCachedBodyPairs.Create(ioContactAllocator, inKey, inKeyHash, 0);
|
|
337
|
-
if (kv == nullptr)
|
|
338
|
-
{
|
|
339
|
-
ioContactAllocator.mErrors |= EPhysicsUpdateError::BodyPairCacheFull;
|
|
340
|
-
return nullptr;
|
|
341
|
-
}
|
|
342
|
-
++ioContactAllocator.mNumBodyPairs;
|
|
343
|
-
return kv;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
void ContactConstraintManager::ManifoldCache::GetAllBodyPairsSorted(Array<const BPKeyValue *> &outAll) const
|
|
347
|
-
{
|
|
348
|
-
JPH_ASSERT(mIsFinalized);
|
|
349
|
-
mCachedBodyPairs.GetAllKeyValues(outAll);
|
|
350
|
-
|
|
351
|
-
// Sort by key
|
|
352
|
-
QuickSort(outAll.begin(), outAll.end(), [](const BPKeyValue *inLHS, const BPKeyValue *inRHS) {
|
|
353
|
-
return inLHS->GetKey() < inRHS->GetKey();
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
void ContactConstraintManager::ManifoldCache::GetAllManifoldsSorted(const CachedBodyPair &inBodyPair, Array<const MKeyValue *> &outAll) const
|
|
358
|
-
{
|
|
359
|
-
JPH_ASSERT(mIsFinalized);
|
|
360
|
-
|
|
361
|
-
// Iterate through the attached manifolds
|
|
362
|
-
for (uint32 handle = inBodyPair.mFirstCachedManifold; handle != ManifoldMap::cInvalidHandle; handle = FromHandle(handle)->GetValue().mNextWithSameBodyPair)
|
|
363
|
-
{
|
|
364
|
-
const MKeyValue *kv = mCachedManifolds.FromHandle(handle);
|
|
365
|
-
outAll.push_back(kv);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// Sort by key
|
|
369
|
-
QuickSort(outAll.begin(), outAll.end(), [](const MKeyValue *inLHS, const MKeyValue *inRHS) {
|
|
370
|
-
return inLHS->GetKey() < inRHS->GetKey();
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
void ContactConstraintManager::ManifoldCache::GetAllCCDManifoldsSorted(Array<const MKeyValue *> &outAll) const
|
|
375
|
-
{
|
|
376
|
-
mCachedManifolds.GetAllKeyValues(outAll);
|
|
377
|
-
|
|
378
|
-
for (int i = (int)outAll.size() - 1; i >= 0; --i)
|
|
379
|
-
if ((outAll[i]->GetValue().mFlags & (uint16)CachedManifold::EFlags::CCDContact) == 0)
|
|
380
|
-
{
|
|
381
|
-
outAll[i] = outAll.back();
|
|
382
|
-
outAll.pop_back();
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// Sort by key
|
|
386
|
-
QuickSort(outAll.begin(), outAll.end(), [](const MKeyValue *inLHS, const MKeyValue *inRHS) {
|
|
387
|
-
return inLHS->GetKey() < inRHS->GetKey();
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
void ContactConstraintManager::ManifoldCache::ContactPointRemovedCallbacks(ContactListener *inListener)
|
|
392
|
-
{
|
|
393
|
-
JPH_PROFILE_FUNCTION();
|
|
394
|
-
|
|
395
|
-
for (MKeyValue &kv : mCachedManifolds)
|
|
396
|
-
if ((kv.GetValue().mFlags & uint16(CachedManifold::EFlags::ContactPersisted)) == 0)
|
|
397
|
-
inListener->OnContactRemoved(kv.GetKey());
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
#ifdef JPH_ENABLE_ASSERTS
|
|
401
|
-
|
|
402
|
-
void ContactConstraintManager::ManifoldCache::Finalize()
|
|
403
|
-
{
|
|
404
|
-
mIsFinalized = true;
|
|
405
|
-
|
|
406
|
-
#ifdef JPH_MANIFOLD_CACHE_DEBUG
|
|
407
|
-
Trace("ManifoldMap:");
|
|
408
|
-
mCachedManifolds.TraceStats();
|
|
409
|
-
Trace("BodyPairMap:");
|
|
410
|
-
mCachedBodyPairs.TraceStats();
|
|
411
|
-
#endif // JPH_MANIFOLD_CACHE_DEBUG
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
#endif
|
|
415
|
-
|
|
416
|
-
void ContactConstraintManager::ManifoldCache::SaveState(StateRecorder &inStream, const StateRecorderFilter *inFilter) const
|
|
417
|
-
{
|
|
418
|
-
JPH_ASSERT(mIsFinalized);
|
|
419
|
-
|
|
420
|
-
// Get contents of cache
|
|
421
|
-
Array<const BPKeyValue *> all_bp;
|
|
422
|
-
GetAllBodyPairsSorted(all_bp);
|
|
423
|
-
|
|
424
|
-
// Determine which ones to save
|
|
425
|
-
Array<const BPKeyValue *> selected_bp;
|
|
426
|
-
if (inFilter == nullptr)
|
|
427
|
-
selected_bp = std::move(all_bp);
|
|
428
|
-
else
|
|
429
|
-
{
|
|
430
|
-
selected_bp.reserve(all_bp.size());
|
|
431
|
-
for (const BPKeyValue *bp_kv : all_bp)
|
|
432
|
-
if (inFilter->ShouldSaveContact(bp_kv->GetKey().mBodyA, bp_kv->GetKey().mBodyB))
|
|
433
|
-
selected_bp.push_back(bp_kv);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Write body pairs
|
|
437
|
-
uint32 num_body_pairs = uint32(selected_bp.size());
|
|
438
|
-
inStream.Write(num_body_pairs);
|
|
439
|
-
for (const BPKeyValue *bp_kv : selected_bp)
|
|
440
|
-
{
|
|
441
|
-
// Write body pair key
|
|
442
|
-
inStream.Write(bp_kv->GetKey());
|
|
443
|
-
|
|
444
|
-
// Write body pair
|
|
445
|
-
const CachedBodyPair &bp = bp_kv->GetValue();
|
|
446
|
-
bp.SaveState(inStream);
|
|
447
|
-
|
|
448
|
-
// Get attached manifolds
|
|
449
|
-
Array<const MKeyValue *> all_m;
|
|
450
|
-
GetAllManifoldsSorted(bp, all_m);
|
|
451
|
-
|
|
452
|
-
// Write num manifolds
|
|
453
|
-
uint32 num_manifolds = uint32(all_m.size());
|
|
454
|
-
inStream.Write(num_manifolds);
|
|
455
|
-
|
|
456
|
-
// Write all manifolds
|
|
457
|
-
for (const MKeyValue *m_kv : all_m)
|
|
458
|
-
{
|
|
459
|
-
// Write key
|
|
460
|
-
inStream.Write(m_kv->GetKey());
|
|
461
|
-
const CachedManifold &cm = m_kv->GetValue();
|
|
462
|
-
JPH_ASSERT((cm.mFlags & (uint16)CachedManifold::EFlags::CCDContact) == 0);
|
|
463
|
-
|
|
464
|
-
// Write amount of contacts
|
|
465
|
-
inStream.Write(cm.mNumContactPoints);
|
|
466
|
-
|
|
467
|
-
// Write manifold
|
|
468
|
-
cm.SaveState(inStream);
|
|
469
|
-
|
|
470
|
-
// Write contact points
|
|
471
|
-
for (uint32 i = 0; i < cm.mNumContactPoints; ++i)
|
|
472
|
-
cm.mContactPoints[i].SaveState(inStream);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// Get CCD manifolds
|
|
477
|
-
Array<const MKeyValue *> all_m;
|
|
478
|
-
GetAllCCDManifoldsSorted(all_m);
|
|
479
|
-
|
|
480
|
-
// Determine which ones to save
|
|
481
|
-
Array<const MKeyValue *> selected_m;
|
|
482
|
-
if (inFilter == nullptr)
|
|
483
|
-
selected_m = std::move(all_m);
|
|
484
|
-
else
|
|
485
|
-
{
|
|
486
|
-
selected_m.reserve(all_m.size());
|
|
487
|
-
for (const MKeyValue *m_kv : all_m)
|
|
488
|
-
if (inFilter->ShouldSaveContact(m_kv->GetKey().GetBody1ID(), m_kv->GetKey().GetBody2ID()))
|
|
489
|
-
selected_m.push_back(m_kv);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// Write all CCD manifold keys
|
|
493
|
-
uint32 num_manifolds = uint32(selected_m.size());
|
|
494
|
-
inStream.Write(num_manifolds);
|
|
495
|
-
for (const MKeyValue *m_kv : selected_m)
|
|
496
|
-
inStream.Write(m_kv->GetKey());
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
bool ContactConstraintManager::ManifoldCache::RestoreState(const ManifoldCache &inReadCache, StateRecorder &inStream, const StateRecorderFilter *inFilter)
|
|
500
|
-
{
|
|
501
|
-
JPH_ASSERT(!mIsFinalized);
|
|
502
|
-
|
|
503
|
-
bool success = true;
|
|
504
|
-
|
|
505
|
-
// Create a contact allocator for restoring the contact cache
|
|
506
|
-
ContactAllocator contact_allocator(GetContactAllocator());
|
|
507
|
-
|
|
508
|
-
// When validating, get all existing body pairs
|
|
509
|
-
Array<const BPKeyValue *> all_bp;
|
|
510
|
-
if (inStream.IsValidating())
|
|
511
|
-
inReadCache.GetAllBodyPairsSorted(all_bp);
|
|
512
|
-
|
|
513
|
-
// Read amount of body pairs
|
|
514
|
-
uint32 num_body_pairs;
|
|
515
|
-
if (inStream.IsValidating())
|
|
516
|
-
num_body_pairs = uint32(all_bp.size());
|
|
517
|
-
inStream.Read(num_body_pairs);
|
|
518
|
-
|
|
519
|
-
// Read entire cache
|
|
520
|
-
for (uint32 i = 0; i < num_body_pairs; ++i)
|
|
521
|
-
{
|
|
522
|
-
// Read key
|
|
523
|
-
BodyPair body_pair_key;
|
|
524
|
-
if (inStream.IsValidating() && i < all_bp.size())
|
|
525
|
-
body_pair_key = all_bp[i]->GetKey();
|
|
526
|
-
inStream.Read(body_pair_key);
|
|
527
|
-
|
|
528
|
-
// Check if we want to restore this contact
|
|
529
|
-
if (inFilter == nullptr || inFilter->ShouldRestoreContact(body_pair_key.mBodyA, body_pair_key.mBodyB))
|
|
530
|
-
{
|
|
531
|
-
// Create new entry for this body pair
|
|
532
|
-
uint64 body_pair_hash = body_pair_key.GetHash();
|
|
533
|
-
BPKeyValue *bp_kv = Create(contact_allocator, body_pair_key, body_pair_hash);
|
|
534
|
-
if (bp_kv == nullptr)
|
|
535
|
-
{
|
|
536
|
-
// Out of cache space
|
|
537
|
-
success = false;
|
|
538
|
-
break;
|
|
539
|
-
}
|
|
540
|
-
CachedBodyPair &bp = bp_kv->GetValue();
|
|
541
|
-
|
|
542
|
-
// Read body pair
|
|
543
|
-
if (inStream.IsValidating() && i < all_bp.size())
|
|
544
|
-
memcpy(&bp, &all_bp[i]->GetValue(), sizeof(CachedBodyPair));
|
|
545
|
-
bp.RestoreState(inStream);
|
|
546
|
-
|
|
547
|
-
// When validating, get all existing manifolds
|
|
548
|
-
Array<const MKeyValue *> all_m;
|
|
549
|
-
if (inStream.IsValidating())
|
|
550
|
-
inReadCache.GetAllManifoldsSorted(all_bp[i]->GetValue(), all_m);
|
|
551
|
-
|
|
552
|
-
// Read amount of manifolds
|
|
553
|
-
uint32 num_manifolds = 0;
|
|
554
|
-
if (inStream.IsValidating())
|
|
555
|
-
num_manifolds = uint32(all_m.size());
|
|
556
|
-
inStream.Read(num_manifolds);
|
|
557
|
-
|
|
558
|
-
uint32 handle = ManifoldMap::cInvalidHandle;
|
|
559
|
-
for (uint32 j = 0; j < num_manifolds; ++j)
|
|
560
|
-
{
|
|
561
|
-
// Read key
|
|
562
|
-
SubShapeIDPair sub_shape_key;
|
|
563
|
-
if (inStream.IsValidating() && j < all_m.size())
|
|
564
|
-
sub_shape_key = all_m[j]->GetKey();
|
|
565
|
-
inStream.Read(sub_shape_key);
|
|
566
|
-
uint64 sub_shape_key_hash = sub_shape_key.GetHash();
|
|
567
|
-
|
|
568
|
-
// Read amount of contact points
|
|
569
|
-
uint16 num_contact_points = 0;
|
|
570
|
-
if (inStream.IsValidating() && j < all_m.size())
|
|
571
|
-
num_contact_points = all_m[j]->GetValue().mNumContactPoints;
|
|
572
|
-
inStream.Read(num_contact_points);
|
|
573
|
-
|
|
574
|
-
// Read manifold
|
|
575
|
-
MKeyValue *m_kv = Create(contact_allocator, sub_shape_key, sub_shape_key_hash, num_contact_points);
|
|
576
|
-
if (m_kv == nullptr)
|
|
577
|
-
{
|
|
578
|
-
// Out of cache space
|
|
579
|
-
success = false;
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
CachedManifold &cm = m_kv->GetValue();
|
|
583
|
-
if (inStream.IsValidating() && j < all_m.size())
|
|
584
|
-
{
|
|
585
|
-
memcpy(&cm, &all_m[j]->GetValue(), CachedManifold::sGetRequiredTotalSize(num_contact_points));
|
|
586
|
-
cm.mNumContactPoints = uint16(num_contact_points); // Restore num contact points
|
|
587
|
-
}
|
|
588
|
-
cm.RestoreState(inStream);
|
|
589
|
-
cm.mNextWithSameBodyPair = handle;
|
|
590
|
-
handle = ToHandle(m_kv);
|
|
591
|
-
|
|
592
|
-
// Read contact points
|
|
593
|
-
for (uint32 k = 0; k < num_contact_points; ++k)
|
|
594
|
-
cm.mContactPoints[k].RestoreState(inStream);
|
|
595
|
-
}
|
|
596
|
-
bp.mFirstCachedManifold = handle;
|
|
597
|
-
}
|
|
598
|
-
else
|
|
599
|
-
{
|
|
600
|
-
// Skip the contact
|
|
601
|
-
CachedBodyPair bp;
|
|
602
|
-
bp.RestoreState(inStream);
|
|
603
|
-
uint32 num_manifolds = 0;
|
|
604
|
-
inStream.Read(num_manifolds);
|
|
605
|
-
for (uint32 j = 0; j < num_manifolds; ++j)
|
|
606
|
-
{
|
|
607
|
-
SubShapeIDPair sub_shape_key;
|
|
608
|
-
inStream.Read(sub_shape_key);
|
|
609
|
-
uint16 num_contact_points;
|
|
610
|
-
inStream.Read(num_contact_points);
|
|
611
|
-
CachedManifold cm;
|
|
612
|
-
cm.RestoreState(inStream);
|
|
613
|
-
for (uint32 k = 0; k < num_contact_points; ++k)
|
|
614
|
-
cm.mContactPoints[0].RestoreState(inStream);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// When validating, get all existing CCD manifolds
|
|
620
|
-
Array<const MKeyValue *> all_m;
|
|
621
|
-
if (inStream.IsValidating())
|
|
622
|
-
inReadCache.GetAllCCDManifoldsSorted(all_m);
|
|
623
|
-
|
|
624
|
-
// Read amount of CCD manifolds
|
|
625
|
-
uint32 num_manifolds;
|
|
626
|
-
if (inStream.IsValidating())
|
|
627
|
-
num_manifolds = uint32(all_m.size());
|
|
628
|
-
inStream.Read(num_manifolds);
|
|
629
|
-
|
|
630
|
-
for (uint32 j = 0; j < num_manifolds; ++j)
|
|
631
|
-
{
|
|
632
|
-
// Read key
|
|
633
|
-
SubShapeIDPair sub_shape_key;
|
|
634
|
-
if (inStream.IsValidating() && j < all_m.size())
|
|
635
|
-
sub_shape_key = all_m[j]->GetKey();
|
|
636
|
-
inStream.Read(sub_shape_key);
|
|
637
|
-
|
|
638
|
-
// Check if we want to restore this contact
|
|
639
|
-
if (inFilter == nullptr || inFilter->ShouldRestoreContact(sub_shape_key.GetBody1ID(), sub_shape_key.GetBody2ID()))
|
|
640
|
-
{
|
|
641
|
-
// Create CCD manifold
|
|
642
|
-
uint64 sub_shape_key_hash = sub_shape_key.GetHash();
|
|
643
|
-
MKeyValue *m_kv = Create(contact_allocator, sub_shape_key, sub_shape_key_hash, 0);
|
|
644
|
-
if (m_kv == nullptr)
|
|
645
|
-
{
|
|
646
|
-
// Out of cache space
|
|
647
|
-
success = false;
|
|
648
|
-
break;
|
|
649
|
-
}
|
|
650
|
-
CachedManifold &cm = m_kv->GetValue();
|
|
651
|
-
cm.mFlags |= (uint16)CachedManifold::EFlags::CCDContact;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
#ifdef JPH_ENABLE_ASSERTS
|
|
656
|
-
// We don't finalize until the last part is restored
|
|
657
|
-
if (inStream.IsLastPart())
|
|
658
|
-
mIsFinalized = true;
|
|
659
|
-
#endif
|
|
660
|
-
|
|
661
|
-
return success;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
665
|
-
// ContactConstraintManager
|
|
666
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
667
|
-
|
|
668
|
-
ContactConstraintManager::ContactConstraintManager(const PhysicsSettings &inPhysicsSettings) :
|
|
669
|
-
mPhysicsSettings(inPhysicsSettings)
|
|
670
|
-
{
|
|
671
|
-
#ifdef JPH_ENABLE_ASSERTS
|
|
672
|
-
// For the first frame mark this empty buffer as finalized
|
|
673
|
-
mCache[mCacheWriteIdx ^ 1].Finalize();
|
|
674
|
-
#endif
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
ContactConstraintManager::~ContactConstraintManager()
|
|
678
|
-
{
|
|
679
|
-
JPH_ASSERT(mConstraints == nullptr);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
void ContactConstraintManager::Init(uint inMaxBodyPairs, uint inMaxContactConstraints)
|
|
683
|
-
{
|
|
684
|
-
// Limit the number of constraints so that the allocation size fits in an unsigned integer
|
|
685
|
-
mMaxConstraints = min(inMaxContactConstraints, cMaxContactConstraintsLimit);
|
|
686
|
-
JPH_ASSERT(mMaxConstraints == inMaxContactConstraints, "Cannot support this many contact constraints!");
|
|
687
|
-
|
|
688
|
-
// Calculate worst case cache usage
|
|
689
|
-
constexpr uint cMaxManifoldSizePerConstraint = sizeof(CachedManifold) + (MaxContactPoints - 1) * sizeof(CachedContactPoint);
|
|
690
|
-
static_assert(cMaxManifoldSizePerConstraint < sizeof(ContactConstraint)); // If not true, then the next line can overflow
|
|
691
|
-
uint cached_manifolds_size = mMaxConstraints * cMaxManifoldSizePerConstraint;
|
|
692
|
-
|
|
693
|
-
// Init the caches
|
|
694
|
-
mCache[0].Init(inMaxBodyPairs, mMaxConstraints, cached_manifolds_size);
|
|
695
|
-
mCache[1].Init(inMaxBodyPairs, mMaxConstraints, cached_manifolds_size);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
void ContactConstraintManager::PrepareConstraintBuffer(PhysicsUpdateContext *inContext)
|
|
699
|
-
{
|
|
700
|
-
// Store context
|
|
701
|
-
mUpdateContext = inContext;
|
|
702
|
-
|
|
703
|
-
// Allocate temporary constraint buffer
|
|
704
|
-
JPH_ASSERT(mConstraints == nullptr);
|
|
705
|
-
mConstraints = (ContactConstraint *)inContext->mTempAllocator->Allocate(mMaxConstraints * sizeof(ContactConstraint));
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
template <EMotionType Type1, EMotionType Type2>
|
|
709
|
-
JPH_INLINE void ContactConstraintManager::TemplatedCalculateFrictionAndNonPenetrationConstraintProperties(ContactConstraint &ioConstraint, const ContactSettings &inSettings, float inDeltaTime, Vec3Arg inGravityDeltaTime, RMat44Arg inTransformBody1, RMat44Arg inTransformBody2, const Body &inBody1, const Body &inBody2)
|
|
710
|
-
{
|
|
711
|
-
// Calculate scaled mass and inertia
|
|
712
|
-
Mat44 inv_i1;
|
|
713
|
-
if constexpr (Type1 == EMotionType::Dynamic)
|
|
714
|
-
{
|
|
715
|
-
const MotionProperties *mp1 = inBody1.GetMotionPropertiesUnchecked();
|
|
716
|
-
inv_i1 = inSettings.mInvInertiaScale1 * mp1->GetInverseInertiaForRotation(inTransformBody1.GetRotation());
|
|
717
|
-
}
|
|
718
|
-
else
|
|
719
|
-
{
|
|
720
|
-
inv_i1 = Mat44::sZero();
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
Mat44 inv_i2;
|
|
724
|
-
if constexpr (Type2 == EMotionType::Dynamic)
|
|
725
|
-
{
|
|
726
|
-
const MotionProperties *mp2 = inBody2.GetMotionPropertiesUnchecked();
|
|
727
|
-
inv_i2 = inSettings.mInvInertiaScale2 * mp2->GetInverseInertiaForRotation(inTransformBody2.GetRotation());
|
|
728
|
-
}
|
|
729
|
-
else
|
|
730
|
-
{
|
|
731
|
-
inv_i2 = Mat44::sZero();
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// Calculate tangents
|
|
735
|
-
Vec3 t1, t2;
|
|
736
|
-
ioConstraint.GetTangents(t1, t2);
|
|
737
|
-
|
|
738
|
-
Vec3 ws_normal = ioConstraint.GetWorldSpaceNormal();
|
|
739
|
-
|
|
740
|
-
// Calculate value for restitution correction
|
|
741
|
-
float gravity_dt_dot_normal = inGravityDeltaTime.Dot(ws_normal);
|
|
742
|
-
|
|
743
|
-
// Setup velocity constraint properties
|
|
744
|
-
float min_velocity_for_restitution = mPhysicsSettings.mMinVelocityForRestitution;
|
|
745
|
-
for (WorldContactPoint &wcp : ioConstraint.mContactPoints)
|
|
746
|
-
{
|
|
747
|
-
RVec3 p1 = inTransformBody1 * Vec3::sLoadFloat3Unsafe(wcp.mContactPoint->mPosition1);
|
|
748
|
-
RVec3 p2 = inTransformBody2 * Vec3::sLoadFloat3Unsafe(wcp.mContactPoint->mPosition2);
|
|
749
|
-
wcp.TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<Type1, Type2>(inDeltaTime, gravity_dt_dot_normal, inBody1, inBody2, ioConstraint.mInvMass1, ioConstraint.mInvMass2, inv_i1, inv_i2, p1, p2, ws_normal, t1, t2, inSettings, min_velocity_for_restitution);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
inline void ContactConstraintManager::CalculateFrictionAndNonPenetrationConstraintProperties(ContactConstraint &ioConstraint, const ContactSettings &inSettings, float inDeltaTime, Vec3Arg inGravityDeltaTime, RMat44Arg inTransformBody1, RMat44Arg inTransformBody2, const Body &inBody1, const Body &inBody2)
|
|
754
|
-
{
|
|
755
|
-
// Dispatch to the correct templated form
|
|
756
|
-
switch (inBody1.GetMotionType())
|
|
757
|
-
{
|
|
758
|
-
case EMotionType::Dynamic:
|
|
759
|
-
switch (inBody2.GetMotionType())
|
|
760
|
-
{
|
|
761
|
-
case EMotionType::Dynamic:
|
|
762
|
-
TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<EMotionType::Dynamic, EMotionType::Dynamic>(ioConstraint, inSettings, inDeltaTime, inGravityDeltaTime, inTransformBody1, inTransformBody2, inBody1, inBody2);
|
|
763
|
-
break;
|
|
764
|
-
|
|
765
|
-
case EMotionType::Kinematic:
|
|
766
|
-
TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<EMotionType::Dynamic, EMotionType::Kinematic>(ioConstraint, inSettings, inDeltaTime, inGravityDeltaTime, inTransformBody1, inTransformBody2, inBody1, inBody2);
|
|
767
|
-
break;
|
|
768
|
-
|
|
769
|
-
case EMotionType::Static:
|
|
770
|
-
TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<EMotionType::Dynamic, EMotionType::Static>(ioConstraint, inSettings, inDeltaTime, inGravityDeltaTime, inTransformBody1, inTransformBody2, inBody1, inBody2);
|
|
771
|
-
break;
|
|
772
|
-
|
|
773
|
-
default:
|
|
774
|
-
JPH_ASSERT(false);
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
break;
|
|
778
|
-
|
|
779
|
-
case EMotionType::Kinematic:
|
|
780
|
-
JPH_ASSERT(inBody2.IsDynamic());
|
|
781
|
-
TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<EMotionType::Kinematic, EMotionType::Dynamic>(ioConstraint, inSettings, inDeltaTime, inGravityDeltaTime, inTransformBody1, inTransformBody2, inBody1, inBody2);
|
|
782
|
-
break;
|
|
783
|
-
|
|
784
|
-
case EMotionType::Static:
|
|
785
|
-
JPH_ASSERT(inBody2.IsDynamic());
|
|
786
|
-
TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<EMotionType::Static, EMotionType::Dynamic>(ioConstraint, inSettings, inDeltaTime, inGravityDeltaTime, inTransformBody1, inTransformBody2, inBody1, inBody2);
|
|
787
|
-
break;
|
|
788
|
-
|
|
789
|
-
default:
|
|
790
|
-
JPH_ASSERT(false);
|
|
791
|
-
break;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
void ContactConstraintManager::GetContactsFromCache(ContactAllocator &ioContactAllocator, Body &inBody1, Body &inBody2, bool &outPairHandled, bool &outConstraintCreated)
|
|
796
|
-
{
|
|
797
|
-
// Start with nothing found and not handled
|
|
798
|
-
outConstraintCreated = false;
|
|
799
|
-
outPairHandled = false;
|
|
800
|
-
|
|
801
|
-
// Swap bodies so that body 1 id < body 2 id
|
|
802
|
-
Body *body1, *body2;
|
|
803
|
-
if (inBody1.GetID() < inBody2.GetID())
|
|
804
|
-
{
|
|
805
|
-
body1 = &inBody1;
|
|
806
|
-
body2 = &inBody2;
|
|
807
|
-
}
|
|
808
|
-
else
|
|
809
|
-
{
|
|
810
|
-
body1 = &inBody2;
|
|
811
|
-
body2 = &inBody1;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
// Find the cached body pair
|
|
815
|
-
BodyPair body_pair_key(body1->GetID(), body2->GetID());
|
|
816
|
-
uint64 body_pair_hash = body_pair_key.GetHash();
|
|
817
|
-
const ManifoldCache &read_cache = mCache[mCacheWriteIdx ^ 1];
|
|
818
|
-
const BPKeyValue *kv = read_cache.Find(body_pair_key, body_pair_hash);
|
|
819
|
-
if (kv == nullptr)
|
|
820
|
-
return;
|
|
821
|
-
const CachedBodyPair &input_cbp = kv->GetValue();
|
|
822
|
-
|
|
823
|
-
// Get relative translation
|
|
824
|
-
Quat inv_r1 = body1->GetRotation().Conjugated();
|
|
825
|
-
Vec3 delta_position = inv_r1 * Vec3(body2->GetCenterOfMassPosition() - body1->GetCenterOfMassPosition());
|
|
826
|
-
|
|
827
|
-
// Get old position delta
|
|
828
|
-
Vec3 old_delta_position = Vec3::sLoadFloat3Unsafe(input_cbp.mDeltaPosition);
|
|
829
|
-
|
|
830
|
-
// Check if bodies are still roughly in the same relative position
|
|
831
|
-
if ((delta_position - old_delta_position).LengthSq() > mPhysicsSettings.mBodyPairCacheMaxDeltaPositionSq)
|
|
832
|
-
return;
|
|
833
|
-
|
|
834
|
-
// Determine relative orientation
|
|
835
|
-
Quat delta_rotation = inv_r1 * body2->GetRotation();
|
|
836
|
-
|
|
837
|
-
// Reconstruct old quaternion delta
|
|
838
|
-
Quat old_delta_rotation = Quat::sLoadFloat3Unsafe(input_cbp.mDeltaRotation);
|
|
839
|
-
|
|
840
|
-
// Check if bodies are still roughly in the same relative orientation
|
|
841
|
-
// The delta between 2 quaternions p and q is: p q^* = [rotation_axis * sin(angle / 2), cos(angle / 2)]
|
|
842
|
-
// From the W component we can extract the angle: cos(angle / 2) = px * qx + py * qy + pz * qz + pw * qw = p . q
|
|
843
|
-
// Since we want to abort if the rotation is smaller than -angle or bigger than angle, we can write the comparison as |p . q| < cos(angle / 2)
|
|
844
|
-
if (abs(delta_rotation.Dot(old_delta_rotation)) < mPhysicsSettings.mBodyPairCacheCosMaxDeltaRotationDiv2)
|
|
845
|
-
return;
|
|
846
|
-
|
|
847
|
-
// The cache is valid, return that we've handled this body pair
|
|
848
|
-
outPairHandled = true;
|
|
849
|
-
|
|
850
|
-
// Copy the cached body pair to this frame
|
|
851
|
-
ManifoldCache &write_cache = mCache[mCacheWriteIdx];
|
|
852
|
-
BPKeyValue *output_bp_kv = write_cache.Create(ioContactAllocator, body_pair_key, body_pair_hash);
|
|
853
|
-
if (output_bp_kv == nullptr)
|
|
854
|
-
return; // Out of cache space
|
|
855
|
-
CachedBodyPair *output_cbp = &output_bp_kv->GetValue();
|
|
856
|
-
memcpy(output_cbp, &input_cbp, sizeof(CachedBodyPair));
|
|
857
|
-
|
|
858
|
-
// If there were no contacts, we have handled the contact
|
|
859
|
-
if (input_cbp.mFirstCachedManifold == ManifoldMap::cInvalidHandle)
|
|
860
|
-
return;
|
|
861
|
-
|
|
862
|
-
// Get body transforms
|
|
863
|
-
RMat44 transform_body1 = body1->GetCenterOfMassTransform();
|
|
864
|
-
RMat44 transform_body2 = body2->GetCenterOfMassTransform();
|
|
865
|
-
|
|
866
|
-
// Get time step
|
|
867
|
-
float delta_time = mUpdateContext->mStepDeltaTime;
|
|
868
|
-
|
|
869
|
-
// Calculate value for restitution correction
|
|
870
|
-
Vec3 gravity_dt = mUpdateContext->mPhysicsSystem->GetGravity() * delta_time;
|
|
871
|
-
|
|
872
|
-
// Copy manifolds
|
|
873
|
-
uint32 output_handle = ManifoldMap::cInvalidHandle;
|
|
874
|
-
uint32 input_handle = input_cbp.mFirstCachedManifold;
|
|
875
|
-
do
|
|
876
|
-
{
|
|
877
|
-
JPH_PROFILE("Add Constraint From Cached Manifold");
|
|
878
|
-
|
|
879
|
-
// Find the existing manifold
|
|
880
|
-
const MKeyValue *input_kv = read_cache.FromHandle(input_handle);
|
|
881
|
-
const SubShapeIDPair &input_key = input_kv->GetKey();
|
|
882
|
-
const CachedManifold &input_cm = input_kv->GetValue();
|
|
883
|
-
JPH_ASSERT(input_cm.mNumContactPoints > 0); // There should be contact points in this manifold!
|
|
884
|
-
|
|
885
|
-
// Create room for manifold in write buffer and copy data
|
|
886
|
-
uint64 input_hash = input_key.GetHash();
|
|
887
|
-
MKeyValue *output_kv = write_cache.Create(ioContactAllocator, input_key, input_hash, input_cm.mNumContactPoints);
|
|
888
|
-
if (output_kv == nullptr)
|
|
889
|
-
break; // Out of cache space
|
|
890
|
-
CachedManifold *output_cm = &output_kv->GetValue();
|
|
891
|
-
memcpy(output_cm, &input_cm, CachedManifold::sGetRequiredTotalSize(input_cm.mNumContactPoints));
|
|
892
|
-
|
|
893
|
-
// Link the object under the body pairs
|
|
894
|
-
output_cm->mNextWithSameBodyPair = output_handle;
|
|
895
|
-
output_handle = write_cache.ToHandle(output_kv);
|
|
896
|
-
|
|
897
|
-
// Calculate default contact settings
|
|
898
|
-
ContactSettings settings;
|
|
899
|
-
settings.mCombinedFriction = mCombineFriction(*body1, input_key.GetSubShapeID1(), *body2, input_key.GetSubShapeID2());
|
|
900
|
-
settings.mCombinedRestitution = mCombineRestitution(*body1, input_key.GetSubShapeID1(), *body2, input_key.GetSubShapeID2());
|
|
901
|
-
settings.mIsSensor = body1->IsSensor() || body2->IsSensor();
|
|
902
|
-
|
|
903
|
-
// Calculate world space contact normal
|
|
904
|
-
Vec3 world_space_normal = transform_body2.Multiply3x3(Vec3::sLoadFloat3Unsafe(output_cm->mContactNormal)).Normalized();
|
|
905
|
-
|
|
906
|
-
// Call contact listener to update settings
|
|
907
|
-
if (mContactListener != nullptr)
|
|
908
|
-
{
|
|
909
|
-
// Convert constraint to manifold structure for callback
|
|
910
|
-
ContactManifold manifold;
|
|
911
|
-
manifold.mWorldSpaceNormal = world_space_normal;
|
|
912
|
-
manifold.mSubShapeID1 = input_key.GetSubShapeID1();
|
|
913
|
-
manifold.mSubShapeID2 = input_key.GetSubShapeID2();
|
|
914
|
-
manifold.mBaseOffset = transform_body1.GetTranslation();
|
|
915
|
-
manifold.mRelativeContactPointsOn1.resize(output_cm->mNumContactPoints);
|
|
916
|
-
manifold.mRelativeContactPointsOn2.resize(output_cm->mNumContactPoints);
|
|
917
|
-
Mat44 local_transform_body2 = transform_body2.PostTranslated(-manifold.mBaseOffset).ToMat44();
|
|
918
|
-
float penetration_depth = -FLT_MAX;
|
|
919
|
-
for (uint32 i = 0; i < output_cm->mNumContactPoints; ++i)
|
|
920
|
-
{
|
|
921
|
-
const CachedContactPoint &ccp = output_cm->mContactPoints[i];
|
|
922
|
-
manifold.mRelativeContactPointsOn1[i] = transform_body1.Multiply3x3(Vec3::sLoadFloat3Unsafe(ccp.mPosition1));
|
|
923
|
-
manifold.mRelativeContactPointsOn2[i] = local_transform_body2 * Vec3::sLoadFloat3Unsafe(ccp.mPosition2);
|
|
924
|
-
penetration_depth = max(penetration_depth, (manifold.mRelativeContactPointsOn1[i] - manifold.mRelativeContactPointsOn2[i]).Dot(world_space_normal));
|
|
925
|
-
}
|
|
926
|
-
manifold.mPenetrationDepth = penetration_depth; // We don't have the penetration depth anymore, estimate it
|
|
927
|
-
|
|
928
|
-
// Notify callback
|
|
929
|
-
mContactListener->OnContactPersisted(*body1, *body2, manifold, settings);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
JPH_ASSERT(settings.mIsSensor || !(body1->IsSensor() || body2->IsSensor()), "Sensors cannot be converted into regular bodies by a contact callback!");
|
|
933
|
-
if (!settings.mIsSensor // If one of the bodies is a sensor, don't actually create the constraint
|
|
934
|
-
&& ((body1->IsDynamic() && settings.mInvMassScale1 != 0.0f) // One of the bodies must have mass to be able to create a contact constraint
|
|
935
|
-
|| (body2->IsDynamic() && settings.mInvMassScale2 != 0.0f)))
|
|
936
|
-
{
|
|
937
|
-
// Add contact constraint in world space for the solver
|
|
938
|
-
uint32 constraint_idx = mNumConstraints++;
|
|
939
|
-
if (constraint_idx >= mMaxConstraints)
|
|
940
|
-
{
|
|
941
|
-
ioContactAllocator.mErrors |= EPhysicsUpdateError::ContactConstraintsFull;
|
|
942
|
-
break;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
// A constraint will be created
|
|
946
|
-
outConstraintCreated = true;
|
|
947
|
-
|
|
948
|
-
ContactConstraint &constraint = mConstraints[constraint_idx];
|
|
949
|
-
new (&constraint) ContactConstraint();
|
|
950
|
-
constraint.mBody1 = body1;
|
|
951
|
-
constraint.mBody2 = body2;
|
|
952
|
-
constraint.mSortKey = input_hash;
|
|
953
|
-
world_space_normal.StoreFloat3(&constraint.mWorldSpaceNormal);
|
|
954
|
-
constraint.mCombinedFriction = settings.mCombinedFriction;
|
|
955
|
-
constraint.mInvMass1 = body1->GetMotionPropertiesUnchecked() != nullptr? settings.mInvMassScale1 * body1->GetMotionPropertiesUnchecked()->GetInverseMassUnchecked() : 0.0f;
|
|
956
|
-
constraint.mInvInertiaScale1 = settings.mInvInertiaScale1;
|
|
957
|
-
constraint.mInvMass2 = body2->GetMotionPropertiesUnchecked() != nullptr? settings.mInvMassScale2 * body2->GetMotionPropertiesUnchecked()->GetInverseMassUnchecked() : 0.0f;
|
|
958
|
-
constraint.mInvInertiaScale2 = settings.mInvInertiaScale2;
|
|
959
|
-
constraint.mContactPoints.resize(output_cm->mNumContactPoints);
|
|
960
|
-
for (uint32 i = 0; i < output_cm->mNumContactPoints; ++i)
|
|
961
|
-
{
|
|
962
|
-
CachedContactPoint &ccp = output_cm->mContactPoints[i];
|
|
963
|
-
WorldContactPoint &wcp = constraint.mContactPoints[i];
|
|
964
|
-
wcp.mNonPenetrationConstraint.SetTotalLambda(ccp.mNonPenetrationLambda);
|
|
965
|
-
wcp.mFrictionConstraint1.SetTotalLambda(ccp.mFrictionLambda[0]);
|
|
966
|
-
wcp.mFrictionConstraint2.SetTotalLambda(ccp.mFrictionLambda[1]);
|
|
967
|
-
wcp.mContactPoint = &ccp;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
JPH_DET_LOG("GetContactsFromCache: id1: " << constraint.mBody1->GetID() << " id2: " << constraint.mBody2->GetID() << " key: " << constraint.mSortKey);
|
|
971
|
-
|
|
972
|
-
// Calculate friction and non-penetration constraint properties for all contact points
|
|
973
|
-
CalculateFrictionAndNonPenetrationConstraintProperties(constraint, settings, delta_time, gravity_dt, transform_body1, transform_body2, *body1, *body2);
|
|
974
|
-
|
|
975
|
-
// Notify island builder
|
|
976
|
-
mUpdateContext->mIslandBuilder->LinkContact(constraint_idx, body1->GetIndexInActiveBodiesInternal(), body2->GetIndexInActiveBodiesInternal());
|
|
977
|
-
|
|
978
|
-
#ifdef JPH_DEBUG_RENDERER
|
|
979
|
-
// Draw the manifold
|
|
980
|
-
if (sDrawContactManifolds)
|
|
981
|
-
constraint.Draw(DebugRenderer::sInstance, Color::sYellow);
|
|
982
|
-
#endif // JPH_DEBUG_RENDERER
|
|
983
|
-
|
|
984
|
-
#ifdef JPH_TRACK_SIMULATION_STATS
|
|
985
|
-
// Track new contact constraints
|
|
986
|
-
if (!body1->IsStatic())
|
|
987
|
-
body1->GetMotionPropertiesUnchecked()->GetSimulationStats().mNumContactConstraints.fetch_add(1, memory_order_relaxed);
|
|
988
|
-
if (!body2->IsStatic())
|
|
989
|
-
body2->GetMotionPropertiesUnchecked()->GetSimulationStats().mNumContactConstraints.fetch_add(1, memory_order_relaxed);
|
|
990
|
-
#endif
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
// Mark contact as persisted so that we won't fire OnContactRemoved callbacks
|
|
994
|
-
input_cm.mFlags |= (uint16)CachedManifold::EFlags::ContactPersisted;
|
|
995
|
-
|
|
996
|
-
// Fetch the next manifold
|
|
997
|
-
input_handle = input_cm.mNextWithSameBodyPair;
|
|
998
|
-
}
|
|
999
|
-
while (input_handle != ManifoldMap::cInvalidHandle);
|
|
1000
|
-
output_cbp->mFirstCachedManifold = output_handle;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
ContactConstraintManager::BodyPairHandle ContactConstraintManager::AddBodyPair(ContactAllocator &ioContactAllocator, const Body &inBody1, const Body &inBody2)
|
|
1004
|
-
{
|
|
1005
|
-
// Swap bodies so that body 1 id < body 2 id
|
|
1006
|
-
const Body *body1, *body2;
|
|
1007
|
-
if (inBody1.GetID() < inBody2.GetID())
|
|
1008
|
-
{
|
|
1009
|
-
body1 = &inBody1;
|
|
1010
|
-
body2 = &inBody2;
|
|
1011
|
-
}
|
|
1012
|
-
else
|
|
1013
|
-
{
|
|
1014
|
-
body1 = &inBody2;
|
|
1015
|
-
body2 = &inBody1;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
// Add an entry
|
|
1019
|
-
BodyPair body_pair_key(body1->GetID(), body2->GetID());
|
|
1020
|
-
uint64 body_pair_hash = body_pair_key.GetHash();
|
|
1021
|
-
BPKeyValue *body_pair_kv = mCache[mCacheWriteIdx].Create(ioContactAllocator, body_pair_key, body_pair_hash);
|
|
1022
|
-
if (body_pair_kv == nullptr)
|
|
1023
|
-
return nullptr; // Out of cache space
|
|
1024
|
-
CachedBodyPair *cbp = &body_pair_kv->GetValue();
|
|
1025
|
-
cbp->mFirstCachedManifold = ManifoldMap::cInvalidHandle;
|
|
1026
|
-
|
|
1027
|
-
// Get relative translation
|
|
1028
|
-
Quat inv_r1 = body1->GetRotation().Conjugated();
|
|
1029
|
-
Vec3 delta_position = inv_r1 * Vec3(body2->GetCenterOfMassPosition() - body1->GetCenterOfMassPosition());
|
|
1030
|
-
|
|
1031
|
-
// Store it
|
|
1032
|
-
delta_position.StoreFloat3(&cbp->mDeltaPosition);
|
|
1033
|
-
|
|
1034
|
-
// Determine relative orientation
|
|
1035
|
-
Quat delta_rotation = inv_r1 * body2->GetRotation();
|
|
1036
|
-
|
|
1037
|
-
// Store it
|
|
1038
|
-
delta_rotation.StoreFloat3(&cbp->mDeltaRotation);
|
|
1039
|
-
|
|
1040
|
-
return cbp;
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
template <EMotionType Type1, EMotionType Type2>
|
|
1044
|
-
bool ContactConstraintManager::TemplatedAddContactConstraint(ContactAllocator &ioContactAllocator, BodyPairHandle inBodyPairHandle, Body &inBody1, Body &inBody2, const ContactManifold &inManifold)
|
|
1045
|
-
{
|
|
1046
|
-
// Calculate hash
|
|
1047
|
-
SubShapeIDPair key { inBody1.GetID(), inManifold.mSubShapeID1, inBody2.GetID(), inManifold.mSubShapeID2 };
|
|
1048
|
-
uint64 key_hash = key.GetHash();
|
|
1049
|
-
|
|
1050
|
-
// Determine number of contact points
|
|
1051
|
-
int num_contact_points = (int)inManifold.mRelativeContactPointsOn1.size();
|
|
1052
|
-
JPH_ASSERT(num_contact_points <= MaxContactPoints);
|
|
1053
|
-
JPH_ASSERT(num_contact_points == (int)inManifold.mRelativeContactPointsOn2.size());
|
|
1054
|
-
|
|
1055
|
-
// Reserve space for new contact cache entry
|
|
1056
|
-
// Note that for dynamic vs dynamic we always require the first body to have a lower body id to get a consistent key
|
|
1057
|
-
// under which to look up the contact
|
|
1058
|
-
ManifoldCache &write_cache = mCache[mCacheWriteIdx];
|
|
1059
|
-
MKeyValue *new_manifold_kv = write_cache.Create(ioContactAllocator, key, key_hash, num_contact_points);
|
|
1060
|
-
if (new_manifold_kv == nullptr)
|
|
1061
|
-
return false; // Out of cache space
|
|
1062
|
-
CachedManifold *new_manifold = &new_manifold_kv->GetValue();
|
|
1063
|
-
|
|
1064
|
-
// Transform the world space normal to the space of body 2 (this is usually the static body)
|
|
1065
|
-
RMat44 inverse_transform_body2 = inBody2.GetInverseCenterOfMassTransform();
|
|
1066
|
-
inverse_transform_body2.Multiply3x3(inManifold.mWorldSpaceNormal).Normalized().StoreFloat3(&new_manifold->mContactNormal);
|
|
1067
|
-
|
|
1068
|
-
// Settings object that gets passed to the callback
|
|
1069
|
-
ContactSettings settings;
|
|
1070
|
-
settings.mCombinedFriction = mCombineFriction(inBody1, inManifold.mSubShapeID1, inBody2, inManifold.mSubShapeID2);
|
|
1071
|
-
settings.mCombinedRestitution = mCombineRestitution(inBody1, inManifold.mSubShapeID1, inBody2, inManifold.mSubShapeID2);
|
|
1072
|
-
settings.mIsSensor = inBody1.IsSensor() || inBody2.IsSensor();
|
|
1073
|
-
|
|
1074
|
-
// Get the contact points for the old cache entry
|
|
1075
|
-
const ManifoldCache &read_cache = mCache[mCacheWriteIdx ^ 1];
|
|
1076
|
-
const MKeyValue *old_manifold_kv = read_cache.Find(key, key_hash);
|
|
1077
|
-
const CachedContactPoint *ccp_start;
|
|
1078
|
-
const CachedContactPoint *ccp_end;
|
|
1079
|
-
if (old_manifold_kv != nullptr)
|
|
1080
|
-
{
|
|
1081
|
-
// Call point persisted listener
|
|
1082
|
-
if (mContactListener != nullptr)
|
|
1083
|
-
mContactListener->OnContactPersisted(inBody1, inBody2, inManifold, settings);
|
|
1084
|
-
|
|
1085
|
-
// Fetch the contact points from the old manifold
|
|
1086
|
-
const CachedManifold *old_manifold = &old_manifold_kv->GetValue();
|
|
1087
|
-
ccp_start = old_manifold->mContactPoints;
|
|
1088
|
-
ccp_end = ccp_start + old_manifold->mNumContactPoints;
|
|
1089
|
-
|
|
1090
|
-
// Mark contact as persisted so that we won't fire OnContactRemoved callbacks
|
|
1091
|
-
old_manifold->mFlags |= (uint16)CachedManifold::EFlags::ContactPersisted;
|
|
1092
|
-
}
|
|
1093
|
-
else
|
|
1094
|
-
{
|
|
1095
|
-
// Call point added listener
|
|
1096
|
-
if (mContactListener != nullptr)
|
|
1097
|
-
mContactListener->OnContactAdded(inBody1, inBody2, inManifold, settings);
|
|
1098
|
-
|
|
1099
|
-
// No contact points available from old manifold
|
|
1100
|
-
ccp_start = nullptr;
|
|
1101
|
-
ccp_end = nullptr;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
// Get inverse transform for body 1
|
|
1105
|
-
RMat44 inverse_transform_body1 = inBody1.GetInverseCenterOfMassTransform();
|
|
1106
|
-
|
|
1107
|
-
bool contact_constraint_created = false;
|
|
1108
|
-
|
|
1109
|
-
// If one of the bodies is a sensor, don't actually create the constraint
|
|
1110
|
-
JPH_ASSERT(settings.mIsSensor || !(inBody1.IsSensor() || inBody2.IsSensor()), "Sensors cannot be converted into regular bodies by a contact callback!");
|
|
1111
|
-
if (!settings.mIsSensor
|
|
1112
|
-
&& ((inBody1.IsDynamic() && settings.mInvMassScale1 != 0.0f) // One of the bodies must have mass to be able to create a contact constraint
|
|
1113
|
-
|| (inBody2.IsDynamic() && settings.mInvMassScale2 != 0.0f)))
|
|
1114
|
-
{
|
|
1115
|
-
// Add contact constraint
|
|
1116
|
-
uint32 constraint_idx = mNumConstraints++;
|
|
1117
|
-
if (constraint_idx >= mMaxConstraints)
|
|
1118
|
-
{
|
|
1119
|
-
ioContactAllocator.mErrors |= EPhysicsUpdateError::ContactConstraintsFull;
|
|
1120
|
-
|
|
1121
|
-
// Manifold has been created already, we're not filling it in, so we need to reset the contact number of points.
|
|
1122
|
-
// Note that we don't hook it up to the body pair cache so that it won't be used as a cache during the next simulation.
|
|
1123
|
-
new_manifold->mNumContactPoints = 0;
|
|
1124
|
-
return false;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
// We will create a contact constraint
|
|
1128
|
-
contact_constraint_created = true;
|
|
1129
|
-
|
|
1130
|
-
ContactConstraint &constraint = mConstraints[constraint_idx];
|
|
1131
|
-
new (&constraint) ContactConstraint();
|
|
1132
|
-
constraint.mBody1 = &inBody1;
|
|
1133
|
-
constraint.mBody2 = &inBody2;
|
|
1134
|
-
constraint.mSortKey = key_hash;
|
|
1135
|
-
inManifold.mWorldSpaceNormal.StoreFloat3(&constraint.mWorldSpaceNormal);
|
|
1136
|
-
constraint.mCombinedFriction = settings.mCombinedFriction;
|
|
1137
|
-
constraint.mInvMass1 = inBody1.GetMotionPropertiesUnchecked() != nullptr? settings.mInvMassScale1 * inBody1.GetMotionPropertiesUnchecked()->GetInverseMassUnchecked() : 0.0f;
|
|
1138
|
-
constraint.mInvInertiaScale1 = settings.mInvInertiaScale1;
|
|
1139
|
-
constraint.mInvMass2 = inBody2.GetMotionPropertiesUnchecked() != nullptr? settings.mInvMassScale2 * inBody2.GetMotionPropertiesUnchecked()->GetInverseMassUnchecked() : 0.0f;
|
|
1140
|
-
constraint.mInvInertiaScale2 = settings.mInvInertiaScale2;
|
|
1141
|
-
|
|
1142
|
-
JPH_DET_LOG("TemplatedAddContactConstraint: id1: " << constraint.mBody1->GetID() << " id2: " << constraint.mBody2->GetID() << " key: " << constraint.mSortKey);
|
|
1143
|
-
|
|
1144
|
-
// Notify island builder
|
|
1145
|
-
mUpdateContext->mIslandBuilder->LinkContact(constraint_idx, inBody1.GetIndexInActiveBodiesInternal(), inBody2.GetIndexInActiveBodiesInternal());
|
|
1146
|
-
|
|
1147
|
-
// Get time step
|
|
1148
|
-
float delta_time = mUpdateContext->mStepDeltaTime;
|
|
1149
|
-
|
|
1150
|
-
// Calculate value for restitution correction
|
|
1151
|
-
float gravity_dt_dot_normal = inManifold.mWorldSpaceNormal.Dot(mUpdateContext->mPhysicsSystem->GetGravity() * delta_time);
|
|
1152
|
-
|
|
1153
|
-
// Calculate scaled mass and inertia
|
|
1154
|
-
float inv_m1;
|
|
1155
|
-
Mat44 inv_i1;
|
|
1156
|
-
if constexpr (Type1 == EMotionType::Dynamic)
|
|
1157
|
-
{
|
|
1158
|
-
const MotionProperties *mp1 = inBody1.GetMotionPropertiesUnchecked();
|
|
1159
|
-
inv_m1 = settings.mInvMassScale1 * mp1->GetInverseMass();
|
|
1160
|
-
inv_i1 = settings.mInvInertiaScale1 * mp1->GetInverseInertiaForRotation(inverse_transform_body1.Transposed3x3());
|
|
1161
|
-
}
|
|
1162
|
-
else
|
|
1163
|
-
{
|
|
1164
|
-
inv_m1 = 0.0f;
|
|
1165
|
-
inv_i1 = Mat44::sZero();
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
float inv_m2;
|
|
1169
|
-
Mat44 inv_i2;
|
|
1170
|
-
if constexpr (Type2 == EMotionType::Dynamic)
|
|
1171
|
-
{
|
|
1172
|
-
const MotionProperties *mp2 = inBody2.GetMotionPropertiesUnchecked();
|
|
1173
|
-
inv_m2 = settings.mInvMassScale2 * mp2->GetInverseMass();
|
|
1174
|
-
inv_i2 = settings.mInvInertiaScale2 * mp2->GetInverseInertiaForRotation(inverse_transform_body2.Transposed3x3());
|
|
1175
|
-
}
|
|
1176
|
-
else
|
|
1177
|
-
{
|
|
1178
|
-
inv_m2 = 0.0f;
|
|
1179
|
-
inv_i2 = Mat44::sZero();
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
// Calculate tangents
|
|
1183
|
-
Vec3 t1, t2;
|
|
1184
|
-
constraint.GetTangents(t1, t2);
|
|
1185
|
-
|
|
1186
|
-
constraint.mContactPoints.resize(num_contact_points);
|
|
1187
|
-
for (int i = 0; i < num_contact_points; ++i)
|
|
1188
|
-
{
|
|
1189
|
-
// Convert to world space and set positions
|
|
1190
|
-
WorldContactPoint &wcp = constraint.mContactPoints[i];
|
|
1191
|
-
RVec3 p1_ws = inManifold.mBaseOffset + inManifold.mRelativeContactPointsOn1[i];
|
|
1192
|
-
RVec3 p2_ws = inManifold.mBaseOffset + inManifold.mRelativeContactPointsOn2[i];
|
|
1193
|
-
|
|
1194
|
-
// Convert to local space to the body
|
|
1195
|
-
Vec3 p1_ls = Vec3(inverse_transform_body1 * p1_ws);
|
|
1196
|
-
Vec3 p2_ls = Vec3(inverse_transform_body2 * p2_ws);
|
|
1197
|
-
|
|
1198
|
-
// Check if we have a close contact point from last update
|
|
1199
|
-
bool lambda_set = false;
|
|
1200
|
-
for (const CachedContactPoint *ccp = ccp_start; ccp < ccp_end; ccp++)
|
|
1201
|
-
if (Vec3::sLoadFloat3Unsafe(ccp->mPosition1).IsClose(p1_ls, mPhysicsSettings.mContactPointPreserveLambdaMaxDistSq)
|
|
1202
|
-
&& Vec3::sLoadFloat3Unsafe(ccp->mPosition2).IsClose(p2_ls, mPhysicsSettings.mContactPointPreserveLambdaMaxDistSq))
|
|
1203
|
-
{
|
|
1204
|
-
// Get lambdas from previous frame
|
|
1205
|
-
wcp.mNonPenetrationConstraint.SetTotalLambda(ccp->mNonPenetrationLambda);
|
|
1206
|
-
wcp.mFrictionConstraint1.SetTotalLambda(ccp->mFrictionLambda[0]);
|
|
1207
|
-
wcp.mFrictionConstraint2.SetTotalLambda(ccp->mFrictionLambda[1]);
|
|
1208
|
-
lambda_set = true;
|
|
1209
|
-
break;
|
|
1210
|
-
}
|
|
1211
|
-
if (!lambda_set)
|
|
1212
|
-
{
|
|
1213
|
-
wcp.mNonPenetrationConstraint.SetTotalLambda(0.0f);
|
|
1214
|
-
wcp.mFrictionConstraint1.SetTotalLambda(0.0f);
|
|
1215
|
-
wcp.mFrictionConstraint2.SetTotalLambda(0.0f);
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
// Create new contact point
|
|
1219
|
-
CachedContactPoint &cp = new_manifold->mContactPoints[i];
|
|
1220
|
-
p1_ls.StoreFloat3(&cp.mPosition1);
|
|
1221
|
-
p2_ls.StoreFloat3(&cp.mPosition2);
|
|
1222
|
-
wcp.mContactPoint = &cp;
|
|
1223
|
-
|
|
1224
|
-
// Setup velocity constraint
|
|
1225
|
-
wcp.TemplatedCalculateFrictionAndNonPenetrationConstraintProperties<Type1, Type2>(delta_time, gravity_dt_dot_normal, inBody1, inBody2, inv_m1, inv_m2, inv_i1, inv_i2, p1_ws, p2_ws, inManifold.mWorldSpaceNormal, t1, t2, settings, mPhysicsSettings.mMinVelocityForRestitution);
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
#ifdef JPH_DEBUG_RENDERER
|
|
1229
|
-
// Draw the manifold
|
|
1230
|
-
if (sDrawContactManifolds)
|
|
1231
|
-
constraint.Draw(DebugRenderer::sInstance, Color::sOrange);
|
|
1232
|
-
#endif // JPH_DEBUG_RENDERER
|
|
1233
|
-
|
|
1234
|
-
#ifdef JPH_TRACK_SIMULATION_STATS
|
|
1235
|
-
// Track new contact constraints
|
|
1236
|
-
if constexpr (Type1 != EMotionType::Static)
|
|
1237
|
-
inBody1.GetMotionPropertiesUnchecked()->GetSimulationStats().mNumContactConstraints.fetch_add(1, memory_order_relaxed);
|
|
1238
|
-
if constexpr (Type2 != EMotionType::Static)
|
|
1239
|
-
inBody2.GetMotionPropertiesUnchecked()->GetSimulationStats().mNumContactConstraints.fetch_add(1, memory_order_relaxed);
|
|
1240
|
-
#endif
|
|
1241
|
-
}
|
|
1242
|
-
else
|
|
1243
|
-
{
|
|
1244
|
-
// Store the contact manifold in the cache
|
|
1245
|
-
for (int i = 0; i < num_contact_points; ++i)
|
|
1246
|
-
{
|
|
1247
|
-
// Convert to local space to the body
|
|
1248
|
-
Vec3 p1 = Vec3(inverse_transform_body1 * (inManifold.mBaseOffset + inManifold.mRelativeContactPointsOn1[i]));
|
|
1249
|
-
Vec3 p2 = Vec3(inverse_transform_body2 * (inManifold.mBaseOffset + inManifold.mRelativeContactPointsOn2[i]));
|
|
1250
|
-
|
|
1251
|
-
// Create new contact point
|
|
1252
|
-
CachedContactPoint &cp = new_manifold->mContactPoints[i];
|
|
1253
|
-
p1.StoreFloat3(&cp.mPosition1);
|
|
1254
|
-
p2.StoreFloat3(&cp.mPosition2);
|
|
1255
|
-
|
|
1256
|
-
// Reset contact impulses, we haven't applied any
|
|
1257
|
-
cp.mNonPenetrationLambda = 0.0f;
|
|
1258
|
-
cp.mFrictionLambda[0] = 0.0f;
|
|
1259
|
-
cp.mFrictionLambda[1] = 0.0f;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
// Store cached contact point in body pair cache
|
|
1264
|
-
CachedBodyPair *cbp = reinterpret_cast<CachedBodyPair *>(inBodyPairHandle);
|
|
1265
|
-
new_manifold->mNextWithSameBodyPair = cbp->mFirstCachedManifold;
|
|
1266
|
-
cbp->mFirstCachedManifold = write_cache.ToHandle(new_manifold_kv);
|
|
1267
|
-
|
|
1268
|
-
// A contact constraint was added
|
|
1269
|
-
return contact_constraint_created;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
bool ContactConstraintManager::AddContactConstraint(ContactAllocator &ioContactAllocator, BodyPairHandle inBodyPairHandle, Body &inBody1, Body &inBody2, const ContactManifold &inManifold)
|
|
1273
|
-
{
|
|
1274
|
-
JPH_PROFILE_FUNCTION();
|
|
1275
|
-
|
|
1276
|
-
JPH_DET_LOG("AddContactConstraint: id1: " << inBody1.GetID() << " id2: " << inBody2.GetID()
|
|
1277
|
-
<< " subshape1: " << inManifold.mSubShapeID1 << " subshape2: " << inManifold.mSubShapeID2
|
|
1278
|
-
<< " normal: " << inManifold.mWorldSpaceNormal << " pendepth: " << inManifold.mPenetrationDepth);
|
|
1279
|
-
|
|
1280
|
-
JPH_ASSERT(inManifold.mWorldSpaceNormal.IsNormalized());
|
|
1281
|
-
|
|
1282
|
-
// Swap bodies so that body 1 id < body 2 id
|
|
1283
|
-
const ContactManifold *manifold;
|
|
1284
|
-
Body *body1, *body2;
|
|
1285
|
-
ContactManifold temp;
|
|
1286
|
-
if (inBody2.GetID() < inBody1.GetID())
|
|
1287
|
-
{
|
|
1288
|
-
body1 = &inBody2;
|
|
1289
|
-
body2 = &inBody1;
|
|
1290
|
-
temp = inManifold.SwapShapes();
|
|
1291
|
-
manifold = &temp;
|
|
1292
|
-
}
|
|
1293
|
-
else
|
|
1294
|
-
{
|
|
1295
|
-
body1 = &inBody1;
|
|
1296
|
-
body2 = &inBody2;
|
|
1297
|
-
manifold = &inManifold;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
// Dispatch to the correct templated form
|
|
1301
|
-
// Note: Non-dynamic vs non-dynamic can happen in this case due to one body being a sensor, so we need to have an extended switch case here
|
|
1302
|
-
switch (body1->GetMotionType())
|
|
1303
|
-
{
|
|
1304
|
-
case EMotionType::Dynamic:
|
|
1305
|
-
{
|
|
1306
|
-
switch (body2->GetMotionType())
|
|
1307
|
-
{
|
|
1308
|
-
case EMotionType::Dynamic:
|
|
1309
|
-
return TemplatedAddContactConstraint<EMotionType::Dynamic, EMotionType::Dynamic>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1310
|
-
|
|
1311
|
-
case EMotionType::Kinematic:
|
|
1312
|
-
return TemplatedAddContactConstraint<EMotionType::Dynamic, EMotionType::Kinematic>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1313
|
-
|
|
1314
|
-
case EMotionType::Static:
|
|
1315
|
-
return TemplatedAddContactConstraint<EMotionType::Dynamic, EMotionType::Static>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1316
|
-
|
|
1317
|
-
default:
|
|
1318
|
-
JPH_ASSERT(false);
|
|
1319
|
-
break;
|
|
1320
|
-
}
|
|
1321
|
-
break;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
case EMotionType::Kinematic:
|
|
1325
|
-
switch (body2->GetMotionType())
|
|
1326
|
-
{
|
|
1327
|
-
case EMotionType::Dynamic:
|
|
1328
|
-
return TemplatedAddContactConstraint<EMotionType::Kinematic, EMotionType::Dynamic>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1329
|
-
|
|
1330
|
-
case EMotionType::Kinematic:
|
|
1331
|
-
return TemplatedAddContactConstraint<EMotionType::Kinematic, EMotionType::Kinematic>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1332
|
-
|
|
1333
|
-
case EMotionType::Static:
|
|
1334
|
-
return TemplatedAddContactConstraint<EMotionType::Kinematic, EMotionType::Static>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1335
|
-
|
|
1336
|
-
default:
|
|
1337
|
-
JPH_ASSERT(false);
|
|
1338
|
-
break;
|
|
1339
|
-
}
|
|
1340
|
-
break;
|
|
1341
|
-
|
|
1342
|
-
case EMotionType::Static:
|
|
1343
|
-
switch (body2->GetMotionType())
|
|
1344
|
-
{
|
|
1345
|
-
case EMotionType::Dynamic:
|
|
1346
|
-
return TemplatedAddContactConstraint<EMotionType::Static, EMotionType::Dynamic>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1347
|
-
|
|
1348
|
-
case EMotionType::Kinematic:
|
|
1349
|
-
return TemplatedAddContactConstraint<EMotionType::Static, EMotionType::Kinematic>(ioContactAllocator, inBodyPairHandle, *body1, *body2, *manifold);
|
|
1350
|
-
|
|
1351
|
-
case EMotionType::Static: // Static vs static not possible
|
|
1352
|
-
default:
|
|
1353
|
-
JPH_ASSERT(false);
|
|
1354
|
-
break;
|
|
1355
|
-
}
|
|
1356
|
-
break;
|
|
1357
|
-
|
|
1358
|
-
default:
|
|
1359
|
-
JPH_ASSERT(false);
|
|
1360
|
-
break;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
return false;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
void ContactConstraintManager::OnCCDContactAdded(ContactAllocator &ioContactAllocator, const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &outSettings)
|
|
1367
|
-
{
|
|
1368
|
-
JPH_ASSERT(inManifold.mWorldSpaceNormal.IsNormalized());
|
|
1369
|
-
|
|
1370
|
-
// Calculate contact settings
|
|
1371
|
-
outSettings.mCombinedFriction = mCombineFriction(inBody1, inManifold.mSubShapeID1, inBody2, inManifold.mSubShapeID2);
|
|
1372
|
-
outSettings.mCombinedRestitution = mCombineRestitution(inBody1, inManifold.mSubShapeID1, inBody2, inManifold.mSubShapeID2);
|
|
1373
|
-
outSettings.mIsSensor = false; // For now, no sensors are supported during CCD
|
|
1374
|
-
|
|
1375
|
-
// The remainder of this function only deals with calling contact callbacks, if there's no contact callback we also don't need to do this work
|
|
1376
|
-
if (mContactListener != nullptr)
|
|
1377
|
-
{
|
|
1378
|
-
// Swap bodies so that body 1 id < body 2 id
|
|
1379
|
-
const ContactManifold *manifold;
|
|
1380
|
-
const Body *body1, *body2;
|
|
1381
|
-
ContactManifold temp;
|
|
1382
|
-
if (inBody2.GetID() < inBody1.GetID())
|
|
1383
|
-
{
|
|
1384
|
-
body1 = &inBody2;
|
|
1385
|
-
body2 = &inBody1;
|
|
1386
|
-
temp = inManifold.SwapShapes();
|
|
1387
|
-
manifold = &temp;
|
|
1388
|
-
}
|
|
1389
|
-
else
|
|
1390
|
-
{
|
|
1391
|
-
body1 = &inBody1;
|
|
1392
|
-
body2 = &inBody2;
|
|
1393
|
-
manifold = &inManifold;
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
// Calculate hash
|
|
1397
|
-
SubShapeIDPair key { body1->GetID(), manifold->mSubShapeID1, body2->GetID(), manifold->mSubShapeID2 };
|
|
1398
|
-
uint64 key_hash = key.GetHash();
|
|
1399
|
-
|
|
1400
|
-
// Check if we already created this contact this physics update
|
|
1401
|
-
ManifoldCache &write_cache = mCache[mCacheWriteIdx];
|
|
1402
|
-
MKVAndCreated new_manifold_kv = write_cache.FindOrCreate(ioContactAllocator, key, key_hash, 0);
|
|
1403
|
-
if (new_manifold_kv.second)
|
|
1404
|
-
{
|
|
1405
|
-
// This contact is new for this physics update, check if previous update we already had this contact.
|
|
1406
|
-
const ManifoldCache &read_cache = mCache[mCacheWriteIdx ^ 1];
|
|
1407
|
-
const MKeyValue *old_manifold_kv = read_cache.Find(key, key_hash);
|
|
1408
|
-
if (old_manifold_kv == nullptr)
|
|
1409
|
-
{
|
|
1410
|
-
// New contact
|
|
1411
|
-
mContactListener->OnContactAdded(*body1, *body2, *manifold, outSettings);
|
|
1412
|
-
}
|
|
1413
|
-
else
|
|
1414
|
-
{
|
|
1415
|
-
// Existing contact
|
|
1416
|
-
mContactListener->OnContactPersisted(*body1, *body2, *manifold, outSettings);
|
|
1417
|
-
|
|
1418
|
-
// Mark contact as persisted so that we won't fire OnContactRemoved callbacks
|
|
1419
|
-
old_manifold_kv->GetValue().mFlags |= (uint16)CachedManifold::EFlags::ContactPersisted;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
// Check if the cache is full
|
|
1423
|
-
if (new_manifold_kv.first != nullptr)
|
|
1424
|
-
{
|
|
1425
|
-
// We don't store any contact points in this manifold as it is not for caching impulses, we only need to know that the contact was created
|
|
1426
|
-
CachedManifold &new_manifold = new_manifold_kv.first->GetValue();
|
|
1427
|
-
new_manifold.mContactNormal = { 0, 0, 0 };
|
|
1428
|
-
new_manifold.mFlags |= (uint16)CachedManifold::EFlags::CCDContact;
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
else
|
|
1432
|
-
{
|
|
1433
|
-
// Already found this contact this physics update.
|
|
1434
|
-
// Note that we can trigger OnContactPersisted multiple times per physics update, but otherwise we have no way of obtaining the settings
|
|
1435
|
-
mContactListener->OnContactPersisted(*body1, *body2, *manifold, outSettings);
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
// If we swapped body1 and body2 we need to swap the mass scales back
|
|
1439
|
-
if (manifold == &temp)
|
|
1440
|
-
{
|
|
1441
|
-
std::swap(outSettings.mInvMassScale1, outSettings.mInvMassScale2);
|
|
1442
|
-
std::swap(outSettings.mInvInertiaScale1, outSettings.mInvInertiaScale2);
|
|
1443
|
-
// Note we do not need to negate the relative surface velocity as it is not applied by the CCD collision constraint
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
JPH_ASSERT(outSettings.mIsSensor || !(inBody1.IsSensor() || inBody2.IsSensor()), "Sensors cannot be converted into regular bodies by a contact callback!");
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
void ContactConstraintManager::SortContacts(uint32 *inConstraintIdxBegin, uint32 *inConstraintIdxEnd) const
|
|
1451
|
-
{
|
|
1452
|
-
JPH_PROFILE_FUNCTION();
|
|
1453
|
-
|
|
1454
|
-
QuickSort(inConstraintIdxBegin, inConstraintIdxEnd, [this](uint32 inLHS, uint32 inRHS) {
|
|
1455
|
-
const ContactConstraint &lhs = mConstraints[inLHS];
|
|
1456
|
-
const ContactConstraint &rhs = mConstraints[inRHS];
|
|
1457
|
-
|
|
1458
|
-
// Most of the time the sort key will be different so we sort on that
|
|
1459
|
-
if (lhs.mSortKey != rhs.mSortKey)
|
|
1460
|
-
return lhs.mSortKey < rhs.mSortKey;
|
|
1461
|
-
|
|
1462
|
-
// If they're equal we use the IDs of body 1 to order
|
|
1463
|
-
if (lhs.mBody1 != rhs.mBody1)
|
|
1464
|
-
return lhs.mBody1->GetID() < rhs.mBody1->GetID();
|
|
1465
|
-
|
|
1466
|
-
// If they're still equal we use the IDs of body 2 to order
|
|
1467
|
-
if (lhs.mBody2 != rhs.mBody2)
|
|
1468
|
-
return lhs.mBody2->GetID() < rhs.mBody2->GetID();
|
|
1469
|
-
|
|
1470
|
-
JPH_ASSERT(inLHS == inRHS, "Hash collision, ordering will be inconsistent");
|
|
1471
|
-
return false;
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
void ContactConstraintManager::FinalizeContactCacheAndCallContactPointRemovedCallbacks(uint inExpectedNumBodyPairs, uint inExpectedNumManifolds)
|
|
1476
|
-
{
|
|
1477
|
-
JPH_PROFILE_FUNCTION();
|
|
1478
|
-
|
|
1479
|
-
#ifdef JPH_ENABLE_ASSERTS
|
|
1480
|
-
// Mark cache as finalized
|
|
1481
|
-
ManifoldCache &old_write_cache = mCache[mCacheWriteIdx];
|
|
1482
|
-
old_write_cache.Finalize();
|
|
1483
|
-
|
|
1484
|
-
// Check that the count of body pairs and manifolds that we tracked outside of the cache (to avoid contention on an atomic) is correct
|
|
1485
|
-
JPH_ASSERT(old_write_cache.GetNumBodyPairs() == inExpectedNumBodyPairs);
|
|
1486
|
-
JPH_ASSERT(old_write_cache.GetNumManifolds() == inExpectedNumManifolds);
|
|
1487
|
-
#endif
|
|
1488
|
-
|
|
1489
|
-
// Buffers are now complete, make write buffer the read buffer
|
|
1490
|
-
mCacheWriteIdx ^= 1;
|
|
1491
|
-
|
|
1492
|
-
// Get the old read cache / new write cache
|
|
1493
|
-
ManifoldCache &old_read_cache = mCache[mCacheWriteIdx];
|
|
1494
|
-
|
|
1495
|
-
// Call the contact point removal callbacks
|
|
1496
|
-
if (mContactListener != nullptr)
|
|
1497
|
-
old_read_cache.ContactPointRemovedCallbacks(mContactListener);
|
|
1498
|
-
|
|
1499
|
-
// We're done with the old read cache now
|
|
1500
|
-
old_read_cache.Clear();
|
|
1501
|
-
|
|
1502
|
-
// Use the amount of contacts from the last iteration to determine the amount of buckets to use in the hash map for the next iteration
|
|
1503
|
-
old_read_cache.Prepare(inExpectedNumBodyPairs, inExpectedNumManifolds);
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
bool ContactConstraintManager::WereBodiesInContact(const BodyID &inBody1ID, const BodyID &inBody2ID) const
|
|
1507
|
-
{
|
|
1508
|
-
// The body pair needs to be in the cache and it needs to have a manifold (otherwise it's just a record indicating that there are no collisions)
|
|
1509
|
-
const ManifoldCache &read_cache = mCache[mCacheWriteIdx ^ 1];
|
|
1510
|
-
BodyPair key;
|
|
1511
|
-
if (inBody1ID < inBody2ID)
|
|
1512
|
-
key = BodyPair(inBody1ID, inBody2ID);
|
|
1513
|
-
else
|
|
1514
|
-
key = BodyPair(inBody2ID, inBody1ID);
|
|
1515
|
-
uint64 key_hash = key.GetHash();
|
|
1516
|
-
const BPKeyValue *kv = read_cache.Find(key, key_hash);
|
|
1517
|
-
return kv != nullptr && kv->GetValue().mFirstCachedManifold != ManifoldMap::cInvalidHandle;
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
template <EMotionType Type1, EMotionType Type2>
|
|
1521
|
-
JPH_INLINE void ContactConstraintManager::sWarmStartConstraint(ContactConstraint &ioConstraint, MotionProperties *ioMotionProperties1, MotionProperties *ioMotionProperties2, float inWarmStartImpulseRatio)
|
|
1522
|
-
{
|
|
1523
|
-
// Calculate tangents
|
|
1524
|
-
Vec3 t1, t2;
|
|
1525
|
-
ioConstraint.GetTangents(t1, t2);
|
|
1526
|
-
|
|
1527
|
-
Vec3 ws_normal = ioConstraint.GetWorldSpaceNormal();
|
|
1528
|
-
|
|
1529
|
-
for (WorldContactPoint &wcp : ioConstraint.mContactPoints)
|
|
1530
|
-
{
|
|
1531
|
-
// Warm starting: Apply impulse from last frame
|
|
1532
|
-
if (wcp.mFrictionConstraint1.IsActive() || wcp.mFrictionConstraint2.IsActive())
|
|
1533
|
-
{
|
|
1534
|
-
wcp.mFrictionConstraint1.TemplatedWarmStart<Type1, Type2>(ioMotionProperties1, ioConstraint.mInvMass1, ioMotionProperties2, ioConstraint.mInvMass2, t1, inWarmStartImpulseRatio);
|
|
1535
|
-
wcp.mFrictionConstraint2.TemplatedWarmStart<Type1, Type2>(ioMotionProperties1, ioConstraint.mInvMass1, ioMotionProperties2, ioConstraint.mInvMass2, t2, inWarmStartImpulseRatio);
|
|
1536
|
-
}
|
|
1537
|
-
wcp.mNonPenetrationConstraint.TemplatedWarmStart<Type1, Type2>(ioMotionProperties1, ioConstraint.mInvMass1, ioMotionProperties2, ioConstraint.mInvMass2, ws_normal, inWarmStartImpulseRatio);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
template <class MotionPropertiesCallback>
|
|
1542
|
-
void ContactConstraintManager::WarmStartVelocityConstraints(const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd, float inWarmStartImpulseRatio, MotionPropertiesCallback &ioCallback)
|
|
1543
|
-
{
|
|
1544
|
-
JPH_PROFILE_FUNCTION();
|
|
1545
|
-
|
|
1546
|
-
for (const uint32 *constraint_idx = inConstraintIdxBegin; constraint_idx < inConstraintIdxEnd; ++constraint_idx)
|
|
1547
|
-
{
|
|
1548
|
-
ContactConstraint &constraint = mConstraints[*constraint_idx];
|
|
1549
|
-
|
|
1550
|
-
// Fetch bodies
|
|
1551
|
-
Body &body1 = *constraint.mBody1;
|
|
1552
|
-
EMotionType motion_type1 = body1.GetMotionType();
|
|
1553
|
-
MotionProperties *motion_properties1 = body1.GetMotionPropertiesUnchecked();
|
|
1554
|
-
|
|
1555
|
-
Body &body2 = *constraint.mBody2;
|
|
1556
|
-
EMotionType motion_type2 = body2.GetMotionType();
|
|
1557
|
-
MotionProperties *motion_properties2 = body2.GetMotionPropertiesUnchecked();
|
|
1558
|
-
|
|
1559
|
-
// Dispatch to the correct templated form
|
|
1560
|
-
// Note: Warm starting doesn't differentiate between kinematic/static bodies so we handle both as static bodies
|
|
1561
|
-
if (motion_type1 == EMotionType::Dynamic)
|
|
1562
|
-
{
|
|
1563
|
-
if (motion_type2 == EMotionType::Dynamic)
|
|
1564
|
-
{
|
|
1565
|
-
sWarmStartConstraint<EMotionType::Dynamic, EMotionType::Dynamic>(constraint, motion_properties1, motion_properties2, inWarmStartImpulseRatio);
|
|
1566
|
-
|
|
1567
|
-
ioCallback(motion_properties2);
|
|
1568
|
-
}
|
|
1569
|
-
else
|
|
1570
|
-
sWarmStartConstraint<EMotionType::Dynamic, EMotionType::Static>(constraint, motion_properties1, motion_properties2, inWarmStartImpulseRatio);
|
|
1571
|
-
|
|
1572
|
-
ioCallback(motion_properties1);
|
|
1573
|
-
}
|
|
1574
|
-
else
|
|
1575
|
-
{
|
|
1576
|
-
JPH_ASSERT(motion_type2 == EMotionType::Dynamic);
|
|
1577
|
-
|
|
1578
|
-
sWarmStartConstraint<EMotionType::Static, EMotionType::Dynamic>(constraint, motion_properties1, motion_properties2, inWarmStartImpulseRatio);
|
|
1579
|
-
|
|
1580
|
-
ioCallback(motion_properties2);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// Specialize for the two body callback types
|
|
1586
|
-
template void ContactConstraintManager::WarmStartVelocityConstraints<CalculateSolverSteps>(const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd, float inWarmStartImpulseRatio, CalculateSolverSteps &ioCallback);
|
|
1587
|
-
template void ContactConstraintManager::WarmStartVelocityConstraints<DummyCalculateSolverSteps>(const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd, float inWarmStartImpulseRatio, DummyCalculateSolverSteps &ioCallback);
|
|
1588
|
-
|
|
1589
|
-
template <EMotionType Type1, EMotionType Type2>
|
|
1590
|
-
JPH_INLINE bool ContactConstraintManager::sSolveVelocityConstraint(ContactConstraint &ioConstraint, MotionProperties *ioMotionProperties1, MotionProperties *ioMotionProperties2)
|
|
1591
|
-
{
|
|
1592
|
-
bool any_impulse_applied = false;
|
|
1593
|
-
|
|
1594
|
-
// Calculate tangents
|
|
1595
|
-
Vec3 t1, t2;
|
|
1596
|
-
ioConstraint.GetTangents(t1, t2);
|
|
1597
|
-
|
|
1598
|
-
// First apply all friction constraints (non-penetration is more important than friction)
|
|
1599
|
-
for (WorldContactPoint &wcp : ioConstraint.mContactPoints)
|
|
1600
|
-
{
|
|
1601
|
-
// Check if friction is enabled
|
|
1602
|
-
if (wcp.mFrictionConstraint1.IsActive() || wcp.mFrictionConstraint2.IsActive())
|
|
1603
|
-
{
|
|
1604
|
-
// Calculate impulse to stop motion in tangential direction
|
|
1605
|
-
float lambda1 = wcp.mFrictionConstraint1.TemplatedSolveVelocityConstraintGetTotalLambda<Type1, Type2>(ioMotionProperties1, ioMotionProperties2, t1);
|
|
1606
|
-
float lambda2 = wcp.mFrictionConstraint2.TemplatedSolveVelocityConstraintGetTotalLambda<Type1, Type2>(ioMotionProperties1, ioMotionProperties2, t2);
|
|
1607
|
-
float total_lambda_sq = Square(lambda1) + Square(lambda2);
|
|
1608
|
-
|
|
1609
|
-
// Calculate max impulse that can be applied. Note that we're using the non-penetration impulse from the previous iteration here.
|
|
1610
|
-
// We do this because non-penetration is more important so is solved last (the last things that are solved in an iterative solver
|
|
1611
|
-
// contribute the most).
|
|
1612
|
-
float max_lambda_f = ioConstraint.mCombinedFriction * wcp.mNonPenetrationConstraint.GetTotalLambda();
|
|
1613
|
-
|
|
1614
|
-
// If the total lambda that we will apply is too large, scale it back
|
|
1615
|
-
if (total_lambda_sq > Square(max_lambda_f))
|
|
1616
|
-
{
|
|
1617
|
-
float scale = max_lambda_f / sqrt(total_lambda_sq);
|
|
1618
|
-
lambda1 *= scale;
|
|
1619
|
-
lambda2 *= scale;
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
// Apply the friction impulse
|
|
1623
|
-
if (wcp.mFrictionConstraint1.TemplatedSolveVelocityConstraintApplyLambda<Type1, Type2>(ioMotionProperties1, ioConstraint.mInvMass1, ioMotionProperties2, ioConstraint.mInvMass2, t1, lambda1))
|
|
1624
|
-
any_impulse_applied = true;
|
|
1625
|
-
if (wcp.mFrictionConstraint2.TemplatedSolveVelocityConstraintApplyLambda<Type1, Type2>(ioMotionProperties1, ioConstraint.mInvMass1, ioMotionProperties2, ioConstraint.mInvMass2, t2, lambda2))
|
|
1626
|
-
any_impulse_applied = true;
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
Vec3 ws_normal = ioConstraint.GetWorldSpaceNormal();
|
|
1631
|
-
|
|
1632
|
-
// Then apply all non-penetration constraints
|
|
1633
|
-
for (WorldContactPoint &wcp : ioConstraint.mContactPoints)
|
|
1634
|
-
{
|
|
1635
|
-
// Solve non penetration velocities
|
|
1636
|
-
if (wcp.mNonPenetrationConstraint.TemplatedSolveVelocityConstraint<Type1, Type2>(ioMotionProperties1, ioConstraint.mInvMass1, ioMotionProperties2, ioConstraint.mInvMass2, ws_normal, 0.0f, FLT_MAX))
|
|
1637
|
-
any_impulse_applied = true;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
return any_impulse_applied;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
bool ContactConstraintManager::SolveVelocityConstraints(const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd)
|
|
1644
|
-
{
|
|
1645
|
-
JPH_PROFILE_FUNCTION();
|
|
1646
|
-
|
|
1647
|
-
bool any_impulse_applied = false;
|
|
1648
|
-
|
|
1649
|
-
for (const uint32 *constraint_idx = inConstraintIdxBegin; constraint_idx < inConstraintIdxEnd; ++constraint_idx)
|
|
1650
|
-
{
|
|
1651
|
-
ContactConstraint &constraint = mConstraints[*constraint_idx];
|
|
1652
|
-
|
|
1653
|
-
// Fetch bodies
|
|
1654
|
-
Body &body1 = *constraint.mBody1;
|
|
1655
|
-
EMotionType motion_type1 = body1.GetMotionType();
|
|
1656
|
-
MotionProperties *motion_properties1 = body1.GetMotionPropertiesUnchecked();
|
|
1657
|
-
|
|
1658
|
-
Body &body2 = *constraint.mBody2;
|
|
1659
|
-
EMotionType motion_type2 = body2.GetMotionType();
|
|
1660
|
-
MotionProperties *motion_properties2 = body2.GetMotionPropertiesUnchecked();
|
|
1661
|
-
|
|
1662
|
-
// Dispatch to the correct templated form
|
|
1663
|
-
switch (motion_type1)
|
|
1664
|
-
{
|
|
1665
|
-
case EMotionType::Dynamic:
|
|
1666
|
-
switch (motion_type2)
|
|
1667
|
-
{
|
|
1668
|
-
case EMotionType::Dynamic:
|
|
1669
|
-
any_impulse_applied |= sSolveVelocityConstraint<EMotionType::Dynamic, EMotionType::Dynamic>(constraint, motion_properties1, motion_properties2);
|
|
1670
|
-
break;
|
|
1671
|
-
|
|
1672
|
-
case EMotionType::Kinematic:
|
|
1673
|
-
any_impulse_applied |= sSolveVelocityConstraint<EMotionType::Dynamic, EMotionType::Kinematic>(constraint, motion_properties1, motion_properties2);
|
|
1674
|
-
break;
|
|
1675
|
-
|
|
1676
|
-
case EMotionType::Static:
|
|
1677
|
-
any_impulse_applied |= sSolveVelocityConstraint<EMotionType::Dynamic, EMotionType::Static>(constraint, motion_properties1, motion_properties2);
|
|
1678
|
-
break;
|
|
1679
|
-
|
|
1680
|
-
default:
|
|
1681
|
-
JPH_ASSERT(false);
|
|
1682
|
-
break;
|
|
1683
|
-
}
|
|
1684
|
-
break;
|
|
1685
|
-
|
|
1686
|
-
case EMotionType::Kinematic:
|
|
1687
|
-
JPH_ASSERT(motion_type2 == EMotionType::Dynamic);
|
|
1688
|
-
any_impulse_applied |= sSolveVelocityConstraint<EMotionType::Kinematic, EMotionType::Dynamic>(constraint, motion_properties1, motion_properties2);
|
|
1689
|
-
break;
|
|
1690
|
-
|
|
1691
|
-
case EMotionType::Static:
|
|
1692
|
-
JPH_ASSERT(motion_type2 == EMotionType::Dynamic);
|
|
1693
|
-
any_impulse_applied |= sSolveVelocityConstraint<EMotionType::Static, EMotionType::Dynamic>(constraint, motion_properties1, motion_properties2);
|
|
1694
|
-
break;
|
|
1695
|
-
|
|
1696
|
-
default:
|
|
1697
|
-
JPH_ASSERT(false);
|
|
1698
|
-
break;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1702
|
-
return any_impulse_applied;
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
void ContactConstraintManager::StoreAppliedImpulses(const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd) const
|
|
1706
|
-
{
|
|
1707
|
-
// Copy back total applied impulse to cache for the next frame
|
|
1708
|
-
for (const uint32 *constraint_idx = inConstraintIdxBegin; constraint_idx < inConstraintIdxEnd; ++constraint_idx)
|
|
1709
|
-
{
|
|
1710
|
-
const ContactConstraint &constraint = mConstraints[*constraint_idx];
|
|
1711
|
-
|
|
1712
|
-
for (const WorldContactPoint &wcp : constraint.mContactPoints)
|
|
1713
|
-
{
|
|
1714
|
-
wcp.mContactPoint->mNonPenetrationLambda = wcp.mNonPenetrationConstraint.GetTotalLambda();
|
|
1715
|
-
wcp.mContactPoint->mFrictionLambda[0] = wcp.mFrictionConstraint1.GetTotalLambda();
|
|
1716
|
-
wcp.mContactPoint->mFrictionLambda[1] = wcp.mFrictionConstraint2.GetTotalLambda();
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
bool ContactConstraintManager::SolvePositionConstraints(const uint32 *inConstraintIdxBegin, const uint32 *inConstraintIdxEnd)
|
|
1722
|
-
{
|
|
1723
|
-
JPH_PROFILE_FUNCTION();
|
|
1724
|
-
|
|
1725
|
-
bool any_impulse_applied = false;
|
|
1726
|
-
|
|
1727
|
-
for (const uint32 *constraint_idx = inConstraintIdxBegin; constraint_idx < inConstraintIdxEnd; ++constraint_idx)
|
|
1728
|
-
{
|
|
1729
|
-
ContactConstraint &constraint = mConstraints[*constraint_idx];
|
|
1730
|
-
|
|
1731
|
-
// Fetch bodies
|
|
1732
|
-
Body &body1 = *constraint.mBody1;
|
|
1733
|
-
Body &body2 = *constraint.mBody2;
|
|
1734
|
-
|
|
1735
|
-
// Get transforms
|
|
1736
|
-
RMat44 transform1 = body1.GetCenterOfMassTransform();
|
|
1737
|
-
RMat44 transform2 = body2.GetCenterOfMassTransform();
|
|
1738
|
-
|
|
1739
|
-
Vec3 ws_normal = constraint.GetWorldSpaceNormal();
|
|
1740
|
-
|
|
1741
|
-
for (WorldContactPoint &wcp : constraint.mContactPoints)
|
|
1742
|
-
{
|
|
1743
|
-
// Calculate new contact point positions in world space (the bodies may have moved)
|
|
1744
|
-
RVec3 p1 = transform1 * Vec3::sLoadFloat3Unsafe(wcp.mContactPoint->mPosition1);
|
|
1745
|
-
RVec3 p2 = transform2 * Vec3::sLoadFloat3Unsafe(wcp.mContactPoint->mPosition2);
|
|
1746
|
-
|
|
1747
|
-
// Calculate separation along the normal (negative if interpenetrating)
|
|
1748
|
-
// Allow a little penetration by default (PhysicsSettings::mPenetrationSlop) to avoid jittering between contact/no-contact which wipes out the contact cache and warm start impulses
|
|
1749
|
-
// Clamp penetration to a max PhysicsSettings::mMaxPenetrationDistance so that we don't apply a huge impulse if we're penetrating a lot
|
|
1750
|
-
float separation = max(Vec3(p2 - p1).Dot(ws_normal) + mPhysicsSettings.mPenetrationSlop, -mPhysicsSettings.mMaxPenetrationDistance);
|
|
1751
|
-
|
|
1752
|
-
// Only enforce constraint when separation < 0 (otherwise we're apart)
|
|
1753
|
-
if (separation < 0.0f)
|
|
1754
|
-
{
|
|
1755
|
-
// Update constraint properties (bodies may have moved)
|
|
1756
|
-
wcp.CalculateNonPenetrationConstraintProperties(body1, constraint.mInvMass1, constraint.mInvInertiaScale1, body2, constraint.mInvMass2, constraint.mInvInertiaScale2, p1, p2, ws_normal);
|
|
1757
|
-
|
|
1758
|
-
// Solve position errors
|
|
1759
|
-
if (wcp.mNonPenetrationConstraint.SolvePositionConstraintWithMassOverride(body1, constraint.mInvMass1, body2, constraint.mInvMass2, ws_normal, separation, mPhysicsSettings.mBaumgarte))
|
|
1760
|
-
any_impulse_applied = true;
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
return any_impulse_applied;
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
void ContactConstraintManager::RecycleConstraintBuffer()
|
|
1769
|
-
{
|
|
1770
|
-
// Reset constraint array
|
|
1771
|
-
mNumConstraints = 0;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
void ContactConstraintManager::FinishConstraintBuffer()
|
|
1775
|
-
{
|
|
1776
|
-
// Free constraints buffer
|
|
1777
|
-
mUpdateContext->mTempAllocator->Free(mConstraints, mMaxConstraints * sizeof(ContactConstraint));
|
|
1778
|
-
mConstraints = nullptr;
|
|
1779
|
-
mNumConstraints = 0;
|
|
1780
|
-
|
|
1781
|
-
// Reset update context
|
|
1782
|
-
mUpdateContext = nullptr;
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
void ContactConstraintManager::SaveState(StateRecorder &inStream, const StateRecorderFilter *inFilter) const
|
|
1786
|
-
{
|
|
1787
|
-
mCache[mCacheWriteIdx ^ 1].SaveState(inStream, inFilter);
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
bool ContactConstraintManager::RestoreState(StateRecorder &inStream, const StateRecorderFilter *inFilter)
|
|
1791
|
-
{
|
|
1792
|
-
bool success = mCache[mCacheWriteIdx].RestoreState(mCache[mCacheWriteIdx ^ 1], inStream, inFilter);
|
|
1793
|
-
|
|
1794
|
-
// If this is the last part, the cache is finalized
|
|
1795
|
-
if (inStream.IsLastPart())
|
|
1796
|
-
{
|
|
1797
|
-
mCacheWriteIdx ^= 1;
|
|
1798
|
-
mCache[mCacheWriteIdx].Clear();
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
return success;
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
JPH_NAMESPACE_END
|