Browse Source

Made PhysicsLock work when compiling Jolt as a shared library with MingW

Fixes #1266
Jorrit Rouwe 10 months ago
parent
commit
6416bcf587
3 changed files with 3 additions and 21 deletions
  1. 0 1
      Jolt/Jolt.cmake
  2. 0 17
      Jolt/Physics/PhysicsLock.cpp
  3. 3 3
      Jolt/Physics/PhysicsLock.h

+ 0 - 1
Jolt/Jolt.cmake

@@ -350,7 +350,6 @@ set(JOLT_PHYSICS_SRC_FILES
 	${JOLT_PHYSICS_ROOT}/Physics/IslandBuilder.h
 	${JOLT_PHYSICS_ROOT}/Physics/LargeIslandSplitter.cpp
 	${JOLT_PHYSICS_ROOT}/Physics/LargeIslandSplitter.h
-	${JOLT_PHYSICS_ROOT}/Physics/PhysicsLock.cpp
 	${JOLT_PHYSICS_ROOT}/Physics/PhysicsLock.h
 	${JOLT_PHYSICS_ROOT}/Physics/PhysicsScene.cpp
 	${JOLT_PHYSICS_ROOT}/Physics/PhysicsScene.h

+ 0 - 17
Jolt/Physics/PhysicsLock.cpp

@@ -1,17 +0,0 @@
-// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
-// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
-// SPDX-License-Identifier: MIT
-
-#include <Jolt/Jolt.h>
-
-#include <Jolt/Physics/PhysicsLock.h>
-
-#ifdef JPH_ENABLE_ASSERTS
-
-JPH_NAMESPACE_BEGIN
-
-thread_local PhysicsLock::LockData PhysicsLock::sLocks[4];
-
-JPH_NAMESPACE_END
-
-#endif

+ 3 - 3
Jolt/Physics/PhysicsLock.h

@@ -29,7 +29,7 @@ using PhysicsLockContext = const BodyManager *;
 
 /// Helpers to safely lock the different mutexes that are part of the physics system while preventing deadlock
 /// Class that keeps track per thread which lock are taken and if the order of locking is correct
-class PhysicsLock
+class JPH_EXPORT PhysicsLock
 {
 public:
 #ifdef JPH_ENABLE_ASSERTS
@@ -86,11 +86,11 @@ private:
 		PhysicsLockContext		mContext = nullptr;
 	};
 
-	static thread_local LockData sLocks[4];
-
 	// Helper function to find the locked mutexes for a particular context
 	static uint32 &				sGetLockedMutexes(PhysicsLockContext inContext)
 	{
+		static thread_local LockData sLocks[4];
+
 		// If we find a matching context we can use it
 		for (LockData &l : sLocks)
 			if (l.mContext == inContext)