mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-06 04:18:36 -06:00
Enable global variables for module Lua scripts (closing #172)
Adapt New Horizons kernels to global switch between accurate and publicly avaiable kernels
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
"${SPICE}/nh_kernels/spk/NavSE_plu047_od122.bsp"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
UseAccurateNewHorizonsKernels = false
|
||||
|
||||
return {
|
||||
ScenePath = ".",
|
||||
CommonFolder = "common",
|
||||
@@ -14,7 +16,6 @@ return {
|
||||
"saturn",
|
||||
"uranus",
|
||||
"neptune",
|
||||
--"PlutoProjection",
|
||||
"plutoprojectionhybrid",
|
||||
"charonprojection",
|
||||
"kerberos",
|
||||
@@ -38,17 +39,6 @@ return {
|
||||
"callistoprojection",
|
||||
"newhorizons",
|
||||
"newhorizonsfov",
|
||||
--"gridGalactic",
|
||||
--"gridEcliptic",
|
||||
--"gridEquatorial",
|
||||
-- "ephemeris",
|
||||
|
||||
-- "newhorizonspath",
|
||||
-- "newhorizonstrail",
|
||||
-- "enlil",
|
||||
-- "volumegl3",
|
||||
-- "volumegl2",
|
||||
-- "volumegl",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
"${SPICE}/nh_kernels/spk/NavSE_plu047_od122.bsp"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
"${SPICE}/nh_kernels/spk/NavSE_plu047_od122.bsp"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
-- SCLK
|
||||
"${SPICE}/nh_kernels/sclk/new-horizons_0976.tsc",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
"${SPICE}/nh_kernels/spk/NavSE_plu047_od122.bsp"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
"${SPICE}/nh_kernels/spk/NavPE_de433_od122.bsp",
|
||||
"${SPICE}/nh_kernels/spk/NavSE_plu047_od122.bsp"
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
UseAccurateKernels = false
|
||||
|
||||
if UseAccurateKernels then
|
||||
if UseAccurateNewHorizonsKernels then
|
||||
NewHorizonsKernels = {
|
||||
"${SPICE}/nh_kernels/spk/NavSE_plu047_od122.bsp"
|
||||
}
|
||||
|
||||
Submodule ext/ghoul updated: 1dea593710...ad456dd4b2
@@ -8,11 +8,7 @@ return {
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
Scene = "${SCENE}/default_nh.scene",
|
||||
-- Scene = "${SCENE}/default.scene",
|
||||
-- Scene = "${SCENE}/default-modified.scene",
|
||||
-- Scene = "${SCENE}/rosetta.scene",
|
||||
-- Scene = "${SCENE}/dawn.scene",
|
||||
|
||||
|
||||
Paths = {
|
||||
SGCT = "${BASE_PATH}/config/sgct",
|
||||
SCRIPTS = "${BASE_PATH}/scripts",
|
||||
|
||||
@@ -126,10 +126,16 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
|
||||
if (!success)
|
||||
// There are no modules that are loaded
|
||||
return true;
|
||||
|
||||
|
||||
lua_State* state = ghoul::lua::createNewLuaState();
|
||||
OsEng.scriptEngine().initializeLuaState(state);
|
||||
|
||||
// Above we generated a ghoul::Dictionary from the scene file; now we run the scene
|
||||
// file again to load any variables defined inside into the state that is passed to
|
||||
// the modules. This allows us to specify global variables that can then be used
|
||||
// inside the modules to toggle settings
|
||||
ghoul::lua::runScriptFile(state, absSceneFile);
|
||||
|
||||
// Get the common directory
|
||||
bool commonFolderSpecified = sceneDictionary.hasKey(KeyCommonFolder);
|
||||
bool commonFolderCorrectType = sceneDictionary.hasKeyAndValue<std::string>(KeyCommonFolder);
|
||||
|
||||
@@ -141,22 +141,20 @@ bool ScriptEngine::runScript(const std::string& script) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int status = luaL_loadstring(_state, script.c_str());
|
||||
if (status != LUA_OK) {
|
||||
LERROR("Error loading script: '" << lua_tostring(_state, -1) << "'");
|
||||
try {
|
||||
ghoul::lua::runScript(_state, script);
|
||||
}
|
||||
catch (const ghoul::lua::LuaLoadingException& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
return false;
|
||||
}
|
||||
catch (const ghoul::lua::LuaExecutionException& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
//LDEBUG("Executing script");
|
||||
//LINFO(script);
|
||||
if (lua_pcall(_state, 0, LUA_MULTRET, 0)) {
|
||||
LERROR("Error executing script: " << lua_tostring(_state, -1));
|
||||
return false;
|
||||
}
|
||||
|
||||
//if we're currently hosting the parallel session, find out if script should be synchronized.
|
||||
if (OsEng.parallelConnection().isHost()){
|
||||
|
||||
// if we're currently hosting the parallel session, find out if script should be synchronized.
|
||||
if (OsEng.parallelConnection().isHost()) {
|
||||
std::string lib, func;
|
||||
if (parseLibraryAndFunctionNames(lib, func, script) && shouldScriptBeSent(lib, func)){
|
||||
// OsEng.parallelConnection()->sendScript(script);
|
||||
@@ -177,18 +175,18 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int status = luaL_loadfile(_state, filename.c_str());
|
||||
if (status != LUA_OK) {
|
||||
LERROR("Error loading script: '" << lua_tostring(_state, -1) << "'");
|
||||
try {
|
||||
ghoul::lua::runScriptFile(_state, filename);
|
||||
}
|
||||
catch (const ghoul::lua::LuaLoadingException& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
return false;
|
||||
}
|
||||
catch (const ghoul::lua::LuaExecutionException& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
LDEBUG("Executing script '" << filename << "'");
|
||||
if (lua_pcall(_state, 0, LUA_MULTRET, 0)) {
|
||||
LERROR("Error executing script: " << lua_tostring(_state, -1));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user