Explorar o código

Removed ugly placement new construct

Jorrit Rouwe %!s(int64=3) %!d(string=hai) anos
pai
achega
fdd0dac23a

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

@@ -27,9 +27,8 @@ class TwoBodyConstraint;
 class BodyInterface : public NonCopyable
 {
 public:
-	/// Constructor
-								BodyInterface() = default;
-								BodyInterface(BodyLockInterface &inBodyLockInterface, BodyManager &inBodyManager, BroadPhase &inBroadPhase) : mBodyLockInterface(&inBodyLockInterface), mBodyManager(&inBodyManager), mBroadPhase(&inBroadPhase) { }
+	/// Initialize the interface (should only be called by PhysicsSystem)
+	void						Init(BodyLockInterface &inBodyLockInterface, BodyManager &inBodyManager, BroadPhase &inBroadPhase) { mBodyLockInterface = &inBodyLockInterface; mBodyManager = &inBodyManager; mBroadPhase = &inBroadPhase; }
 	
 	/// Create a body
 	/// @return Created body or null when out of bodies

+ 2 - 3
Jolt/Physics/Collision/NarrowPhaseQuery.h

@@ -20,9 +20,8 @@ class RayCastResult;
 class NarrowPhaseQuery : public NonCopyable
 {
 public:
-	/// Constructor
-								NarrowPhaseQuery() = default;
-								NarrowPhaseQuery(BodyLockInterface &inBodyLockInterface, BroadPhase &inBroadPhase) : mBodyLockInterface(&inBodyLockInterface), mBroadPhase(&inBroadPhase) { }
+	/// Initialize the interface (should only be called by PhysicsSystem)
+	void						Init(BodyLockInterface &inBodyLockInterface, BroadPhase &inBroadPhase) { mBodyLockInterface = &inBodyLockInterface; mBroadPhase = &inBroadPhase; }
 
 	/// Cast a ray and find the closest hit. Returns true if it finds a hit. Hits further than ioHit.mFraction will not be considered and in this case ioHit will remain unmodified (and the function will return false).
 	/// Convex objects will be treated as solid (meaning if the ray starts inside, you'll get a hit fraction of 0) and back face hits against triangles are returned.

+ 4 - 10
Jolt/Physics/PhysicsSystem.cpp

@@ -78,18 +78,12 @@ void PhysicsSystem::Init(uint inMaxBodies, uint inNumBodyMutexes, uint inMaxBody
 	mIslandBuilder.Init(inMaxBodies);
 
 	// Initialize body interface
-	mBodyInterfaceLocking.~BodyInterface();
-	new (&mBodyInterfaceLocking) BodyInterface(mBodyLockInterfaceLocking, mBodyManager, *mBroadPhase);
-
-	mBodyInterfaceNoLock.~BodyInterface();
-	new (&mBodyInterfaceNoLock) BodyInterface(mBodyLockInterfaceNoLock, mBodyManager, *mBroadPhase);
+	mBodyInterfaceLocking.Init(mBodyLockInterfaceLocking, mBodyManager, *mBroadPhase);
+	mBodyInterfaceNoLock.Init(mBodyLockInterfaceNoLock, mBodyManager, *mBroadPhase);
 
 	// Initialize narrow phase query
-	mNarrowPhaseQueryLocking.~NarrowPhaseQuery();
-	new (&mNarrowPhaseQueryLocking) NarrowPhaseQuery(mBodyLockInterfaceLocking, *mBroadPhase);
-
-	mNarrowPhaseQueryNoLock.~NarrowPhaseQuery();
-	new (&mNarrowPhaseQueryNoLock) NarrowPhaseQuery(mBodyLockInterfaceNoLock, *mBroadPhase);
+	mNarrowPhaseQueryLocking.Init(mBodyLockInterfaceLocking, *mBroadPhase);
+	mNarrowPhaseQueryNoLock.Init(mBodyLockInterfaceNoLock, *mBroadPhase);
 }
 
 void PhysicsSystem::OptimizeBroadPhase()