From 5d1a217936bf4a64afbf14bf0dc5a90ceaebceac Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Fri, 27 Sep 2019 15:30:19 -0400 Subject: [PATCH] Changed star speck file reading to work with problematic getline function in Windows. --- modules/space/rendering/renderablestars.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index f5ba7cf51c..56fbc1c0c7 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -1384,7 +1384,7 @@ void RenderableStars::readSpeckFile() { std::string line; while (true) { std::streampos position = file.tellg(); - std::getline(file, line); + std::getline(file, line, '\n'); if (line[0] == '#' || line.empty()) { continue; @@ -1399,9 +1399,6 @@ void RenderableStars::readSpeckFile() { if (_enableTestGrid) { file.seekg(position - std::streamoff(8)); } - else { - file.seekg(position); - } break; } @@ -1450,22 +1447,14 @@ void RenderableStars::readSpeckFile() { float minLumValue = std::numeric_limits::max(); float maxLumValue = std::numeric_limits::min(); - bool first = true; do { std::vector values(_nValuesPerStar); - - if (!first) { - std::getline(file, line); - } - else { - first = false; - } - std::stringstream str(line); for (int i = 0; i < _nValuesPerStar; ++i) { str >> values[i]; } + bool nullArray = true; for (float v : values) { if (v != 0.0) { @@ -1480,6 +1469,9 @@ void RenderableStars::readSpeckFile() { if (!nullArray) { _fullData.insert(_fullData.end(), values.begin(), values.end()); } + + std::getline(file, line, '\n'); + } while (!file.eof()); // Normalize Luminosity: