1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-26 06:40:22 +00:00

Fix clamping physics threads

This commit is contained in:
elsid 2023-03-03 18:39:23 +01:00
parent 0d25656d81
commit 3d3cccb8e5
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

View File

@ -330,8 +330,8 @@ namespace MWPhysics
case LockingPolicy::ExclusiveLocksOnly: case LockingPolicy::ExclusiveLocksOnly:
return 1; return 1;
case LockingPolicy::AllowSharedLocks: case LockingPolicy::AllowSharedLocks:
return static_cast<unsigned>(std::max( return static_cast<unsigned>(std::clamp(
getMaxBulletSupportedThreads(), Settings::Manager::getInt("async num threads", "Physics"))); Settings::Manager::getInt("async num threads", "Physics"), 0, getMaxBulletSupportedThreads()));
} }
throw std::runtime_error("Unsupported LockingPolicy: " throw std::runtime_error("Unsupported LockingPolicy: "
@ -372,6 +372,7 @@ namespace MWPhysics
{ {
if (mNumThreads >= 1) if (mNumThreads >= 1)
{ {
Log(Debug::Info) << "Using " << mNumThreads << " async physics threads";
for (unsigned i = 0; i < mNumThreads; ++i) for (unsigned i = 0; i < mNumThreads; ++i)
mThreads.emplace_back([&] { worker(); }); mThreads.emplace_back([&] { worker(); });
} }