Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions modules/jolt_physics/objects/jolt_soft_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void JoltSoftBody3D::_space_changing() {
if (jolt_body != nullptr) {
jolt_settings = new JPH::SoftBodyCreationSettings(jolt_body->GetSoftBodyCreationSettings());
jolt_settings->mSettings = nullptr;
jolt_settings->mVertexRadius = JoltProjectSettings::soft_body_point_radius;
}

_deref_shared_data();
Expand Down Expand Up @@ -146,8 +147,6 @@ bool JoltSoftBody3D::_ref_shared_data() {
LocalVector<int> &mesh_to_physics = iter_shared_data->value.mesh_to_physics;

JPH::SoftBodySharedSettings &settings = *iter_shared_data->value.settings;
settings.mVertexRadius = JoltProjectSettings::soft_body_point_radius;

JPH::Array<JPH::SoftBodySharedSettings::Vertex> &physics_vertices = settings.mVertices;
JPH::Array<JPH::SoftBodySharedSettings::Face> &physics_faces = settings.mFaces;

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ Files generated from upstream source:
## jolt_physics

- Upstream: https://github.com/jrouwe/JoltPhysics
- Version: 5.3.0 (0373ec0dd762e4bc2f6acdb08371ee84fa23c6db, 2025)
- Version: 5.4.0 (036ea7b1d717b3e713ac9d8cbd47118fb9cd5d60, 2025)
- License: MIT

Files extracted from upstream source:
Expand Down
3 changes: 3 additions & 0 deletions thirdparty/jolt_physics/Jolt/ConfigurationString.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ inline const char *GetConfigurationString()
#ifdef JPH_PROFILE_ENABLED
"(Profile) "
#endif
#ifdef JPH_EXTERNAL_PROFILE
"(External Profile) "
#endif
#if defined(JPH_OBJECT_LAYER_BITS) && JPH_OBJECT_LAYER_BITS == 32
"(32-bit ObjectLayer) "
#else
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/jolt_physics/Jolt/Core/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class [[nodiscard]] Array : private Allocator
rev_it & operator -- () { ++mValue; return *this; }
rev_it operator -- (int) { return rev_it(mValue++); }

rev_it operator + (int inValue) { return rev_it(mValue - inValue); }
rev_it operator - (int inValue) { return rev_it(mValue + inValue); }
rev_it operator + (int inValue) const { return rev_it(mValue - inValue); }
rev_it operator - (int inValue) const { return rev_it(mValue + inValue); }

rev_it & operator += (int inValue) { mValue -= inValue; return *this; }
rev_it & operator -= (int inValue) { mValue += inValue; return *this; }
Expand Down
9 changes: 7 additions & 2 deletions thirdparty/jolt_physics/Jolt/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Jolt library version
#define JPH_VERSION_MAJOR 5
#define JPH_VERSION_MINOR 3
#define JPH_VERSION_MINOR 4
#define JPH_VERSION_PATCH 0

// Determine which features the library was compiled with
Expand Down Expand Up @@ -437,6 +437,11 @@
#define JPH_SUPPRESS_WARNINGS_STD_END \
JPH_SUPPRESS_WARNING_POP

// MSVC STL requires _HAS_EXCEPTIONS=0 if exceptions are turned off
#if defined(JPH_COMPILER_MSVC) && (!defined(__cpp_exceptions) || !__cpp_exceptions) && !defined(_HAS_EXCEPTIONS)
#define _HAS_EXCEPTIONS 0
#endif

// Standard C++ includes
JPH_SUPPRESS_WARNINGS_STD_BEGIN
#include <float.h>
Expand All @@ -448,7 +453,7 @@ JPH_SUPPRESS_WARNINGS_STD_BEGIN
#include <functional>
#include <algorithm>
#include <cstdint>
#ifdef JPH_COMPILER_MSVC
#if defined(JPH_COMPILER_MSVC) || (defined(JPH_COMPILER_CLANG) && defined(_MSC_VER)) // MSVC or clang-cl
#include <malloc.h> // for alloca
#endif
#if defined(JPH_USE_SSE)
Expand Down
4 changes: 4 additions & 0 deletions thirdparty/jolt_physics/Jolt/Core/HashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ class HashTable
using Base = IteratorBase<HashTable, iterator>;

public:
using IteratorBase<HashTable, iterator>::operator ==;

/// Properties
using reference = typename Base::value_type &;
using pointer = typename Base::value_type *;
Expand Down Expand Up @@ -401,6 +403,8 @@ class HashTable
using Base = IteratorBase<const HashTable, const_iterator>;

public:
using IteratorBase<const HashTable, const_iterator>::operator ==;

/// Properties
using reference = const typename Base::value_type &;
using pointer = const typename Base::value_type *;
Expand Down
13 changes: 12 additions & 1 deletion thirdparty/jolt_physics/Jolt/Core/TickCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <x86intrin.h>
#elif defined(JPH_CPU_E2K)
#include <x86intrin.h>
#elif defined(JPH_CPU_LOONGARCH)
#include <larchintrin.h>
#endif

JPH_NAMESPACE_BEGIN
Expand All @@ -35,7 +37,16 @@ JPH_INLINE uint64 GetProcessorTickCount()
uint64 val;
asm volatile("mrs %0, cntvct_el0" : "=r" (val));
return val;
#elif defined(JPH_CPU_ARM) || defined(JPH_CPU_RISCV) || defined(JPH_CPU_WASM) || defined(JPH_CPU_PPC) || defined(JPH_CPU_LOONGARCH)
#elif defined(JPH_CPU_LOONGARCH)
#if JPH_CPU_ADDRESS_BITS == 64
__drdtime_t t = __rdtime_d();
return t.dvalue;
#else
__rdtime_t h = __rdtimeh_w();
__rdtime_t l = __rdtimel_w();
return ((uint64)h.value << 32) + l.value;
#endif
#elif defined(JPH_CPU_ARM) || defined(JPH_CPU_RISCV) || defined(JPH_CPU_WASM) || defined(JPH_CPU_PPC)
return 0; // Not supported
#else
#error Undefined
Expand Down
2 changes: 0 additions & 2 deletions thirdparty/jolt_physics/Jolt/Geometry/EPAPenetrationDepth.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ class EPAPenetrationDepth
template <typename AE, typename BE>
EStatus GetPenetrationDepthStepGJK(const AE &inAExcludingConvexRadius, float inConvexRadiusA, const BE &inBExcludingConvexRadius, float inConvexRadiusB, float inTolerance, Vec3 &ioV, Vec3 &outPointA, Vec3 &outPointB)
{
JPH_PROFILE_FUNCTION();

JPH_IF_ENABLE_ASSERTS(mGJKTolerance = inTolerance;)

// Don't supply a zero ioV, we only want to get points on the hull of the Minkowsky sum and not internal points.
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/jolt_physics/Jolt/Geometry/GJKClosestPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class GJKClosestPoint : public NonCopyable
#ifdef JPH_GJK_DEBUG
Trace("v . r = %g", (double)v_dot_r);
#endif
if (v_dot_r >= 0.0f)
if (v_dot_r >= -1.0e-18f) // Instead of checking >= 0, check with epsilon as we don't want the division below to overflow to infinity as it can cause a float exception
return false;

// Update the lower bound for lambda
Expand Down Expand Up @@ -744,7 +744,7 @@ class GJKClosestPoint : public NonCopyable
#ifdef JPH_GJK_DEBUG
Trace("v . r = %g", (double)v_dot_r);
#endif
if (v_dot_r >= 0.0f)
if (v_dot_r >= -1.0e-18f) // Instead of checking >= 0, check with epsilon as we don't want the division below to overflow to infinity as it can cause a float exception
return false;

// Update the lower bound for lambda
Expand Down
3 changes: 3 additions & 0 deletions thirdparty/jolt_physics/Jolt/Geometry/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class [[nodiscard]] Plane
float GetConstant() const { return mNormalAndConstant.GetW(); }
void SetConstant(float inConstant) { mNormalAndConstant.SetW(inConstant); }

/// Store as 4 floats
void StoreFloat4(Float4 *outV) const { mNormalAndConstant.StoreFloat4(outV); }

/// Offset the plane (positive value means move it in the direction of the plane normal)
Plane Offset(float inDistance) const { return Plane(mNormalAndConstant - Vec4(Vec3::sZero(), inDistance)); }

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/jolt_physics/Jolt/Math/DMat44.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
JPH_NAMESPACE_BEGIN

/// Holds a 4x4 matrix of floats with the last column consisting of doubles
class [[nodiscard]] alignas(JPH_DVECTOR_ALIGNMENT) DMat44
class [[nodiscard]] alignas(max(JPH_VECTOR_ALIGNMENT, JPH_DVECTOR_ALIGNMENT)) DMat44
{
public:
JPH_OVERRIDE_NEW_DELETE
Expand Down
11 changes: 11 additions & 0 deletions thirdparty/jolt_physics/Jolt/Math/Float4.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ class [[nodiscard]] Float4
Float4() = default; ///< Intentionally not initialized for performance reasons
Float4(const Float4 &inRHS) = default;
Float4(float inX, float inY, float inZ, float inW) : x(inX), y(inY), z(inZ), w(inW) { }
Float4 & operator = (const Float4 &inRHS) = default;

float operator [] (int inCoordinate) const
{
JPH_ASSERT(inCoordinate < 4);
return *(&x + inCoordinate);
}

bool operator == (const Float4 &inRHS) const
{
return x == inRHS.x && y == inRHS.y && z == inRHS.z && w == inRHS.w;
}

bool operator != (const Float4 &inRHS) const
{
return x != inRHS.x || y != inRHS.y || z != inRHS.z || w != inRHS.w;
}

float x;
float y;
float z;
Expand Down
12 changes: 6 additions & 6 deletions thirdparty/jolt_physics/Jolt/Math/Mat44.inl
Original file line number Diff line number Diff line change
Expand Up @@ -838,18 +838,18 @@ Quat Mat44::GetQuaternion() const
Mat44 Mat44::sQuatLeftMultiply(QuatArg inQ)
{
return Mat44(
Vec4(1, 1, -1, -1) * inQ.mValue.Swizzle<SWIZZLE_W, SWIZZLE_Z, SWIZZLE_Y, SWIZZLE_X>(),
Vec4(-1, 1, 1, -1) * inQ.mValue.Swizzle<SWIZZLE_Z, SWIZZLE_W, SWIZZLE_X, SWIZZLE_Y>(),
Vec4(1, -1, 1, -1) * inQ.mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>(),
inQ.mValue.Swizzle<SWIZZLE_W, SWIZZLE_Z, SWIZZLE_Y, SWIZZLE_X>().FlipSign<1, 1, -1, -1>(),
inQ.mValue.Swizzle<SWIZZLE_Z, SWIZZLE_W, SWIZZLE_X, SWIZZLE_Y>().FlipSign<-1, 1, 1, -1>(),
inQ.mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>().FlipSign<1, -1, 1, -1>(),
inQ.mValue);
}

Mat44 Mat44::sQuatRightMultiply(QuatArg inQ)
{
return Mat44(
Vec4(1, -1, 1, -1) * inQ.mValue.Swizzle<SWIZZLE_W, SWIZZLE_Z, SWIZZLE_Y, SWIZZLE_X>(),
Vec4(1, 1, -1, -1) * inQ.mValue.Swizzle<SWIZZLE_Z, SWIZZLE_W, SWIZZLE_X, SWIZZLE_Y>(),
Vec4(-1, 1, 1, -1) * inQ.mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>(),
inQ.mValue.Swizzle<SWIZZLE_W, SWIZZLE_Z, SWIZZLE_Y, SWIZZLE_X>().FlipSign<1, -1, 1, -1>(),
inQ.mValue.Swizzle<SWIZZLE_Z, SWIZZLE_W, SWIZZLE_X, SWIZZLE_Y>().FlipSign<1, 1, -1, -1>(),
inQ.mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>().FlipSign<-1, 1, 1, -1>(),
inQ.mValue);
}

Expand Down
19 changes: 16 additions & 3 deletions thirdparty/jolt_physics/Jolt/Math/Quat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT) Quat
Quat(const Quat &inRHS) = default;
Quat & operator = (const Quat &inRHS) = default;
inline Quat(float inX, float inY, float inZ, float inW) : mValue(inX, inY, inZ, inW) { }
inline explicit Quat(const Float4 &inV) : mValue(Vec4::sLoadFloat4(&inV)) { }
inline explicit Quat(Vec4Arg inV) : mValue(inV) { }
///@}

Expand Down Expand Up @@ -159,6 +160,9 @@ class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT) Quat
/// Rotate a vector by this quaternion
JPH_INLINE Vec3 operator * (Vec3Arg inValue) const;

/// Multiply a quaternion with imaginary components and no real component (x, y, z, 0) with a quaternion
static JPH_INLINE Quat sMultiplyImaginary(Vec3Arg inLHS, QuatArg inRHS);

/// Rotate a vector by the inverse of this quaternion
JPH_INLINE Vec3 InverseRotate(Vec3Arg inValue) const;

Expand All @@ -175,7 +179,7 @@ class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT) Quat
JPH_INLINE float Dot(QuatArg inRHS) const { return mValue.Dot(inRHS.mValue); }

/// The conjugate [w, -x, -y, -z] is the same as the inverse for unit quaternions
JPH_INLINE Quat Conjugated() const { return Quat(Vec4::sXor(mValue, UVec4(0x80000000, 0x80000000, 0x80000000, 0).ReinterpretAsFloat())); }
JPH_INLINE Quat Conjugated() const { return Quat(mValue.FlipSign<-1, -1, -1, 1>()); }

/// Get inverse quaternion
JPH_INLINE Quat Inversed() const { return Conjugated() / Length(); }
Expand All @@ -184,7 +188,7 @@ class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT) Quat
JPH_INLINE Quat EnsureWPositive() const { return Quat(Vec4::sXor(mValue, Vec4::sAnd(mValue.SplatW(), UVec4::sReplicate(0x80000000).ReinterpretAsFloat()))); }

/// Get a quaternion that is perpendicular to this quaternion
JPH_INLINE Quat GetPerpendicular() const { return Quat(Vec4(1, -1, 1, -1) * mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>()); }
JPH_INLINE Quat GetPerpendicular() const { return Quat(mValue.Swizzle<SWIZZLE_Y, SWIZZLE_X, SWIZZLE_W, SWIZZLE_Z>().FlipSign<1, -1, 1, -1>()); }

/// Get rotation angle around inAxis (uses Swing Twist Decomposition to get the twist quaternion and uses q(axis, angle) = [cos(angle / 2), axis * sin(angle / 2)])
JPH_INLINE float GetRotationAngle(Vec3Arg inAxis) const { return GetW() == 0.0f? JPH_PI : 2.0f * ATan(GetXYZ().Dot(inAxis) / GetW()); }
Expand Down Expand Up @@ -238,9 +242,18 @@ class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT) Quat
/// Load 3 floats from memory (X, Y and Z component and then calculates W) reads 32 bits extra which it doesn't use
static JPH_INLINE Quat sLoadFloat3Unsafe(const Float3 &inV);

/// Store 3 as floats to memory (X, Y and Z component)
/// Store as 3 floats to memory (X, Y and Z component). Ensures that W is positive before storing.
JPH_INLINE void StoreFloat3(Float3 *outV) const;

/// Store as 4 floats
JPH_INLINE void StoreFloat4(Float4 *outV) const;

/// Compress a unit quaternion to a 32 bit value, precision is around 0.5 degree
JPH_INLINE uint32 CompressUnitQuat() const { return mValue.CompressUnitVector(); }

/// Decompress a unit quaternion from a 32 bit value
JPH_INLINE static Quat sDecompressUnitQuat(uint32 inValue) { return Quat(Vec4::sDecompressUnitVector(inValue)); }

/// To String
friend ostream & operator << (ostream &inStream, QuatArg inQ) { inStream << inQ.mValue; return inStream; }

Expand Down
Loading