Automatically pause simulation time when starting a camera path (adresses #1832)

This commit is contained in:
Emma Broman
2022-01-19 10:27:44 +01:00
parent c2755b8633
commit 0da8afa550
2 changed files with 24 additions and 7 deletions

View File

@@ -81,6 +81,8 @@ public:
static scripting::LuaLibrary luaLibrary();
private:
void handlePathEnd();
/**
* Populate list of nodes that are relevant for collision checks, etc
*/
@@ -90,6 +92,7 @@ private:
std::unique_ptr<Path> _currentPath = nullptr;
bool _isPlaying = false;
bool _startSimulationTimeOnFinish = false;
properties::OptionProperty _defaultPathType;
properties::BoolProperty _includeRoll;

View File

@@ -200,7 +200,7 @@ void PathNavigator::updateCamera(double deltaTime) {
if (_currentPath->hasReachedEnd()) {
LINFO("Reached end of path");
_isPlaying = false;
handlePathEnd();
if (_applyIdleBehaviorOnFinish) {
constexpr const char* ApplyIdleBehaviorScript =
@@ -263,10 +263,16 @@ void PathNavigator::startPath() {
return;
}
//OBS! Until we can handle simulation time: early out if not paused
// Always pause the simulation time when flying, to aovid problem with objects
// moving. However, keep track of whether the time was running before the path
// was started, so we can reset it on finish
if (!global::timeManager->isPaused()) {
LERROR("Simulation time must be paused to run a camera path");
return;
global::timeManager->setPause(true);
_startSimulationTimeOnFinish = true;
LINFO(
"Pausing time simulation during path traversal. "
"Will unpause once the camera path is finished"
);
}
LINFO("Starting path");
@@ -280,9 +286,7 @@ void PathNavigator::abortPath() {
LWARNING("No camera path is playing");
return;
}
_isPlaying = false;
clearPath(); // TODO: instead of clearing this could be handled better
handlePathEnd();
LINFO("Aborted camera path");
}
@@ -329,6 +333,16 @@ const std::vector<SceneGraphNode*>& PathNavigator::relevantNodes() {
return _relevantNodes;
}
void PathNavigator::handlePathEnd() {
_isPlaying = false;
if (_startSimulationTimeOnFinish) {
global::timeManager->setPause(false);
}
_startSimulationTimeOnFinish = false;
clearPath();
}
void PathNavigator::findRelevantNodes() {
const std::vector<SceneGraphNode*>& allNodes =
global::renderEngine->scene()->allSceneGraphNodes();