diff --git a/configs/configs.xml b/configs/configs.xml
index c90be1d..49d9853 100644
--- a/configs/configs.xml
+++ b/configs/configs.xml
@@ -53,6 +53,16 @@
16
false
0.2
+
60
+
+ 4
diff --git a/hdtSMP64/config.cpp b/hdtSMP64/config.cpp
index 537000b..5eea755 100644
--- a/hdtSMP64/config.cpp
+++ b/hdtSMP64/config.cpp
@@ -29,6 +29,8 @@ namespace hdt
SkyrimPhysicsWorld::get()->min_fps = (btClamped(reader.readInt(), 1, 300));
SkyrimPhysicsWorld::get()->m_timeTick = 1.0f / SkyrimPhysicsWorld::get()->min_fps;
}
+ else if (reader.GetLocalName() == "maxSubSteps")
+ SkyrimPhysicsWorld::get()->m_maxSubSteps = btClamped(reader.readInt(), 1, 60);
else
{
_WARNING("Unknown config : %s", reader.GetLocalName());
diff --git a/hdtSMP64/hdtSkyrimPhysicsWorld.cpp b/hdtSMP64/hdtSkyrimPhysicsWorld.cpp
index 0b2da44..f25cae6 100644
--- a/hdtSMP64/hdtSkyrimPhysicsWorld.cpp
+++ b/hdtSMP64/hdtSkyrimPhysicsWorld.cpp
@@ -81,15 +81,14 @@ namespace hdt
// This magic value directly impacts the number of computations and the time cost of the mod...
if (m_accumulatedInterval * 2.0f > tick)
{
- // We limit the interval to 4 substeps.
+ // The interval is limited to a configurable number of substeps, by default 4.
// Additional substeps happens when there is a very sudden slowdown, or when fps is lower than min-fps,
// we have to compute for the passed time we haven't computed.
// n substeps means that when instant fps is n times lower than usual current fps, we stop computing.
// So, we guarantee no jitter for fps greater than min-fps / maxSubsteps.
// For example, if min-fps = 60 and maxSubsteps = 4, we guarantee no jitter for 15+ fps,
// at the cost of additional simulations.
- const auto maxSubSteps = 4;
- const auto remainingTimeStep = std::min(m_accumulatedInterval, tick * maxSubSteps);
+ const auto remainingTimeStep = std::min(m_accumulatedInterval, tick * m_maxSubSteps);
readTransform(remainingTimeStep);
updateActiveState();
diff --git a/hdtSMP64/hdtSkyrimPhysicsWorld.h b/hdtSMP64/hdtSkyrimPhysicsWorld.h
index f8cf6c7..2ef7ea7 100644
--- a/hdtSMP64/hdtSkyrimPhysicsWorld.h
+++ b/hdtSMP64/hdtSkyrimPhysicsWorld.h
@@ -64,6 +64,7 @@ namespace hdt
int min_fps = 60;
int m_percentageOfFrameTime = 300; // percentage of time per frame doing hdt. Profiler shows 30% is reasonable. Out of 1000.
float m_timeTick = 1 / 60.f;
+ int m_maxSubSteps = 4;
bool m_clampRotations = true;
bool m_unclampedResets = true;
float m_unclampedResetAngle = 120.0f;