1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 23:15:43 +00:00

Merge branch 'fix_clamp_physics_threads' into 'master'

Fix clamping physics threads

See merge request OpenMW/openmw!2792

(cherry picked from commit fbb00027d8)

3d3cccb8 Fix clamping physics threads
This commit is contained in:
psi29a 2023-03-03 19:52:15 +00:00 committed by elsid
parent a7116aacbc
commit 5dfd2709b7

View file

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