Skip to content

Commit 1cb3f98

Browse files
committed
Add missing patch files to thirdparty/jolt_physics
1 parent 0227be0 commit 1cb3f98

8 files changed

+443
-0
lines changed

thirdparty/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ Files extracted from upstream source:
501501
- All files in `Jolt/`, except `Jolt/Jolt.cmake` and any files dependent on `ENABLE_OBJECT_STREAM`, as seen in `Jolt/Jolt.cmake`
502502
- `LICENSE`
503503

504+
Patches:
505+
506+
- `0001-backport-upstream-commit-b385bc3d7.patch` ([GH-111087](https://github.com/godotengine/godot/pull/111087))
507+
- `0002-backport-upstream-commit-ccfe0a0df.patch` ([GH-111408](https://github.com/godotengine/godot/pull/111408))
508+
- `0003-backport-upstream-commit-9e48d59be.patch` ([GH-111767](https://github.com/godotengine/godot/pull/111767))
509+
- `0004-backport-upstream-commit-ee3725250.patch` ([GH-115089](https://github.com/godotengine/godot/pull/115089))
510+
- `0005-backport-upstream-commit-bc7f1fb8c.patch` ([GH-115305](https://github.com/godotengine/godot/pull/115305))
511+
- `0006-no-static-assert-false.patch` ([GH-115305](https://github.com/godotengine/godot/pull/115305))
512+
- `0007-backport-upstream-commit-e0a6a9a16.patch` ([GH-115327](https://github.com/godotengine/godot/pull/115327))
513+
504514

505515
## libbacktrace
506516

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h b/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h
2+
index ec84776a46..387c0d9737 100644
3+
--- a/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h
4+
+++ b/thirdparty/jolt_physics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h
5+
@@ -143,8 +143,21 @@ public:
6+
mInvI2 = inBody2.IsDynamic()? inBody2.GetMotionProperties()->GetInverseInertiaForRotation(inRotation2) : Mat44::sZero();
7+
8+
// Calculate effective mass: K^-1 = (J M^-1 J^T)^-1
9+
- if (!mEffectiveMass.SetInversed3x3(mInvI1 + mInvI2))
10+
- Deactivate();
11+
+ Mat44 inertia_sum = mInvI1 + mInvI2;
12+
+ if (!mEffectiveMass.SetInversed3x3(inertia_sum))
13+
+ {
14+
+ // If a column is zero, the axis is locked and we set the column to identity.
15+
+ // This does not matter because any impulse will always be multiplied with mInvI1 or mInvI2 which will result in zero for the locked coordinate.
16+
+ Vec4 zero = Vec4::sZero();
17+
+ if (inertia_sum.GetColumn4(0) == zero)
18+
+ inertia_sum.SetColumn4(0, Vec4(1, 0, 0, 0));
19+
+ if (inertia_sum.GetColumn4(1) == zero)
20+
+ inertia_sum.SetColumn4(1, Vec4(0, 1, 0, 0));
21+
+ if (inertia_sum.GetColumn4(2) == zero)
22+
+ inertia_sum.SetColumn4(2, Vec4(0, 0, 1, 0));
23+
+ if (!mEffectiveMass.SetInversed3x3(inertia_sum))
24+
+ Deactivate();
25+
+ }
26+
}
27+
28+
/// Deactivate this constraint
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/thirdparty/jolt_physics/Jolt/Core/Core.h b/thirdparty/jolt_physics/Jolt/Core/Core.h
2+
index b306f5a686..b433a77946 100644
3+
--- a/thirdparty/jolt_physics/Jolt/Core/Core.h
4+
+++ b/thirdparty/jolt_physics/Jolt/Core/Core.h
5+
@@ -453,6 +453,7 @@ JPH_SUPPRESS_WARNINGS_STD_BEGIN
6+
#include <functional>
7+
#include <algorithm>
8+
#include <cstdint>
9+
+#include <type_traits>
10+
#if defined(JPH_COMPILER_MSVC) || (defined(JPH_COMPILER_CLANG) && defined(_MSC_VER)) // MSVC or clang-cl
11+
#include <malloc.h> // for alloca
12+
#endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/thirdparty/jolt_physics/Jolt/RegisterTypes.cpp b/thirdparty/jolt_physics/Jolt/RegisterTypes.cpp
2+
index ccfcc1bbe0..e343dd2fa7 100644
3+
--- a/thirdparty/jolt_physics/Jolt/RegisterTypes.cpp
4+
+++ b/thirdparty/jolt_physics/Jolt/RegisterTypes.cpp
5+
@@ -74,6 +74,10 @@ void RegisterTypesInternal(uint64 inVersionID)
6+
{
7+
Trace("Version mismatch, make sure you compile the client code with the same Jolt version and compiler definitions!");
8+
uint64 mismatch = JPH_VERSION_ID ^ inVersionID;
9+
+ if (mismatch & 0xffffff)
10+
+ Trace("Client reported version %d.%d.%d, library version is %d.%d.%d.",
11+
+ (inVersionID >> 16) & 0xff, (inVersionID >> 8) & 0xff, inVersionID & 0xff,
12+
+ JPH_VERSION_MAJOR, JPH_VERSION_MINOR, JPH_VERSION_PATCH);
13+
auto check_bit = [mismatch](int inBit, const char *inLabel) { if (mismatch & (uint64(1) << (inBit + 23))) Trace("Mismatching define %s.", inLabel); };
14+
check_bit(1, "JPH_DOUBLE_PRECISION");
15+
check_bit(2, "JPH_CROSS_PLATFORM_DETERMINISTIC");
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/thirdparty/jolt_physics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp b/thirdparty/jolt_physics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp
2+
index e8a8c21459..4fb6c58c18 100644
3+
--- a/thirdparty/jolt_physics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp
4+
+++ b/thirdparty/jolt_physics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp
5+
@@ -92,11 +92,14 @@ void CastConvexVsTriangles::Cast(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2, uint8
6+
static_cast<const ConvexShape *>(mShapeCast.mShape)->GetSupportingFace(SubShapeID(), transform_1_to_2.Multiply3x3Transposed(-contact_normal), mShapeCast.mScale, mCenterOfMassTransform2 * transform_1_to_2, result.mShape1Face);
7+
8+
// Get face of the triangle
9+
- triangle.GetSupportingFace(contact_normal, result.mShape2Face);
10+
+ result.mShape2Face.resize(3);
11+
+ result.mShape2Face[0] = mCenterOfMassTransform2 * v0;
12+
+ result.mShape2Face[1] = mCenterOfMassTransform2 * v1;
13+
+ result.mShape2Face[2] = mCenterOfMassTransform2 * v2;
14+
15+
- // Convert to world space
16+
- for (Vec3 &p : result.mShape2Face)
17+
- p = mCenterOfMassTransform2 * p;
18+
+ // When inside out, we need to swap the triangle winding
19+
+ if (mScaleSign < 0.0f)
20+
+ std::swap(result.mShape2Face[1], result.mShape2Face[2]);
21+
}
22+
23+
JPH_IF_TRACK_NARROWPHASE_STATS(TrackNarrowPhaseCollector track;)
24+
diff --git a/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp b/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp
25+
index e03659454d..05c21eebfa 100644
26+
--- a/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp
27+
+++ b/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp
28+
@@ -145,6 +145,10 @@ void CollideConvexVsTriangles::Collide(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2,
29+
result.mShape2Face[0] = mTransform1 * v0;
30+
result.mShape2Face[1] = mTransform1 * v1;
31+
result.mShape2Face[2] = mTransform1 * v2;
32+
+
33+
+ // When inside out, we need to swap the triangle winding
34+
+ if (mScaleSign2 < 0.0f)
35+
+ std::swap(result.mShape2Face[1], result.mShape2Face[2]);
36+
}
37+
38+
// Notify the collector
39+
diff --git a/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp b/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp
40+
index 18441ea73b..566efb38ae 100644
41+
--- a/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp
42+
+++ b/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp
43+
@@ -111,6 +111,10 @@ void CollideSphereVsTriangles::Collide(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2,
44+
result.mShape2Face[0] = mTransform2 * (mSphereCenterIn2 + v0);
45+
result.mShape2Face[1] = mTransform2 * (mSphereCenterIn2 + v1);
46+
result.mShape2Face[2] = mTransform2 * (mSphereCenterIn2 + v2);
47+
+
48+
+ // When inside out, we need to swap the triangle winding
49+
+ if (mScaleSign2 < 0.0f)
50+
+ std::swap(result.mShape2Face[1], result.mShape2Face[2]);
51+
}
52+
53+
// Notify the collector

0 commit comments

Comments
 (0)