Adapt hardcoded paths

Don't crash when adding new scenegraphnodes
This commit is contained in:
Alexander Bock
2018-12-06 15:30:01 -05:00
parent 10ddabdc40
commit eb3f7b9559
7 changed files with 51 additions and 27 deletions
+1
View File
@@ -108,6 +108,7 @@ int main(int argc, char** argv) {
std::string configFile = configuration::findConfiguration();
global::configuration = configuration::loadConfigurationFromFile(configFile);
openspace::global::openSpaceEngine.registerPathTokens();
global::openSpaceEngine.initialize();
+3 -1
View File
@@ -88,7 +88,9 @@ public:
// Guaranteed to return a valid pointer
AssetManager& assetManager();
LoadingScreen& loadingScreen();
// Could be nullptr (and will be after startup)
LoadingScreen* loadingScreen();
void writeSceneDocumentation();
void writeStaticDocumentation();
@@ -460,7 +460,7 @@ namespace openspace::exoplanets{
"Type = 'RenderablePlaneImageLocal',"
"Size = 6.957E8," //RSTAR. in meters. 1 solar radii = 6.95700×10e8 m
"Billboard = true,"
"Texture = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/target-blue-ring.png',"
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/target-blue-ring.png'),"
"BlendMode = 'Additive'"
"},"
"Transform = {"
@@ -487,7 +487,7 @@ namespace openspace::exoplanets{
"Type = 'RenderablePlaneImageLocal',"
"Size = 6378137," // in meters
"Billboard = true,"
"Texture = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/target-blue-ring.png',"
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/target-blue-ring.png'),"
"BlendMode = 'Additive'"
"},"
"Transform = {"
@@ -515,7 +515,7 @@ namespace openspace::exoplanets{
"Type = 'RenderablePlaneImageLocal',"
"Size = 1.496E11," // earths semi-major axis in m
"Billboard = false,"
"Texture = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/target-blue-ring.png',"
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/target-blue-ring.png'),"
"BlendMode = 'Additive'"
"},"
"Transform = {"
+14 -8
View File
@@ -43,7 +43,7 @@ namespace openspace{
std::string getStarColor(float bv) {
std::string colorString;
std::ifstream colormap(absPath("${BASE}/modules/exoplanets/colorbv.cmap"), std::ios::in);
std::ifstream colormap(absPath("${MODULE_EXOPLANETS}/colorbv.cmap"), std::ios::in);
if (!colormap.good()) {
std::cout << "Failed to open colormap data file";
}
@@ -332,15 +332,16 @@ int addExoplanetSystem(lua_State* L) {
std::string starname_csv = getCsvStarname(starname);
// If user have given name as in EOD, change it to speck-name
std::string starname_speck = getSpeckStarname(starname);
std::replace(starname_speck.begin(), starname_speck.end(), ' ', '_');
global::moduleEngine.module<ExoplanetsModule>()->setStarName(starname_speck);
std::ifstream data(absPath("${BASE}/modules/exoplanets/expl_data.bin"), std::ios::in | std::ios::binary);
std::ifstream data(absPath("${MODULE_EXOPLANETS}/expl_data.bin"), std::ios::in | std::ios::binary);
if (!data.good()) {
std::cout << "Failed to open exoplanets data file";
}
std::ifstream lut(absPath("${BASE}/modules/exoplanets/lookup.txt"));
std::ifstream lut(absPath("${MODULE_EXOPLANETS}/lookup.txt"));
if (!lut.good()) {
std::cout << "Failed to open exoplanets look-up table file";
}
@@ -411,6 +412,9 @@ int addExoplanetSystem(lua_State* L) {
beta.x, beta.y, beta.z,
starToSunVec.x, starToSunVec.y, starToSunVec.z);
std::replace(starname_speck.begin(), starname_speck.end(), ' ', '_');
const std::string starParent = "{"
"Identifier = '" + starname_speck + "',"
"Parent = 'SolarSystemBarycenter',"
@@ -458,6 +462,7 @@ int addExoplanetSystem(lua_State* L) {
}
else
sepoch_star = "2009-05-19T07:11:34.080";
const std::string starGlobe = "{"
"Identifier = '" + starname_speck + "Globe',"
"Parent = '" + starname_speck + "',"
@@ -477,7 +482,7 @@ int addExoplanetSystem(lua_State* L) {
"},"
"{"
"Identifier = 'StarTexture',"
"FilePath = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/sun.jpg',"
"FilePath = openspace.absPath('${MODULE_EXOPLANETS}/sun.jpg'),"
"BlendMode = 'Color',"
"Enabled = true"
"}"
@@ -593,7 +598,7 @@ int addExoplanetSystem(lua_State* L) {
"ColorLayers = {"
"{"
"Identifier = 'ExoplanetTexture',"
"FilePath = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/data/test3.jpg',"
"FilePath = openspace.absPath('${DATA}/test3.jpg'),"
"Enabled = true"
"}"
"}"
@@ -669,7 +674,7 @@ int addExoplanetSystem(lua_State* L) {
"Enabled = true,"
"Renderable = {"
"Type = 'RenderableOrbitdisc',"
"Texture = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/disc3.png',"
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/disc3.png'),"
"Size = " + std::to_string(plsy[i].A) + " * 149597870700," // 149 597 870 700 m = 1 AU. A
"Eccentricity = " + std::to_string(plsy[i].ECC) + ","
"Offset = { " + std::to_string(plsy[i].ALOWER) + ", " + std::to_string(plsy[i].AUPPER) + " }," //min / max extend
@@ -700,7 +705,7 @@ int addExoplanetSystem(lua_State* L) {
"Parent = '" + starname_speck + "',"
"Renderable = {"
"Type = 'RenderableOrbitdisc',"
"Texture = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/discL.png',"
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/discL.png'),"
"Size = " + std::to_string(plsy[i].A) + " * 149597870700," // 149 597 870 700 m = 1 AU. A
"Eccentricity = " + std::to_string(lower_ecc) + ","
"Offset = { " + std::to_string(plsy[i].ALOWER) + ", " + std::to_string(plsy[i].AUPPER) + " }," //min / max extend
@@ -731,7 +736,7 @@ int addExoplanetSystem(lua_State* L) {
"Parent = '" + starname_speck + "',"
"Renderable = {"
"Type = 'RenderableOrbitdisc',"
"Texture = 'C:/Users/Karin/Documents/LiU/Exjobb/clone_to_branch/OpenSpace/modules/exoplanets/discU.png',"
"Texture = openspace.absPath('${MODULE_EXOPLANETS}/discU.png'),"
"Size = " + std::to_string(plsy[i].A) + " * 149597870700," // 149 597 870 700 m = 1 AU. A
"Eccentricity = " + std::to_string(upper_ecc) + ","
"Offset = { " + std::to_string(plsy[i].ALOWER) + ", " + std::to_string(plsy[i].AUPPER) + " }," //min / max extend
@@ -771,6 +776,7 @@ int removeExoplanetSystem(lua_State* L) {
const int StringLocation = -1;
const std::string starname = luaL_checkstring(L, StringLocation);
std::string starname_speck = getSpeckStarname(starname);
std::replace(starname_speck.begin(), starname_speck.end(), ' ', '_');
std::string script = "openspace.removeSceneGraphNode('" + starname_speck + "');";
openspace::global::scriptEngine.queueScript(
script,
@@ -233,8 +233,19 @@ void ExoplanetsCsvToBinTask::perform(const Task::ProgressCallback& progressCallb
std::string data_s;
bool iskeplerobject = false;
int total = 0;
while (getline(csv_file, planet_row)) {
++total;
}
csv_file.clear();
csv_file.seekg(0);
getline(csv_file, planet_row); // The first line, containing the data names
LINFOC("CSVTOBIN", fmt::format("Loading {} stars", total));
int count = 0;
while (getline(csv_file, planet_row)) {
++count;
progressCallback(static_cast<float>(count) / static_cast<float>(total));
std::istringstream lineStream(planet_row);
+2 -3
View File
@@ -1349,9 +1349,8 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
};
}
LoadingScreen& OpenSpaceEngine::loadingScreen() {
ghoul_assert(_loadingScreen, "Loading Screen must not be nullptr");
return *_loadingScreen;
LoadingScreen* OpenSpaceEngine::loadingScreen() {
return _loadingScreen.get();
}
AssetManager& OpenSpaceEngine::assetManager() {
+17 -12
View File
@@ -52,11 +52,14 @@ MultiThreadedSceneInitializer::MultiThreadedSceneInitializer(unsigned int nThrea
void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
auto initFunction = [this, node]() {
LoadingScreen& loadingScreen = global::openSpaceEngine.loadingScreen();
LoadingScreen* loadingScreen = global::openSpaceEngine.loadingScreen();
if (!loadingScreen) {
return;
}
LoadingScreen::ProgressInfo progressInfo;
progressInfo.progress = 1.f;
loadingScreen.updateItem(
loadingScreen->updateItem(
node->identifier(),
node->guiName(),
LoadingScreen::ItemStatus::Initializing,
@@ -68,7 +71,7 @@ void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
_initializedNodes.push_back(node);
_initializingNodes.erase(node);
loadingScreen.updateItem(
loadingScreen->updateItem(
node->identifier(),
node->guiName(),
LoadingScreen::ItemStatus::Finished,
@@ -79,16 +82,18 @@ void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
LoadingScreen::ProgressInfo progressInfo;
progressInfo.progress = 0.f;
LoadingScreen& loadingScreen = global::openSpaceEngine.loadingScreen();
loadingScreen.setItemNumber(loadingScreen.itemNumber() + 1);
loadingScreen.updateItem(
node->identifier(),
node->guiName(),
LoadingScreen::ItemStatus::Started,
progressInfo
);
LoadingScreen* loadingScreen = global::openSpaceEngine.loadingScreen();
if (loadingScreen) {
loadingScreen->setItemNumber(loadingScreen->itemNumber() + 1);
loadingScreen->updateItem(
node->identifier(),
node->guiName(),
LoadingScreen::ItemStatus::Started,
progressInfo
);
}
std::lock_guard<std::mutex> g(_mutex);
std::lock_guard g(_mutex);
_initializingNodes.insert(node);
_threadPool.enqueue(initFunction);
}