1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-29 17:04:29 +00:00

Address various conversion warnings in openmw

This commit is contained in:
Evil Eye 2025-09-21 12:00:59 +02:00
parent 9523f46409
commit b845e07ad6
21 changed files with 91 additions and 86 deletions

View file

@ -25,7 +25,7 @@ namespace MWGui
struct BookTypesetter::Style
{
virtual ~Style() {}
virtual ~Style() = default;
};
struct TypesetBookImpl : TypesetBook

View file

@ -93,7 +93,7 @@ namespace MWGui
void CountDialog::onSliderMoved(MyGUI::ScrollBar* sender, size_t position)
{
mItemEdit->setValue(position + 1);
mItemEdit->setValue(static_cast<int>(position + 1));
}
bool CountDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)

View file

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

View file

@ -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<int>(modified)));
if (modified > base)
mAttributeValueWidget->_setWidgetState("increased");
else if (modified < base)

View file

@ -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<int>(count), false);
}
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override
{
return dropItemImpl(item, count, true);
return dropItemImpl(item, static_cast<int>(count), true);
}
void removeItem(const ItemStack& /*item*/, size_t /*count*/) override

View file

@ -266,14 +266,14 @@ namespace MWInput
{
mGuiCursorX += xMove;
mGuiCursorY += yMove;
mMouseWheel += mouseWheelMove;
mMouseWheel += static_cast<int>(mouseWheelMove);
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
mGuiCursorX = std::clamp<float>(mGuiCursorX, 0.f, viewSize.width - 1);
mGuiCursorY = std::clamp<float>(mGuiCursorY, 0.f, viewSize.height - 1);
mGuiCursorX = std::clamp<float>(mGuiCursorX, 0.f, viewSize.width - 1.f);
mGuiCursorY = std::clamp<float>(mGuiCursorY, 0.f, viewSize.height - 1.f);
MyGUI::InputManager::getInstance().injectMouseMove(
static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), static_cast<int>(mMouseWheel));
static_cast<int>(mGuiCursorX), static_cast<int>(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;

View file

@ -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<float>(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<float>(nv->getFrameStamp()->getSimulationTime());
if (mBlendTrigger)
{

View file

@ -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<osg::Material> 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<GLsizei>(mLinesVertices->size()));
mTrisDrawArrays->setCount(static_cast<GLsizei>(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<float>(radius)));
geom->setColor(osg::Vec4(1, 1, 1, 1));
mShapesRoot->addChild(geom);
}

View file

@ -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<float>(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<float>(Misc::normalizeAngle(-ptr.getRefData().getPosition().rot[0] - mPitch));
mDeferredRotation.z() = static_cast<float>(Misc::normalizeAngle(-ptr.getRefData().getPosition().rot[2] - mYaw));
if (!mDeferredRotationAllowed)
mDeferredRotationDisabled = true;
}

View file

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

View file

@ -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<PostProcessor*>(renderInfo.getCurrentCamera()->getUserData());

View file

@ -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<int>(mInstances.size()));
}
osg::ref_ptr<osg::Vec4Array> transforms = new osg::Vec4Array(mInstances.size());
osg::ref_ptr<osg::Vec4Array> transforms = new osg::Vec4Array(static_cast<unsigned>(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<osg::Vec3Array> rotations = new osg::Vec3Array(mInstances.size());
osg::ref_ptr<osg::Vec3Array> rotations = new osg::Vec3Array(static_cast<unsigned>(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<int>(std::floor(center.x() - size / 2.f)),
static_cast<int>(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)

View file

@ -40,7 +40,7 @@ namespace
return val * val;
}
std::pair<int, int> divideIntoSegments(const osg::BoundingBox& bounds, float mapSize)
std::pair<int, int> 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<int>(
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<int>(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<int>(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<float>(mMapWorldSize * x), static_cast<float>(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<std::uint8_t>(
*data >> 24, std::clamp(sqrDist / sqrExploreRadius, 0.f, 1.f) * 255);
const std::uint8_t alpha = std::min<std::uint8_t>(*data >> 24,
static_cast<std::uint8_t>(std::clamp(sqrDist / sqrExploreRadius, 0.f, 1.f) * 255));
std::uint32_t val = static_cast<std::uint32_t>(alpha << 24);
if (*data != val)
{

View file

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

View file

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

View file

@ -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<unsigned>(i), pos);
}
positions->dirty();
@ -217,7 +217,7 @@ namespace MWRender
}
osg::GLExtensions& ext = *state.get<osg::GLExtensions>();
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);

View file

@ -64,8 +64,8 @@ namespace
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON);
osg::ref_ptr<osg::PolygonOffset> 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<float>(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<float>(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));
}
}
}

View file

@ -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<int>(renderInfo.getCurrentCamera()->getViewport()->width());
int screenH = static_cast<int>(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<int>(screenW - screenH * imageaspect) / 2);
int topPadding = std::max(0, static_cast<int>(screenH - screenW / imageaspect) / 2);
int width = screenW - leftPadding * 2;

View file

@ -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<osg::StateSet> stateset = mRainParticleSystem->getOrCreateStateSet();

View file

@ -57,10 +57,10 @@ namespace
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> 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<float>(angleRadians);
}
osg::ref_ptr<osg::PositionAttitudeTransform> mSunTransform;
@ -787,7 +787,7 @@ namespace MWRender
if (!sceneManager.getForceShaders())
{
osg::ref_ptr<osg::AlphaFunc> 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;

View file

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