From b845e07ad6927733d0a52d42722f351899400b3e Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 21 Sep 2025 12:00:59 +0200 Subject: [PATCH] Address various conversion warnings in openmw --- apps/openmw/mwgui/bookpage.cpp | 2 +- apps/openmw/mwgui/countdialog.cpp | 2 +- apps/openmw/mwgui/race.cpp | 2 +- apps/openmw/mwgui/widgets.cpp | 5 +++-- apps/openmw/mwgui/worlditemmodel.hpp | 20 +++++++++--------- apps/openmw/mwinput/mousemanager.cpp | 12 +++++------ apps/openmw/mwrender/animblendcontroller.cpp | 4 ++-- apps/openmw/mwrender/bulletdebugdraw.cpp | 9 ++++---- apps/openmw/mwrender/camera.cpp | 13 ++++++------ apps/openmw/mwrender/characterpreview.cpp | 4 ++-- apps/openmw/mwrender/distortion.cpp | 2 +- apps/openmw/mwrender/groundcover.cpp | 15 ++++++------- apps/openmw/mwrender/localmap.cpp | 17 ++++++++------- apps/openmw/mwrender/localmap.hpp | 2 +- apps/openmw/mwrender/pingpongcull.cpp | 4 ++-- apps/openmw/mwrender/ripples.cpp | 6 +++--- apps/openmw/mwrender/ripplesimulation.cpp | 16 +++++++------- apps/openmw/mwrender/screenshotmanager.cpp | 6 +++--- apps/openmw/mwrender/sky.cpp | 2 +- apps/openmw/mwrender/skyutil.cpp | 22 ++++++++++---------- apps/openmw/mwrender/water.cpp | 12 +++++------ 21 files changed, 91 insertions(+), 86 deletions(-) diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 008c935c73..305b3276f7 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -25,7 +25,7 @@ namespace MWGui struct BookTypesetter::Style { - virtual ~Style() {} + virtual ~Style() = default; }; struct TypesetBookImpl : TypesetBook diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index 608257a0e7..08372093f6 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -93,7 +93,7 @@ namespace MWGui void CountDialog::onSliderMoved(MyGUI::ScrollBar* sender, size_t position) { - mItemEdit->setValue(position + 1); + mItemEdit->setValue(static_cast(position + 1)); } bool CountDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index fe01a60894..c9a591ddc1 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -248,7 +248,7 @@ namespace MWGui void RaceDialog::onHeadRotate(MyGUI::ScrollBar* scroll, size_t position) { - float angle = (float(position) / (scroll->getScrollRange() - 1) - 0.5f) * osg::PI * 2; + float angle = (float(position) / (scroll->getScrollRange() - 1) - 0.5f) * osg::PIf * 2; mPreview->setAngle(angle); mCurrentAngle = angle; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 496fa2ea50..1d14aa4af9 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -147,8 +147,9 @@ namespace MWGui::Widgets } if (mAttributeValueWidget) { - int modified = mValue.getModified(), base = mValue.getBase(); - mAttributeValueWidget->setCaption(MyGUI::utility::toString(modified)); + float modified = mValue.getModified(); + float base = mValue.getBase(); + mAttributeValueWidget->setCaption(MyGUI::utility::toString(static_cast(modified))); if (modified > base) mAttributeValueWidget->_setWidgetState("increased"); else if (modified < base) diff --git a/apps/openmw/mwgui/worlditemmodel.hpp b/apps/openmw/mwgui/worlditemmodel.hpp index 137062eeb4..1999cb40ed 100644 --- a/apps/openmw/mwgui/worlditemmodel.hpp +++ b/apps/openmw/mwgui/worlditemmodel.hpp @@ -18,14 +18,7 @@ namespace MWGui // Makes it possible to use ItemModel::moveItem to move an item from an inventory to the world. class WorldItemModel : public ItemModel { - public: - explicit WorldItemModel(float cursorX, float cursorY) - : mCursorX(cursorX) - , mCursorY(cursorY) - { - } - - MWWorld::Ptr dropItemImpl(const ItemStack& item, size_t count, bool copy) + MWWorld::Ptr dropItemImpl(const ItemStack& item, int count, bool copy) { MWBase::World& world = *MWBase::Environment::get().getWorld(); @@ -42,14 +35,21 @@ namespace MWGui return dropped; } + public: + explicit WorldItemModel(float cursorX, float cursorY) + : mCursorX(cursorX) + , mCursorY(cursorY) + { + } + MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override { - return dropItemImpl(item, count, false); + return dropItemImpl(item, static_cast(count), false); } MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override { - return dropItemImpl(item, count, true); + return dropItemImpl(item, static_cast(count), true); } void removeItem(const ItemStack& /*item*/, size_t /*count*/) override diff --git a/apps/openmw/mwinput/mousemanager.cpp b/apps/openmw/mwinput/mousemanager.cpp index ced69fbe79..4186b5a023 100644 --- a/apps/openmw/mwinput/mousemanager.cpp +++ b/apps/openmw/mwinput/mousemanager.cpp @@ -266,14 +266,14 @@ namespace MWInput { mGuiCursorX += xMove; mGuiCursorY += yMove; - mMouseWheel += mouseWheelMove; + mMouseWheel += static_cast(mouseWheelMove); const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); - mGuiCursorX = std::clamp(mGuiCursorX, 0.f, viewSize.width - 1); - mGuiCursorY = std::clamp(mGuiCursorY, 0.f, viewSize.height - 1); + mGuiCursorX = std::clamp(mGuiCursorX, 0.f, viewSize.width - 1.f); + mGuiCursorY = std::clamp(mGuiCursorY, 0.f, viewSize.height - 1.f); MyGUI::InputManager::getInstance().injectMouseMove( - static_cast(mGuiCursorX), static_cast(mGuiCursorY), static_cast(mMouseWheel)); + static_cast(mGuiCursorX), static_cast(mGuiCursorY), mMouseWheel); } void MouseManager::warpMouse() @@ -285,8 +285,8 @@ namespace MWInput void MouseManager::warpMouseToWidget(MyGUI::Widget* widget) { - float widgetX = widget->getAbsoluteCoord().left + widget->getWidth() / 2; - float widgetY = widget->getAbsoluteCoord().top + widget->getHeight() / 4; + float widgetX = widget->getAbsoluteCoord().left + widget->getWidth() / 2.f; + float widgetY = widget->getAbsoluteCoord().top + widget->getHeight() / 4.f; if (std::abs(mGuiCursorX - widgetX) > 1 || std::abs(mGuiCursorY - widgetY) > 1) { mGuiCursorX = widgetX; diff --git a/apps/openmw/mwrender/animblendcontroller.cpp b/apps/openmw/mwrender/animblendcontroller.cpp index 3d8b7b59d7..bfd4c0041d 100644 --- a/apps/openmw/mwrender/animblendcontroller.cpp +++ b/apps/openmw/mwrender/animblendcontroller.cpp @@ -279,7 +279,7 @@ namespace MWRender // such as bip01, bip01 spine1 etc. The child bones of these controllers have their own callback wrapper // which will call this instance's applyBoneBlend for each child bone. The order of update is important // as the blending calculations expect the bone's skeleton matrix to be at the sample point - float time = nv->getFrameStamp()->getSimulationTime(); + float time = static_cast(nv->getFrameStamp()->getSimulationTime()); assert(node != nullptr); if (mBlendTrigger) @@ -308,7 +308,7 @@ namespace MWRender auto [translation, rotation, scale] = mKeyframeTrack->getCurrentTransformation(nv); - float time = nv->getFrameStamp()->getSimulationTime(); + float time = static_cast(nv->getFrameStamp()->getSimulationTime()); if (mBlendTrigger) { diff --git a/apps/openmw/mwrender/bulletdebugdraw.cpp b/apps/openmw/mwrender/bulletdebugdraw.cpp index 3e0383b567..e662d0a5f4 100644 --- a/apps/openmw/mwrender/bulletdebugdraw.cpp +++ b/apps/openmw/mwrender/bulletdebugdraw.cpp @@ -68,7 +68,7 @@ namespace MWRender new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE), osg::StateAttribute::ON); stateSet->setAttributeAndModes(new osg::PolygonOffset( - SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0, SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0)); + SceneUtil::AutoDepth::isReversed() ? 1.f : -1.f, SceneUtil::AutoDepth::isReversed() ? 1.f : -1.f)); osg::ref_ptr material = new osg::Material; material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE); stateSet->setAttribute(material); @@ -118,8 +118,8 @@ namespace MWRender mShapesRoot->removeChildren(0, mShapesRoot->getNumChildren()); mWorld->debugDrawWorld(); showCollisions(); - mLinesDrawArrays->setCount(mLinesVertices->size()); - mTrisDrawArrays->setCount(mTrisVertices->size()); + mLinesDrawArrays->setCount(static_cast(mLinesVertices->size())); + mTrisDrawArrays->setCount(static_cast(mTrisVertices->size())); mLinesVertices->dirty(); mTrisVertices->dirty(); mLinesColors->dirty(); @@ -194,7 +194,8 @@ namespace MWRender void DebugDrawer::drawSphere(btScalar radius, const btTransform& transform, const btVector3& color) { - auto* geom = new osg::ShapeDrawable(new osg::Sphere(Misc::Convert::toOsg(transform.getOrigin()), radius)); + auto* geom = new osg::ShapeDrawable( + new osg::Sphere(Misc::Convert::toOsg(transform.getOrigin()), static_cast(radius))); geom->setColor(osg::Vec4(1, 1, 1, 1)); mShapesRoot->addChild(geom); } diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index 1c163a6701..9a22409158 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -179,7 +179,7 @@ namespace MWRender osg::Vec3d focal = mTrackedPosition + focalOffset; focalOffset.z() += 10.f; // Needed to avoid camera clipping through the ceiling because // character's head can be a bit higher than the collision area. - float offsetLen = focalOffset.length(); + double offsetLen = focalOffset.length(); if (offsetLen > 0) { MWPhysics::RayCastingResult result @@ -280,9 +280,9 @@ namespace MWRender osg::Vec2d delta = mFocalPointTargetOffset - mFocalPointCurrentOffset; if (delta.length2() > 0) { - float coef = duration * (1.0 + 5.0 / delta.length()) * mFocalPointTransitionSpeedCoef + double coef = duration * (1.0 + 5.0 / delta.length()) * mFocalPointTransitionSpeedCoef * (1.0f - mPreviousTransitionInfluence); - mFocalPointCurrentOffset += delta * std::min(coef, 1.0f); + mFocalPointCurrentOffset += delta * std::min(coef, 1.0); } else { @@ -315,7 +315,7 @@ namespace MWRender void Camera::setYaw(float angle, bool force) { if (!mLockYaw || force) - mYaw = Misc::normalizeAngle(angle); + mYaw = static_cast(Misc::normalizeAngle(angle)); if (force) mLockYaw = true; } @@ -433,8 +433,9 @@ namespace MWRender return; } - mDeferredRotation.x() = Misc::normalizeAngle(-ptr.getRefData().getPosition().rot[0] - mPitch); - mDeferredRotation.z() = Misc::normalizeAngle(-ptr.getRefData().getPosition().rot[2] - mYaw); + mDeferredRotation.x() + = static_cast(Misc::normalizeAngle(-ptr.getRefData().getPosition().rot[0] - mPitch)); + mDeferredRotation.z() = static_cast(Misc::normalizeAngle(-ptr.getRefData().getPosition().rot[2] - mYaw)); if (!mDeferredRotationAllowed) mDeferredRotationDisabled = true; } diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 18604e78ca..ef50c1145d 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -479,8 +479,8 @@ namespace MWRender { if (!mViewport) return -1; - float projX = (posX / mViewport->width()) * 2 - 1.f; - float projY = (posY / mViewport->height()) * 2 - 1.f; + double projX = (posX / mViewport->width()) * 2 - 1; + double projY = (posY / mViewport->height()) * 2 - 1; // With Intersector::WINDOW, the intersection ratios are slightly inaccurate. Seems to be a // precision issue - compiling with OSG_USE_FLOAT_MATRIX=0, Intersector::WINDOW works ok. // Using Intersector::PROJECTION results in better precision because the start/end points and the model matrices diff --git a/apps/openmw/mwrender/distortion.cpp b/apps/openmw/mwrender/distortion.cpp index 5df2bfb703..3466df8125 100644 --- a/apps/openmw/mwrender/distortion.cpp +++ b/apps/openmw/mwrender/distortion.cpp @@ -10,7 +10,7 @@ namespace MWRender osgUtil::RenderBin* bin, osg::RenderInfo& renderInfo, osgUtil::RenderLeaf*& previous) { osg::State* state = renderInfo.getState(); - size_t frameId = state->getFrameStamp()->getFrameNumber() % 2; + unsigned frameId = state->getFrameStamp()->getFrameNumber() % 2; PostProcessor* postProcessor = dynamic_cast(renderInfo.getCurrentCamera()->getUserData()); diff --git a/apps/openmw/mwrender/groundcover.cpp b/apps/openmw/mwrender/groundcover.cpp index 9fc40f3e19..d7e65a99b5 100644 --- a/apps/openmw/mwrender/groundcover.cpp +++ b/apps/openmw/mwrender/groundcover.cpp @@ -106,7 +106,7 @@ namespace MWRender for (const auto& instanceMatrix : mInstanceMatrices) { osg::Matrix fullMatrix = instanceMatrix * matrix; - osg::Vec3 instanceLookVector(-fullMatrix(0, 2), -fullMatrix(1, 2), -fullMatrix(2, 2)); + osg::Vec3d instanceLookVector(-fullMatrix(0, 2), -fullMatrix(1, 2), -fullMatrix(2, 2)); unsigned int instanceBbCornerFar = (instanceLookVector.x() >= 0 ? 1 : 0) | (instanceLookVector.y() >= 0 ? 2 : 0) | (instanceLookVector.z() >= 0 ? 4 : 0); unsigned int instanceBbCornerNear = (~instanceBbCornerFar) & 7; @@ -146,7 +146,7 @@ namespace MWRender for (const auto& instanceMatrix : mInstanceMatrices) { osg::Matrix fullMatrix = instanceMatrix * matrix; - osg::Vec3 instanceLookVector(-fullMatrix(0, 2), -fullMatrix(1, 2), -fullMatrix(2, 2)); + osg::Vec3d instanceLookVector(-fullMatrix(0, 2), -fullMatrix(1, 2), -fullMatrix(2, 2)); unsigned int instanceBbCornerFar = (instanceLookVector.x() >= 0 ? 1 : 0) | (instanceLookVector.y() >= 0 ? 2 : 0) | (instanceLookVector.z() >= 0 ? 4 : 0); unsigned int instanceBbCornerNear = (~instanceBbCornerFar) & 7; @@ -217,10 +217,10 @@ namespace MWRender { for (unsigned int i = 0; i < geom.getNumPrimitiveSets(); ++i) { - geom.getPrimitiveSet(i)->setNumInstances(mInstances.size()); + geom.getPrimitiveSet(i)->setNumInstances(static_cast(mInstances.size())); } - osg::ref_ptr transforms = new osg::Vec4Array(mInstances.size()); + osg::ref_ptr transforms = new osg::Vec4Array(static_cast(mInstances.size())); osg::BoundingBox box; osg::BoundingBox originalBox = geom.getBoundingBox(); float radius = originalBox.radius(); @@ -238,7 +238,7 @@ namespace MWRender geom.setInitialBound(box); - osg::ref_ptr rotations = new osg::Vec3Array(mInstances.size()); + osg::ref_ptr rotations = new osg::Vec3Array(static_cast(mInstances.size())); for (unsigned int i = 0; i < rotations->getNumElements(); i++) { (*rotations)[i] = mInstances[i].mPos.asRotationVec3(); @@ -368,7 +368,7 @@ namespace MWRender mProgramTemplate->addBindAttribLocation("aRotation", 7); } - Groundcover::~Groundcover() {} + Groundcover::~Groundcover() = default; void Groundcover::collectInstances(InstanceMap& instances, float size, const osg::Vec2f& center) { @@ -379,7 +379,8 @@ namespace MWRender osg::Vec2f maxBound = (center + osg::Vec2f(size / 2.f, size / 2.f)); DensityCalculator calculator(mDensity); ESM::ReadersCache readers; - osg::Vec2i startCell = osg::Vec2i(std::floor(center.x() - size / 2.f), std::floor(center.y() - size / 2.f)); + osg::Vec2i startCell = osg::Vec2i(static_cast(std::floor(center.x() - size / 2.f)), + static_cast(std::floor(center.y() - size / 2.f))); for (int cellX = startCell.x(); cellX < startCell.x() + size; ++cellX) { for (int cellY = startCell.y(); cellY < startCell.y() + size; ++cellY) diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 86999d753c..65c3add82d 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -40,7 +40,7 @@ namespace return val * val; } - std::pair divideIntoSegments(const osg::BoundingBox& bounds, float mapSize) + std::pair divideIntoSegments(const osg::BoundingBox& bounds, int mapSize) { osg::Vec2f min(bounds.xMin(), bounds.yMin()); osg::Vec2f max(bounds.xMax(), bounds.yMax()); @@ -76,8 +76,8 @@ namespace MWRender LocalMap::LocalMap(osg::Group* root) : mRoot(root) - , mMapResolution( - Settings::map().mLocalMapResolution * MWBase::Environment::get().getWindowManager()->getScalingFactor()) + , mMapResolution(static_cast( + Settings::map().mLocalMapResolution * MWBase::Environment::get().getWindowManager()->getScalingFactor())) , mMapWorldSize(Constants::CellSizeInUnits) , mCellDistance(Constants::CellGridRadius) , mAngle(0.f) @@ -352,7 +352,7 @@ namespace MWRender else if (fog->mBounds.mMinX > mBounds.xMin()) { float diff = fog->mBounds.mMinX - mBounds.xMin(); - xOffset = std::ceil(diff / mMapWorldSize); + xOffset = static_cast(std::ceil(diff / mMapWorldSize)); mBounds.xMin() = fog->mBounds.mMinX - xOffset * mMapWorldSize; } if (fog->mBounds.mMinY < mBounds.yMin()) @@ -362,7 +362,7 @@ namespace MWRender else if (fog->mBounds.mMinY > mBounds.yMin()) { float diff = fog->mBounds.mMinY - mBounds.yMin(); - yOffset = std::ceil(diff / mMapWorldSize); + yOffset = static_cast(std::ceil(diff / mMapWorldSize)); mBounds.yMin() = fog->mBounds.mMinY - yOffset * mMapWorldSize; } if (fog->mBounds.mMaxX > mBounds.xMax()) @@ -388,7 +388,8 @@ namespace MWRender { for (int y = 0; y < segments.second; ++y) { - osg::Vec2f start = min + osg::Vec2f(mMapWorldSize * x, mMapWorldSize * y); + osg::Vec2f start + = min + osg::Vec2f(static_cast(mMapWorldSize * x), static_cast(mMapWorldSize * y)); osg::Vec2f newcenter = start + osg::Vec2f(mMapWorldSize / 2.f, mMapWorldSize / 2.f); osg::Vec2f a = newcenter - mCenter; @@ -535,8 +536,8 @@ namespace MWRender float sqrDist = square((texU + mx * (sFogOfWarResolution - 1)) - u * (sFogOfWarResolution - 1)) + square((texV + my * (sFogOfWarResolution - 1)) - v * (sFogOfWarResolution - 1)); - const std::uint8_t alpha = std::min( - *data >> 24, std::clamp(sqrDist / sqrExploreRadius, 0.f, 1.f) * 255); + const std::uint8_t alpha = std::min(*data >> 24, + static_cast(std::clamp(sqrDist / sqrExploreRadius, 0.f, 1.f) * 255)); std::uint32_t val = static_cast(alpha << 24); if (*data != val) { diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index bf7844f2c1..f890733888 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -144,7 +144,7 @@ namespace MWRender static const int sFogOfWarResolution = 32; // size of a map segment (for exteriors, 1 cell) - float mMapWorldSize; + int mMapWorldSize; int mCellDistance; diff --git a/apps/openmw/mwrender/pingpongcull.cpp b/apps/openmw/mwrender/pingpongcull.cpp index 497c6c734a..03653f25f8 100644 --- a/apps/openmw/mwrender/pingpongcull.cpp +++ b/apps/openmw/mwrender/pingpongcull.cpp @@ -34,8 +34,8 @@ namespace MWRender void PingPongCull::operator()(osg::Node* node, osgUtil::CullVisitor* cv) { osgUtil::RenderStage* renderStage = cv->getCurrentRenderStage(); - size_t frame = cv->getTraversalNumber(); - size_t frameId = frame % 2; + unsigned frame = cv->getTraversalNumber(); + unsigned frameId = frame % 2; if (Stereo::getStereo()) { diff --git a/apps/openmw/mwrender/ripples.cpp b/apps/openmw/mwrender/ripples.cpp index b19863d695..5b468c7cdc 100644 --- a/apps/openmw/mwrender/ripples.cpp +++ b/apps/openmw/mwrender/ripples.cpp @@ -43,7 +43,7 @@ namespace MWRender // we can not trust Apple :) mUseCompute = false; #else - constexpr float minimumGLVersionRequiredForCompute = 4.4; + constexpr float minimumGLVersionRequiredForCompute = 4.4f; osg::GLExtensions& exts = SceneUtil::getGLExtensions(); mUseCompute = exts.glVersion >= minimumGLVersionRequiredForCompute && exts.glslLanguageVersion >= minimumGLVersionRequiredForCompute; @@ -183,7 +183,7 @@ namespace MWRender - osg::Vec3f(mCurrentPlayerPos.x() * sWorldScaleFactor, mCurrentPlayerPos.y() * sWorldScaleFactor, 0.0) + osg::Vec3f(sRTTSize * sWorldScaleFactor / 2, sRTTSize * sWorldScaleFactor / 2, 0.0); pos /= sWorldScaleFactor; - positions->setElement(i, pos); + positions->setElement(static_cast(i), pos); } positions->dirty(); @@ -217,7 +217,7 @@ namespace MWRender } osg::GLExtensions& ext = *state.get(); - const std::size_t contextID = state.getContextID(); + const unsigned contextID = state.getContextID(); const auto bindImage = [&](osg::Texture2D* texture, GLuint index, GLenum access) { osg::Texture::TextureObject* to = texture->getTextureObject(contextID); diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index 88a620efd0..232dd99f6b 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -64,8 +64,8 @@ namespace stateset->setAttributeAndModes(depth, osg::StateAttribute::ON); osg::ref_ptr polygonOffset(new osg::PolygonOffset); - polygonOffset->setUnits(SceneUtil::AutoDepth::isReversed() ? 1 : -1); - polygonOffset->setFactor(SceneUtil::AutoDepth::isReversed() ? 1 : -1); + polygonOffset->setUnits(SceneUtil::AutoDepth::isReversed() ? 1.f : -1.f); + polygonOffset->setFactor(SceneUtil::AutoDepth::isReversed() ? 1.f : -1.f); stateset->setAttributeAndModes(polygonOffset, osg::StateAttribute::ON); stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); @@ -84,13 +84,13 @@ namespace int findOldestParticleAlive(const osgParticle::ParticleSystem* partsys) { int oldest = -1; - float oldestAge = 0.f; + double oldestAge = 0.f; for (int i = 0; i < partsys->numParticles(); ++i) { const osgParticle::Particle* particle = partsys->getParticle(i); if (!particle->isAlive()) continue; - const float age = particle->getAge(); + const double age = particle->getAge(); if (oldest == -1 || age > oldestAge) { oldest = i; @@ -116,7 +116,7 @@ namespace MWRender osgParticle::Particle& particleTemplate = mParticleSystem->getDefaultParticleTemplate(); particleTemplate.setSizeRange(osgParticle::rangef(15, 180)); - particleTemplate.setColorRange(osgParticle::rangev4(osg::Vec4f(1, 1, 1, 0.7), osg::Vec4f(1, 1, 1, 0.7))); + particleTemplate.setColorRange(osgParticle::rangev4(osg::Vec4f(1, 1, 1, 0.7f), osg::Vec4f(1, 1, 1, 0.7f))); particleTemplate.setAlphaRange(osgParticle::rangef(1.f, 0.f)); particleTemplate.setAngularVelocity(osg::Vec3f(0, 0, Fallback::Map::getFloat("Water_RippleRotSpeed"))); particleTemplate.setLifeTime(Fallback::Map::getFloat("Water_RippleLifetime")); @@ -169,7 +169,7 @@ namespace MWRender { // Ripple simulation needs to continously apply impulses to keep simulation alive. // Adding a timer delay will introduce many smaller ripples around actor instead of a smooth wake - currentPos.z() = mParticleNode->getPosition().z(); + currentPos.z() = static_cast(mParticleNode->getPosition().z()); emitRipple(currentPos); } else if (emitter.mTimer <= 0.f || (currentPos - emitter.mLastEmitPosition).length() > 10) @@ -177,7 +177,7 @@ namespace MWRender emitter.mLastEmitPosition = currentPos; emitter.mTimer = 1.5f; - currentPos.z() = mParticleNode->getPosition().z(); + currentPos.z() = static_cast(mParticleNode->getPosition().z()); emitRipple(currentPos); } @@ -258,7 +258,7 @@ namespace MWRender } osgParticle::Particle* p = mParticleSystem->createParticle(nullptr); p->setPosition(osg::Vec3f(pos.x(), pos.y(), 0.f)); - p->setAngle(osg::Vec3f(0, 0, Misc::Rng::rollProbability() * osg::PI * 2 - osg::PI)); + p->setAngle(osg::Vec3f(0, 0, Misc::Rng::rollProbability() * osg::PIf * 2 - osg::PIf)); } } } diff --git a/apps/openmw/mwrender/screenshotmanager.cpp b/apps/openmw/mwrender/screenshotmanager.cpp index 2c86a70f23..d55daa09b8 100644 --- a/apps/openmw/mwrender/screenshotmanager.cpp +++ b/apps/openmw/mwrender/screenshotmanager.cpp @@ -65,15 +65,15 @@ namespace MWRender } void drawImplementation(osg::RenderInfo& renderInfo, const osg::Drawable* /*drawable*/) const override { - int screenW = renderInfo.getCurrentCamera()->getViewport()->width(); - int screenH = renderInfo.getCurrentCamera()->getViewport()->height(); + int screenW = static_cast(renderInfo.getCurrentCamera()->getViewport()->width()); + int screenH = static_cast(renderInfo.getCurrentCamera()->getViewport()->height()); if (Stereo::getStereo()) { auto eyeRes = Stereo::Manager::instance().eyeResolution(); screenW = eyeRes.x(); screenH = eyeRes.y(); } - double imageaspect = (double)mWidth / (double)mHeight; + double imageaspect = double(mWidth) / double(mHeight); int leftPadding = std::max(0, static_cast(screenW - screenH * imageaspect) / 2); int topPadding = std::max(0, static_cast(screenH - screenW / imageaspect) / 2); int width = screenW - leftPadding * 2; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 244e1035ed..7e485862a9 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -391,7 +391,7 @@ namespace MWRender osg::Vec3 rainRange = osg::Vec3(mRainDiameter, mRainDiameter, (mRainMinHeight + mRainMaxHeight) / 2.f); mRainParticleSystem->setParticleAlignment(osgParticle::ParticleSystem::FIXED); - mRainParticleSystem->setAlignVectorX(osg::Vec3f(0.1, 0, 0)); + mRainParticleSystem->setAlignVectorX(osg::Vec3f(0.1f, 0, 0)); mRainParticleSystem->setAlignVectorY(osg::Vec3f(0, 0, 1)); osg::ref_ptr stateset = mRainParticleSystem->getOrCreateStateSet(); diff --git a/apps/openmw/mwrender/skyutil.cpp b/apps/openmw/mwrender/skyutil.cpp index dacf628a2c..8523499a83 100644 --- a/apps/openmw/mwrender/skyutil.cpp +++ b/apps/openmw/mwrender/skyutil.cpp @@ -57,10 +57,10 @@ namespace osg::ref_ptr geom = new osg::Geometry; osg::ref_ptr verts = new osg::Vec3Array; - verts->push_back(osg::Vec3f(-0.5 * scale, -0.5 * scale, 0)); - verts->push_back(osg::Vec3f(-0.5 * scale, 0.5 * scale, 0)); - verts->push_back(osg::Vec3f(0.5 * scale, 0.5 * scale, 0)); - verts->push_back(osg::Vec3f(0.5 * scale, -0.5 * scale, 0)); + verts->push_back(osg::Vec3f(-0.5f * scale, -0.5f * scale, 0.f)); + verts->push_back(osg::Vec3f(-0.5f * scale, 0.5f * scale, 0.f)); + verts->push_back(osg::Vec3f(0.5f * scale, 0.5f * scale, 0.f)); + verts->push_back(osg::Vec3f(0.5f * scale, -0.5f * scale, 0.f)); geom->setVertexArray(verts); @@ -179,7 +179,7 @@ namespace MWRender if (visibleRatio > 0.f) { - const float fadeThreshold = 0.1; + const float fadeThreshold = 0.1f; if (visibleRatio < fadeThreshold) { float fade = 1.f - (fadeThreshold - visibleRatio) / fadeThreshold; @@ -190,7 +190,7 @@ namespace MWRender } else if (visibleRatio < 1.f) { - const float threshold = 0.6; + const float threshold = 0.6f; visibleRatio = visibleRatio * (1.f - threshold) + threshold; } } @@ -304,8 +304,8 @@ namespace MWRender forward.normalize(); sun.normalize(); - float angleRadians = std::acos(forward * sun); - return angleRadians; + double angleRadians = std::acos(forward * sun); + return static_cast(angleRadians); } osg::ref_ptr mSunTransform; @@ -787,7 +787,7 @@ namespace MWRender if (!sceneManager.getForceShaders()) { osg::ref_ptr alphaFunc = new osg::AlphaFunc; - alphaFunc->setFunction(osg::AlphaFunc::GREATER, 0.8); + alphaFunc->setFunction(osg::AlphaFunc::GREATER, 0.8f); stateset->setAttributeAndModes(alphaFunc); } stateset->setTextureAttributeAndModes(0, sunTex); @@ -1146,7 +1146,7 @@ namespace MWRender void RainShooter::shoot(osgParticle::Particle* particle) const { particle->setVelocity(mVelocity); - particle->setAngle(osg::Vec3f(-mAngle, 0, (Misc::Rng::rollProbability() * 2 - 1) * osg::PI)); + particle->setAngle(osg::Vec3f(-mAngle, 0, (Misc::Rng::rollProbability() * 2 - 1) * osg::PIf)); } void RainShooter::setVelocity(const osg::Vec3f& velocity) @@ -1195,7 +1195,7 @@ namespace MWRender if (i >= 49 && i <= 64) alpha = 0.f; // bottom-most row else if (i >= 33 && i <= 48) - alpha = 0.25098; // second row + alpha = 0.25098f; // second row else alpha = 1.f; break; diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 81688a3444..265b97eacc 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -114,10 +114,10 @@ namespace MWRender } // move the plane back along its normal a little bit to prevent bleeding at the water shore - float fov = Settings::camera().mFieldOfView; - const float clipFudgeMin = 2.5; // minimum offset of clip plane - const float clipFudgeScale = -15000.0; - float clipFudge = abs(abs((*mCullPlane)[3]) - eyePoint.z()) * fov / clipFudgeScale - clipFudgeMin; + const float fov = Settings::camera().mFieldOfView; + constexpr double clipFudgeMin = 2.5; // minimum offset of clip plane + constexpr double clipFudgeScale = -15000.0; + double clipFudge = std::abs(std::abs((*mCullPlane)[3]) - eyePoint.z()) * fov / clipFudgeScale - clipFudgeMin; modelViewMatrix->preMultTranslate(mCullPlane->getNormal() * clipFudge); cv->pushModelViewMatrix(modelViewMatrix, osg::Transform::RELATIVE_RF); @@ -188,7 +188,7 @@ namespace MWRender public: void operator()(osg::Node* node, osgUtil::CullVisitor* cv) { - const float fudge = 0.2; + const float fudge = 0.2f; if (std::abs(cv->getEyeLocal().z()) < fudge) { float diff = fudge - cv->getEyeLocal().z(); @@ -422,7 +422,7 @@ namespace MWRender void drawImplementation(osg::RenderInfo& renderInfo, const osg::Drawable* drawable) const override { static bool supported = osg::isGLExtensionOrVersionSupported( - renderInfo.getState()->getContextID(), "GL_ARB_depth_clamp", 3.3); + renderInfo.getState()->getContextID(), "GL_ARB_depth_clamp", 3.3f); if (!supported) { drawable->drawImplementation(renderInfo);