Add funciton and keybinding to stop playing a path

This commit is contained in:
Emma Broman
2020-01-26 16:30:20 -05:00
parent da8a773122
commit e209e7cd6a
5 changed files with 31 additions and 1 deletions

View File

@@ -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 ()

View File

@@ -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)

View File

@@ -62,6 +62,7 @@ public:
void startPath();
void pausePath();
void continuePath();
void stopPath();
private:
bool handleInstruction(const Instruction& instruction, int index);

View File

@@ -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,

View File

@@ -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<AutoNavigationModule>();
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<AutoNavigationModule>();
AutoNavigationHandler& handler = module->AutoNavigationHandler();
handler.stopPath();
return 0;
}
int goTo(lua_State* L) {
int nArguments = ghoul::lua::checkArgumentsAndThrow(L, { 1, 2 }, "lua::goTo");