forked from mirror/openmw-tes3mp
Refactor ownership of ViewDataMap
This commit is contained in:
parent
5a3c645c89
commit
2580de11a4
3 changed files with 12 additions and 9 deletions
|
@ -90,7 +90,7 @@ namespace Terrain
|
|||
|
||||
osg::ref_ptr<LodCallback> mLodCallback;
|
||||
|
||||
osg::ref_ptr<ViewDataMap> mViewDataMap;
|
||||
ViewDataMap* mViewDataMap;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -110,10 +110,11 @@ private:
|
|||
class BuildQuadTreeItem : public SceneUtil::WorkItem
|
||||
{
|
||||
public:
|
||||
BuildQuadTreeItem(Terrain::Storage* storage, float minSize)
|
||||
BuildQuadTreeItem(Terrain::Storage* storage, ViewDataMap* viewDataMap, float minSize)
|
||||
: mStorage(storage)
|
||||
, mMinX(0.f), mMaxX(0.f), mMinY(0.f), mMaxY(0.f)
|
||||
, mMinSize(minSize)
|
||||
, mViewDataMap(viewDataMap)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -131,7 +132,7 @@ public:
|
|||
float centerY = (mMinY+mMaxY)/2.f + (size-origSizeY)/2.f;
|
||||
|
||||
mRootNode = new RootNode(size, osg::Vec2f(centerX, centerY));
|
||||
mRootNode->setViewDataMap(new ViewDataMap);
|
||||
mRootNode->setViewDataMap(mViewDataMap);
|
||||
addChildren(mRootNode);
|
||||
|
||||
mRootNode->initNeighbours();
|
||||
|
@ -174,7 +175,7 @@ public:
|
|||
|
||||
osg::ref_ptr<QuadTreeNode> node = new QuadTreeNode(parent, direction, size, center);
|
||||
node->setLodCallback(new DefaultLodCallback);
|
||||
node->setViewDataMap(parent->getViewDataMap());
|
||||
node->setViewDataMap(mViewDataMap);
|
||||
parent->addChild(node);
|
||||
|
||||
if (center.x() - size > mMaxX
|
||||
|
@ -218,6 +219,7 @@ private:
|
|||
|
||||
float mMinX, mMaxX, mMinY, mMaxY;
|
||||
float mMinSize;
|
||||
ViewDataMap* mViewDataMap;
|
||||
|
||||
osg::ref_ptr<RootNode> mRootNode;
|
||||
};
|
||||
|
@ -225,6 +227,7 @@ private:
|
|||
QuadTreeWorld::QuadTreeWorld(SceneUtil::WorkQueue* workQueue, osg::Group *parent, osg::Group *compileRoot, Resource::ResourceSystem *resourceSystem, Storage *storage, int nodeMask, int preCompileMask)
|
||||
: World(parent, compileRoot, resourceSystem, storage, nodeMask, preCompileMask)
|
||||
, mWorkQueue(workQueue)
|
||||
, mViewDataMap(new ViewDataMap)
|
||||
, mQuadTreeBuilt(false)
|
||||
{
|
||||
}
|
||||
|
@ -237,10 +240,7 @@ QuadTreeWorld::~QuadTreeWorld()
|
|||
mWorkItem->waitTillDone();
|
||||
}
|
||||
|
||||
if (mRootNode && mRootNode->getViewDataMap())
|
||||
{
|
||||
mRootNode->getViewDataMap()->clear();
|
||||
}
|
||||
mViewDataMap->clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,7 +351,7 @@ osg::ref_ptr<osg::Node> QuadTreeWorld::cacheCell(int x, int y)
|
|||
if (!mQuadTreeBuilt)
|
||||
{
|
||||
const float minSize = 1/4.f;
|
||||
mWorkItem = new BuildQuadTreeItem(mStorage, minSize);
|
||||
mWorkItem = new BuildQuadTreeItem(mStorage, mViewDataMap.get(), minSize);
|
||||
mWorkQueue->addWorkItem(mWorkItem);
|
||||
|
||||
mWorkItem->waitTillDone();
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Terrain
|
|||
{
|
||||
class RootNode;
|
||||
class BuildQuadTreeItem;
|
||||
class ViewDataMap;
|
||||
|
||||
/// @brief Terrain implementation that loads cells into a Quad Tree, with geometry LOD and texture LOD. The entire world is displayed at all times.
|
||||
class QuadTreeWorld : public Terrain::World
|
||||
|
@ -39,6 +40,8 @@ namespace Terrain
|
|||
|
||||
osg::ref_ptr<BuildQuadTreeItem> mWorkItem;
|
||||
|
||||
osg::ref_ptr<ViewDataMap> mViewDataMap;
|
||||
|
||||
bool mQuadTreeBuilt;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue