From 1bf2ddac4db6b266f92559d4bfc157375c4fb7b2 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 7 May 2020 15:35:34 +0300 Subject: [PATCH] Cleanup Move static variable declaration out of the loop Remove redundant boolean argument from applyDrawableProperties() Improve HeightCullCallback class formatting --- components/nifosg/nifloader.cpp | 6 +-- components/terrain/quadtreeworld.cpp | 2 +- components/terrain/world.hpp | 68 ++++++++++++++++------------ 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 72654da6d..00576943a 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1111,7 +1111,7 @@ namespace NifOsg std::vector drawableProps; collectDrawableProperties(nifNode, drawableProps); - applyDrawableProperties(parentNode, drawableProps, composite, true, animflags, true); + applyDrawableProperties(parentNode, drawableProps, composite, true, animflags); // particle system updater (after the emitters and affectors in the scene graph) // I think for correct culling needs to be *before* the ParticleSystem, though osg examples do it the other way @@ -1203,7 +1203,7 @@ namespace NifOsg // above the actual renderable would be tedious. std::vector drawableProps; collectDrawableProperties(nifNode, drawableProps); - applyDrawableProperties(parentNode, drawableProps, composite, vertexColorsPresent, animflags, false); + applyDrawableProperties(parentNode, drawableProps, composite, vertexColorsPresent, animflags); } void handleTriShape(const Nif::Node* nifNode, osg::Group* parentNode, SceneUtil::CompositeStateSetUpdater* composite, const std::vector& boundTextures, int animflags) @@ -1755,7 +1755,7 @@ namespace NifOsg } void applyDrawableProperties(osg::Node* node, const std::vector& properties, SceneUtil::CompositeStateSetUpdater* composite, - bool hasVertexColors, int animflags, bool particleMaterial) + bool hasVertexColors, int animflags) { osg::StateSet* stateset = node->getOrCreateStateSet(); diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index 0140ade49..c43a9a21b 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -323,6 +323,7 @@ void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil: return; } cv->pushCurrentMask(); + static bool debug = getenv("OPENMW_WATER_CULLING_DEBUG") != nullptr; for (unsigned int i=0; igetNumEntries(); ++i) { ViewData::Entry& entry = vd->getEntry(i); @@ -337,7 +338,6 @@ void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil: continue; lowZ = bb._min.z(); - static bool debug = getenv("OPENMW_WATER_CULLING_DEBUG") != nullptr; if (!debug) break; osg::Box* b = new osg::Box; diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index fb6c45967..a69d03ca9 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -40,36 +40,46 @@ namespace Terrain class ChunkManager; class CompositeMapRenderer; -class HeightCullCallback : public osg::NodeCallback -{ -public: - HeightCullCallback() : mLowZ(-std::numeric_limits::max()), mHighZ(std::numeric_limits::max()), mMask(~0) {} - - void setLowZ(float z) + class HeightCullCallback : public osg::NodeCallback { - mLowZ = z; - } - float getLowZ() const { return mLowZ; } - - void setHighZ(float highZ) - { - mHighZ = highZ; - } - float getHighZ() const { return mHighZ; } - - void setCullMask(unsigned int mask) { mMask = mask; } - unsigned int getCullMask() const { return mMask; } - - virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) - { - if (mLowZ <= mHighZ) - traverse(node, nv); - } -private: - float mLowZ; - float mHighZ; - unsigned int mMask; -}; + public: + void setLowZ(float z) + { + mLowZ = z; + } + float getLowZ() const + { + return mLowZ; + } + + void setHighZ(float highZ) + { + mHighZ = highZ; + } + float getHighZ() const + { + return mHighZ; + } + + void setCullMask(unsigned int mask) + { + mMask = mask; + } + unsigned int getCullMask() const + { + return mMask; + } + + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + if (mLowZ <= mHighZ) + traverse(node, nv); + } + private: + float mLowZ{-std::numeric_limits::max()}; + float mHighZ{std::numeric_limits::max()}; + unsigned int mMask{~0u}; + }; /** * @brief A View is a collection of rendering objects that are visible from a given camera/intersection.