From e697f1c14c10c2d8c6a9ef55fc8880b93a2fa360 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 4 Aug 2022 14:03:30 +0200 Subject: [PATCH] removed more osg/Version includes that are not necessary revert to old formatting --- apps/openmw/engine.cpp | 2 - components/nifosg/particle.cpp | 5 - components/sceneutil/lightmanager.cpp | 164 +++++++++--------- components/sceneutil/morphgeometry.cpp | 4 - components/sceneutil/optimizer.cpp | 47 ++--- components/sceneutil/riggeometry.cpp | 4 - .../sceneutil/riggeometryosgaextension.cpp | 1 - 7 files changed, 92 insertions(+), 135 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 53a27ebd9b..d0a3afc361 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -7,8 +7,6 @@ #include -#include - #include #include diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 9706a1f91b..320c24164f 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -138,7 +137,6 @@ osgParticle::Particle* ParticleSystem::createParticle(const osgParticle::Particl void ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo) const { osg::State & state = *renderInfo.getState(); -#if OSG_MIN_VERSION_REQUIRED(3, 5, 6) if(state.useVertexArrayObject(getUseVertexArrayObject())) { state.getCurrentVertexArrayState()->assignNormalArrayDispatcher(); @@ -148,9 +146,6 @@ void ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo) const { state.getAttributeDispatchers().activateNormalArray(mNormalArray); } -#else - state.Normal(0.3, 0.3, 0.3); -#endif osgParticle::ParticleSystem::drawImplementation(renderInfo); } diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 12aefe4c52..85c3b67c68 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -76,9 +76,9 @@ namespace SceneUtil namespace { const std::unordered_map lightingMethodSettingMap = { - {"legacy", LightingMethod::FFP}, - {"shaders compatibility", LightingMethod::PerObjectUniform}, - {"shaders", LightingMethod::SingleUBO}, + {"legacy", LightingMethod::FFP}, + {"shaders compatibility", LightingMethod::PerObjectUniform}, + {"shaders", LightingMethod::SingleUBO}, }; } @@ -100,10 +100,10 @@ namespace SceneUtil }; LightBuffer(int count) - : mData(new osg::FloatArray(3*4*count)) - , mEndian(osg::getCpuByteOrder()) - , mCount(count) - , mCachedSunPos(osg::Vec4()) + : mData(new osg::FloatArray(3*4*count)) + , mEndian(osg::getCpuByteOrder()) + , mCount(count) + , mCachedSunPos(osg::Vec4()) { } @@ -198,40 +198,40 @@ namespace SceneUtil private: class Offsets { - public: - Offsets() + public: + Offsets() : mStride(12) - { - mValues[Diffuse] = 0; - mValues[Ambient] = 1; - mValues[Specular] = 2; - mValues[DiffuseSign] = 3; - mValues[Position] = 4; - mValues[AttenuationRadius] = 8; - } + { + mValues[Diffuse] = 0; + mValues[Ambient] = 1; + mValues[Specular] = 2; + mValues[DiffuseSign] = 3; + mValues[Position] = 4; + mValues[AttenuationRadius] = 8; + } - Offsets(int offsetColors, int offsetPosition, int offsetAttenuationRadius, int stride) + Offsets(int offsetColors, int offsetPosition, int offsetAttenuationRadius, int stride) : mStride((offsetAttenuationRadius + sizeof(GLfloat) * osg::Vec4::num_components + stride) / 4) - { - constexpr auto sizeofFloat = sizeof(GLfloat); - const auto diffuseOffset = offsetColors / sizeofFloat; + { + constexpr auto sizeofFloat = sizeof(GLfloat); + const auto diffuseOffset = offsetColors / sizeofFloat; - mValues[Diffuse] = diffuseOffset; - mValues[Ambient] = diffuseOffset + 1; - mValues[Specular] = diffuseOffset + 2; - mValues[DiffuseSign] = diffuseOffset + 3; - mValues[Position] = offsetPosition / sizeofFloat; - mValues[AttenuationRadius] = offsetAttenuationRadius / sizeofFloat; - } + mValues[Diffuse] = diffuseOffset; + mValues[Ambient] = diffuseOffset + 1; + mValues[Specular] = diffuseOffset + 2; + mValues[DiffuseSign] = diffuseOffset + 3; + mValues[Position] = offsetPosition / sizeofFloat; + mValues[AttenuationRadius] = offsetAttenuationRadius / sizeofFloat; + } - int get(int index, LayoutOffset slot) const - { - return mStride * index + mValues[slot]; - } + int get(int index, LayoutOffset slot) const + { + return mStride * index + mValues[slot]; + } - private: - int mStride; - std::array mValues; + private: + int mStride; + std::array mValues; }; void configureLayout(const Offsets& offsets, int size) @@ -275,11 +275,11 @@ namespace SceneUtil auto method = lightManager->getLightingMethod(); switch (method) { - case LightingMethod::FFP: + case LightingMethod::FFP: { break; } - case LightingMethod::PerObjectUniform: + case LightingMethod::PerObjectUniform: { osg::Matrixf lightMat; configurePosition(lightMat, light->getPosition()); @@ -290,7 +290,7 @@ namespace SceneUtil stateset->addUniform(lightManager->generateLightBufferUniform(lightMat), mode); break; } - case LightingMethod::SingleUBO: + case LightingMethod::SingleUBO: { osg::ref_ptr buffer = new LightBuffer(lightManager->getMaxLightsInScene()); @@ -316,7 +316,7 @@ namespace SceneUtil DisableLight(int index) : mIndex(index) {} DisableLight(const DisableLight& copy,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) - : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex) {} + : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex) {} META_StateAttribute(SceneUtil, DisableLight, osg::StateAttribute::LIGHT) @@ -359,7 +359,7 @@ namespace SceneUtil FFPLightStateAttribute(size_t index, const std::vector>& lights) : mIndex(index), mLights(lights) {} FFPLightStateAttribute(const FFPLightStateAttribute& copy,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) - : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex), mLights(copy.mLights) {} + : osg::StateAttribute(copy,copyop), mIndex(copy.mIndex), mLights(copy.mLights) {} unsigned int getMember() const override { @@ -557,11 +557,11 @@ namespace SceneUtil { public: CollectLightCallback() - : mLightManager(nullptr) { } + : mLightManager(nullptr) { } CollectLightCallback(const CollectLightCallback& copy, const osg::CopyOp& copyop) - : NodeCallback(copy, copyop) - , mLightManager(nullptr) { } + : NodeCallback(copy, copyop) + , mLightManager(nullptr) { } META_Object(SceneUtil, CollectLightCallback) @@ -658,10 +658,10 @@ namespace SceneUtil }; UBOManager::UBOManager(int lightCount) - : mDummyProgram(new osg::Program) - , mInitLayout(false) - , mDirty({ true, true }) - , mTemplate(new LightBuffer(lightCount)) + : mDummyProgram(new osg::Program) + , mInitLayout(false) + , mDirty({ true, true }) + , mTemplate(new LightBuffer(lightCount)) { static const std::string dummyVertSource = generateDummyShader(lightCount); @@ -759,9 +759,9 @@ namespace SceneUtil ext->glGetActiveUniformsiv(handle, index.size(), index.data(), GL_UNIFORM_ARRAY_STRIDE, &stride); std::array names = { - "LightBuffer[0].packedColors", - "LightBuffer[0].position", - "LightBuffer[0].attenuation", + "LightBuffer[0].packedColors", + "LightBuffer[0].position", + "LightBuffer[0].attenuation", }; std::vector indices(names.size()); std::vector offsets(names.size()); @@ -792,12 +792,12 @@ namespace SceneUtil } LightManager::LightManager(bool ffp) - : mStartLight(0) - , mLightingMask(~0u) - , mSun(nullptr) - , mPointLightRadiusMultiplier(1.f) - , mPointLightFadeEnd(0.f) - , mPointLightFadeStart(0.f) + : mStartLight(0) + , mLightingMask(~0u) + , mSun(nullptr) + , mPointLightRadiusMultiplier(1.f) + , mPointLightFadeEnd(0.f) + , mPointLightFadeStart(0.f) { osg::GLExtensions* exts = osg::GLExtensions::Get(0, false); bool supportsUBO = exts && exts->isUniformBufferObjectSupported; @@ -845,16 +845,16 @@ namespace SceneUtil } LightManager::LightManager(const LightManager ©, const osg::CopyOp ©op) - : osg::Group(copy, copyop) - , mStartLight(copy.mStartLight) - , mLightingMask(copy.mLightingMask) - , mSun(copy.mSun) - , mLightingMethod(copy.mLightingMethod) - , mPointLightRadiusMultiplier(copy.mPointLightRadiusMultiplier) - , mPointLightFadeEnd(copy.mPointLightFadeEnd) - , mPointLightFadeStart(copy.mPointLightFadeStart) - , mMaxLights(copy.mMaxLights) - , mPPLightBuffer(copy.mPPLightBuffer) + : osg::Group(copy, copyop) + , mStartLight(copy.mStartLight) + , mLightingMask(copy.mLightingMask) + , mSun(copy.mSun) + , mLightingMethod(copy.mLightingMethod) + , mPointLightRadiusMultiplier(copy.mPointLightRadiusMultiplier) + , mPointLightFadeEnd(copy.mPointLightFadeEnd) + , mPointLightFadeStart(copy.mPointLightFadeStart) + , mMaxLights(copy.mMaxLights) + , mPPLightBuffer(copy.mPPLightBuffer) { } @@ -971,15 +971,15 @@ namespace SceneUtil mLightingMethod = method; switch (method) { - case LightingMethod::FFP: - mStateSetGenerator = std::make_unique(); - break; - case LightingMethod::SingleUBO: - mStateSetGenerator = std::make_unique(); - break; - case LightingMethod::PerObjectUniform: - mStateSetGenerator = std::make_unique(); - break; + case LightingMethod::FFP: + mStateSetGenerator = std::make_unique(); + break; + case LightingMethod::SingleUBO: + mStateSetGenerator = std::make_unique(); + break; + case LightingMethod::PerObjectUniform: + mStateSetGenerator = std::make_unique(); + break; } mStateSetGenerator->mLightManager = this; } @@ -1210,19 +1210,19 @@ namespace SceneUtil } LightSource::LightSource() - : mRadius(0.f) - , mActorFade(1.f) - , mLastAppliedFrame(0) + : mRadius(0.f) + , mActorFade(1.f) + , mLastAppliedFrame(0) { setUpdateCallback(new CollectLightCallback); mId = sLightId++; } LightSource::LightSource(const LightSource ©, const osg::CopyOp ©op) - : osg::Node(copy, copyop) - , mRadius(copy.mRadius) - , mActorFade(copy.mActorFade) - , mLastAppliedFrame(copy.mLastAppliedFrame) + : osg::Node(copy, copyop) + , mRadius(copy.mRadius) + , mActorFade(copy.mActorFade) + , mLastAppliedFrame(copy.mLastAppliedFrame) { mId = sLightId++; diff --git a/components/sceneutil/morphgeometry.cpp b/components/sceneutil/morphgeometry.cpp index 3e34e3dedc..39102b575a 100644 --- a/components/sceneutil/morphgeometry.cpp +++ b/components/sceneutil/morphgeometry.cpp @@ -3,8 +3,6 @@ #include #include -#include - namespace SceneUtil { @@ -189,9 +187,7 @@ void MorphGeometry::cull(osg::NodeVisitor *nv) positionDst->dirty(); -#if OSG_MIN_VERSION_REQUIRED(3, 5, 10) geom.osg::Drawable::dirtyGLObjects(); -#endif nv->pushOntoNodePath(&geom); nv->apply(geom); diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index 9012349804..00ebd018e1 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -13,12 +13,8 @@ /* Modified for OpenMW */ -#include -#include - #include "optimizer.hpp" -#include #include #include #include @@ -37,7 +33,6 @@ #include #include -#include #include #include @@ -629,22 +624,11 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Node& node) traverse(node); } -bool needvbo(const osg::Geometry* geom) -{ -#if OSG_MIN_VERSION_REQUIRED(3,5,6) - return true; -#else - return geom->getUseVertexBufferObjects(); -#endif -} - osg::Array* cloneArray(osg::Array* array, osg::VertexBufferObject*& vbo, const osg::Geometry* geom) { array = static_cast(array->clone(osg::CopyOp::DEEP_COPY_ALL)); - if (!vbo && needvbo(geom)) - vbo = new osg::VertexBufferObject; - if (vbo) - array->setVertexBufferObject(vbo); + if (!vbo) vbo = new osg::VertexBufferObject; + array->setVertexBufferObject(vbo); return array; } @@ -1199,10 +1183,8 @@ osg::PrimitiveSet* clonePrimitive(osg::PrimitiveSet* ps, osg::ElementBufferObjec osg::DrawElements* drawElements = ps->getDrawElements(); if (!drawElements) return ps; - if (!ebo && needvbo(geom)) - ebo = new osg::ElementBufferObject; - if (ebo) - drawElements->setElementBufferObject(ebo); + if (!ebo) ebo = new osg::ElementBufferObject; + drawElements->setElementBufferObject(ebo); return ps; } @@ -1808,11 +1790,8 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom { // must promote to a DrawElementsUInt osg::DrawElementsUInt* new_primitive = new osg::DrawElementsUInt(primitive->getMode()); - if (needvbo(&lhs)) - { - if (!ebo) ebo = new osg::ElementBufferObject; - new_primitive->setElementBufferObject(ebo); - } + if (!ebo) ebo = new osg::ElementBufferObject; + new_primitive->setElementBufferObject(ebo); std::copy(primitiveUByte->begin(),primitiveUByte->end(),std::back_inserter(*new_primitive)); new_primitive->offsetIndices(base); (*primItr) = new_primitive; @@ -1820,11 +1799,8 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom { // must promote to a DrawElementsUShort osg::DrawElementsUShort* new_primitive = new osg::DrawElementsUShort(primitive->getMode()); - if (needvbo(&lhs)) - { - if (!ebo) ebo = new osg::ElementBufferObject; - new_primitive->setElementBufferObject(ebo); - } + if (!ebo) ebo = new osg::ElementBufferObject; + new_primitive->setElementBufferObject(ebo); std::copy(primitiveUByte->begin(),primitiveUByte->end(),std::back_inserter(*new_primitive)); new_primitive->offsetIndices(base); (*primItr) = new_primitive; @@ -1851,11 +1827,8 @@ bool Optimizer::MergeGeometryVisitor::mergeGeometry(osg::Geometry& lhs,osg::Geom { // must promote to a DrawElementsUInt osg::DrawElementsUInt* new_primitive = new osg::DrawElementsUInt(primitive->getMode()); - if (needvbo(&lhs)) - { - if (!ebo) ebo = new osg::ElementBufferObject; - new_primitive->setElementBufferObject(ebo); - } + if (!ebo) ebo = new osg::ElementBufferObject; + new_primitive->setElementBufferObject(ebo); std::copy(primitiveUShort->begin(),primitiveUShort->end(),std::back_inserter(*new_primitive)); new_primitive->offsetIndices(base); (*primItr) = new_primitive; diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index 84b31f4afc..5fca265877 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -1,7 +1,5 @@ #include "riggeometry.hpp" -#include - #include #include #include @@ -260,9 +258,7 @@ void RigGeometry::cull(osg::NodeVisitor* nv) if (tangentDst) tangentDst->dirty(); -#if OSG_MIN_VERSION_REQUIRED(3, 5, 10) geom.osg::Drawable::dirtyGLObjects(); -#endif nv->pushOntoNodePath(&geom); nv->apply(geom); diff --git a/components/sceneutil/riggeometryosgaextension.cpp b/components/sceneutil/riggeometryosgaextension.cpp index 75af4c4b82..8768eb403f 100644 --- a/components/sceneutil/riggeometryosgaextension.cpp +++ b/components/sceneutil/riggeometryosgaextension.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include