| 14 | using namespace sim; |
| 15 | |
| 16 | void runMainLoop(vis::VisRoot& visRoot, EngineRoot& engineRoot, UpdateLoop::ShouldExit shouldExit, SimPausedPredicate paused) |
| 17 | { |
| 18 | // Run main loop |
| 19 | auto systemRegistry = engineRoot.systemRegistry; |
| 20 | auto simStepper = std::make_shared<SimStepper>(systemRegistry); |
| 21 | |
| 22 | SecondsD minFrameDuration = 0.01; |
| 23 | SecondsD currentWallTime = 0; |
| 24 | |
| 25 | UpdateLoop loop(minFrameDuration); |
| 26 | loop.exec([&](float dtWallClock) { |
| 27 | SecondsD dtSim = paused() ? 0.0 : dtWallClock; |
| 28 | simStepper->update(dtSim); |
| 29 | |
| 30 | for (const auto& system : *systemRegistry) |
| 31 | { |
| 32 | system->advanceWallTime(currentWallTime, dtWallClock); |
| 33 | } |
| 34 | currentWallTime += dtWallClock; |
| 35 | |
| 36 | return visRoot.render(); |
| 37 | }, shouldExit); |
| 38 | } |
| 39 | |
| 40 | } // namespace skybolt |