Move static variable declaration out of the loop
Remove redundant boolean argument from applyDrawableProperties()
Improve HeightCullCallback class formatting
pull/2824/head
Capostrophic 5 years ago
parent 12833d66af
commit 1bf2ddac4d

@ -1111,7 +1111,7 @@ namespace NifOsg
std::vector<const Nif::Property*> 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<const Nif::Property*> 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<unsigned int>& boundTextures, int animflags)
@ -1755,7 +1755,7 @@ namespace NifOsg
}
void applyDrawableProperties(osg::Node* node, const std::vector<const Nif::Property*>& properties, SceneUtil::CompositeStateSetUpdater* composite,
bool hasVertexColors, int animflags, bool particleMaterial)
bool hasVertexColors, int animflags)
{
osg::StateSet* stateset = node->getOrCreateStateSet();

@ -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; i<vd->getNumEntries(); ++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;

@ -40,36 +40,46 @@ namespace Terrain
class ChunkManager;
class CompositeMapRenderer;
class HeightCullCallback : public osg::NodeCallback
{
public:
HeightCullCallback() : mLowZ(-std::numeric_limits<float>::max()), mHighZ(std::numeric_limits<float>::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<float>::max()};
float mHighZ{std::numeric_limits<float>::max()};
unsigned int mMask{~0u};
};
/**
* @brief A View is a collection of rendering objects that are visible from a given camera/intersection.

Loading…
Cancel
Save