From bcf92804b601bf075de8492999e4e1cc86e61777 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 10 Mar 2017 09:32:16 -0500 Subject: [PATCH] Updating Ghoul repository Updating SGCT repository Removing compiler warnings --- ext/ghoul | 2 +- ext/sgct | 2 +- include/openspace/documentation/verifier.h | 2 + .../openspace/interaction/interactionmode.h | 5 +- .../openspace/network/parallelconnection.h | 2 +- include/openspace/rendering/volumeraycaster.h | 4 +- modules/base/rendering/renderablemodel.cpp | 3 - modules/base/rendering/renderableplane.cpp | 6 +- .../rendering/renderablesphericalgrid.cpp | 4 +- modules/base/rendering/renderabletrail.cpp | 14 ++-- .../base/rendering/renderabletrailorbit.cpp | 8 +- .../rendering/renderabletrailtrajectory.cpp | 16 ++-- .../base/rendering/screenspaceframebuffer.cpp | 18 ++++- modules/base/rendering/screenspaceimage.cpp | 7 +- modules/base/scale/staticscale.cpp | 2 +- .../rendering/renderablemultiresvolume.cpp | 2 +- .../renderablePlanetProjection_fs.glsl | 4 +- modules/space/rendering/renderableplanet.cpp | 12 ++- modules/space/rendering/renderablerings.cpp | 2 +- modules/space/rendering/renderablestars.cpp | 2 +- .../space/translation/keplertranslation.cpp | 3 + modules/space/translation/tletranslation.cpp | 29 +++---- src/documentation/documentation.cpp | 4 + src/documentation/verifier.cpp | 16 ++-- src/engine/downloadmanager.cpp | 78 ++++++++++--------- src/engine/openspaceengine.cpp | 8 +- src/engine/settingsengine.cpp | 2 +- src/engine/wrapper/sgctwindowwrapper.cpp | 5 +- src/interaction/interactionhandler.cpp | 4 +- src/interaction/interactionhandler_lua.inl | 23 +++--- src/interaction/luaconsole.cpp | 2 +- src/mission/missionmanager_lua.inl | 41 +++++----- src/network/networkengine.cpp | 4 +- src/network/parallelconnection.cpp | 4 +- src/network/parallelconnection_lua.inl | 12 +-- src/performance/performancemanager.cpp | 2 +- src/properties/optionproperty.cpp | 1 + src/rendering/framebufferrenderer.cpp | 4 +- src/util/spicemanager.cpp | 6 ++ 39 files changed, 201 insertions(+), 164 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 445ed6353f..d2aa3d3616 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 445ed6353fe53ffc2f799de29328ca44de9e3ffb +Subproject commit d2aa3d3616f0a3698d38639acf5b7caa5924da64 diff --git a/ext/sgct b/ext/sgct index 0bea7bdb11..bdff5552b4 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit 0bea7bdb11fe060b39194801646fb1b8a7ff597d +Subproject commit bdff5552b406183876375b42bfeb0d6806953e8a diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 61a7cb5b47..f431add35f 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -44,6 +44,8 @@ namespace documentation { * description of the Verifier subclass and what it tests for. */ struct Verifier { + virtual ~Verifier() = default; + /** * This method tests whether the \p key contained in the \p dictionary adheres to * whatever the concrete Verifer needs to test. The actual testing depends on the diff --git a/include/openspace/interaction/interactionmode.h b/include/openspace/interaction/interactionmode.h index 6a0b383403..ae9efa3be2 100644 --- a/include/openspace/interaction/interactionmode.h +++ b/include/openspace/interaction/interactionmode.h @@ -108,11 +108,10 @@ namespace interaction { -class InteractionMode -{ +class InteractionMode { public: InteractionMode(); - ~InteractionMode(); + virtual ~InteractionMode(); // Mutators virtual void setFocusNode(SceneGraphNode* focusNode); diff --git a/include/openspace/network/parallelconnection.h b/include/openspace/network/parallelconnection.h index d95060d7c0..8b43662206 100644 --- a/include/openspace/network/parallelconnection.h +++ b/include/openspace/network/parallelconnection.h @@ -120,7 +120,7 @@ class ParallelConnection { */ static scripting::LuaLibrary luaLibrary(); Status status(); - size_t nConnections(); + int nConnections(); std::shared_ptr> connectionEvent(); diff --git a/include/openspace/rendering/volumeraycaster.h b/include/openspace/rendering/volumeraycaster.h index 4315ebc5cc..e9cb1674b0 100644 --- a/include/openspace/rendering/volumeraycaster.h +++ b/include/openspace/rendering/volumeraycaster.h @@ -38,8 +38,8 @@ namespace ghoul { namespace openspace { -class RenderData; -class RaycastData; +struct RenderData; +struct RaycastData; class VolumeRaycaster { public: diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 1adca3f960..8fce14dc90 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -170,8 +170,6 @@ bool RenderableModel::deinitialize() { void RenderableModel::render(const RenderData& data) { _programObject->activate(); - double lt; - // Fading if (_performFade && _fading > 0.f) { _fading = _fading - 0.01f; @@ -243,7 +241,6 @@ void RenderableModel::update(const UpdateData& data) { // _time = futureTime; //} - double lt; _sunPos = OsEng.renderEngine().scene()->sceneGraphNode("Sun")->worldPosition(); } diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 744c94e83e..965ffd0307 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -203,9 +203,9 @@ void RenderablePlane::render(const RenderData& data) { if (textureNode != nullptr){ RenderablePlanetProjection* t = static_cast(textureNode->renderable()); _texture = std::unique_ptr(&(t->baseTexture())); - float h = _texture->height(); - float w = _texture->width(); - float scale = h / w; + unsigned int h = _texture->height(); + unsigned int w = _texture->width(); + float scale = static_cast(h) / static_cast(w); scaleTransform = glm::scale(glm::mat4(1.0), glm::vec3(1.f, scale, 1.f)); } } diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index 4af5bc3a82..da602a2c5f 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -82,10 +82,10 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio //int nr2 = 0; - for (int i = 0; i <= _segments; i++) { + for (int nSegment = 0; nSegment <= _segments; ++nSegment) { // define an extra vertex around the y-axis due to texture mapping for (int j = 0; j <= _segments; j++) { - const float fi = static_cast(i); + const float fi = static_cast(nSegment); const float fj = static_cast(j); // inclination angle (north to south) diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 7085abd948..4dd118eb1b 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -155,17 +155,17 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) addProperty(_useLineFade); if (dictionary.hasKeyAndValue(KeyFade)) { - _lineFade = dictionary.value(KeyFade); + _lineFade = static_cast(dictionary.value(KeyFade)); } addProperty(_lineFade); if (dictionary.hasKeyAndValue(KeyLineWidth)) { - _lineWidth = dictionary.value(KeyLineWidth); + _lineWidth = static_cast(dictionary.value(KeyLineWidth)); } addProperty(_lineWidth); if (dictionary.hasKeyAndValue(KeyPointSize)) { - _pointSize = dictionary.value(KeyPointSize); + _pointSize = static_cast(dictionary.value(KeyPointSize)); } addProperty(_pointSize); @@ -247,12 +247,12 @@ void RenderableTrail::render(const RenderData & data) { } bool renderLines = - _renderingModes == RenderingModeLines | - _renderingModes == RenderingModeLinesPoints; + (_renderingModes == RenderingModeLines) | + (_renderingModes == RenderingModeLinesPoints); bool renderPoints = - _renderingModes == RenderingModePoints | - _renderingModes == RenderingModeLinesPoints; + (_renderingModes == RenderingModePoints) | + (_renderingModes == RenderingModeLinesPoints); if (renderLines) { glLineWidth(_lineWidth); diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index 9f08db6fcc..90f5551b14 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -132,7 +132,7 @@ documentation::Documentation RenderableTrailOrbit::Documentation() { RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) : RenderableTrail(dictionary) , _period("period", "Period in days", 0.0, 0.0, 1e9) - , _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1e6) + , _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1000000) , _needsFullSweep(true) , _indexBufferDirty(true) { @@ -148,7 +148,7 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) // Period is in days using namespace std::chrono; - int factor = duration_cast(hours(24)).count(); + long long factor = duration_cast(hours(24)).count(); _period = dictionary.value(KeyPeriod) * factor; _period.onChange([&] { _needsFullSweep = true; _indexBufferDirty = true; }); addProperty(_period); @@ -349,7 +349,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( } // See how many points we need to drop - int nNewPoints = floor(delta / secondsPerPoint); + int nNewPoints = static_cast(floor(delta / secondsPerPoint)); // If we would need to generate more new points than there are total points in the // array, it is faster to regenerate the entire array @@ -384,7 +384,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( else { // See how many new points needs to be generated. Delta is negative, so we need // to invert the ratio - int nNewPoints = -(floor(delta / secondsPerPoint)); + int nNewPoints = -(static_cast(floor(delta / secondsPerPoint))); // If we would need to generate more new points than there are total points in the // array, it is faster to regenerate the entire array diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 2fcc079b79..25f5fc686d 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -130,7 +130,7 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di , _timeStampSubsamplingFactor( "subSample", "Time Stamp Subsampling Factor", - 1, 1, 1e9 + 1, 1, 1000000000 ) , _renderFullTrail("renderFullTrail", "Render Full Trail", false) , _needsFullSweep(true) @@ -159,7 +159,9 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di addProperty(_sampleInterval); if (dictionary.hasKeyAndValue(KeyTimeStampSubsample)) { - _timeStampSubsamplingFactor = dictionary.value(KeyTimeStampSubsample); + _timeStampSubsamplingFactor = static_cast( + dictionary.value(KeyTimeStampSubsample) + ); } _timeStampSubsamplingFactor.onChange([this] { _subsamplingIsDirty = true; }); addProperty(_timeStampSubsamplingFactor); @@ -208,7 +210,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { double totalSampleInterval = _sampleInterval / _timeStampSubsamplingFactor; // How many values do we need to compute given the distance between the start and // end date and the desired sample interval - int nValues = (_end - _start) / totalSampleInterval; + int nValues = static_cast((_end - _start) / totalSampleInterval); // Make space for the vertices _vertexArray.clear(); @@ -246,16 +248,16 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { // If the full trail should be rendered at all times, we can directly render the // entire set _primaryRenderInformation.first = 0; - _primaryRenderInformation.count = _vertexArray.size(); + _primaryRenderInformation.count = static_cast(_vertexArray.size()); } else { // If only trail so far should be rendered, we need to find the corresponding time // in the array and only render it until then _primaryRenderInformation.first = 0; double t = (data.time - _start) / (_end - _start); - _primaryRenderInformation.count = std::min( - ceil(_vertexArray.size() * t), - _vertexArray.size() - 1 + _primaryRenderInformation.count = std::min( + static_cast(ceil(_vertexArray.size() * t)), + static_cast(_vertexArray.size() - 1) ); } diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 630bb6d39b..e41c126ae8 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -82,15 +82,20 @@ bool ScreenSpaceFramebuffer::deinitialize(){ return true; } -void ScreenSpaceFramebuffer::render(){ +void ScreenSpaceFramebuffer::render() { glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution(); glm::vec4 size = _size.value(); float xratio = _originalViewportSize.x / (size.z-size.x); float yratio = _originalViewportSize.y / (size.w-size.y);; - if(!_renderFunctions.empty()){ - glViewport (-size.x*xratio, -size.y*yratio, _originalViewportSize.x*xratio, _originalViewportSize.y*yratio); + if (!_renderFunctions.empty()) { + glViewport( + static_cast(-size.x * xratio), + static_cast(-size.y * yratio), + static_cast(_originalViewportSize.x * xratio), + static_cast(_originalViewportSize.y * yratio) + ); GLint defaultFBO = _framebuffer->getActiveObject(); _framebuffer->activate(); @@ -103,7 +108,12 @@ void ScreenSpaceFramebuffer::render(){ _framebuffer->deactivate(); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - glViewport (0, 0, resolution.x, resolution.y); + glViewport( + 0, + 0, + static_cast(resolution.x), + static_cast(resolution.y) + ); glm::mat4 rotation = rotationMatrix(); glm::mat4 translation = translationMatrix(); diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index d5822c567c..3839cbe352 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -157,15 +157,18 @@ void ScreenSpaceImage::updateTexture() { if (_futureImage.valid() && DownloadManager::futureReady(_futureImage)) { DownloadManager::MemoryFile imageFile = _futureImage.get(); - if (imageFile.corrupted) + if (imageFile.corrupted) { return nullptr; + } return (ghoul::io::TextureReader::ref().loadTexture( reinterpret_cast(imageFile.buffer), imageFile.size, imageFile.format) ); - + } + else { + return nullptr; } } diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index ef6a448dba..dd7f16167d 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -59,7 +59,7 @@ StaticScale::StaticScale(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale"); - _scaleValue = dictionary.value(KeyValue); + _scaleValue = static_cast(dictionary.value(KeyValue)); } double StaticScale::scaleValue() const { diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index 7da992b017..797ab6e88a 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -224,7 +224,7 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic } addProperty(_selectorName); - _selectorName.onChange([&] { + _selectorName.onChange([&]() { Selector s; std::string newSelectorName = _selectorName; if (newSelectorName == "simple") { diff --git a/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl b/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl index 34020b7eef..b0aa7dc9be 100644 --- a/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl +++ b/modules/newhorizons/shaders/renderablePlanetProjection_fs.glsl @@ -65,7 +65,9 @@ bool inRange(float x, float a, float b){ void main() { vec2 uv = (vs_position.xy + vec2(1.0)) / vec2(2.0); - vec4 vertex = uvToModel(uv, _radius, _segments); + vec4 radius = vec4(1.1883, 1.1883, 1.1883, 6); + vec4 vertex = uvToModel(uv, radius, _segments); + // vec4 vertex = uvToModel(uv, _radius, _segments); vec4 raw_pos = psc_to_meter(vertex, _scaling); vec4 projected = ProjectorMatrix * ModelTransform * raw_pos; diff --git a/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index a5a9e7a691..17bdd3c71d 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -97,10 +97,14 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) glm::vec2 planetRadiusVec; success = geometryDictionary.getValue(keyRadius, planetRadiusVec); - if (success) - _planetRadius = planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1]); - else + if (success) { + _planetRadius = static_cast( + planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1]) + ); + } + else { LWARNING("No Radius value expecified for " << name << " planet."); + } } dictionary.getValue(keyFrame, _frame); @@ -432,7 +436,7 @@ void RenderablePlanet::render(const RenderData& data) { float xp_test = shadowConf.caster.second * sc_length / (shadowConf.source.second + shadowConf.caster.second); float rp_test = shadowConf.caster.second * (glm::length(planetCaster_proj) + xp_test) / xp_test; - float casterDistSun = glm::length(casterPos); + double casterDistSun = glm::length(casterPos); float planetDistSun = glm::length(data.position.vec3()); ShadowRenderingStruct shadowData; diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index ffc6e99951..1e16d2d838 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -105,7 +105,7 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) "RenderableRings" ); - _size = dictionary.value(KeySize); + _size = static_cast(dictionary.value(KeySize)); setBoundingSphere(PowerScaledScalar::CreatePSS(_size)); addProperty(_size); _size.onChange([&]() { _planeIsDirty = true; }); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index d233addc7b..2e9b9e38d9 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -467,7 +467,7 @@ bool RenderableStars::readSpeckFile() { // (signaled by the keywords 'datavar', 'texturevar', and 'texture') std::string line = ""; while (true) { - std::ifstream::streampos position = file.tellg(); + std::streampos position = file.tellg(); std::getline(file, line); if (line[0] == '#' || line.empty()) { diff --git a/modules/space/translation/keplertranslation.cpp b/modules/space/translation/keplertranslation.cpp index 333d24fb70..59acd25e0d 100644 --- a/modules/space/translation/keplertranslation.cpp +++ b/modules/space/translation/keplertranslation.cpp @@ -252,6 +252,9 @@ double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const { }; return solveIteration(solver, e, 0.0, 8); } + else { + ghoul_assert(false, "Eccentricity must not be >= 1.0"); + } } void KeplerTranslation::update(const UpdateData& data) { diff --git a/modules/space/translation/tletranslation.cpp b/modules/space/translation/tletranslation.cpp index 5fa236dc41..14e65d5b9e 100644 --- a/modules/space/translation/tletranslation.cpp +++ b/modules/space/translation/tletranslation.cpp @@ -64,7 +64,7 @@ namespace { auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); // The distance between the two iterators gives us the number of leap years - int nLeapYears = std::abs(std::distance(y2000, lb)); + int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); int nYears = std::abs(year - Epoch); int nRegularYears = nYears - nLeapYears; @@ -130,7 +130,7 @@ namespace { auto y2000 = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), Epoch); // The distance between the two iterators gives us the number of leap years - int nLeapSeconds = std::abs(std::distance(y2000, it)); + int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); return nLeapSeconds; }; @@ -182,16 +182,19 @@ namespace { // 3 using namespace std::chrono; - int SecondsPerDay = seconds(hours(24)).count(); + int SecondsPerDay = static_cast(seconds(hours(24)).count()); double nSecondsSince2000 = (daysSince2000 + daysInYear) * SecondsPerDay; // 4 // We need to remove additionbal leap seconds past 2000 and add them prior to // 2000 to sync up the time zones - double nLeapSecondsOffset = -countLeapSeconds(year, std::floor(daysInYear)); + double nLeapSecondsOffset = -countLeapSeconds( + year, + static_cast(std::floor(daysInYear)) + ); // 5 - double nSecondsEpochOffset = seconds(hours(12)).count(); + double nSecondsEpochOffset = static_cast(seconds(hours(12)).count()); // Combine all of the values double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; @@ -270,14 +273,14 @@ void TLETranslation::readTLEFile(const std::string& filename) { // All of the Kepler element information struct { - double inclination; - double semiMajorAxis; - double ascendingNode; - double eccentricity; - double argumentOfPeriapsis; - double meanAnomaly; - double meanMotion; - double epoch; + double inclination = 0.0; + double semiMajorAxis = 0.0; + double ascendingNode = 0.0; + double eccentricity = 0.0; + double argumentOfPeriapsis = 0.0; + double meanAnomaly = 0.0; + double meanMotion = 0.0; + double epoch = 0.0; } keplerElements; enum class State { diff --git a/src/documentation/documentation.cpp b/src/documentation/documentation.cpp index f33368b971..96b1d6dbc6 100644 --- a/src/documentation/documentation.cpp +++ b/src/documentation/documentation.cpp @@ -78,6 +78,8 @@ std::string to_string(openspace::documentation::TestResult::Offense::Reason reas return "Verification failed"; case openspace::documentation::TestResult::Offense::Reason::WrongType: return "Wrong type"; + default: + ghoul_assert(false, "Missing case label"); } } @@ -85,6 +87,8 @@ std::string to_string(openspace::documentation::TestResult::Warning::Reason reas switch (reason) { case openspace::documentation::TestResult::Warning::Reason::Deprecated: return "Deprecated"; + default: + ghoul_assert(false, "Missing case label"); } } diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index 85db8531ff..eae93a5c01 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -217,33 +217,33 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary, { TestResult res = TableVerifier::operator()(dictionary, key); if (res.success) { - std::vector documentations = DocEng.documentations(); + std::vector docs = DocEng.documentations(); auto it = std::find_if( - documentations.begin(), - documentations.end(), + docs.begin(), + docs.end(), [this](const Documentation& doc) { return doc.id == identifier; } ); ghoul_assert( - it != documentations.end(), + it != docs.end(), "Did not find referencing identifier '" + identifier + "'" ); ghoul::Dictionary d = dictionary.value(key); - TestResult res = testSpecification(*it, d); + TestResult r = testSpecification(*it, d); // Add the 'key' as a prefix to make the offender a fully qualified identifer - for (TestResult::Offense& s : res.offenses) { + for (TestResult::Offense& s : r.offenses) { s.offender = key + "." + s.offender; } // Add the 'key' as a prefix to make the warning a fully qualified identifer - for (TestResult::Warning& w : res.warnings) { + for (TestResult::Warning& w : r.warnings) { w.offender = key + "." + w.offender; } - return res; + return r; } else { return res; diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 42d6c7afac..ea7e9ad77b 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -111,7 +111,9 @@ namespace { // Compute estimated time remaining. auto timeRemaining = estimatedTime - transferTime; - float s = std::chrono::duration_cast(timeRemaining).count(); + float s = static_cast( + std::chrono::duration_cast(timeRemaining).count() + ); i->future->secondsRemaining = s; @@ -233,44 +235,46 @@ std::future DownloadManager::fetchFile( file.corrupted = false; CURL* curl = curl_easy_init(); - if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&file); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeMemoryCallback); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L); - // Will fail when response status is 400 or above - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); - - CURLcode res = curl_easy_perform(curl); - if(res == CURLE_OK){ - // ask for the content-type - char *ct; - res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); - if(res == CURLE_OK){ - std::string extension = std::string(ct); - std::stringstream ss(extension); - getline(ss, extension ,'/'); - getline(ss, extension); - file.format = extension; - } else{ - LWARNING("Could not get File extension from file downloaded from: " + url); - } - successCallback(file); - curl_easy_cleanup(curl); - return std::move(file); - } else { - std::string err = curl_easy_strerror(res); - errorCallback(err); - curl_easy_cleanup(curl); - // Throw an error and use try-catch around call to future.get() - //throw std::runtime_error( err ); + if (!curl) { + throw ghoul::RuntimeError("Error initializing cURL"); + } - // or set a boolean variable in MemoryFile to determine if it is valid/corrupted or not. - // Return MemoryFile even if it is not valid, and check if it is after future.get() call. - file.corrupted = true; - return std::move(file); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&file); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeMemoryCallback); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L); + // Will fail when response status is 400 or above + curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); + + CURLcode res = curl_easy_perform(curl); + if(res == CURLE_OK){ + // ask for the content-type + char *ct; + res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); + if(res == CURLE_OK){ + std::string extension = std::string(ct); + std::stringstream ss(extension); + getline(ss, extension ,'/'); + getline(ss, extension); + file.format = extension; + } else{ + LWARNING("Could not get File extension from file downloaded from: " + url); } + successCallback(file); + curl_easy_cleanup(curl); + return std::move(file); + } else { + std::string err = curl_easy_strerror(res); + errorCallback(err); + curl_easy_cleanup(curl); + // Throw an error and use try-catch around call to future.get() + //throw std::runtime_error( err ); + + // or set a boolean variable in MemoryFile to determine if it is valid/corrupted or not. + // Return MemoryFile even if it is not valid, and check if it is after future.get() call. + file.corrupted = true; + return std::move(file); } }; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 32389d5649..6b28d6fa28 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -276,7 +276,7 @@ void OpenSpaceEngine::create(int argc, char** argv, } throw; } - catch (const ghoul::RuntimeError& e) { + catch (const ghoul::RuntimeError&) { LFATAL("Loading of configuration file '" << configurationFilePath << "' failed"); throw; } @@ -475,9 +475,9 @@ void OpenSpaceEngine::initialize() { writeDocumentation(); if (configurationManager().hasKey(ConfigurationManager::KeyShutdownCountdown)) { - _shutdown.waitTime = configurationManager().value( + _shutdown.waitTime = static_cast(configurationManager().value( ConfigurationManager::KeyShutdownCountdown - ); + )); } if (!commandlineArgumentPlaceholders.sceneName.empty()) { @@ -874,7 +874,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { if (_shutdown.timer <= 0.f) { _windowWrapper->terminate(); } - _shutdown.timer -= _windowWrapper->averageDeltaTime(); + _shutdown.timer -= static_cast(_windowWrapper->averageDeltaTime()); } _renderEngine->updateSceneGraph(); diff --git a/src/engine/settingsengine.cpp b/src/engine/settingsengine.cpp index 506c073b16..b12fb3687b 100644 --- a/src/engine/settingsengine.cpp +++ b/src/engine/settingsengine.cpp @@ -74,7 +74,7 @@ void SettingsEngine::initialize() { std::vector scenes = ghoul::filesystem::Directory(sceneDir).readFiles(); for (std::size_t i = 0; i < scenes.size(); ++i) { std::size_t found = scenes[i].find_last_of("/\\"); - _scenes.addOption(i, scenes[i].substr(found + 1)); + _scenes.addOption(static_cast(i), scenes[i].substr(found + 1)); } // Set interaction to change ConfigurationManager and schedule the load diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index b9c9fbdd2e..3c6d6b80cf 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -224,8 +224,9 @@ bool SGCTWindowWrapper::isExternalControlConnected() const { void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector& message) const { sgct::Engine::instance()->sendMessageToExternalControl( - message.data(), - message.size()); + message.data(), + static_cast(message.size()) + ); } bool SGCTWindowWrapper::isSimpleRendering() const { diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 0a76bf2f4b..2b0dcaeff9 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -77,8 +77,8 @@ InteractionHandler::InteractionHandler() , _rotationalFriction("rotationalFriction", "Rotational Friction", true) , _horizontalFriction("horizontalFriction", "Horizontal Friction", true) , _verticalFriction("verticalFriction", "Vertical Friction", true) - , _sensitivity("sensitivity", "Sensitivity", 0.5, 0.001, 1) - , _rapidness("rapidness", "Rapidness", 1, 0.1, 60) + , _sensitivity("sensitivity", "Sensitivity", 0.5f, 0.001f, 1.f) + , _rapidness("rapidness", "Rapidness", 1.f, 0.1f, 60.f) { _origin.onChange([this]() { SceneGraphNode* node = sceneGraphNode(_origin.value()); diff --git a/src/interaction/interactionhandler_lua.inl b/src/interaction/interactionhandler_lua.inl index 50e99139e0..3e5fefb8ad 100644 --- a/src/interaction/interactionhandler_lua.inl +++ b/src/interaction/interactionhandler_lua.inl @@ -198,9 +198,9 @@ int goToChunk(lua_State* L) { if (nArguments != 3) return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments); - int x = lua_tonumber(L, 1); - int y = lua_tonumber(L, 2); - int level = lua_tonumber(L, 3); + int x = static_cast(lua_tonumber(L, 1)); + int y = static_cast(lua_tonumber(L, 2)); + int level = static_cast(lua_tonumber(L, 3)); OsEng.interactionHandler().goToChunk(x, y, level); @@ -214,8 +214,8 @@ int goToGeo(lua_State* L) { if (nArguments != 2) return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); - double latitude = lua_tonumber(L, 1); - double longitude = lua_tonumber(L, 2); + double latitude = static_cast(lua_tonumber(L, 1)); + double longitude = static_cast(lua_tonumber(L, 2)); OsEng.interactionHandler().goToGeo(latitude, longitude); @@ -224,7 +224,6 @@ int goToGeo(lua_State* L) { int restoreCameraStateFromFile(lua_State* L) { using ghoul::lua::luaTypeToString; - const std::string _loggerCat = "lua.restoreCameraStateFromFile"; int nArguments = lua_gettop(L); if (nArguments != 1) @@ -232,8 +231,9 @@ int restoreCameraStateFromFile(lua_State* L) { std::string cameraStateFilePath = luaL_checkstring(L, -1); - if (cameraStateFilePath.empty()) + if (cameraStateFilePath.empty()) { return luaL_error(L, "filepath string is empty"); + } OsEng.interactionHandler().restoreCameraStateFromFile(cameraStateFilePath); return 0; @@ -241,7 +241,6 @@ int restoreCameraStateFromFile(lua_State* L) { int saveCameraStateToFile(lua_State* L) { using ghoul::lua::luaTypeToString; - const std::string _loggerCat = "lua.setCameraPosition"; int nArguments = lua_gettop(L); if (nArguments != 1) @@ -249,10 +248,12 @@ int saveCameraStateToFile(lua_State* L) { std::string cameraStateFilePath = luaL_checkstring(L, -1); - if (cameraStateFilePath.empty()) + if (cameraStateFilePath.empty()) { return luaL_error(L, "filepath string is empty"); + } OsEng.interactionHandler().saveCameraStateToFile(cameraStateFilePath); + return 0; } int resetCameraDirection(lua_State* L) { @@ -260,10 +261,12 @@ int resetCameraDirection(lua_State* L) { const std::string _loggerCat = "lua.resetCameraDirection"; int nArguments = lua_gettop(L); - if (nArguments != 0) + if (nArguments != 0) { return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + } OsEng.interactionHandler().resetCameraDirection(); + return 0; } diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 548427c820..f16010ffac 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -384,7 +384,7 @@ void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) { return; } - addToCommand(std::string(1, codepoint)); + addToCommand(std::string(1, static_cast(codepoint))); } void LuaConsole::render() { diff --git a/src/mission/missionmanager_lua.inl b/src/mission/missionmanager_lua.inl index 9d2bcee237..ad8e65c7c1 100644 --- a/src/mission/missionmanager_lua.inl +++ b/src/mission/missionmanager_lua.inl @@ -25,31 +25,34 @@ namespace openspace { namespace luascriptfunctions { + int loadMission(lua_State* L) { - using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + using ghoul::lua::luaTypeToString; + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - std::string missionFileName = luaL_checkstring(L, -1); - if (missionFileName.empty()) { - return luaL_error(L, "filepath string is empty"); - } - MissionManager::ref().loadMission(absPath(missionFileName)); + std::string missionFileName = luaL_checkstring(L, -1); + if (missionFileName.empty()) { + return luaL_error(L, "filepath string is empty"); } + MissionManager::ref().loadMission(absPath(missionFileName)); + return 0; +} - int setCurrentMission(lua_State* L) { - using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); +int setCurrentMission(lua_State* L) { + using ghoul::lua::luaTypeToString; + int nArguments = lua_gettop(L); + if (nArguments != 1) + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - std::string missionName = luaL_checkstring(L, -1); - if (missionName.empty()) { - return luaL_error(L, "mission name string is empty"); - } - MissionManager::ref().setCurrentMission(missionName); + std::string missionName = luaL_checkstring(L, -1); + if (missionName.empty()) { + return luaL_error(L, "mission name string is empty"); } + MissionManager::ref().setCurrentMission(missionName); + return 0; +} } // namespace luascriptfunction } // namespace openspace diff --git a/src/network/networkengine.cpp b/src/network/networkengine.cpp index b7f2573657..09d60687b9 100644 --- a/src/network/networkengine.cpp +++ b/src/network/networkengine.cpp @@ -128,13 +128,13 @@ void NetworkEngine::publishIdentifierMappingMessage() { std::vector buffer(bufferSize); size_t currentWritingPosition = 0; - uint16_t size = _identifiers.size(); + uint16_t size = static_cast(_identifiers.size()); std::memcpy(buffer.data(), &size, sizeof(uint16_t)); currentWritingPosition += sizeof(uint16_t); for (const std::pair& i : _identifiers) { std::memcpy(buffer.data() + currentWritingPosition, &(i.second), sizeof(MessageIdentifier)); currentWritingPosition += sizeof(MessageIdentifier); - uint8_t stringSize = i.first.size(); + uint8_t stringSize = static_cast(i.first.size()); std::memcpy(buffer.data() + currentWritingPosition, &stringSize, sizeof(uint8_t)); currentWritingPosition += sizeof(uint8_t); std::memcpy(buffer.data() + currentWritingPosition, i.first.data(), stringSize); diff --git a/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index 23c97a114a..1f8547f7cd 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -231,7 +231,7 @@ void ParallelConnection::clientConnect(){ return; } - struct addrinfo *addresult = NULL, *ptr = NULL, hints; + struct addrinfo *addresult = NULL, hints; memset(&hints, 0, sizeof(hints)); @@ -963,7 +963,7 @@ void ParallelConnection::setNConnections(size_t nConnections) { } } -size_t ParallelConnection::nConnections() { +int ParallelConnection::nConnections() { return _nConnections; } diff --git a/src/network/parallelconnection_lua.inl b/src/network/parallelconnection_lua.inl index 2646581aed..538f0180cc 100644 --- a/src/network/parallelconnection_lua.inl +++ b/src/network/parallelconnection_lua.inl @@ -41,7 +41,7 @@ int setPort(lua_State* L) { bool isNumber = (lua_isnumber(L, -1) != 0); if (isNumber) { - int value = lua_tonumber(L, -1); + int value = static_cast(lua_tonumber(L, -1)); std::string port = std::to_string(value); if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().setPort(port); @@ -53,8 +53,6 @@ int setPort(lua_State* L) { lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1)); return luaL_error(L, "bad argument #%d (%s)", 1, msg); } - - return 0; } int setAddress(lua_State* L) { @@ -78,8 +76,6 @@ int setAddress(lua_State* L) { lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); return luaL_error(L, "bad argument #%d (%s)", 1, msg); } - - return 0; } int setPassword(lua_State* L) { @@ -103,8 +99,6 @@ int setPassword(lua_State* L) { lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); return luaL_error(L, "bad argument #%d (%s)", 1, msg); } - - return 0; } int setDisplayName(lua_State* L) { @@ -128,8 +122,6 @@ int setDisplayName(lua_State* L) { lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); return luaL_error(L, "bad argument #%d (%s)", 1, msg); } - - return 0; } int connect(lua_State* L) { @@ -175,8 +167,6 @@ int requestHostship(lua_State* L) { lua_typename(L, LUA_TSTRING), luaL_typename(L, -1)); return luaL_error(L, "bad argument #%d (%s)", 1, msg); } - - return 0; } int resignHostship(lua_State* L) { diff --git a/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp index 383cb25e4f..57bc4de704 100644 --- a/src/performance/performancemanager.cpp +++ b/src/performance/performancemanager.cpp @@ -242,7 +242,7 @@ void PerformanceManager::storeScenePerformanceMeasurements( _performanceMemory->acquireLock(); int nNodes = static_cast(sceneNodes.size()); - layout->nScaleGraphEntries = nNodes; + layout->nScaleGraphEntries = static_cast(nNodes); for (int i = 0; i < nNodes; ++i) { SceneGraphNode* node = sceneNodes[i]; diff --git a/src/properties/optionproperty.cpp b/src/properties/optionproperty.cpp index 0eb83a96fc..824719f56a 100644 --- a/src/properties/optionproperty.cpp +++ b/src/properties/optionproperty.cpp @@ -98,6 +98,7 @@ std::string OptionProperty::getDescriptionByValue(int value) { return option.description; } } + return ""; } std::string OptionProperty::generateAdditionalDescription() const { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index d5769de82f..9c241472bd 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -374,12 +374,12 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure ghoul::opengl::ProgramObject* raycastProgram = nullptr; if (cameraIsInside) { - if (raycastProgram = _insideRaycastPrograms[raycaster].get()) { + if (raycastProgram == _insideRaycastPrograms[raycaster].get()) { raycastProgram->activate(); raycastProgram->setUniform("cameraPosInRaycaster", cameraPosition); } } else { - if (raycastProgram = _raycastPrograms[raycaster].get()) { + if (raycastProgram == _raycastPrograms[raycaster].get()) { raycastProgram->activate(); } } diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 3a2ac01d26..21405c71ed 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -74,6 +74,8 @@ namespace { return "ELLIPSOID"; case openspace::SpiceManager::FieldOfViewMethod::Point: return "POINT"; + default: + ghoul_assert(false, "Missing case label"); } } @@ -83,6 +85,8 @@ namespace { return "UMBRAL"; case openspace::SpiceManager::TerminatorType::Penumbral: return "PENUMBRAL"; + default: + ghoul_assert(false, "Missing case label"); } } } @@ -143,6 +147,8 @@ SpiceManager::AberrationCorrection::operator const char*() const { return (direction == Direction::Reception) ? "CN" : "XCN"; case Type::ConvergedNewtonianStellar: return (direction == Direction::Reception) ? "CN+S" : "XCN+S"; + default: + ghoul_assert(false, "Missing case label"); } }