Remove warnings

This commit is contained in:
Alexander Bock
2021-05-25 22:06:49 +02:00
parent d2f9530885
commit cb17bd7570
22 changed files with 81 additions and 58 deletions

View File

@@ -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<Offense> offenses;

View File

@@ -92,7 +92,7 @@ public:
Relative
};
Type type;
Type type = Type::Absolute;
std::string value;
};
struct CameraNavState {

View File

@@ -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;
};

View File

@@ -40,7 +40,7 @@ namespace openspace {
struct TimeKeyframeData {
Time time;
double delta;
double delta = 0.0;
bool pause = false;
bool jump = false;
};

View File

@@ -203,13 +203,13 @@ namespace {
std::optional<AnimationMode> animationMode;
// [[codegen::verbatim(AmbientIntensityInfo.description)]]
std::optional<double> ambientIntensity;
std::optional<float> ambientIntensity;
// [[codegen::verbatim(DiffuseIntensityInfo.description)]]
std::optional<double> diffuseIntensity;
std::optional<float> diffuseIntensity;
// [[codegen::verbatim(SpecularIntensityInfo.description)]]
std::optional<double> specularIntensity;
std::optional<float> specularIntensity;
// [[codegen::verbatim(ShadingInfo.description)]]
std::optional<bool> 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<float>(
convertTime(1.0, timeUnit, TimeUnit::Second))
);
}
else {
throw ghoul::MissingCaseException();

View File

@@ -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<int>(BlendMode::Normal), "Normal" },
{ static_cast<int>(BlendMode::Additive), "Additive"}
});
_blendMode.onChange([&]() {
switch (_blendMode) {
case BlendModeNormal:
case static_cast<int>(BlendMode::Normal):
setRenderBinFromOpacity();
break;
case BlendModeAdditive:
case static_cast<int>(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<int>(BlendMode::Normal)) {
setRenderBinFromOpacity();
}
});
if (p.blendMode.has_value()) {
if (*p.blendMode == Parameters::BlendMode::Normal) {
_blendMode = BlendModeNormal;
_blendMode = static_cast<int>(BlendMode::Normal);
}
else if (*p.blendMode == Parameters::BlendMode::Additive) {
_blendMode = BlendModeAdditive;
_blendMode = static_cast<int>(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<int>(BlendMode::Additive)
);
}
bool additiveBlending = (_blendMode == BlendModeAdditive) && usingFramebufferRenderer;
bool additiveBlending =
(_blendMode == static_cast<int>(BlendMode::Additive)) && usingFramebufferRenderer;
if (additiveBlending) {
glDepthMask(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

View File

@@ -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) {

View File

@@ -124,12 +124,16 @@ namespace {
int iDataset = -1;
std::array<char, 256> 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) {

View File

@@ -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
);
}
}
}

View File

@@ -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();
}
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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) {

View File

@@ -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
};

View File

@@ -38,13 +38,13 @@ BooleanType(SkipAllZeroLines);
struct Dataset {
struct Variable {
int index;
int index = -1;
std::string name;
};
std::vector<Variable> variables;
struct Texture {
int index;
int index = -1;
std::string file;
};
std::vector<Texture> textures;

View File

@@ -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<double>() * glm::pi<double>();
constexpr const double pisq = glm::pi<double>() * glm::pi<double>();
double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0);
// We need the semi major axis in km instead of m

View File

@@ -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<std::string>(L, 1);
const std::string& command = ghoul::lua::value<std::string>(L, 2);
std::string command = ghoul::lua::value<std::string>(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<std::string>(L, 1);
const std::string& command = ghoul::lua::value<std::string>(L, 2);
std::string command = ghoul::lua::value<std::string>(L, 2);
if (command.empty()) {
return ghoul::lua::luaError(L, "Command string is empty");

View File

@@ -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<int>(L, 1);
const std::string& command = ghoul::lua::value<std::string>(L, 2);
const std::string& documentation = ghoul::lua::value<std::string>(L, 3);
std::string command = ghoul::lua::value<std::string>(L, 2);
std::string documentation = ghoul::lua::value<std::string>(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");

View File

@@ -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();