mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 20:21:24 -06:00
Add Lua method to check whether a scenegraphnode is present in the scene
Make use of the function to guard mark_interesting_nodes against a nonexisting scenegraph node
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user