mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 19:15:41 +00:00
Avoid adding redundant osg;;Group in non debug mode
This commit is contained in:
parent
98a0819d52
commit
4b7d0bba53
3 changed files with 13 additions and 6 deletions
|
@ -238,19 +238,20 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
|
||||||
}
|
}
|
||||||
geometry->setNodeMask(mNodeMask);
|
geometry->setNodeMask(mNodeMask);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> result(new osg::Group);
|
|
||||||
result->addChild(geometry);
|
|
||||||
if (mDebugChunks)
|
if (mDebugChunks)
|
||||||
{
|
{
|
||||||
|
osg::ref_ptr<osg::Group> result(new osg::Group);
|
||||||
|
result->addChild(geometry);
|
||||||
auto chunkBorder = CellBorder::createBorderGeometry(chunkCenter.x() - chunkSize / 2.f, chunkCenter.y() - chunkSize / 2.f, chunkSize, mStorage, mSceneManager, getNodeMask());
|
auto chunkBorder = CellBorder::createBorderGeometry(chunkCenter.x() - chunkSize / 2.f, chunkCenter.y() - chunkSize / 2.f, chunkSize, mStorage, mSceneManager, getNodeMask());
|
||||||
osg::Vec3f center = { chunkCenter.x(), chunkCenter.y(), 0 };
|
osg::Vec3f center = { chunkCenter.x(), chunkCenter.y(), 0 };
|
||||||
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform(osg::Matrixf::translate(-center*Constants::CellSizeInUnits));
|
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform(osg::Matrixf::translate(-center*Constants::CellSizeInUnits));
|
||||||
trans->setDataVariance(osg::Object::STATIC);
|
trans->setDataVariance(osg::Object::STATIC);
|
||||||
trans->addChild(chunkBorder);
|
trans->addChild(chunkBorder);
|
||||||
result->addChild(trans);
|
result->addChild(trans);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,7 @@ QuadTreeWorld::QuadTreeWorld(osg::Group *parent, osg::Group *compileRoot, Resour
|
||||||
, mVertexLodMod(vertexLodMod)
|
, mVertexLodMod(vertexLodMod)
|
||||||
, mViewDistance(std::numeric_limits<float>::max())
|
, mViewDistance(std::numeric_limits<float>::max())
|
||||||
, mMinSize(1/8.f)
|
, mMinSize(1/8.f)
|
||||||
|
, mDebugTerrainChunks(Settings::Manager::getBool("debug chunks", "Terrain"))
|
||||||
{
|
{
|
||||||
mChunkManager->setCompositeMapSize(compMapResolution);
|
mChunkManager->setCompositeMapSize(compMapResolution);
|
||||||
mChunkManager->setCompositeMapLevel(compMapLevel);
|
mChunkManager->setCompositeMapLevel(compMapLevel);
|
||||||
|
@ -351,7 +352,7 @@ void loadRenderingNode(ViewData::Entry& entry, ViewData* vd, int vertexLodMod, f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil::CullVisitor* cv, float cellworldsize, bool outofworld)
|
void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil::CullVisitor* cv, float cellworldsize, bool outofworld, bool debugTerrainChunk)
|
||||||
{
|
{
|
||||||
if (!(cv->getTraversalMask() & callback->getCullMask()))
|
if (!(cv->getTraversalMask() & callback->getCullMask()))
|
||||||
return;
|
return;
|
||||||
|
@ -367,7 +368,11 @@ void updateWaterCullingView(HeightCullCallback* callback, ViewData* vd, osgUtil:
|
||||||
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
|
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
|
||||||
{
|
{
|
||||||
ViewData::Entry& entry = vd->getEntry(i);
|
ViewData::Entry& entry = vd->getEntry(i);
|
||||||
osg::BoundingBox bb = static_cast<TerrainDrawable*>(entry.mRenderingNode->asGroup()->getChild(0)->asGroup()->getChild(0))->getWaterBoundingBox();
|
osg::BoundingBox bb;
|
||||||
|
if(debugTerrainChunk)
|
||||||
|
bb = static_cast<TerrainDrawable*>(entry.mRenderingNode->asGroup()->getChild(0)->asGroup()->getChild(0))->getWaterBoundingBox();
|
||||||
|
else
|
||||||
|
bb = static_cast<TerrainDrawable*>(entry.mRenderingNode->asGroup()->getChild(0))->getWaterBoundingBox();
|
||||||
if (!bb.valid())
|
if (!bb.valid())
|
||||||
continue;
|
continue;
|
||||||
osg::Vec3f ofs (entry.mNode->getCenter().x()*cellworldsize, entry.mNode->getCenter().y()*cellworldsize, 0.f);
|
osg::Vec3f ofs (entry.mNode->getCenter().x()*cellworldsize, entry.mNode->getCenter().y()*cellworldsize, 0.f);
|
||||||
|
@ -443,7 +448,7 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHeightCullCallback && isCullVisitor)
|
if (mHeightCullCallback && isCullVisitor)
|
||||||
updateWaterCullingView(mHeightCullCallback, vd, static_cast<osgUtil::CullVisitor*>(&nv), mStorage->getCellWorldSize(), !isGridEmpty());
|
updateWaterCullingView(mHeightCullCallback, vd, static_cast<osgUtil::CullVisitor*>(&nv), mStorage->getCellWorldSize(), !isGridEmpty(), mDebugTerrainChunks);
|
||||||
|
|
||||||
vd->markUnchanged();
|
vd->markUnchanged();
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ namespace Terrain
|
||||||
int mVertexLodMod;
|
int mVertexLodMod;
|
||||||
float mViewDistance;
|
float mViewDistance;
|
||||||
float mMinSize;
|
float mMinSize;
|
||||||
|
bool mDebugTerrainChunks;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue