Преглед на файлове

Removed some of the using std::... statements (#1353)

* Factory::Register function will now reserve memory to avoid frequent reallocation
* Added determinism remark in documentation for std::hash
Jorrit Rouwe преди 8 месеца
родител
ревизия
79ce4b2801
променени са 53 файла, в които са добавени 79 реда и са изтрити 82 реда
  1. 1 1
      Build/Android/build.gradle
  2. 1 1
      Build/Android/gradle/wrapper/gradle-wrapper.properties
  3. 4 3
      Docs/Architecture.md
  4. 2 2
      Jolt/Core/Array.h
  5. 1 1
      Jolt/Core/Color.h
  6. 0 7
      Jolt/Core/Core.h
  7. 3 0
      Jolt/Core/Factory.cpp
  8. 1 1
      Jolt/Core/FixedSizeFreeList.inl
  9. 1 1
      Jolt/Core/HashTable.h
  10. 4 4
      Jolt/Core/QuickSort.h
  11. 4 4
      Jolt/Core/StaticArray.h
  12. 2 2
      Jolt/Geometry/ConvexHullBuilder.cpp
  13. 1 1
      Jolt/Geometry/ConvexHullBuilder2D.cpp
  14. 1 1
      Jolt/Geometry/Indexify.cpp
  15. 2 2
      Jolt/Geometry/RaySphere.h
  16. 1 1
      Jolt/Math/BVec16.h
  17. 1 1
      Jolt/Math/DMat44.h
  18. 1 1
      Jolt/Math/DVec3.h
  19. 1 1
      Jolt/Math/Double3.h
  20. 1 1
      Jolt/Math/Float2.h
  21. 1 1
      Jolt/Math/Float3.h
  22. 1 1
      Jolt/Math/Float4.h
  23. 2 2
      Jolt/Math/GaussianElimination.h
  24. 1 1
      Jolt/Math/Mat44.h
  25. 1 1
      Jolt/Math/Quat.h
  26. 1 1
      Jolt/Math/UVec4.h
  27. 1 1
      Jolt/Math/Vec3.h
  28. 1 1
      Jolt/Math/Vec4.h
  29. 1 1
      Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp
  30. 2 2
      Jolt/Physics/Collision/BroadPhase/QuadTree.cpp
  31. 1 1
      Jolt/Physics/Collision/BroadPhase/QuadTree.h
  32. 1 1
      Jolt/Physics/Collision/GroupFilterTable.h
  33. 1 1
      Jolt/Physics/Collision/ObjectLayerPairFilterTable.h
  34. 1 1
      Jolt/Physics/Collision/Shape/HeightFieldShape.cpp
  35. 1 1
      Jolt/Physics/Collision/Shape/MeshShape.cpp
  36. 6 6
      Jolt/Physics/Collision/Shape/PlaneShape.cpp
  37. 2 2
      Jolt/Physics/Collision/Shape/Shape.h
  38. 2 2
      Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp
  39. 1 1
      Jolt/Physics/Collision/Shape/SubShapeIDPair.h
  40. 2 2
      Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp
  41. 1 1
      Jolt/Physics/Collision/Shape/TriangleShape.cpp
  42. 2 2
      Jolt/Physics/Constraints/ContactConstraintManager.cpp
  43. 1 1
      Jolt/Physics/Constraints/ContactConstraintManager.h
  44. 1 1
      Jolt/Physics/PhysicsSystem.cpp
  45. 1 1
      Jolt/Physics/Ragdoll/Ragdoll.h
  46. 1 1
      Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp
  47. 1 1
      Jolt/Physics/StateRecorderImpl.h
  48. 3 3
      Jolt/Physics/Vehicle/TrackedVehicleController.cpp
  49. 1 1
      Jolt/RegisterTypes.cpp
  50. 1 1
      Jolt/TriangleGrouper/TriangleGrouperClosestCentroid.cpp
  51. 1 1
      Jolt/TriangleSplitter/TriangleSplitter.cpp
  52. 1 1
      Jolt/TriangleSplitter/TriangleSplitterFixedLeafSize.cpp
  53. 1 1
      UnitTests/UnitTestFramework.cpp

+ 1 - 1
Build/Android/build.gradle

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

+ 1 - 1
Build/Android/gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME

+ 4 - 3
Docs/Architecture.md

@@ -634,9 +634,10 @@ The most important things to look out for in your own application:
 * Compile your application mode in Precise mode (clang: -ffp-model=precise, MSVC: /fp:precise)
 * Turn off floating point contract operations (clang: -ffp-contract=off)
 * Make sure the FPU state is consistent across platforms / threads. Check the floating point rounding behavior (should be nearest). Check that the denormals are zero (DAZ) and flush to zero (FTZ) flags are set consistently.
-* Do not use the standard trigonometry functions (`sin`, `cos` etc.) as they have different implementations on different platforms, use Jolt's functions ([Sin](@ref Sin), [Cos](@ref Cos) etc.)
-* Do not use `std::sort` as it has a different implementation on different platforms, use Jolt's [QuickSort](@ref QuickSort) function
-* Do not use `std::push_heap` and `std::pop_heap` as it has a different implementation on different platforms when elements are equal, use Jolt's [BinaryHeapPush](@ref BinaryHeapPush)/[BinaryHeapPop](@ref BinaryHeapPop) functions
+* Do not use the standard trigonometry functions (`sin`, `cos` etc.) as they have different implementations on different platforms, use Jolt's functions ([Sin](@ref Sin), [Cos](@ref Cos) etc.).
+* Do not use `std::sort` as it has a different implementation on different platforms, use [QuickSort](@ref QuickSort) instead.
+* Do not use `std::push_heap` and `std::pop_heap` as it has a different implementation on different platforms when elements are equal, use [BinaryHeapPush](@ref BinaryHeapPush)/[BinaryHeapPop](@ref BinaryHeapPop) instead.
+* Do not use `std::hash` as it is also platform dependent, use [Hash](@ref Hash) instead.
 
 When running the Samples Application you can press ESC, Physics Settings and check the 'Check Determinism' checkbox. Before every simulation step we will record the state using the [StateRecorder](@ref StateRecorder) interface, rewind the simulation and do the step again to validate that the simulation runs deterministically. Some of the tests (e.g. the MultiThreaded) test will explicitly disable the check because they randomly add/remove bodies from different threads. This violates the rule that the API calls must be done in the same order so will not result in a deterministic simulation.
 

+ 2 - 2
Jolt/Core/Array.h

@@ -102,7 +102,7 @@ private:
 	/// Destruct elements [inStart, inEnd - 1]
 	inline void				destruct(size_type inStart, size_type inEnd)
 	{
-		if constexpr (!is_trivially_destructible<T>())
+		if constexpr (!std::is_trivially_destructible<T>())
 			if (inStart < inEnd)
 				for (T *element = mElements + inStart, *element_end = mElements + inEnd; element < element_end; ++element)
 					element->~T();
@@ -122,7 +122,7 @@ public:
 		destruct(inNewSize, mSize);
 		reserve(inNewSize);
 
-		if constexpr (!is_trivially_constructible<T>())
+		if constexpr (!std::is_trivially_constructible<T>())
 			for (T *element = mElements + mSize, *element_end = mElements + inNewSize; element < element_end; ++element)
 				::new (element) T;
 		mSize = inNewSize;

+ 1 - 1
Jolt/Core/Color.h

@@ -79,6 +79,6 @@ public:
 	};
 };
 
-static_assert(is_trivial<Color>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Color>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END

+ 0 - 7
Jolt/Core/Core.h

@@ -425,7 +425,6 @@ JPH_SUPPRESS_WARNINGS_STD_END
 JPH_NAMESPACE_BEGIN
 
 // Commonly used STL types
-using std::pair;
 using std::min;
 using std::max;
 using std::abs;
@@ -435,17 +434,11 @@ using std::floor;
 using std::trunc;
 using std::round;
 using std::fmod;
-using std::swap;
-using std::size;
-using std::string;
 using std::string_view;
 using std::function;
 using std::numeric_limits;
 using std::isfinite;
 using std::isnan;
-using std::is_trivial;
-using std::is_trivially_constructible;
-using std::is_trivially_destructible;
 using std::ostream;
 using std::istream;
 

+ 3 - 0
Jolt/Core/Factory.cpp

@@ -64,6 +64,9 @@ bool Factory::Register(const RTTI *inRTTI)
 
 bool Factory::Register(const RTTI **inRTTIs, uint inNumber)
 {
+	mClassHashMap.reserve(mClassHashMap.size() + inNumber);
+	mClassNameMap.reserve(mClassNameMap.size() + inNumber);
+
 	for (const RTTI **rtti = inRTTIs; rtti < inRTTIs + inNumber; ++rtti)
 		if (!Register(*rtti))
 			return false;

+ 1 - 1
Jolt/Core/FixedSizeFreeList.inl

@@ -130,7 +130,7 @@ void FixedSizeFreeList<Object>::DestructObjectBatch(Batch &ioBatch)
 	if (ioBatch.mFirstObjectIndex != cInvalidObjectIndex)
 	{
 		// Call destructors
-		if constexpr (!is_trivially_destructible<Object>())
+		if constexpr (!std::is_trivially_destructible<Object>())
 		{
 			uint32 object_idx = ioBatch.mFirstObjectIndex;
 			do

+ 1 - 1
Jolt/Core/HashTable.h

@@ -435,7 +435,7 @@ public:
 	void					clear()
 	{
 		// Delete all elements
-		if constexpr (!is_trivially_destructible<KeyValue>())
+		if constexpr (!std::is_trivially_destructible<KeyValue>())
 			if (!empty())
 				for (size_type i = 0; i < mMaxSize; ++i)
 					if (mControl[i] & cBucketUsed)

+ 4 - 4
Jolt/Core/QuickSort.h

@@ -16,13 +16,13 @@ inline void QuickSortMedianOfThree(Iterator inFirst, Iterator inMiddle, Iterator
 	JPH_ASSERT(inFirst != inMiddle && inMiddle != inLast);
 
 	if (inCompare(*inMiddle, *inFirst))
-		swap(*inFirst, *inMiddle);
+		std::swap(*inFirst, *inMiddle);
 
 	if (inCompare(*inLast, *inFirst))
-		swap(*inFirst, *inLast);
+		std::swap(*inFirst, *inLast);
 
 	if (inCompare(*inLast, *inMiddle))
-		swap(*inMiddle, *inLast);
+		std::swap(*inMiddle, *inLast);
 }
 
 /// Helper function for QuickSort using the Ninther method, will move the pivot element to inMiddle.
@@ -94,7 +94,7 @@ inline void QuickSort(Iterator inBegin, Iterator inEnd, Compare inCompare)
 				break;
 
 			// Swap the elements
-			swap(*i, *j);
+			std::swap(*i, *j);
 
 			// Note that the first while loop in this function should
 			// have been do i++ while (...) but since we cannot decrement

+ 4 - 4
Jolt/Core/StaticArray.h

@@ -43,7 +43,7 @@ public:
 	/// Destruct all elements
 						~StaticArray()
 	{
-		if constexpr (!is_trivially_destructible<T>())
+		if constexpr (!std::is_trivially_destructible<T>())
 			for (T *e = reinterpret_cast<T *>(mElements), *end = e + mSize; e < end; ++e)
 				e->~T();
 	}
@@ -51,7 +51,7 @@ public:
 	/// Destruct all elements and set length to zero
 	void				clear()
 	{
-		if constexpr (!is_trivially_destructible<T>())
+		if constexpr (!std::is_trivially_destructible<T>())
 			for (T *e = reinterpret_cast<T *>(mElements), *end = e + mSize; e < end; ++e)
 				e->~T();
 		mSize = 0;
@@ -101,10 +101,10 @@ public:
 	void				resize(size_type inNewSize)
 	{
 		JPH_ASSERT(inNewSize <= N);
-		if constexpr (!is_trivially_constructible<T>())
+		if constexpr (!std::is_trivially_constructible<T>())
 			for (T *element = reinterpret_cast<T *>(mElements) + mSize, *element_end = reinterpret_cast<T *>(mElements) + inNewSize; element < element_end; ++element)
 				::new (element) T;
-		if constexpr (!is_trivially_destructible<T>())
+		if constexpr (!std::is_trivially_destructible<T>())
 			for (T *element = reinterpret_cast<T *>(mElements) + inNewSize, *element_end = reinterpret_cast<T *>(mElements) + mSize; element < element_end; ++element)
 				element->~T();
 		mSize = inNewSize;

+ 2 - 2
Jolt/Geometry/ConvexHullBuilder.cpp

@@ -468,7 +468,7 @@ ConvexHullBuilder::EResult ConvexHullBuilder::Initialize(int inMaxVertices, floa
 
 	// Ensure the planes are facing outwards
 	if (max_dist < 0.0f)
-		swap(idx2, idx3);
+		std::swap(idx2, idx3);
 
 	// Create tetrahedron
 	Face *t1 = CreateTriangle(idx1, idx2, idx4);
@@ -554,7 +554,7 @@ ConvexHullBuilder::EResult ConvexHullBuilder::Initialize(int inMaxVertices, floa
 				}
 
 				// Swap it to the end
-				swap(mCoplanarList[best_idx], mCoplanarList.back());
+				std::swap(mCoplanarList[best_idx], mCoplanarList.back());
 
 				// Remove it
 				furthest_point_idx = mCoplanarList.back().mPositionIdx;

+ 1 - 1
Jolt/Geometry/ConvexHullBuilder2D.cpp

@@ -169,7 +169,7 @@ ConvexHullBuilder2D::EResult ConvexHullBuilder2D::Initialize(int inIdx1, int inI
 	// Start with the initial indices in counter clockwise order
 	float z = (mPositions[inIdx2] - mPositions[inIdx1]).Cross(mPositions[inIdx3] - mPositions[inIdx1]).GetZ();
 	if (z < 0.0f)
-		swap(inIdx1, inIdx2);
+		std::swap(inIdx1, inIdx2);
 
 	// Create and link edges
 	Edge *e1 = new Edge(inIdx1);

+ 1 - 1
Jolt/Geometry/Indexify.cpp

@@ -107,7 +107,7 @@ static void sIndexifyVerticesRecursively(const TriangleList &inTriangles, uint32
 		{
 			// Vertex is on the wrong side, swap with the last vertex
 			--v_end;
-			swap(*v_read, *v_end);
+			std::swap(*v_read, *v_end);
 		}
 		else
 		{

+ 2 - 2
Jolt/Geometry/RaySphere.h

@@ -27,7 +27,7 @@ JPH_INLINE float RaySphere(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, Vec3Arg
 
 	// Sort so that the smallest is first
 	if (fraction1 > fraction2)
-		swap(fraction1, fraction2);
+		std::swap(fraction1, fraction2);
 
 	// Test solution with lowest fraction, this will be the ray entering the sphere
 	if (fraction1 >= 0.0f)
@@ -85,7 +85,7 @@ JPH_INLINE int RaySphere(Vec3Arg inRayOrigin, Vec3Arg inRayDirection, Vec3Arg in
 
 		// Sort so that the smallest is first
 		if (fraction1 > fraction2)
-			swap(fraction1, fraction2);
+			std::swap(fraction1, fraction2);
 
 		outMinFraction = fraction1;
 		outMaxFraction = fraction2;

+ 1 - 1
Jolt/Math/BVec16.h

@@ -92,7 +92,7 @@ public:
 	};
 };
 
-static_assert(is_trivial<BVec16>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<BVec16>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/DMat44.h

@@ -151,7 +151,7 @@ private:
 	DVec3						mCol3;													///< Translation column, 4th element is assumed to be 1
 };
 
-static_assert(is_trivial<DMat44>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<DMat44>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/DVec3.h

@@ -281,7 +281,7 @@ public:
 	};
 };
 
-static_assert(is_trivial<DVec3>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<DVec3>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/Double3.h

@@ -40,7 +40,7 @@ public:
 	double		z;
 };
 
-static_assert(is_trivial<Double3>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Double3>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/Float2.h

@@ -31,6 +31,6 @@ public:
 	float				y;
 };
 
-static_assert(is_trivial<Float2>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Float2>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END

+ 1 - 1
Jolt/Math/Float3.h

@@ -42,7 +42,7 @@ public:
 
 using VertexList = Array<Float3>;
 
-static_assert(is_trivial<Float3>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Float3>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/Float4.h

@@ -28,6 +28,6 @@ public:
 	float		w;
 };
 
-static_assert(is_trivial<Float4>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Float4>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END

+ 2 - 2
Jolt/Math/GaussianElimination.h

@@ -64,9 +64,9 @@ bool GaussianElimination(MatrixA &ioA, MatrixB &ioB, float inTolerance = 1.0e-16
 		if (pivot_row != pivot_col)
 		{
 			for (uint j = 0; j < n; ++j)
-				swap(ioA(pivot_row, j), ioA(pivot_col, j));
+				std::swap(ioA(pivot_row, j), ioA(pivot_col, j));
 			for (uint j = 0; j < m; ++j)
-				swap(ioB(pivot_row, j), ioB(pivot_col, j));
+				std::swap(ioB(pivot_row, j), ioB(pivot_col, j));
 		}
 
 		// Get diagonal element that we are about to set to 1

+ 1 - 1
Jolt/Math/Mat44.h

@@ -236,7 +236,7 @@ private:
 	Vec4						mCol[4];												///< Column
 };
 
-static_assert(is_trivial<Mat44>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Mat44>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/Quat.h

@@ -248,7 +248,7 @@ public:
 	Vec4						mValue;
 };
 
-static_assert(is_trivial<Quat>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Quat>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/UVec4.h

@@ -213,7 +213,7 @@ public:
 	};
 };
 
-static_assert(is_trivial<UVec4>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<UVec4>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/Vec3.h

@@ -288,7 +288,7 @@ public:
 	};
 };
 
-static_assert(is_trivial<Vec3>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Vec3>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Math/Vec4.h

@@ -276,7 +276,7 @@ public:
 	};
 };
 
-static_assert(is_trivial<Vec4>(), "Is supposed to be a trivial type!");
+static_assert(std::is_trivial<Vec4>(), "Is supposed to be a trivial type!");
 
 JPH_NAMESPACE_END
 

+ 1 - 1
Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp

@@ -383,7 +383,7 @@ void BroadPhaseQuadTree::NotifyBodiesLayerChanged(BodyID *ioBodies, int inNumber
 			mTracking[index].mObjectLayer = body->GetObjectLayer();
 
 			// Move the body to the end, layer didn't change
-			swap(*body_id, ioBodies[inNumber - 1]);
+			std::swap(*body_id, ioBodies[inNumber - 1]);
 			--inNumber;
 		}
 	}

+ 2 - 2
Jolt/Physics/Collision/BroadPhase/QuadTree.cpp

@@ -433,8 +433,8 @@ void QuadTree::sPartition(NodeID *ioNodeIDs, Vec3 *ioNodeCenters, int inNumber,
 		if (start < end)
 		{
 			// Swap the two elements
-			swap(ioNodeIDs[start], ioNodeIDs[end - 1]);
-			swap(ioNodeCenters[start], ioNodeCenters[end - 1]);
+			std::swap(ioNodeIDs[start], ioNodeIDs[end - 1]);
+			std::swap(ioNodeCenters[start], ioNodeCenters[end - 1]);
 			++start;
 			--end;
 		}

+ 1 - 1
Jolt/Physics/Collision/BroadPhase/QuadTree.h

@@ -143,7 +143,7 @@ private:
 
 	static_assert(sizeof(atomic<float>) == 4, "Assuming that an atomic doesn't add any additional storage");
 	static_assert(sizeof(atomic<uint32>) == 4, "Assuming that an atomic doesn't add any additional storage");
-	static_assert(is_trivially_destructible<Node>(), "Assuming that we don't have a destructor");
+	static_assert(std::is_trivially_destructible<Node>(), "Assuming that we don't have a destructor");
 
 public:
 	/// Class that allocates tree nodes, can be shared between multiple trees

+ 1 - 1
Jolt/Physics/Collision/GroupFilterTable.h

@@ -47,7 +47,7 @@ private:
 
 		// We store the lower left half only, so swap the inputs when trying to access the top right half
 		if (inSubGroup1 > inSubGroup2)
-			swap(inSubGroup1, inSubGroup2);
+			std::swap(inSubGroup1, inSubGroup2);
 
 		JPH_ASSERT(inSubGroup2 < mNumSubGroups);
 

+ 1 - 1
Jolt/Physics/Collision/ObjectLayerPairFilterTable.h

@@ -18,7 +18,7 @@ private:
 	{
 		// We store the lower left half only, so swap the inputs when trying to access the top right half
 		if (inLayer1 > inLayer2)
-			swap(inLayer1, inLayer2);
+			std::swap(inLayer1, inLayer2);
 
 		JPH_ASSERT(inLayer2 < mNumObjectLayers);
 

+ 1 - 1
Jolt/Physics/Collision/Shape/HeightFieldShape.cpp

@@ -1501,7 +1501,7 @@ void HeightFieldShape::GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg
 
 	// Flip triangle if scaled inside out
 	if (ScaleHelpers::IsInsideOut(inScale))
-		swap(outVertices[1], outVertices[2]);
+		std::swap(outVertices[1], outVertices[2]);
 
 	// Transform to world space
 	Mat44 transform = inCenterOfMassTransform.PreScaled(inScale);

+ 1 - 1
Jolt/Physics/Collision/Shape/MeshShape.cpp

@@ -421,7 +421,7 @@ void MeshShape::GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDire
 
 	// Flip triangle if scaled inside out
 	if (ScaleHelpers::IsInsideOut(inScale))
-		swap(outVertices[1], outVertices[2]);
+		std::swap(outVertices[1], outVertices[2]);
 
 	// Calculate transform with scale
 	Mat44 transform = inCenterOfMassTransform.PreScaled(inScale);

+ 6 - 6
Jolt/Physics/Collision/Shape/PlaneShape.cpp

@@ -116,8 +116,8 @@ void PlaneShape::GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDir
 	// Reverse if scale is inside out
 	if (ScaleHelpers::IsInsideOut(inScale))
 	{
-		swap(vertices[0], vertices[3]);
-		swap(vertices[1], vertices[2]);
+		std::swap(vertices[0], vertices[3]);
+		std::swap(vertices[1], vertices[2]);
 	}
 
 	// Transform them to world space
@@ -137,8 +137,8 @@ void PlaneShape::Draw(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransfo
 	// Reverse if scale is inside out
 	if (ScaleHelpers::IsInsideOut(inScale))
 	{
-		swap(local_vertices[0], local_vertices[3]);
-		swap(local_vertices[1], local_vertices[2]);
+		std::swap(local_vertices[0], local_vertices[3]);
+		std::swap(local_vertices[1], local_vertices[2]);
 	}
 
 	// Transform them to world space
@@ -400,8 +400,8 @@ void PlaneShape::GetTrianglesStart(GetTrianglesContext &ioContext, const AABox &
 	// Reverse if scale is inside out
 	if (ScaleHelpers::IsInsideOut(inScale))
 	{
-		swap(vertices[0], vertices[3]);
-		swap(vertices[1], vertices[2]);
+		std::swap(vertices[0], vertices[3]);
+		std::swap(vertices[1], vertices[2]);
 	}
 
 	// Transform them to world space

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

@@ -131,11 +131,11 @@ static constexpr EShapeSubType sCompoundSubShapeTypes[] = { EShapeSubType::Stati
 static constexpr EShapeSubType sDecoratorSubShapeTypes[] = { EShapeSubType::RotatedTranslated, EShapeSubType::Scaled, EShapeSubType::OffsetCenterOfMass };
 
 /// How many shape types we support
-static constexpr uint NumSubShapeTypes = uint(size(sAllSubShapeTypes));
+static constexpr uint NumSubShapeTypes = uint(std::size(sAllSubShapeTypes));
 
 /// Names of sub shape types
 static constexpr const char *sSubShapeTypeNames[] = { "Sphere", "Box", "Triangle", "Capsule", "TaperedCapsule", "Cylinder", "ConvexHull", "StaticCompound", "MutableCompound", "RotatedTranslated", "Scaled", "OffsetCenterOfMass", "Mesh", "HeightField", "SoftBody", "User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8", "UserConvex1", "UserConvex2", "UserConvex3", "UserConvex4", "UserConvex5", "UserConvex6", "UserConvex7", "UserConvex8", "Plane", "TaperedCylinder", "Empty" };
-static_assert(size(sSubShapeTypeNames) == NumSubShapeTypes);
+static_assert(std::size(sSubShapeTypeNames) == NumSubShapeTypes);
 
 /// Class that can construct shapes and that is serializable using the ObjectStream system.
 /// Can be used to store shape data in 'uncooked' form (i.e. in a form that is still human readable and authorable).

+ 2 - 2
Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp

@@ -133,8 +133,8 @@ void StaticCompoundShape::sPartition(uint *ioBodyIdx, AABox *ioBounds, int inNum
 		if (start < end)
 		{
 			// Swap the two elements
-			swap(ioBodyIdx[start], ioBodyIdx[end - 1]);
-			swap(ioBounds[start], ioBounds[end - 1]);
+			std::swap(ioBodyIdx[start], ioBodyIdx[end - 1]);
+			std::swap(ioBounds[start], ioBounds[end - 1]);
 			++start;
 			--end;
 		}

+ 1 - 1
Jolt/Physics/Collision/Shape/SubShapeIDPair.h

@@ -66,7 +66,7 @@ JPH_SUPPRESS_WARNINGS_STD_BEGIN
 
 namespace std
 {
-	/// Declare std::hash for SubShapeIDPair, note that std::hash is platform dependent and we need this one to be consistent because we sort on it in the ContactConstraintManager
+	/// Declare std::hash for SubShapeIDPair
 	template <>
 	struct hash<JPH::SubShapeIDPair>
 	{

+ 2 - 2
Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp

@@ -205,8 +205,8 @@ JPH_INLINE void TaperedCylinderShape::GetScaled(Vec3Arg inScale, float &outTop,
 	// Negative Y-scale flips the top and bottom
 	if (outBottom > outTop)
 	{
-		swap(outTop, outBottom);
-		swap(outTopRadius, outBottomRadius);
+		std::swap(outTop, outBottom);
+		std::swap(outTopRadius, outBottomRadius);
 	}
 }
 

+ 1 - 1
Jolt/Physics/Collision/Shape/TriangleShape.cpp

@@ -220,7 +220,7 @@ void TriangleShape::Draw(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTran
 	RVec3 v3 = inCenterOfMassTransform * (inScale * mV3);
 
 	if (ScaleHelpers::IsInsideOut(inScale))
-		swap(v1, v2);
+		std::swap(v1, v2);
 
 	if (inDrawWireframe)
 		inRenderer->DrawWireTriangle(v1, v2, v3, inUseMaterialColors? GetMaterial()->GetDebugColor() : inColor);

+ 2 - 2
Jolt/Physics/Constraints/ContactConstraintManager.cpp

@@ -1417,8 +1417,8 @@ void ContactConstraintManager::OnCCDContactAdded(ContactAllocator &ioContactAllo
 		// If we swapped body1 and body2 we need to swap the mass scales back
 		if (manifold == &temp)
 		{
-			swap(outSettings.mInvMassScale1, outSettings.mInvMassScale2);
-			swap(outSettings.mInvInertiaScale1, outSettings.mInvInertiaScale2);
+			std::swap(outSettings.mInvMassScale1, outSettings.mInvMassScale2);
+			std::swap(outSettings.mInvInertiaScale1, outSettings.mInvInertiaScale2);
 			// Note we do not need to negate the relative surface velocity as it is not applied by the CCD collision constraint
 		}
 	}

+ 1 - 1
Jolt/Physics/Constraints/ContactConstraintManager.h

@@ -319,7 +319,7 @@ private:
 	/// Define a map that maps SubShapeIDPair -> manifold
 	using ManifoldMap = LockFreeHashMap<SubShapeIDPair, CachedManifold>;
 	using MKeyValue = ManifoldMap::KeyValue;
-	using MKVAndCreated = pair<MKeyValue *, bool>;
+	using MKVAndCreated = std::pair<MKeyValue *, bool>;
 
 	/// Start of list of contact points for a particular pair of bodies
 	class CachedBodyPair

+ 1 - 1
Jolt/Physics/PhysicsSystem.cpp

@@ -993,7 +993,7 @@ void PhysicsSystem::ProcessBodyPair(ContactAllocator &ioContactAllocator, const
 	// Ensure that body1 id < body2 id when motion types are the same.
 	if (body1->GetMotionType() < body2->GetMotionType()
 		|| (body1->GetMotionType() == body2->GetMotionType() && inBodyPair.mBodyB < inBodyPair.mBodyA))
-		swap(body1, body2);
+		std::swap(body1, body2);
 
 	// Check if the contact points from the previous frame are reusable and if so copy them
 	bool pair_handled = false, constraint_created = false;

+ 1 - 1
Jolt/Physics/Ragdoll/Ragdoll.h

@@ -73,7 +73,7 @@ public:
 	/// Calculate the map needed for GetConstraintIndexToBodyIdxPair()
 	void								CalculateConstraintIndexToBodyIdxPair();
 
-	using BodyIdxPair = pair<int, int>;
+	using BodyIdxPair = std::pair<int, int>;
 
 	/// Table that maps a constraint index (index in mConstraints) to the indices of the bodies that the constraint is connected to (index in mBodyIDs)
 	const Array<BodyIdxPair> &			GetConstraintIndexToBodyIdxPair() const							{ return mConstraintIndexToBodyIdxPair; }

+ 1 - 1
Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp

@@ -497,7 +497,7 @@ void SoftBodySharedSettings::Optimize(OptimizationResults &outResults)
 				if (!found)
 					connectivity[inV1].push_back({ inV2, 1 });
 
-				swap(inV1, inV2);
+				std::swap(inV1, inV2);
 			}
 		};
 	for (const Edge &c : mEdgeConstraints)

+ 1 - 1
Jolt/Physics/StateRecorderImpl.h

@@ -38,7 +38,7 @@ public:
 	bool				IsEqual(StateRecorderImpl &inReference);
 
 	/// Convert the binary data to a string
-	string				GetData() const												{ return mStream.str(); }
+	std::string			GetData() const												{ return mStream.str(); }
 
 	/// Get size of the binary data in bytes
 	size_t				GetDataSize()												{ return size_t(mStream.tellp()); }

+ 3 - 3
Jolt/Physics/Vehicle/TrackedVehicleController.cpp

@@ -144,7 +144,7 @@ TrackedVehicleController::TrackedVehicleController(const TrackedVehicleControlle
 	JPH_ASSERT(inSettings.mTransmission.mShiftUpRPM > inSettings.mTransmission.mShiftDownRPM);
 
 	// Copy track settings
-	for (uint i = 0; i < size(mTracks); ++i)
+	for (uint i = 0; i < std::size(mTracks); ++i)
 	{
 		const VehicleTrackSettings &d = inSettings.mTracks[i];
 		static_cast<VehicleTrackSettings &>(mTracks[i]) = d;
@@ -167,7 +167,7 @@ void TrackedVehicleController::PreCollide(float inDeltaTime, PhysicsSystem &inPh
 	Wheels &wheels = mConstraint.GetWheels();
 
 	// Fill in track index
-	for (size_t t = 0; t < size(mTracks); ++t)
+	for (size_t t = 0; t < std::size(mTracks); ++t)
 		for (uint w : mTracks[t].mWheels)
 			static_cast<WheelTV *>(wheels[w])->mTrackIndex = (uint)t;
 
@@ -261,7 +261,7 @@ void TrackedVehicleController::PostCollide(float inDeltaTime, PhysicsSystem &inP
 	if (transmission_torque != 0.0f)
 	{
 		// Apply the transmission torque to the wheels
-		for (uint i = 0; i < size(mTracks); ++i)
+		for (uint i = 0; i < std::size(mTracks); ++i)
 		{
 			VehicleTrack &t = mTracks[i];
 

+ 1 - 1
Jolt/RegisterTypes.cpp

@@ -172,7 +172,7 @@ void RegisterTypesInternal(uint64 inVersionID)
 	};
 
 	// Register them all
-	Factory::sInstance->Register(types, (uint)size(types));
+	Factory::sInstance->Register(types, (uint)std::size(types));
 
 	// Initialize default physics material
 	if (PhysicsMaterial::sDefault == nullptr)

+ 1 - 1
Jolt/TriangleGrouper/TriangleGrouperClosestCentroid.cpp

@@ -54,7 +54,7 @@ void TriangleGrouperClosestCentroid::Group(const VertexList &inVertices, const I
 		}
 
 		// Make this triangle the first in a new batch
-		swap(*batch_begin, *lowest_iter);
+		std::swap(*batch_begin, *lowest_iter);
 		Vec3 first_centroid = centroids[*batch_begin];
 
 		// Sort remaining triangles in batch on distance to first triangle

+ 1 - 1
Jolt/TriangleSplitter/TriangleSplitter.cpp

@@ -42,7 +42,7 @@ bool TriangleSplitter::SplitInternal(const Range &inTriangles, uint inDimension,
 		if (start < end)
 		{
 			// Swap the two elements
-			swap(mSortedTriangleIdx[start], mSortedTriangleIdx[end - 1]);
+			std::swap(mSortedTriangleIdx[start], mSortedTriangleIdx[end - 1]);
 			++start;
 			--end;
 		}

+ 1 - 1
Jolt/TriangleSplitter/TriangleSplitterFixedLeafSize.cpp

@@ -149,7 +149,7 @@ bool TriangleSplitterFixedLeafSize::Split(const Range &inTriangles, Range &outLe
 		{
 			// Swap the two elements
 			for (uint g = 0; g < mLeafSize; ++g)
-				swap(mSortedTriangleIdx[start + g], mSortedTriangleIdx[end - mLeafSize + g]);
+				std::swap(mSortedTriangleIdx[start + g], mSortedTriangleIdx[end - mLeafSize + g]);
 			start += mLeafSize;
 			end -= mLeafSize;
 		}

+ 1 - 1
UnitTests/UnitTestFramework.cpp

@@ -230,7 +230,7 @@ struct LogReporter : public ConsoleReporter
 	void func(type arg) override								\
 	{															\
 		ConsoleReporter::func(arg);								\
-		string str = mStream.str();								\
+		std::string str = mStream.str();						\
 		if (!str.empty())										\
 			__android_log_write(ANDROID_LOG_INFO, "Jolt", str.c_str());	\
 		mStream.str("");										\