瀏覽代碼

Added support for 32-bit ARM and x86 on Android and dropped the min required SDK to 21 (#739)

Also Fixed MSVC Shared Lib build warnings by marking a number of classes NonCopyable
Jorrit Rouwe 1 年之前
父節點
當前提交
ab534eaa51

+ 2 - 2
Build/Android/PerformanceTest/build.gradle

@@ -8,11 +8,11 @@ android {
 
 
     defaultConfig {
     defaultConfig {
         applicationId "com.joltphysics.performancetest"
         applicationId "com.joltphysics.performancetest"
-        minSdk 24
+        minSdk 21
         targetSdk 33
         targetSdk 33
         versionCode 1
         versionCode 1
         versionName "1.0"
         versionName "1.0"
-        ndk.abiFilters 'arm64-v8a', 'x86_64'
+        ndk.abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64', 'x86'
 
 
         externalNativeBuild {
         externalNativeBuild {
             cmake {
             cmake {

+ 2 - 2
Build/Android/UnitTests/build.gradle

@@ -8,11 +8,11 @@ android {
 
 
     defaultConfig {
     defaultConfig {
         applicationId "com.joltphysics.unittests"
         applicationId "com.joltphysics.unittests"
-        minSdk 24
+        minSdk 21
         targetSdk 33
         targetSdk 33
         versionCode 1
         versionCode 1
         versionName "1.0"
         versionName "1.0"
-        ndk.abiFilters 'arm64-v8a', 'x86_64'
+        ndk.abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64', 'x86'
 
 
         externalNativeBuild {
         externalNativeBuild {
             cmake {
             cmake {

+ 1 - 1
Build/Android/build.gradle

@@ -5,7 +5,7 @@ buildscript {
         mavenCentral()
         mavenCentral()
     }
     }
     dependencies {
     dependencies {
-        classpath 'com.android.tools.build:gradle:8.1.0'
+        classpath 'com.android.tools.build:gradle:8.1.2'
 
 
         // NOTE: Do not place your application dependencies here; they belong
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
         // in the individual module build.gradle files

+ 3 - 1
Jolt/Core/StreamIn.h

@@ -4,10 +4,12 @@
 
 
 #pragma once
 #pragma once
 
 
+#include <Jolt/Core/NonCopyable.h>
+
 JPH_NAMESPACE_BEGIN
 JPH_NAMESPACE_BEGIN
 
 
 /// Simple binary input stream
 /// Simple binary input stream
-class JPH_EXPORT StreamIn
+class JPH_EXPORT StreamIn : public NonCopyable
 {
 {
 public:
 public:
 	/// Virtual destructor
 	/// Virtual destructor

+ 3 - 1
Jolt/Core/StreamOut.h

@@ -4,10 +4,12 @@
 
 
 #pragma once
 #pragma once
 
 
+#include <Jolt/Core/NonCopyable.h>
+
 JPH_NAMESPACE_BEGIN
 JPH_NAMESPACE_BEGIN
 
 
 /// Simple binary output stream
 /// Simple binary output stream
-class JPH_EXPORT StreamOut
+class JPH_EXPORT StreamOut : public NonCopyable
 {
 {
 public:
 public:
 	/// Virtual destructor
 	/// Virtual destructor

+ 1 - 1
Jolt/Math/DVec3.inl

@@ -65,7 +65,7 @@ DVec3::DVec3(const Double3 &inV)
 	Type xy = _mm256_unpacklo_pd(x, y);
 	Type xy = _mm256_unpacklo_pd(x, y);
 	mValue = _mm256_blend_pd(xy, z, 0b1100); // Assure Z and W are the same
 	mValue = _mm256_blend_pd(xy, z, 0b1100); // Assure Z and W are the same
 #elif defined(JPH_USE_SSE)
 #elif defined(JPH_USE_SSE)
-	mValue.mLow = _mm_load_pd(&inV.x);
+	mValue.mLow = _mm_loadu_pd(&inV.x);
 	mValue.mHigh = _mm_set_pd1(inV.z);
 	mValue.mHigh = _mm_set_pd1(inV.z);
 #elif defined(JPH_USE_NEON)
 #elif defined(JPH_USE_NEON)
 	mValue.val[0] = vld1q_f64(&inV.x);
 	mValue.val[0] = vld1q_f64(&inV.x);

+ 4 - 3
Jolt/ObjectStream/ObjectStream.h

@@ -6,13 +6,14 @@
 
 
 #include <Jolt/Core/StaticArray.h>
 #include <Jolt/Core/StaticArray.h>
 #include <Jolt/Core/Reference.h>
 #include <Jolt/Core/Reference.h>
-#include <Jolt/ObjectStream/SerializableAttribute.h>
 #include <Jolt/Core/RTTI.h>
 #include <Jolt/Core/RTTI.h>
+#include <Jolt/Core/NonCopyable.h>
+#include <Jolt/ObjectStream/SerializableAttribute.h>
 
 
 JPH_NAMESPACE_BEGIN
 JPH_NAMESPACE_BEGIN
 
 
 /// Base class for object stream input and output streams.
 /// Base class for object stream input and output streams.
-class JPH_EXPORT ObjectStream
+class JPH_EXPORT ObjectStream : public NonCopyable
 {
 {
 public:
 public:
 	/// Stream type
 	/// Stream type
@@ -23,7 +24,7 @@ public:
 	};
 	};
 
 
 protected:
 protected:
-	/// Constructor
+	/// Destructor
 	virtual							~ObjectStream() = default;
 	virtual							~ObjectStream() = default;
 
 
 	/// Identifier for objects
 	/// Identifier for objects

+ 1 - 1
Jolt/ObjectStream/SerializableObject.h

@@ -143,7 +143,7 @@ public:																												\
 /// Classes must be derived from SerializableObject if you want to be able to save pointers or
 /// Classes must be derived from SerializableObject if you want to be able to save pointers or
 /// reference counting pointers to objects of this or derived classes. The type will automatically
 /// reference counting pointers to objects of this or derived classes. The type will automatically
 /// be determined during serialization and upon deserialization it will be restored correctly.
 /// be determined during serialization and upon deserialization it will be restored correctly.
-class JPH_EXPORT SerializableObject
+class JPH_EXPORT SerializableObject : public NonCopyable
 {
 {
 	JPH_DECLARE_SERIALIZABLE_ABSTRACT_BASE(JPH_EXPORT, SerializableObject)
 	JPH_DECLARE_SERIALIZABLE_ABSTRACT_BASE(JPH_EXPORT, SerializableObject)
 
 

+ 5 - 0
Jolt/Physics/Character/CharacterBase.h

@@ -22,6 +22,11 @@ class JPH_EXPORT CharacterBaseSettings : public RefTarget<CharacterBaseSettings>
 public:
 public:
 	JPH_OVERRIDE_NEW_DELETE
 	JPH_OVERRIDE_NEW_DELETE
 
 
+	/// Constructor
+										CharacterBaseSettings() = default;
+										CharacterBaseSettings(const CharacterBaseSettings &inSettings) = default;
+	CharacterBaseSettings &				operator = (const CharacterBaseSettings &inSettings) = default;
+
 	/// Virtual destructor
 	/// Virtual destructor
 	virtual								~CharacterBaseSettings() = default;
 	virtual								~CharacterBaseSettings() = default;
 
 

+ 2 - 1
Jolt/Physics/Vehicle/VehicleCollisionTester.h

@@ -5,6 +5,7 @@
 #pragma once
 #pragma once
 
 
 #include <Jolt/Physics/Body/Body.h>
 #include <Jolt/Physics/Body/Body.h>
+#include <Jolt/Core/NonCopyable.h>
 
 
 JPH_NAMESPACE_BEGIN
 JPH_NAMESPACE_BEGIN
 
 
@@ -15,7 +16,7 @@ class ObjectLayerFilter;
 class BodyFilter;
 class BodyFilter;
 
 
 /// Class that does collision detection between wheels and ground
 /// Class that does collision detection between wheels and ground
-class JPH_EXPORT VehicleCollisionTester : public RefTarget<VehicleCollisionTester>
+class JPH_EXPORT VehicleCollisionTester : public RefTarget<VehicleCollisionTester>, public NonCopyable
 {
 {
 public:
 public:
 	JPH_OVERRIDE_NEW_DELETE
 	JPH_OVERRIDE_NEW_DELETE

+ 1 - 1
Jolt/Physics/Vehicle/VehicleController.h

@@ -37,7 +37,7 @@ public:
 };
 };
 
 
 /// Runtime data for interface that controls acceleration / decelleration of the vehicle
 /// Runtime data for interface that controls acceleration / decelleration of the vehicle
-class JPH_EXPORT VehicleController : public RefTarget<VehicleController>
+class JPH_EXPORT VehicleController : public RefTarget<VehicleController>, public NonCopyable
 {
 {
 public:
 public:
 	JPH_OVERRIDE_NEW_DELETE
 	JPH_OVERRIDE_NEW_DELETE

+ 2 - 2
Jolt/Physics/Vehicle/Wheel.h

@@ -15,7 +15,7 @@ JPH_NAMESPACE_BEGIN
 class VehicleConstraint;
 class VehicleConstraint;
 
 
 /// Base class for wheel settings, each VehicleController can implement a derived class of this
 /// Base class for wheel settings, each VehicleController can implement a derived class of this
-class JPH_EXPORT WheelSettings : public SerializableObject, public RefTarget<WheelSettings>, public NonCopyable
+class JPH_EXPORT WheelSettings : public SerializableObject, public RefTarget<WheelSettings>
 {
 {
 public:
 public:
 	JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, WheelSettings)
 	JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, WheelSettings)
@@ -42,7 +42,7 @@ public:
 };
 };
 
 
 /// Base class for runtime data for a wheel, each VehicleController can implement a derived class of this
 /// Base class for runtime data for a wheel, each VehicleController can implement a derived class of this
-class JPH_EXPORT Wheel
+class JPH_EXPORT Wheel : public NonCopyable
 {
 {
 public:
 public:
 	JPH_OVERRIDE_NEW_DELETE
 	JPH_OVERRIDE_NEW_DELETE

+ 2 - 1
Jolt/TriangleGrouper/TriangleGrouper.h

@@ -5,11 +5,12 @@
 #pragma once
 #pragma once
 
 
 #include <Jolt/Geometry/IndexedTriangle.h>
 #include <Jolt/Geometry/IndexedTriangle.h>
+#include <Jolt/Core/NonCopyable.h>
 
 
 JPH_NAMESPACE_BEGIN
 JPH_NAMESPACE_BEGIN
 
 
 /// A class that groups triangles in batches of N (according to closeness)
 /// A class that groups triangles in batches of N (according to closeness)
-class JPH_EXPORT TriangleGrouper
+class JPH_EXPORT TriangleGrouper : public NonCopyable
 {
 {
 public:
 public:
 	/// Virtual destructor
 	/// Virtual destructor

+ 2 - 1
Jolt/TriangleSplitter/TriangleSplitter.h

@@ -5,11 +5,12 @@
 #pragma once
 #pragma once
 
 
 #include <Jolt/Geometry/IndexedTriangle.h>
 #include <Jolt/Geometry/IndexedTriangle.h>
+#include <Jolt/Core/NonCopyable.h>
 
 
 JPH_NAMESPACE_BEGIN
 JPH_NAMESPACE_BEGIN
 
 
 /// A class that splits a triangle list into two parts for building a tree
 /// A class that splits a triangle list into two parts for building a tree
-class JPH_EXPORT TriangleSplitter
+class JPH_EXPORT TriangleSplitter : public NonCopyable
 {
 {
 public:
 public:
 	/// Constructor
 	/// Constructor

+ 2 - 2
README.md

@@ -86,9 +86,9 @@ For more information see the [Architecture and API documentation](https://jrouwe
 
 
 ## Supported Platforms
 ## Supported Platforms
 
 
-* Windows (VS2019, VS2022) x86/x64/ARM/ARM64 (Desktop/UWP)
+* Windows (VS2019, VS2022) x86/x64/ARM32/ARM64 (Desktop/UWP)
 * Linux (tested on Ubuntu 22.04) x64/ARM64
 * Linux (tested on Ubuntu 22.04) x64/ARM64
-* Android (tested on Android 10) x64/ARM64
+* Android (tested on Android 14) x86/x64/ARM32/ARM64
 * Platform Blue (a popular game console) x64
 * Platform Blue (a popular game console) x64
 * macOS (tested on Monterey) x64/ARM64
 * macOS (tested on Monterey) x64/ARM64
 * iOS (tested on iOS 15) x64/ARM64
 * iOS (tested on iOS 15) x64/ARM64

+ 69 - 1
UnitTests/Math/UVec4Tests.cpp

@@ -74,7 +74,7 @@ TEST_SUITE("UVec4Tests")
 		CHECK(UVec4::sMax(v1, v2) == UVec4(5, 6, 7, 8));
 		CHECK(UVec4::sMax(v1, v2) == UVec4(5, 6, 7, 8));
 	}
 	}
 
 
-	TEST_CASE("TestUVec4omparisons")
+	TEST_CASE("TestUVec4Comparisons")
 	{
 	{
 		CHECK(UVec4::sEquals(UVec4(1, 2, 3, 4), UVec4(2, 1, 3, 4)) == UVec4(0, 0, 0xffffffffU, 0xffffffffU));
 		CHECK(UVec4::sEquals(UVec4(1, 2, 3, 4), UVec4(2, 1, 3, 4)) == UVec4(0, 0, 0xffffffffU, 0xffffffffU));
 
 
@@ -111,6 +111,74 @@ TEST_SUITE("UVec4Tests")
 		CHECK(UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0xffffffffU).CountTrues() == 3);
 		CHECK(UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0xffffffffU).CountTrues() == 3);
 		CHECK(UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0xffffffffU).CountTrues() == 3);
 		CHECK(UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0xffffffffU).CountTrues() == 3);
 		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU).CountTrues() == 4);
 		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU).CountTrues() == 4);
+
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0xffffffffU).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0xffffffffU).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAllTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAllTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAllTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAllTrue());
+
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAllXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0xffffffffU).TestAllXYZTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0xffffffffU).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAllXYZTrue());
+		CHECK(!UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAllXYZTrue());
+		CHECK(!UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAllXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAllXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAllXYZTrue());
+
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAnyTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAnyTrue());
+
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0x00000000U).TestAnyXYZTrue());
+		CHECK(!UVec4(0x00000000U, 0x00000000U, 0x00000000U, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0x00000000U, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0x00000000U, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0x00000000U, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0x00000000U, 0xffffffffU, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0x00000000U, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAnyXYZTrue());
+		CHECK(UVec4(0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU).TestAnyXYZTrue());
 	}
 	}
 
 
 	TEST_CASE("TestUVec4Select")
 	TEST_CASE("TestUVec4Select")

+ 2 - 2
UnitTests/Math/Vec3Tests.cpp

@@ -262,8 +262,8 @@ TEST_SUITE("Vec3Tests")
 
 
 	TEST_CASE("TestVec3Cast")
 	TEST_CASE("TestVec3Cast")
 	{
 	{
-		CHECK(Vec3(1, 2, 3).ToInt() == UVec4(1, 2, 3, 3));
-		CHECK(Vec3(1, 2, 3).ReinterpretAsInt() == UVec4(0x3f800000U, 0x40000000U, 0x40400000U, 0x40400000U));
+		CHECK(UVec4::sEquals(Vec3(1, 2, 3).ToInt(), UVec4(1, 2, 3, 0)).TestAllXYZTrue());
+		CHECK(UVec4::sEquals(Vec3(1, 2, 3).ReinterpretAsInt(), UVec4(0x3f800000U, 0x40000000U, 0x40400000U, 0)).TestAllXYZTrue());
 	}
 	}
 
 
 	TEST_CASE("TestVec3NormalizedPerpendicular")
 	TEST_CASE("TestVec3NormalizedPerpendicular")