diff --git a/ext/ghoul b/ext/ghoul index eef92b2f8f..5bc318245d 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit eef92b2f8f0982b9d6eaff38213d21aaf2dcdd90 +Subproject commit 5bc318245db24ed93ed48b72d6eaab3c0b88346c diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 39ed62320e..a5c17c8622 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -93,7 +93,7 @@ struct TestResult { /// Is \c true if the TestResult is positive, \c false otherwise - bool success; + bool success = false; /// Contains a list of offenses that were found in the test. Is empty if /// TestResult::Success is \c true std::vector offenses; diff --git a/include/openspace/scene/profile.h b/include/openspace/scene/profile.h index 28a3a360eb..e1565b1dc7 100644 --- a/include/openspace/scene/profile.h +++ b/include/openspace/scene/profile.h @@ -92,7 +92,7 @@ public: Relative }; - Type type; + Type type = Type::Absolute; std::string value; }; struct CameraNavState { diff --git a/include/openspace/util/timeline.h b/include/openspace/util/timeline.h index 1f2936cf40..60e71f25cc 100644 --- a/include/openspace/util/timeline.h +++ b/include/openspace/util/timeline.h @@ -47,8 +47,8 @@ struct Keyframe : public KeyframeBase { Keyframe(size_t i, double t, T d); Keyframe(Keyframe const&) = default; - Keyframe(Keyframe&&) = default; - Keyframe& operator=(Keyframe&&) = default; + Keyframe(Keyframe&&) noexcept = default; + Keyframe& operator=(Keyframe&&) noexcept = default; Keyframe& operator=(Keyframe const&) = default; T data; }; diff --git a/include/openspace/util/timemanager.h b/include/openspace/util/timemanager.h index 1e213abb0a..d7500939c6 100644 --- a/include/openspace/util/timemanager.h +++ b/include/openspace/util/timemanager.h @@ -40,7 +40,7 @@ namespace openspace { struct TimeKeyframeData { Time time; - double delta; + double delta = 0.0; bool pause = false; bool jump = false; }; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 56e7b12635..e3d774bc70 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -203,13 +203,13 @@ namespace { std::optional animationMode; // [[codegen::verbatim(AmbientIntensityInfo.description)]] - std::optional ambientIntensity; + std::optional ambientIntensity; // [[codegen::verbatim(DiffuseIntensityInfo.description)]] - std::optional diffuseIntensity; + std::optional diffuseIntensity; // [[codegen::verbatim(SpecularIntensityInfo.description)]] - std::optional specularIntensity; + std::optional specularIntensity; // [[codegen::verbatim(ShadingInfo.description)]] std::optional performShading; @@ -385,7 +385,9 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) throw ghoul::MissingCaseException(); } - _geometry->setTimeScale(convertTime(1.0, timeUnit, TimeUnit::Second)); + _geometry->setTimeScale(static_cast( + convertTime(1.0, timeUnit, TimeUnit::Second)) + ); } else { throw ghoul::MissingCaseException(); diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 52cbaf638e..8af691c8cb 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -45,9 +45,9 @@ namespace { constexpr const char* ProgramName = "Plane"; - enum BlendMode { - BlendModeNormal = 0, - BlendModeAdditive + enum class BlendMode { + Normal = 0, + Additive }; constexpr openspace::properties::Property::PropertyInfo BillboardInfo = { @@ -121,15 +121,15 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) _billboard = p.billboard.value_or(_billboard); _blendMode.addOptions({ - { BlendModeNormal, "Normal" }, - { BlendModeAdditive, "Additive"} + { static_cast(BlendMode::Normal), "Normal" }, + { static_cast(BlendMode::Additive), "Additive"} }); _blendMode.onChange([&]() { switch (_blendMode) { - case BlendModeNormal: + case static_cast(BlendMode::Normal): setRenderBinFromOpacity(); break; - case BlendModeAdditive: + case static_cast(BlendMode::Additive): setRenderBin(Renderable::RenderBin::PreDeferredTransparent); break; default: @@ -138,17 +138,17 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) }); _opacity.onChange([&]() { - if (_blendMode == BlendModeNormal) { + if (_blendMode == static_cast(BlendMode::Normal)) { setRenderBinFromOpacity(); } }); if (p.blendMode.has_value()) { if (*p.blendMode == Parameters::BlendMode::Normal) { - _blendMode = BlendModeNormal; + _blendMode = static_cast(BlendMode::Normal); } else if (*p.blendMode == Parameters::BlendMode::Additive) { - _blendMode = BlendModeAdditive; + _blendMode = static_cast(BlendMode::Additive); } } @@ -264,10 +264,14 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { RenderEngine::RendererImplementation::ABuffer; if (usingABufferRenderer) { - _shader->setUniform("additiveBlending", _blendMode == BlendModeAdditive); + _shader->setUniform( + "additiveBlending", + _blendMode == static_cast(BlendMode::Additive) + ); } - bool additiveBlending = (_blendMode == BlendModeAdditive) && usingFramebufferRenderer; + bool additiveBlending = + (_blendMode == static_cast(BlendMode::Additive)) && usingFramebufferRenderer; if (additiveBlending) { glDepthMask(false); glBlendFunc(GL_SRC_ALPHA, GL_ONE); diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 889772bc58..11bcd6a06f 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -432,10 +432,10 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); } - const bool renderLines = (_appearance.renderingModes == RenderingModeLines) | + const bool renderLines = (_appearance.renderingModes == RenderingModeLines) || (_appearance.renderingModes == RenderingModeLinesPoints); - const bool renderPoints = (_appearance.renderingModes == RenderingModePoints) | + const bool renderPoints = (_appearance.renderingModes == RenderingModePoints) || (_appearance.renderingModes == RenderingModeLinesPoints); if (renderLines) { diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 912efc92f2..89b7fe275b 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -124,12 +124,16 @@ namespace { int iDataset = -1; std::array IdentifierBuffer; std::fill(IdentifierBuffer.begin(), IdentifierBuffer.end(), '\0'); - sscanf( + int ret = sscanf( subDatasets[i], "SUBDATASET_%i_%256[^=]", &iDataset, IdentifierBuffer.data() ); + if (ret != 2) { + LERROR("Error parsing dataset"); + continue; + } if (iDataset != currentLayerNumber) { diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index adc0ca2516..04052bee2b 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -727,7 +727,10 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask // Render from light source point of view renderChunks(lightRenderData, rendererTask, {}, true); if (_hasRings && _ringsComponent.isEnabled()) { - _ringsComponent.draw(lightRenderData, RingsComponent::GeometryOnly); + _ringsComponent.draw( + lightRenderData, + RingsComponent::RenderPass::GeometryOnly + ); } glEnable(GL_BLEND); @@ -739,7 +742,7 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask if (_hasRings && _ringsComponent.isEnabled()) { _ringsComponent.draw( data, - RingsComponent::GeometryAndShading, + RingsComponent::RenderPass::GeometryAndShading, _shadowComponent.shadowMapData() ); } @@ -747,7 +750,10 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask else { renderChunks(data, rendererTask); if (_hasRings && _ringsComponent.isEnabled()) { - _ringsComponent.draw(data, RingsComponent::GeometryAndShading); + _ringsComponent.draw( + data, + RingsComponent::RenderPass::GeometryAndShading + ); } } } diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 9a57781935..b65eab725d 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -382,14 +382,13 @@ void RingsComponent::deinitializeGL() { _geometryOnlyShader = nullptr; } -void RingsComponent::draw(const RenderData& data, - const RingsComponent::RenderPass renderPass, +void RingsComponent::draw(const RenderData& data, RenderPass renderPass, const ShadowComponent::ShadowMapData& shadowData) { - if (renderPass == GeometryAndShading) { + if (renderPass == RenderPass::GeometryAndShading) { _shader->activate(); } - else if (renderPass == GeometryOnly) { + else if (renderPass == RenderPass::GeometryOnly) { _geometryOnlyShader->activate(); } @@ -408,7 +407,7 @@ void RingsComponent::draw(const RenderData& data, ghoul::opengl::TextureUnit ringTextureUnlitUnit; ghoul::opengl::TextureUnit ringTextureColorUnit; ghoul::opengl::TextureUnit ringTextureTransparencyUnit; - if (renderPass == GeometryAndShading) { + if (renderPass == RenderPass::GeometryAndShading) { if (_isAdvancedTextureEnabled) { _shader->setUniform( _uniformCacheAdvancedRings.modelViewProjectionMatrix, @@ -542,7 +541,7 @@ void RingsComponent::draw(const RenderData& data, glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - else if (renderPass == GeometryOnly) { + else if (renderPass == RenderPass::GeometryOnly) { _geometryOnlyShader->setUniform( _geomUniformCache.modelViewProjectionMatrix, modelViewProjectionTransform @@ -568,12 +567,11 @@ void RingsComponent::draw(const RenderData& data, glEnable(GL_CULL_FACE); - if (renderPass == GeometryAndShading) { + if (renderPass == RenderPass::GeometryAndShading) { _shader->deactivate(); global::renderEngine->openglStateCache().resetBlendState(); - //global::renderEngine->openglStateCache().resetDepthState(); } - else if (renderPass == GeometryOnly) { + else if (renderPass == RenderPass::GeometryOnly) { _geometryOnlyShader->deactivate(); } } diff --git a/modules/globebrowsing/src/ringscomponent.h b/modules/globebrowsing/src/ringscomponent.h index c19a8565b9..6c9acc4fd3 100644 --- a/modules/globebrowsing/src/ringscomponent.h +++ b/modules/globebrowsing/src/ringscomponent.h @@ -50,7 +50,7 @@ namespace documentation { struct Documentation; } class RingsComponent : public properties::PropertyOwner { public: - enum RenderPass { + enum class RenderPass { GeometryOnly, GeometryAndShading }; @@ -63,7 +63,7 @@ public: bool isReady() const; - void draw(const RenderData& data, const RingsComponent::RenderPass renderPass, + void draw(const RenderData& data, RenderPass renderPass, const ShadowComponent::ShadowMapData& shadowData = {} ); void update(const UpdateData& data); diff --git a/modules/globebrowsing/src/tiletextureinitdata.cpp b/modules/globebrowsing/src/tiletextureinitdata.cpp index b47d838548..04137f7d6f 100644 --- a/modules/globebrowsing/src/tiletextureinitdata.cpp +++ b/modules/globebrowsing/src/tiletextureinitdata.cpp @@ -192,7 +192,7 @@ TileTextureInitData TileTextureInitData::operator=(const TileTextureInitData& rh return rhs; } -TileTextureInitData TileTextureInitData::operator=(TileTextureInitData&& rhs) { +TileTextureInitData TileTextureInitData::operator=(TileTextureInitData&& rhs) noexcept { if (this == &rhs) { return *this; } diff --git a/modules/globebrowsing/src/tiletextureinitdata.h b/modules/globebrowsing/src/tiletextureinitdata.h index 2a311a81f5..46d0ea0215 100644 --- a/modules/globebrowsing/src/tiletextureinitdata.h +++ b/modules/globebrowsing/src/tiletextureinitdata.h @@ -49,7 +49,7 @@ public: TileTextureInitData(TileTextureInitData&& original) = default; TileTextureInitData operator=(const TileTextureInitData& rhs); - TileTextureInitData operator=(TileTextureInitData&& rhs); + TileTextureInitData operator=(TileTextureInitData&& rhs) noexcept; ~TileTextureInitData() = default; diff --git a/modules/server/include/topics/luascripttopic.h b/modules/server/include/topics/luascripttopic.h index 7ed757e3dd..49b81f37f4 100644 --- a/modules/server/include/topics/luascripttopic.h +++ b/modules/server/include/topics/luascripttopic.h @@ -36,8 +36,9 @@ public: void handleJson(const nlohmann::json& json) override; bool isDone() const override; + private: - void runScript(const std::string& script, bool returnValue); + void runScript(std::string script, bool returnValue); bool _waitingForReturnValue = true; }; diff --git a/modules/server/src/topics/luascripttopic.cpp b/modules/server/src/topics/luascripttopic.cpp index b718ea4838..d2140b6e75 100644 --- a/modules/server/src/topics/luascripttopic.cpp +++ b/modules/server/src/topics/luascripttopic.cpp @@ -176,7 +176,7 @@ void LuaScriptTopic::handleJson(const nlohmann::json& json) { } } -void LuaScriptTopic::runScript(const std::string& script, bool shouldReturn) { +void LuaScriptTopic::runScript(std::string script, bool shouldReturn) { scripting::ScriptEngine::ScriptCallback callback; if (shouldReturn) { callback = [this](ghoul::Dictionary data) { diff --git a/modules/space/rendering/renderableconstellationbounds.h b/modules/space/rendering/renderableconstellationbounds.h index c6ea6e606c..5af808d7c5 100644 --- a/modules/space/rendering/renderableconstellationbounds.h +++ b/modules/space/rendering/renderableconstellationbounds.h @@ -66,7 +66,7 @@ private: struct ConstellationBound { std::string constellationAbbreviation; ///< The abbreviation of the constellation std::string constellationFullName; - bool isEnabled; + bool isEnabled = false; GLsizei startIndex; ///< The index of the first vertex describing the bounds GLsizei nVertices; ///< The number of vertices describing the bounds }; diff --git a/modules/space/speckloader.h b/modules/space/speckloader.h index 20fb087719..a733b3f02c 100644 --- a/modules/space/speckloader.h +++ b/modules/space/speckloader.h @@ -38,13 +38,13 @@ BooleanType(SkipAllZeroLines); struct Dataset { struct Variable { - int index; + int index = -1; std::string name; }; std::vector variables; struct Texture { - int index; + int index = -1; std::string file; }; std::vector textures; diff --git a/modules/space/translation/tletranslation.cpp b/modules/space/translation/tletranslation.cpp index 36082a69c8..fec5d05143 100644 --- a/modules/space/translation/tletranslation.cpp +++ b/modules/space/translation/tletranslation.cpp @@ -204,7 +204,7 @@ namespace { // mu = G*M_earth double period = std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; - const double pisq = glm::pi() * glm::pi(); + constexpr const double pisq = glm::pi() * glm::pi(); double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); // We need the semi major axis in km instead of m diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index 5627bd26aa..e5da1e3e30 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -40,7 +40,7 @@ int bindKey(lua_State* L) { int nArguments = ghoul::lua::checkArgumentsAndThrow(L, { 2, 5 }, "lua::bindKey"); const std::string& key = ghoul::lua::value(L, 1); - const std::string& command = ghoul::lua::value(L, 2); + std::string command = ghoul::lua::value(L, 2); if (command.empty()) { lua_settop(L, 0); @@ -85,7 +85,7 @@ int bindKeyLocal(lua_State* L) { int nArguments = ghoul::lua::checkArgumentsAndThrow(L, { 2, 5 }, "lua::bindKeyLocal"); const std::string& key = ghoul::lua::value(L, 1); - const std::string& command = ghoul::lua::value(L, 2); + std::string command = ghoul::lua::value(L, 2); if (command.empty()) { return ghoul::lua::luaError(L, "Command string is empty"); diff --git a/src/interaction/navigationhandler_lua.inl b/src/interaction/navigationhandler_lua.inl index 58ca4737f2..b31d487e58 100644 --- a/src/interaction/navigationhandler_lua.inl +++ b/src/interaction/navigationhandler_lua.inl @@ -228,8 +228,15 @@ int joystickAxis(lua_State* L) { const bool invert = info.invert; const bool normalize = info.normalize; const bool isSticky = info.isSticky; - const float sensitivity = info.sensitivity; - ghoul::lua::push(L, ghoul::to_string(info.type), invert, normalize, isSticky, sensitivity); + const double sensitivity = info.sensitivity; + ghoul::lua::push( + L, + ghoul::to_string(info.type), + invert, + normalize, + isSticky, + sensitivity + ); ghoul_assert(lua_gettop(L) == 5, "Incorrect number of items left on stack"); return 5; @@ -268,8 +275,8 @@ int bindJoystickButton(lua_State* L) { ); const int button = ghoul::lua::value(L, 1); - const std::string& command = ghoul::lua::value(L, 2); - const std::string& documentation = ghoul::lua::value(L, 3); + std::string command = ghoul::lua::value(L, 2); + std::string documentation = ghoul::lua::value(L, 3); interaction::JoystickAction action = interaction::JoystickAction::Press; if (n >= 4) { @@ -282,10 +289,10 @@ int bindJoystickButton(lua_State* L) { global::navigationHandler->bindJoystickButtonCommand( button, - std::move(command), + command, action, interaction::JoystickCameraStates::ButtonCommandRemote(isRemote), - std::move(documentation) + documentation ); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); diff --git a/src/util/versionchecker.cpp b/src/util/versionchecker.cpp index 6eddfd9644..6ee129c32e 100644 --- a/src/util/versionchecker.cpp +++ b/src/util/versionchecker.cpp @@ -43,9 +43,10 @@ void VersionChecker::requestLatestVersion(const std::string& url) { HttpRequest::RequestOptions opt; opt.requestTimeoutSeconds = 0; - const std::string fullUrl = url + - "?client_version=" + OPENSPACE_VERSION_NUMBER + - "&commit_hash=" + OPENSPACE_GIT_COMMIT; + std::string fullUrl = fmt::format( + "{}?client_version={}&commit_hash={}", + url, OPENSPACE_VERSION_NUMBER, OPENSPACE_GIT_COMMIT + ); if (_request) { _request->cancel();