MCPcopy Create free account
hub / github.com/chrxh/alien / slowdownTPS

Method slowdownTPS

source/EngineImpl/EngineWorker.cpp:581–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579}
580
581void EngineWorker::slowdownTPS()
582{
583 if (_slowDownTimepoint) {
584 auto timestepDuration = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - *_slowDownTimepoint);
585 if (_slowDownOvershot) {
586 timestepDuration += *_slowDownOvershot;
587 }
588 auto tpsRestriction = _tpsRestriction.load();
589 if (_isSimulationRunning.load() && tpsRestriction > 0) {
590 auto desiredDuration = std::chrono::microseconds(1000000 / tpsRestriction);
591 if (desiredDuration > timestepDuration) {
592 waitAndAllowAccess(desiredDuration - timestepDuration);
593 } else {
594 }
595 _slowDownOvershot = std::min(std::max(timestepDuration - desiredDuration, std::chrono::microseconds(0)), desiredDuration);
596 }
597 }
598 _slowDownTimepoint = std::chrono::steady_clock::now();
599}
600
601void EngineWorker::registerImageResource()
602{

Callers

nothing calls this directly

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected