2
0
Jorrit Rouwe 3 жил өмнө
parent
commit
01a3f45a27

+ 2 - 3
Jolt/Core/Factory.cpp

@@ -52,9 +52,8 @@ bool Factory::Register(const RTTI *inRTTI)
 	for (int i = 0; i < inRTTI->GetAttributeCount(); ++i)
 	{
 		const RTTI *rtti = inRTTI->GetAttribute(i)->GetMemberPrimitiveType();
-		if (rtti != nullptr)
-			if (!Register(rtti))
-				return false;
+		if (rtti != nullptr && !Register(rtti))
+			return false;
 	}
 
 	return true;

+ 11 - 8
Jolt/Core/HashCombine.h

@@ -5,12 +5,16 @@
 
 JPH_NAMESPACE_BEGIN
 
-inline void hash_combine(std::size_t &ioSeed) 
-{ 
+/// @brief Helper function that hashes a single value into ioSeed
+/// Taken from: https://stackoverflow.com/questions/2590677/how-do-i-combine-hash-values-in-c0x
+template <typename T>
+inline void hash_combine_helper(std::size_t &ioSeed, const T &inValue)
+{
+	std::hash<T> hasher;
+    ioSeed ^= hasher(inValue) + 0x9e3779b9 + (ioSeed << 6) + (ioSeed >> 2);
 }
 
 /// Hash combiner to use a custom struct in an unordered map or set
-/// Taken from: https://stackoverflow.com/questions/2590677/how-do-i-combine-hash-values-in-c0x
 ///
 /// Usage:
 ///
@@ -22,12 +26,11 @@ inline void hash_combine(std::size_t &ioSeed)
 ///		};
 /// 
 ///		JPH_MAKE_HASHABLE(SomeHashKey, t.key1, t.key2, t.key3)
-template <typename T, typename... Rest>
-inline void hash_combine(std::size_t &ioSeed, const T &inValue, Rest... inRest) 
+template <typename... Values>
+inline void hash_combine(std::size_t &ioSeed, Values... inValues) 
 {
-	std::hash<T> hasher;
-    ioSeed ^= hasher(inValue) + 0x9e3779b9 + (ioSeed << 6) + (ioSeed >> 2);
-    hash_combine(ioSeed, inRest...);
+	// Hash all values together using a fold expression
+	(hash_combine_helper(ioSeed, inValues), ...);
 }
 
 JPH_NAMESPACE_END

+ 1 - 1
Jolt/Core/JobSystem.h

@@ -54,7 +54,7 @@ public:
 	public:
 		/// Constructor 
 		inline				JobHandle() = default;
-		inline				JobHandle(const JobHandle &inHandle)		: Ref<Job>(inHandle) { }
+		inline				JobHandle(const JobHandle &inHandle) = default;
 		inline				JobHandle(JobHandle &&inHandle) noexcept	: Ref<Job>(move(inHandle)) { }
 
 		/// Constructor, only to be used by JobSystem

+ 1 - 3
Jolt/Core/StaticArray.h

@@ -15,9 +15,7 @@ public:
 	using size_type = uint;
 
 	/// Default constructor
-						StaticArray()
-	{
-	}
+						StaticArray() = default;
 
 	/// Constructor from initializer list
 	explicit			StaticArray(initializer_list<T> inList)

+ 1 - 1
Jolt/Geometry/EPAConvexHullBuilder.h

@@ -181,7 +181,7 @@ public:
 	{
 	public:
 		/// Function to sort triangles on closest distance to origin
-		static bool		sTriangleSorter(Triangle *inT1, Triangle *inT2)
+		static bool		sTriangleSorter(const Triangle *inT1, const Triangle *inT2)
 		{
 			return inT1->mClosestLenSq > inT2->mClosestLenSq;
 		}

+ 2 - 2
Jolt/Geometry/IndexedTriangle.h

@@ -65,9 +65,9 @@ public:
 class IndexedTriangle : public IndexedTriangleNoMaterial
 {
 public:
+	using IndexedTriangleNoMaterial::IndexedTriangleNoMaterial;
+
 	/// Constructor
-					IndexedTriangle() = default;
-					IndexedTriangle(uint32 inI1, uint32 inI2, uint32 inI3) : IndexedTriangleNoMaterial(inI1, inI2, inI3) { }
 					IndexedTriangle(uint32 inI1, uint32 inI2, uint32 inI3, uint32 inMaterialIndex) : IndexedTriangleNoMaterial(inI1, inI2, inI3), mMaterialIndex(inMaterialIndex) { }
 
 	/// Check if two triangles are identical

+ 1 - 1
Jolt/ObjectStream/SerializableAttribute.h

@@ -16,7 +16,7 @@ class SerializableAttribute : public RTTIAttribute
 {
 public:
 	/// Constructor
-	explicit					SerializableAttribute(const char *inName)							: RTTIAttribute(inName) { }
+	using RTTIAttribute::RTTIAttribute;
 
 	///@name Serialization operations
 	virtual bool				IsType(int inArrayDepth, ObjectStream::EDataType inDataType, const char *inClassName) const = 0;

+ 1 - 1
Jolt/Physics/Character/Character.cpp

@@ -22,7 +22,7 @@ static inline BodyInterface &sGetBodyInterface(PhysicsSystem *inSystem, bool inL
 	return inLockBodies? inSystem->GetBodyInterface() : inSystem->GetBodyInterfaceNoLock();
 }
 
-static inline const NarrowPhaseQuery &sGetNarrowPhaseQuery(PhysicsSystem *inSystem, bool inLockBodies)
+static inline const NarrowPhaseQuery &sGetNarrowPhaseQuery(const PhysicsSystem *inSystem, bool inLockBodies)
 {
 	return inLockBodies? inSystem->GetNarrowPhaseQuery() : inSystem->GetNarrowPhaseQueryNoLock();
 }

+ 1 - 0
Jolt/Physics/Collision/Shape/CapsuleShape.h

@@ -75,6 +75,7 @@ public:
 #endif // JPH_DEBUG_RENDERER
 
 	// See Shape::CastRay
+	using ConvexShape::CastRay;
 	virtual bool			CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const override;
 
 	// See: Shape::CollidePoint

+ 1 - 0
Jolt/Physics/Collision/Shape/CylinderShape.h

@@ -71,6 +71,7 @@ public:
 #endif // JPH_DEBUG_RENDERER
 
 	// See Shape::CastRay
+	using ConvexShape::CastRay;
 	virtual bool			CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const override;
 
 	// See: Shape::CollidePoint

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

@@ -155,7 +155,7 @@ public:
 	}
 
 	/// Add a mesh part and its transform
-	void			AddPart(const Mat44 inLocalToWorld, const Vec3 *inTriangleVertices, size_t inNumTriangleVertices)
+	void			AddPart(Mat44Arg inLocalToWorld, const Vec3 *inTriangleVertices, size_t inNumTriangleVertices)
 	{
 		JPH_ASSERT(inNumTriangleVertices % 3 == 0);
 		

+ 1 - 0
Jolt/Physics/Constraints/ConstraintPart/SpringPart.h

@@ -4,6 +4,7 @@
 #pragma once
 
 JPH_NAMESPACE_BEGIN
+JPH_MSVC_SUPPRESS_WARNING(4723) // potential divide by 0 - caused by line: outEffectiveMass = 1.0f / inInvEffectiveMass, note that JPH_NAMESPACE_BEGIN already pushes the warning state
 
 /// Class used in other constraint parts to calculate the required bias factor in the lagrange multiplier for creating springs
 class SpringPart

+ 1 - 1
Jolt/Physics/IslandBuilder.cpp

@@ -278,7 +278,7 @@ void IslandBuilder::BuildBodyIslands(const BodyID *inActiveBodies, uint32 inNumA
 	mBodyIslandEnds = body_island_starts;
 }
 
-void IslandBuilder::BuildConstraintIslands(uint32 *inConstraintToBody, uint32 inNumConstraints, uint32 *&outConstraints, uint32 *&outConstraintsEnd, TempAllocator *inTempAllocator) const
+void IslandBuilder::BuildConstraintIslands(const uint32 *inConstraintToBody, uint32 inNumConstraints, uint32 *&outConstraints, uint32 *&outConstraintsEnd, TempAllocator *inTempAllocator) const
 {
 	JPH_PROFILE_FUNCTION();
 

+ 1 - 1
Jolt/Physics/IslandBuilder.h

@@ -66,7 +66,7 @@ private:
 
 	// Helper functions to build various islands
 	void					BuildBodyIslands(const BodyID *inActiveBodies, uint32 inNumActiveBodies, TempAllocator *inTempAllocator);
-	void					BuildConstraintIslands(uint32 *inConstraintToBody, uint32 inNumConstraints, uint32 *&outConstraints, uint32 *&outConstraintsEnd, TempAllocator *inTempAllocator) const;
+	void					BuildConstraintIslands(const uint32 *inConstraintToBody, uint32 inNumConstraints, uint32 *&outConstraints, uint32 *&outConstraintsEnd, TempAllocator *inTempAllocator) const;
 
 	/// Sorts the islands so that the islands with most constraints go first
 	void					SortIslands(TempAllocator *inTempAllocator);

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

@@ -35,7 +35,7 @@ static inline BodyInterface &sGetBodyInterface(PhysicsSystem *inSystem, bool inL
 	return inLockBodies? inSystem->GetBodyInterface() : inSystem->GetBodyInterfaceNoLock();
 }
 
-static inline const BodyLockInterface &sGetBodyLockInterface(PhysicsSystem *inSystem, bool inLockBodies)
+static inline const BodyLockInterface &sGetBodyLockInterface(const PhysicsSystem *inSystem, bool inLockBodies)
 {
 	return inLockBodies? static_cast<const BodyLockInterface &>(inSystem->GetBodyLockInterface()) : static_cast<const BodyLockInterface &>(inSystem->GetBodyLockInterfaceNoLock());
 }