mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 04:15:33 +00:00
removed more osg/Version includes that are not necessary
revert to old formatting
This commit is contained in:
parent
57d519f26d
commit
e697f1c14c
7 changed files with 92 additions and 135 deletions
|
@ -7,8 +7,6 @@
|
|||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <osg/Version>
|
||||
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
#include <osg/Version>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/ValueObject>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace SceneUtil
|
|||
namespace
|
||||
{
|
||||
const std::unordered_map<std::string, LightingMethod> 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<int, 6> mValues;
|
||||
private:
|
||||
int mStride;
|
||||
std::array<int, 6> 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<LightBuffer> 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<osg::ref_ptr<osg::Light>>& 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<CollectLightCallback>(copy, copyop)
|
||||
, mLightManager(nullptr) { }
|
||||
: NodeCallback<CollectLightCallback>(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<const char*, 3> names = {
|
||||
"LightBuffer[0].packedColors",
|
||||
"LightBuffer[0].position",
|
||||
"LightBuffer[0].attenuation",
|
||||
"LightBuffer[0].packedColors",
|
||||
"LightBuffer[0].position",
|
||||
"LightBuffer[0].attenuation",
|
||||
};
|
||||
std::vector<unsigned int> indices(names.size());
|
||||
std::vector<int> 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<StateSetGeneratorFFP>();
|
||||
break;
|
||||
case LightingMethod::SingleUBO:
|
||||
mStateSetGenerator = std::make_unique<StateSetGeneratorSingleUBO>();
|
||||
break;
|
||||
case LightingMethod::PerObjectUniform:
|
||||
mStateSetGenerator = std::make_unique<StateSetGeneratorPerObjectUniform>();
|
||||
break;
|
||||
case LightingMethod::FFP:
|
||||
mStateSetGenerator = std::make_unique<StateSetGeneratorFFP>();
|
||||
break;
|
||||
case LightingMethod::SingleUBO:
|
||||
mStateSetGenerator = std::make_unique<StateSetGeneratorSingleUBO>();
|
||||
break;
|
||||
case LightingMethod::PerObjectUniform:
|
||||
mStateSetGenerator = std::make_unique<StateSetGeneratorPerObjectUniform>();
|
||||
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++;
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#include <cassert>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
#include <osg/Version>
|
||||
|
||||
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);
|
||||
|
|
|
@ -13,12 +13,8 @@
|
|||
|
||||
/* Modified for OpenMW */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "optimizer.hpp"
|
||||
|
||||
#include <osg/Version>
|
||||
#include <osg/Transform>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
|
@ -37,7 +33,6 @@
|
|||
#include <osgUtil/Statistics>
|
||||
#include <osgUtil/MeshOptimizers>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
|
@ -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<osg::Array*>(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;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "riggeometry.hpp"
|
||||
|
||||
#include <osg/Version>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
#include <osg/MatrixTransform>
|
||||
|
@ -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);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <osg/Drawable>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Version>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
|
|
Loading…
Reference in a new issue