From e209e7cd6a911754e297d8526b828588abae170f Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Sun, 26 Jan 2020 16:30:20 -0500 Subject: [PATCH] Add funciton and keybinding to stop playing a path --- data/assets/camera_paths_test.scene | 8 ++++++++ modules/autonavigation/autonavigationhandler.cpp | 4 ++++ modules/autonavigation/autonavigationhandler.h | 1 + modules/autonavigation/autonavigationmodule.cpp | 7 +++++++ modules/autonavigation/autonavigationmodule_lua.inl | 12 +++++++++++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/data/assets/camera_paths_test.scene b/data/assets/camera_paths_test.scene index ee91baa52b..d8ef10a6b3 100644 --- a/data/assets/camera_paths_test.scene +++ b/data/assets/camera_paths_test.scene @@ -69,6 +69,14 @@ local Keybindings = { GuiPath = "/Interaction", Local = false }, + { + Key = "Q", + Name = "Stop camera path", + Command = "openspace.autonavigation.stopPath()", + Documentation = "Stop a camera path.", + GuiPath = "/Interaction", + Local = false + }, } asset.onInitialize(function () diff --git a/modules/autonavigation/autonavigationhandler.cpp b/modules/autonavigation/autonavigationhandler.cpp index d96c09712d..957593cb06 100644 --- a/modules/autonavigation/autonavigationhandler.cpp +++ b/modules/autonavigation/autonavigationhandler.cpp @@ -236,6 +236,10 @@ void AutoNavigationHandler::continuePath() { _isPlaying = true; } +void AutoNavigationHandler::stopPath() { + _isPlaying = false; +} + bool AutoNavigationHandler::handleInstruction(const Instruction& instruction, int index) { bool success = true; switch (instruction.type) diff --git a/modules/autonavigation/autonavigationhandler.h b/modules/autonavigation/autonavigationhandler.h index 0082173e10..1e131f8c1d 100644 --- a/modules/autonavigation/autonavigationhandler.h +++ b/modules/autonavigation/autonavigationhandler.h @@ -62,6 +62,7 @@ public: void startPath(); void pausePath(); void continuePath(); + void stopPath(); private: bool handleInstruction(const Instruction& instruction, int index); diff --git a/modules/autonavigation/autonavigationmodule.cpp b/modules/autonavigation/autonavigationmodule.cpp index 4bc4f73142..1a10a4f5fb 100644 --- a/modules/autonavigation/autonavigationmodule.cpp +++ b/modules/autonavigation/autonavigationmodule.cpp @@ -59,6 +59,13 @@ scripting::LuaLibrary AutoNavigationModule::luaLibrary() const { "", "Continue playing a paused camera path." }, + { + "stopPath", + &autonavigation::luascriptfunctions::stopPath, + {}, + "", + "Stops a path, if one is being played." + }, { "goTo", &autonavigation::luascriptfunctions::goTo, diff --git a/modules/autonavigation/autonavigationmodule_lua.inl b/modules/autonavigation/autonavigationmodule_lua.inl index b247ae3fd3..e9b1457844 100644 --- a/modules/autonavigation/autonavigationmodule_lua.inl +++ b/modules/autonavigation/autonavigationmodule_lua.inl @@ -42,7 +42,7 @@ namespace openspace::autonavigation::luascriptfunctions { const double EPSILON = 1e-12; int continuePath(lua_State* L) { - int nArguments = ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::continuePath"); + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::continuePath"); AutoNavigationModule* module = global::moduleEngine.module(); AutoNavigationHandler& handler = module->AutoNavigationHandler(); @@ -51,6 +51,16 @@ namespace openspace::autonavigation::luascriptfunctions { return 0; } + int stopPath(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::stopPath"); + + AutoNavigationModule* module = global::moduleEngine.module(); + AutoNavigationHandler& handler = module->AutoNavigationHandler(); + handler.stopPath(); + + return 0; + } + int goTo(lua_State* L) { int nArguments = ghoul::lua::checkArgumentsAndThrow(L, { 1, 2 }, "lua::goTo");