Browse Source

Fix compilation errors with -DDOUBLE_PRECISION=ON on LoongArch (#1592)

There were several places that assumed that the alignment of RVec3 is bigger than that of Vec3. This caused static asserts and alignment compile errors.

Co-authored-by: Jorrit Rouwe <[email protected]>
stdmnpkg 4 months ago
parent
commit
e8c2ecf99c
3 changed files with 6 additions and 6 deletions
  1. 1 1
      Jolt/Math/DMat44.h
  2. 3 3
      Jolt/Physics/Body/Body.h
  3. 2 2
      Jolt/Physics/Collision/TransformedShape.h

+ 1 - 1
Jolt/Math/DMat44.h

@@ -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

+ 3 - 3
Jolt/Physics/Body/Body.h

@@ -33,7 +33,7 @@ class SoftBodyCreationSettings;
 /// The linear velocity is also velocity of the center of mass, to correct for this: \f$VelocityCOM = Velocity - AngularVelocity \times ShapeCOM\f$.
 class
 #ifndef JPH_PLATFORM_DOXYGEN // Doxygen gets confused here
-	JPH_EXPORT_GCC_BUG_WORKAROUND alignas(JPH_RVECTOR_ALIGNMENT)
+	JPH_EXPORT_GCC_BUG_WORKAROUND alignas(max(JPH_VECTOR_ALIGNMENT, JPH_RVECTOR_ALIGNMENT))
 #endif
 	Body : public NonCopyable
 {
@@ -444,8 +444,8 @@ private:
 	// 122 bytes up to here (64-bit mode, single precision, 16-bit ObjectLayer)
 };
 
-static_assert(JPH_CPU_ADDRESS_BITS != 64 || sizeof(Body) == JPH_IF_SINGLE_PRECISION_ELSE(128, 160), "Body size is incorrect");
-static_assert(alignof(Body) == JPH_RVECTOR_ALIGNMENT, "Body should properly align");
+static_assert(JPH_CPU_ADDRESS_BITS != 64 || JPH_RVECTOR_ALIGNMENT < 16 || sizeof(Body) == JPH_IF_SINGLE_PRECISION_ELSE(128, 160), "Body size is incorrect");
+static_assert(alignof(Body) == max(JPH_VECTOR_ALIGNMENT, JPH_RVECTOR_ALIGNMENT), "Body should properly align");
 
 JPH_NAMESPACE_END
 

+ 2 - 2
Jolt/Physics/Collision/TransformedShape.h

@@ -188,7 +188,7 @@ public:
 	SubShapeIDCreator			mSubShapeIDCreator;							///< Optional sub shape ID creator for the shape (can be used when expanding compound shapes into multiple transformed shapes)
 };
 
-static_assert(JPH_CPU_ADDRESS_BITS != 64 || sizeof(TransformedShape) == JPH_IF_SINGLE_PRECISION_ELSE(64, 96), "Not properly packed");
-static_assert(alignof(TransformedShape) == JPH_RVECTOR_ALIGNMENT, "Not properly aligned");
+static_assert(JPH_CPU_ADDRESS_BITS != 64 || JPH_RVECTOR_ALIGNMENT < 16 || sizeof(TransformedShape) == JPH_IF_SINGLE_PRECISION_ELSE(64, 96), "Not properly packed");
+static_assert(alignof(TransformedShape) == max(JPH_VECTOR_ALIGNMENT, JPH_RVECTOR_ALIGNMENT), "Not properly aligned");
 
 JPH_NAMESPACE_END