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

First batch of warning fixes

This commit is contained in:
AnyOldName3 2025-09-18 00:38:08 +01:00
parent 7520e86ab3
commit 98291f1377
34 changed files with 111 additions and 106 deletions

View file

@ -21,7 +21,7 @@ namespace DetourNavigator
switch (agentBounds.mShapeType)
{
case CollisionShapeType::Aabb:
return std::max(agentBounds.mHalfExtents.x(), agentBounds.mHalfExtents.y()) * std::sqrt(2);
return std::max(agentBounds.mHalfExtents.x(), agentBounds.mHalfExtents.y()) * std::sqrt(2.0f);
case CollisionShapeType::RotatingBox:
return agentBounds.mHalfExtents.x();
case CollisionShapeType::Cylinder:

View file

@ -56,8 +56,8 @@ namespace DetourNavigator
inline TileBounds maxCellTileBounds(const osg::Vec2i& position, int size)
{
return TileBounds{ osg::Vec2f(position.x(), position.y()) * size,
osg::Vec2f(position.x() + 1, position.y() + 1) * size };
return TileBounds{ osg::Vec2f(static_cast<float>(position.x()), static_cast<float>(position.y())) * static_cast<float>(size),
osg::Vec2f(static_cast<float>(position.x() + 1), static_cast<float>(position.y() + 1)) * static_cast<float>(size) };
}
inline TileBounds makeObjectTileBounds(const btCollisionShape& shape, const btTransform& transform)

View file

@ -29,7 +29,7 @@ namespace ESM
inline ESM::ExteriorCellLocation positionToExteriorCellLocation(
float x, float y, ESM::RefId worldspaceId = ESM::Cell::sDefaultWorldspaceId)
{
const float cellSize = getCellSize(worldspaceId);
const float cellSize = static_cast<float>(getCellSize(worldspaceId));
return { static_cast<int>(std::floor(x / cellSize)), static_cast<int>(std::floor(y / cellSize)), worldspaceId };
}

View file

@ -141,11 +141,11 @@ namespace ESM
effects[MagicEffect::Effects::DisintegrateArmor] = MagicEffect::Effects::Sanctuary;
effects[MagicEffect::Effects::DisintegrateWeapon] = MagicEffect::Effects::Sanctuary;
for (int i = MagicEffect::Effects::DrainAttribute; i <= MagicEffect::Effects::DamageSkill; ++i)
for (short i = MagicEffect::Effects::DrainAttribute; i <= MagicEffect::Effects::DamageSkill; ++i)
effects[i] = MagicEffect::Effects::ResistMagicka;
for (int i = MagicEffect::Effects::AbsorbAttribute; i <= MagicEffect::Effects::AbsorbSkill; ++i)
for (short i = MagicEffect::Effects::AbsorbAttribute; i <= MagicEffect::Effects::AbsorbSkill; ++i)
effects[i] = MagicEffect::Effects::ResistMagicka;
for (int i = MagicEffect::Effects::WeaknessToFire; i <= MagicEffect::Effects::WeaknessToNormalWeapons; ++i)
for (short i = MagicEffect::Effects::WeaknessToFire; i <= MagicEffect::Effects::WeaknessToNormalWeapons; ++i)
effects[i] = MagicEffect::Effects::ResistMagicka;
effects[MagicEffect::Effects::Burden] = MagicEffect::Effects::ResistMagicka;
@ -154,7 +154,7 @@ namespace ESM
effects[MagicEffect::Effects::Blind] = MagicEffect::Effects::ResistMagicka;
effects[MagicEffect::Effects::Sound] = MagicEffect::Effects::ResistMagicka;
for (int i = 0; i < 2; ++i)
for (short i = 0; i < 2; ++i)
{
effects[MagicEffect::Effects::CalmHumanoid + i] = MagicEffect::Effects::ResistMagicka;
effects[MagicEffect::Effects::FrenzyHumanoid + i] = MagicEffect::Effects::ResistMagicka;
@ -194,11 +194,11 @@ namespace ESM
static std::map<short, short> effects;
if (effects.empty())
{
for (int i = DrainAttribute; i <= DamageSkill; ++i)
for (short i = DrainAttribute; i <= DamageSkill; ++i)
effects[i] = WeaknessToMagicka;
for (int i = AbsorbAttribute; i <= AbsorbSkill; ++i)
for (short i = AbsorbAttribute; i <= AbsorbSkill; ++i)
effects[i] = WeaknessToMagicka;
for (int i = WeaknessToFire; i <= WeaknessToNormalWeapons; ++i)
for (short i = WeaknessToFire; i <= WeaknessToNormalWeapons; ++i)
effects[i] = WeaknessToMagicka;
effects[Burden] = WeaknessToMagicka;
@ -207,7 +207,7 @@ namespace ESM
effects[Blind] = WeaknessToMagicka;
effects[Sound] = WeaknessToMagicka;
for (int i = 0; i < 2; ++i)
for (short i = 0; i < 2; ++i)
{
effects[CalmHumanoid + i] = WeaknessToMagicka;
effects[FrenzyHumanoid + i] = WeaknessToMagicka;

View file

@ -117,7 +117,7 @@ namespace ESM
osg::Vec4f getColor() const;
enum Effects
enum Effects : short
{
WaterBreathing = 0,
SwiftSwim = 1,

View file

@ -19,7 +19,7 @@ namespace Files
pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) override
{
if (dir == std::ios_base::cur)
gbump(off);
setg(bufferStart, gptr() + off, bufferEnd);
else
setg(bufferStart, (dir == std::ios_base::beg ? bufferStart : bufferEnd) + off, bufferEnd);

View file

@ -130,7 +130,7 @@ namespace LuaUtil
{
const ESM::LuaScriptCfg& script = mScripts[id];
if (script.mFlags & flag)
res[id] = script.mInitializationData;
res[static_cast<int>(id)] = script.mInitializationData;
}
return res;
}

View file

@ -19,7 +19,7 @@ namespace Misc::Convert
inline osg::Vec3f makeOsgVec3f(const ESM::Pathgrid::Point& value)
{
return osg::Vec3f(value.mX, value.mY, value.mZ);
return osg::Vec3f(static_cast<float>(value.mX), static_cast<float>(value.mY), static_cast<float>(value.mZ));
}
inline btVector3 toBullet(const osg::Vec3f& vec)
@ -32,9 +32,9 @@ namespace Misc::Convert
return btQuaternion(quat.x(), quat.y(), quat.z(), quat.w());
}
inline osg::Vec3f toOsg(const btVector3& vec)
inline osg::Vec3d toOsg(const btVector3& vec)
{
return osg::Vec3f(vec.x(), vec.y(), vec.z());
return osg::Vec3d(vec.x(), vec.y(), vec.z());
}
inline osg::Quat toOsg(const btQuaternion& quat)

View file

@ -263,7 +263,7 @@ namespace NifOsg
if (mKeyFrames.size() <= 1)
return;
float input = getInputValue(nv);
size_t i = 1;
unsigned int i = 1;
for (std::vector<FloatInterpolator>::iterator it = mKeyFrames.begin() + 1; it != mKeyFrames.end();
++it, ++i)
{

View file

@ -40,7 +40,7 @@ namespace NifOsg
for (int j = 0; j < 3; ++j)
{
// Update the current decomposed rotation and restore the known scale.
mRotationScale.mValues[j][i] = _matrix(i, j); // NB: column/row major difference
mRotationScale.mValues[j][i] = static_cast<float>(_matrix(i, j)); // NB: column/row major difference
_matrix(i, j) *= mScale;
}
}

View file

@ -106,7 +106,7 @@ namespace NifOsg
{
mNormalArray = new osg::Vec3Array(1);
mNormalArray->setBinding(osg::Array::BIND_OVERALL);
(*mNormalArray.get())[0] = osg::Vec3(0.3, 0.3, 0.3);
(*mNormalArray.get())[0] = osg::Vec3(0.3f, 0.3f, 0.3f);
}
ParticleSystem::ParticleSystem(const ParticleSystem& copy, const osg::CopyOp& copyop)
@ -115,7 +115,7 @@ namespace NifOsg
{
mNormalArray = new osg::Vec3Array(1);
mNormalArray->setBinding(osg::Array::BIND_OVERALL);
(*mNormalArray.get())[0] = osg::Vec3(0.3, 0.3, 0.3);
(*mNormalArray.get())[0] = osg::Vec3(0.3f, 0.3f, 0.3f);
// For some reason the osgParticle constructor doesn't copy the particles
for (int i = 0; i < copy.numParticles() - copy.numDeadParticles(); ++i)
@ -247,9 +247,9 @@ namespace NifOsg
{
float size = mCachedDefaultSize;
if (particle->getAge() < mGrowTime && mGrowTime != 0.f)
size *= particle->getAge() / mGrowTime;
size *= static_cast<float>(particle->getAge() / mGrowTime);
if (particle->getLifeTime() - particle->getAge() < mFadeTime && mFadeTime != 0.f)
size *= (particle->getLifeTime() - particle->getAge()) / mFadeTime;
size *= static_cast<float>(particle->getLifeTime() - particle->getAge()) / mFadeTime;
particle->setSizeRange(osgParticle::rangef(size, size));
}
@ -326,7 +326,7 @@ namespace NifOsg
decayFactor = std::exp(-1.f * mDecay * distance);
}
particle->addVelocity(mCachedWorldDirection * mForce * dt * decayFactor * magic);
particle->addVelocity(mCachedWorldDirection * mForce * static_cast<float>(dt) * decayFactor * magic);
break;
}
@ -340,7 +340,7 @@ namespace NifOsg
diff.normalize();
particle->addVelocity(diff * mForce * dt * decayFactor * magic);
particle->addVelocity(diff * mForce * static_cast<float>(dt) * decayFactor * magic);
break;
}
}
@ -421,7 +421,7 @@ namespace NifOsg
break;
}
particle->addVelocity(explosionDir * mStrength * decay * dt);
particle->addVelocity(explosionDir * mStrength * decay * static_cast<float>(dt));
}
Emitter::Emitter()
@ -487,7 +487,7 @@ namespace NifOsg
}
else
{
int randomIndex = Misc::Rng::rollClosedProbability() * (mTargets.size() - 1);
int randomIndex = static_cast<int>(std::floor(Misc::Rng::rollClosedProbability() * (mTargets.size() - 1)));
recIndex = mTargets[randomIndex];
}

View file

@ -83,11 +83,11 @@ namespace Resource
auto triangleMeshShape = std::make_unique<TriangleMeshShape>(mTriangleMesh.release(), true);
btVector3 aabbMin = triangleMeshShape->getLocalAabbMin();
btVector3 aabbMax = triangleMeshShape->getLocalAabbMax();
shape->mCollisionBox.mExtents[0] = (aabbMax[0] - aabbMin[0]) / 2.0f;
shape->mCollisionBox.mExtents[1] = (aabbMax[1] - aabbMin[1]) / 2.0f;
shape->mCollisionBox.mExtents[2] = (aabbMax[2] - aabbMin[2]) / 2.0f;
shape->mCollisionBox.mExtents[0] = static_cast<float>(aabbMax[0] - aabbMin[0]) / 2.0f;
shape->mCollisionBox.mExtents[1] = static_cast<float>(aabbMax[1] - aabbMin[1]) / 2.0f;
shape->mCollisionBox.mExtents[2] = static_cast<float>(aabbMax[2] - aabbMin[2]) / 2.0f;
shape->mCollisionBox.mCenter = osg::Vec3f(
(aabbMax[0] + aabbMin[0]) / 2.0f, (aabbMax[1] + aabbMin[1]) / 2.0f, (aabbMax[2] + aabbMin[2]) / 2.0f);
static_cast<float>(aabbMax[0] + aabbMin[0]) / 2.0f, static_cast<float>(aabbMax[1] + aabbMin[1]) / 2.0f, static_cast<float>(aabbMax[2] + aabbMin[2]) / 2.0f);
shape->mCollisionShape.reset(triangleMeshShape.release());
return shape;

View file

@ -144,8 +144,8 @@ namespace Resource
callback->addMergedAnimationTrack(std::move(mergedAnimationTrack));
float startTime = animation->getStartTime();
float stopTime = startTime + animation->getDuration();
float startTime = static_cast<float>(animation->getStartTime());
float stopTime = static_cast<float>(startTime + animation->getDuration());
SceneUtil::EmulatedAnimation emulatedAnimation;
emulatedAnimation.mStartTime = startTime;
@ -168,7 +168,7 @@ namespace Resource
{
std::string line;
while (getline(*textKeysFile, line))
mTarget.mTextKeys.emplace(parseTimeSignature(line), parseTextKey(line));
mTarget.mTextKeys.emplace(static_cast<float>(parseTimeSignature(line)), parseTextKey(line));
}
catch (const std::exception& e)
{

View file

@ -520,14 +520,14 @@ namespace Resource
void StatsHandler::setUpScene(osgViewer::ViewerBase& viewer)
{
const osg::Vec4 backgroundColor(0.0, 0.0, 0.0f, 0.3);
const osg::Vec4 staticTextColor(1.0, 1.0, 0.0f, 1.0);
const osg::Vec4 dynamicTextColor(1.0, 1.0, 1.0f, 1.0);
const osg::Vec4 backgroundColor(0.0f, 0.0f, 0.0f, 0.3f);
const osg::Vec4 staticTextColor(1.0f, 1.0f, 0.0f, 1.0f);
const osg::Vec4 dynamicTextColor(1.0f, 1.0f, 1.0f, 1.0f);
const auto longest = std::max_element(mStatNames.begin(), mStatNames.end(),
[](const std::string& lhs, const std::string& rhs) { return lhs.size() < rhs.size(); });
const std::size_t longestSize = longest->size();
const float statNamesWidth = longestSize * characterSize * 0.6 + 2 * backgroundMargin;
const float statNamesWidth = longestSize * characterSize * 0.6f + 2 * backgroundMargin;
const float statTextWidth = 7 * characterSize + 2 * backgroundMargin;
const float statHeight = pageSize * characterSize + 2 * backgroundMargin;
const float width = statNamesWidth + backgroundSpacing + statTextWidth;

View file

@ -51,7 +51,7 @@ namespace SceneUtil
float FrameTimeSource::getValue(osg::NodeVisitor* nv)
{
return nv->getFrameStamp()->getSimulationTime();
return static_cast<float>(nv->getFrameStamp()->getSimulationTime());
}
ControllerVisitor::ControllerVisitor()
@ -83,7 +83,7 @@ namespace SceneUtil
visit(node, *ctrl);
if (CompositeStateSetUpdater* composite = dynamic_cast<CompositeStateSetUpdater*>(callback))
{
for (unsigned int i = 0; i < composite->getNumControllers(); ++i)
for (size_t i = 0; i < composite->getNumControllers(); ++i)
{
StateSetUpdater* statesetcontroller = composite->getController(i);
if (Controller* ctrl = dynamic_cast<Controller*>(statesetcontroller))

View file

@ -114,8 +114,8 @@ namespace SceneUtil
osg::ref_ptr<osg::Material> material = new osg::Material;
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
const float polygonOffsetFactor = SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0;
const float polygonOffsetUnits = SceneUtil::AutoDepth::isReversed() ? 1.0 : -1.0;
const float polygonOffsetFactor = SceneUtil::AutoDepth::isReversed() ? 1.0f : -1.0f;
const float polygonOffsetUnits = SceneUtil::AutoDepth::isReversed() ? 1.0f : -1.0f;
osg::ref_ptr<osg::PolygonOffset> polygonOffset
= new osg::PolygonOffset(polygonOffsetFactor, polygonOffsetUnits);

View file

@ -14,7 +14,7 @@ namespace SceneUtil
, mPulseSlow(light.mData.mFlags & ESM::Light::PulseSlow)
, mOffDefault(light.mData.mFlags & ESM::Light::OffDefault)
, mColor(SceneUtil::colourFromRGB(light.mData.mColor))
, mRadius(light.mData.mRadius)
, mRadius(static_cast<float>(light.mData.mRadius))
{
}
@ -26,7 +26,7 @@ namespace SceneUtil
, mPulseSlow(light.mData.flags & ESM4::Light::PulseSlow)
, mOffDefault(light.mData.flags & ESM4::Light::OffDefault)
, mColor(SceneUtil::colourFromRGB(light.mData.colour))
, mRadius(light.mData.radius)
, mRadius(static_cast<float>(light.mData.radius))
{
}

View file

@ -168,7 +168,7 @@ namespace SceneUtil
void configureLayout(const LightBuffer* other)
{
mOffsets = other->mOffsets;
int size = other->mData->size();
int size = static_cast<int>(other->mData->size());
configureLayout(mOffsets, size);
}
@ -192,7 +192,7 @@ namespace SceneUtil
: mStride((offsetAttenuationRadius + sizeof(GLfloat) * osg::Vec4::num_components + stride) / 4)
{
constexpr auto sizeofFloat = sizeof(GLfloat);
const auto diffuseOffset = offsetColors / sizeofFloat;
const auto diffuseOffset = static_cast<int>(offsetColors / sizeofFloat);
mValues[Diffuse] = diffuseOffset;
mValues[Ambient] = diffuseOffset + 1;
@ -310,7 +310,7 @@ namespace SceneUtil
META_StateAttribute(SceneUtil, DisableLight, osg::StateAttribute::LIGHT)
unsigned int getMember() const override { return mIndex; }
unsigned int getMember() const override { return static_cast<unsigned int>(mIndex); }
bool getModeUsage(ModeUsage& usage) const override
{
@ -360,12 +360,12 @@ namespace SceneUtil
{
}
unsigned int getMember() const override { return mIndex; }
unsigned int getMember() const override { return static_cast<unsigned int>(mIndex); }
bool getModeUsage(ModeUsage& usage) const override
{
for (size_t i = 0; i < mLights.size(); ++i)
usage.usesMode(GL_LIGHT0 + mIndex + i);
usage.usesMode(GL_LIGHT0 + static_cast<int>(mIndex) + i);
return true;
}
@ -451,7 +451,7 @@ namespace SceneUtil
new FFPLightStateAttribute(mLightManager->getStartLight(), std::move(lights)), osg::StateAttribute::ON);
for (size_t i = 0; i < lightList.size(); ++i)
stateset->setMode(GL_LIGHT0 + mLightManager->getStartLight() + i, osg::StateAttribute::ON);
stateset->setMode(GL_LIGHT0 + mLightManager->getStartLight() + static_cast<int>(i), osg::StateAttribute::ON);
// need to push some dummy attributes to ensure proper state tracking
// lights need to reset to their default when the StateSet is popped
@ -533,7 +533,7 @@ namespace SceneUtil
configureAttenuation(lightMat, light->getConstantAttenuation(), light->getLinearAttenuation(),
light->getQuadraticAttenuation(), lightList[i]->mLightSource->getRadius());
data->setElement(i + 1, lightMat);
data->setElement(static_cast<unsigned int>(i + 1), lightMat);
}
stateset->addUniform(data);
@ -774,7 +774,7 @@ namespace SceneUtil
int stride = -1;
ext->glGetActiveUniformBlockiv(handle, 0, GL_UNIFORM_BLOCK_DATA_SIZE, &totalBlockSize);
ext->glGetActiveUniformsiv(handle, index.size(), index.data(), GL_UNIFORM_ARRAY_STRIDE, &stride);
ext->glGetActiveUniformsiv(handle, static_cast<GLsizei>(index.size()), index.data(), GL_UNIFORM_ARRAY_STRIDE, &stride);
std::array<const char*, 3> names = {
"LightBuffer[0].packedColors",
@ -784,8 +784,8 @@ namespace SceneUtil
std::vector<unsigned int> indices(names.size());
std::vector<int> offsets(names.size());
ext->glGetUniformIndices(handle, names.size(), names.data(), indices.data());
ext->glGetActiveUniformsiv(handle, indices.size(), indices.data(), GL_UNIFORM_OFFSET, offsets.data());
ext->glGetUniformIndices(handle, static_cast<GLsizei>(names.size()), names.data(), indices.data());
ext->glGetActiveUniformsiv(handle, static_cast<GLsizei>(indices.size()), indices.data(), GL_UNIFORM_OFFSET, offsets.data());
mTemplate->configureLayout(offsets[0], offsets[1], offsets[2], totalBlockSize, stride);
}
@ -1047,7 +1047,7 @@ namespace SceneUtil
LightSourceTransform l;
l.mLightSource = lightSource;
l.mWorldMatrix = worldMat;
osg::Vec3f pos = osg::Vec3f(worldMat.getTrans().x(), worldMat.getTrans().y(), worldMat.getTrans().z());
osg::Vec3f pos = worldMat.getTrans();
lightSource->getLight(frameNum)->setPosition(osg::Vec4f(pos, 1.f));
mLights.push_back(l);
@ -1094,7 +1094,7 @@ namespace SceneUtil
if (getLightIndexMap(frameNum).find(id) != getLightIndexMap(frameNum).end())
continue;
int index = getLightIndexMap(frameNum).size() + 1;
int index = static_cast<int>(getLightIndexMap(frameNum).size()) + 1;
updateGPUPointLight(index, lightList[i]->mLightSource, frameNum, viewMatrix);
getLightIndexMap(frameNum).emplace(id, index);
}

View file

@ -55,7 +55,7 @@ namespace SceneUtil
void setLight(size_t frame, const osg::Light* light, float radius)
{
size_t frameId = frame % 2;
size_t i = mIndex[frameId];
int i = mIndex[frameId];
if (i >= (sMaxPPLights - 1))
return;
@ -74,11 +74,11 @@ namespace SceneUtil
void updateCount(size_t frame)
{
size_t frameId = frame % 2;
mUniformCount[frameId]->set(static_cast<int>(mIndex[frameId]));
mUniformCount[frameId]->set(mIndex[frameId]);
}
private:
std::array<size_t, 2> mIndex;
std::array<int, 2> mIndex;
std::array<osg::ref_ptr<osg::Uniform>, 2> mUniformBuffers;
std::array<osg::ref_ptr<osg::Uniform>, 2> mUniformCount;
};
@ -106,7 +106,7 @@ namespace SceneUtil
float mActorFade;
unsigned int mLastAppliedFrame;
size_t mLastAppliedFrame;
bool mEmpty = false;
@ -148,9 +148,9 @@ namespace SceneUtil
/// Get the unique ID for this light source.
int getId() const { return mId; }
void setLastAppliedFrame(unsigned int lastAppliedFrame) { mLastAppliedFrame = lastAppliedFrame; }
void setLastAppliedFrame(size_t lastAppliedFrame) { mLastAppliedFrame = lastAppliedFrame; }
unsigned int getLastAppliedFrame() const { return mLastAppliedFrame; }
size_t getLastAppliedFrame() const { return mLastAppliedFrame; }
};
class UBOManager : public osg::StateAttribute

View file

@ -73,7 +73,7 @@ namespace SceneUtil
linearAttenuation = linearMethod == 0 ? linearValue : 0.01f;
float r = radius * linearRadiusMult;
if (r > 0.f && (linearMethod == 1 || linearMethod == 2))
linearAttenuation = linearValue / std::pow(r, linearMethod);
linearAttenuation = linearValue / std::pow(r, static_cast<float>(linearMethod));
}
if (useQuadratic && (!outQuadInLin || isExterior))
@ -81,7 +81,7 @@ namespace SceneUtil
quadraticAttenuation = quadraticMethod == 0 ? quadraticValue : 0.01f;
float r = radius * quadraticRadiusMult;
if (r > 0.f && (quadraticMethod == 1 || quadraticMethod == 2))
quadraticAttenuation = quadraticValue / std::pow(r, quadraticMethod);
quadraticAttenuation = quadraticValue / std::pow(r, static_cast<float>(quadraticMethod));
}
// If the values are still nonsense, try to at least prevent UB and disable attenuation

View file

@ -3341,7 +3341,7 @@ void SceneUtil::MWShadowTechnique::DebugHUD::setFrustumVertices(osg::ref_ptr<osg
void SceneUtil::MWShadowTechnique::DebugHUD::addAnotherShadowMap()
{
unsigned int shadowMapNumber = mDebugCameras.size();
size_t shadowMapNumber = mDebugCameras.size();
mDebugCameras.push_back(new osg::Camera);
mDebugCameras[shadowMapNumber]->setViewport(200 * shadowMapNumber, 0, 200, 200);

View file

@ -300,12 +300,12 @@ namespace SceneUtil {
double _splitPointUniformLogRatio = 0.5;
double _splitPointDeltaBias = 0.0;
float _polygonOffsetFactor = 1.1;
float _polygonOffsetUnits = 4.0;
float _polygonOffsetFactor = 1.f;
float _polygonOffsetUnits = 4.0f;
bool _useFrontFaceCulling = true;
float _shadowFadeStart = 0.0;
float _shadowFadeStart = 0.0f;
unsigned int _worldMask = ~0u;

View file

@ -47,16 +47,19 @@ namespace SceneUtil
void addPathgridToGeometry(const size_t vertexCount, const size_t pointIndexCount, const size_t edgeIndexCount,
osg::ref_ptr<osg::Geometry>& gridGeometry, const ESM::Pathgrid& pathgrid)
{
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(vertexCount);
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(vertexCount);
osg::ref_ptr<PType> pointIndices = new PType(osg::PrimitiveSet::TRIANGLES, pointIndexCount);
osg::ref_ptr<LType> lineIndices = new LType(osg::PrimitiveSet::LINES, edgeIndexCount);
assert(vertexCount < std::numeric_limits<unsigned int>::max());
assert(pointIndexCount < std::numeric_limits<unsigned int>::max());
assert(edgeIndexCount < std::numeric_limits<unsigned int>::max());
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(static_cast<unsigned int>(vertexCount));
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(static_cast<unsigned int>(vertexCount));
osg::ref_ptr<PType> pointIndices = new PType(osg::PrimitiveSet::TRIANGLES, static_cast<unsigned int>(pointIndexCount));
osg::ref_ptr<LType> lineIndices = new LType(osg::PrimitiveSet::LINES, static_cast<unsigned int>(edgeIndexCount));
// Add each point/node
for (size_t pointIndex = 0; pointIndex < pathgrid.mPoints.size(); ++pointIndex)
{
const ESM::Pathgrid::Point& point = pathgrid.mPoints[pointIndex];
osg::Vec3f position = osg::Vec3f(point.mX, point.mY, point.mZ);
osg::Vec3f position = osg::Vec3f(static_cast<float>(point.mX), static_cast<float>(point.mY), static_cast<float>(point.mZ));
size_t vertexOffset = pointIndex * DiamondTotalVertexCount;
size_t indexOffset = pointIndex * DiamondIndexCount;
@ -70,7 +73,7 @@ namespace SceneUtil
for (unsigned short i = 0; i < DiamondIndexCount; ++i)
{
pointIndices->setElement(indexOffset + i, vertexOffset + DiamondIndices[i]);
pointIndices->setElement(static_cast<unsigned int>(indexOffset + i), static_cast<unsigned int>(vertexOffset + DiamondIndices[i]));
}
// Connectors
@ -93,8 +96,8 @@ namespace SceneUtil
const ESM::Pathgrid::Point& from = pathgrid.mPoints[edge.mV0];
const ESM::Pathgrid::Point& to = pathgrid.mPoints[edge.mV1];
osg::Vec3f fromPos = osg::Vec3f(from.mX, from.mY, from.mZ);
osg::Vec3f toPos = osg::Vec3f(to.mX, to.mY, to.mZ);
osg::Vec3f fromPos = osg::Vec3f(static_cast<float>(from.mX), static_cast<float>(from.mY), static_cast<float>(from.mZ));
osg::Vec3f toPos = osg::Vec3f(static_cast<float>(to.mX), static_cast<float>(to.mY), static_cast<float>(to.mZ));
osg::Vec3f dir = toPos - fromPos;
dir.normalize();
@ -138,9 +141,11 @@ namespace SceneUtil
osg::ref_ptr<osg::Geometry>& wireframeGeometry, const ESM::Pathgrid& pathgrid,
const std::vector<unsigned short>& selected)
{
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(vertexCount);
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(vertexCount);
osg::ref_ptr<T> indices = new T(osg::PrimitiveSet::LINES, indexCount);
assert(vertexCount < std::numeric_limits<unsigned int>::max());
assert(indexCount < std::numeric_limits<unsigned int>::max());
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(static_cast<unsigned int>(vertexCount));
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(static_cast<unsigned int>(vertexCount));
osg::ref_ptr<T> indices = new T(osg::PrimitiveSet::LINES, static_cast<unsigned int>(indexCount));
osg::Vec3f wireOffset = osg::Vec3f(0, 0, (1 - DiamondWireframeScalar) * DiamondHalfHeight);
@ -148,7 +153,7 @@ namespace SceneUtil
for (size_t it = 0; it < selected.size(); ++it)
{
const ESM::Pathgrid::Point& point = pathgrid.mPoints[selected[it]];
osg::Vec3f position = osg::Vec3f(point.mX, point.mY, point.mZ) + wireOffset;
osg::Vec3f position = osg::Vec3f(static_cast<float>(point.mX), static_cast<float>(point.mY), static_cast<float>(point.mZ)) + wireOffset;
size_t vertexOffset = it * DiamondVertexCount;
size_t indexOffset = it * DiamondWireframeIndexCount;
@ -166,7 +171,7 @@ namespace SceneUtil
for (unsigned short i = 0; i < DiamondWireframeIndexCount; ++i)
{
indices->setElement(indexOffset + i, vertexOffset + DiamondWireframeIndices[i]);
indices->setElement(static_cast<unsigned int>(indexOffset + i), static_cast<unsigned int>(vertexOffset + DiamondWireframeIndices[i]));
}
}

View file

@ -34,13 +34,13 @@ namespace SceneUtil
{
matrix.postMultTranslate(-_position);
matrix.postMultRotate(_attitude.inverse());
matrix.postMultScale(osg::Vec3f(1.0 / _scale.x(), 1.0 / _scale.y(), 1.0 / _scale.z()));
matrix.postMultScale(osg::Vec3f(1.0f / _scale.x(), 1.0f / _scale.y(), 1.0f / _scale.z()));
}
else // absolute
{
matrix.makeRotate(_attitude.inverse());
matrix.preMultTranslate(-_position);
matrix.postMultScale(osg::Vec3f(1.0 / _scale.x(), 1.0 / _scale.y(), 1.0 / _scale.z()));
matrix.postMultScale(osg::Vec3f(1.0f / _scale.x(), 1.0f / _scale.y(), 1.0f / _scale.z()));
}
return true;
}

View file

@ -32,7 +32,7 @@ namespace
const osg::Vec3f e1 = v2 - v0;
osg::Vec3f normal = e0 ^ e1;
normal.normalize();
for (std::size_t j = 0; j < 3; ++j)
for (int j = 0; j < 3; ++j)
result[i + j] = normal[j];
}
return result;

View file

@ -61,7 +61,7 @@ namespace SceneUtil
else if (Misc::StringUtils::ciEqual(computeSceneBounds, "bounds"))
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
const int mapres = settings.mShadowMapResolution;
const short mapres = static_cast<short>(settings.mShadowMapResolution);
mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres));
mShadowTechnique->setSplitPointUniformLogarithmicRatio(settings.mSplitPointUniformLogarithmicRatio);

View file

@ -88,14 +88,14 @@ namespace SceneUtil
void CompositeStateSetUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
{
for (unsigned int i = 0; i < mCtrls.size(); ++i)
mCtrls[i]->apply(stateset, nv);
for (const auto& ctrl : mCtrls)
ctrl->apply(stateset, nv);
}
void CompositeStateSetUpdater::setDefaults(osg::StateSet* stateset)
{
for (unsigned int i = 0; i < mCtrls.size(); ++i)
mCtrls[i]->setDefaults(stateset);
for (const auto& ctrl : mCtrls)
ctrl->setDefaults(stateset);
}
CompositeStateSetUpdater::CompositeStateSetUpdater() {}
@ -103,16 +103,16 @@ namespace SceneUtil
CompositeStateSetUpdater::CompositeStateSetUpdater(const CompositeStateSetUpdater& copy, const osg::CopyOp& copyop)
: StateSetUpdater(copy, copyop)
{
for (unsigned int i = 0; i < copy.mCtrls.size(); ++i)
mCtrls.emplace_back(osg::clone(copy.mCtrls[i].get(), copyop));
for (const auto& ctrl : copy.mCtrls)
mCtrls.emplace_back(osg::clone(ctrl.get(), copyop));
}
unsigned int CompositeStateSetUpdater::getNumControllers()
size_t CompositeStateSetUpdater::getNumControllers()
{
return mCtrls.size();
}
StateSetUpdater* CompositeStateSetUpdater::getController(int i)
StateSetUpdater* CompositeStateSetUpdater::getController(size_t i)
{
return mCtrls[i];
}

View file

@ -79,8 +79,8 @@ namespace SceneUtil
META_Object(SceneUtil, CompositeStateSetUpdater)
unsigned int getNumControllers();
StateSetUpdater* getController(int i);
size_t getNumControllers();
StateSetUpdater* getController(size_t i);
void addController(StateSetUpdater* ctrl);

View file

@ -131,8 +131,8 @@ namespace SceneUtil
if ((mDuration >= 0) && mStartingTime == 0)
mStartingTime = nv->getFrameStamp()->getSimulationTime();
float time = nv->getFrameStamp()->getSimulationTime();
int index = (int)(time * 16) % mTextures.size();
double time = nv->getFrameStamp()->getSimulationTime();
int index = static_cast<int>(std::floor(time * 16)) % mTextures.size();
stateset->setTextureAttribute(
mTexUnit, mTextures[index], osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);

View file

@ -41,7 +41,7 @@ namespace SceneUtil
float mDuration;
float mOriginalDuration; // for recording that this is originally a permanent glow if it is changed to a
// temporary one
float mStartingTime;
double mStartingTime;
Resource::ResourceSystem* mResourceSystem;
bool mColorChanged;
bool mDone;

View file

@ -58,7 +58,7 @@ namespace SceneUtil
normal->push_back(osg::Vec3f(0, 0, 1));
waterGeom->setNormalArray(normal, osg::Array::BIND_OVERALL);
waterGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, verts->size()));
waterGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, static_cast<GLsizei>(verts->size())));
waterGeom->setComputeBoundingBoxCallback(new WaterBoundCallback);
waterGeom->setCullingActive(false);
return waterGeom;

View file

@ -99,13 +99,13 @@ namespace SceneUtil
return nullptr;
}
unsigned int WorkQueue::getNumItems() const
size_t WorkQueue::getNumItems() const
{
std::unique_lock<std::mutex> lock(mMutex);
return mQueue.size();
}
unsigned int WorkQueue::getNumActiveThreads() const
size_t WorkQueue::getNumActiveThreads() const
{
return std::accumulate(
mThreads.begin(), mThreads.end(), 0u, [](auto r, const auto& t) { return r + t->isActive(); });

View file

@ -62,9 +62,9 @@ namespace SceneUtil
/// @par Used internally by the WorkThread.
osg::ref_ptr<WorkItem> removeWorkItem();
unsigned int getNumItems() const;
size_t getNumItems() const;
unsigned int getNumActiveThreads() const;
size_t getNumActiveThreads() const;
private:
bool mIsReleased;

View file

@ -441,7 +441,7 @@ namespace Shader
normalMapTex->setMaxAnisotropy(diffuseMap->getMaxAnisotropy());
normalMap = normalMapTex;
int unit = texAttributes.size();
int unit = static_cast<int>(texAttributes.size());
if (!writableStateSet)
writableStateSet = getWritableStateSet(node);
writableStateSet->setTextureAttributeAndModes(unit, normalMapTex, osg::StateAttribute::ON);
@ -487,7 +487,7 @@ namespace Shader
osg::Texture::MAG_FILTER, diffuseMap->getFilter(osg::Texture::MAG_FILTER));
specularMapTex->setMaxAnisotropy(diffuseMap->getMaxAnisotropy());
int unit = texAttributes.size();
int unit = static_cast<int>(texAttributes.size());
if (!writableStateSet)
writableStateSet = getWritableStateSet(node);
writableStateSet->setTextureAttributeAndModes(unit, specularMapTex, osg::StateAttribute::ON);