diff --git a/scripts/scene_helper.lua b/scripts/scene_helper.lua index 9b12b56023..b97a32d37c 100644 --- a/scripts/scene_helper.lua +++ b/scripts/scene_helper.lua @@ -1,5 +1,7 @@ mark_interesting_nodes = function(nodes) for _, n in pairs(nodes) do - openspace.addTag(n, "GUI.Interesting") + if openspace.hasSceneGraphNode(n) then + openspace.addTag(n, "GUI.Interesting") + end end end diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index b889f5ab46..436bc12a9b 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -416,6 +416,13 @@ scripting::LuaLibrary Scene::luaLibrary() { &luascriptfunctions::removeSceneGraphNode, "string", "Removes the SceneGraphNode identified by name" + }, + { + "hasSceneGraphNode", + &luascriptfunctions::hasSceneGraphNode, + "string", + "Checks whether the specifies SceneGraphNode is present in the current " + "scene" } } }; diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 4dc36497bc..e8d05672eb 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -390,4 +390,16 @@ int removeSceneGraphNode(lua_State* L) { return 1; } + +int hasSceneGraphNode(lua_State* L) { + int nArguments = lua_gettop(L); + SCRIPT_CHECK_ARGUMENTS("removeSceneGraphNode", L, 1, nArguments); + + std::string nodeName = luaL_checkstring(L, -1); + SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(nodeName); + + lua_pushboolean(L, node != nullptr); + return 1; +} + } // namespace openspace::luascriptfunctions