mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 00:45:32 +00:00
fix map glitch + cleanup
Signed-off-by: Bret Curtis <psi29a@gmail.com>
This commit is contained in:
parent
77b92aee9c
commit
b7b31926a8
5 changed files with 5 additions and 66 deletions
|
@ -168,11 +168,10 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
|
|||
osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, float width, float height, const osg::Vec3d& upVector, float zmin, float zmax)
|
||||
{
|
||||
osg::ref_ptr<osg::Camera> camera (new osg::Camera);
|
||||
|
||||
camera->setProjectionMatrixAsOrtho(-width/2, width/2, -height/2, height/2, 5, (zmax-zmin) + 10);
|
||||
camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
camera->setViewMatrixAsLookAt(osg::Vec3d(x, y, zmax + 5), osg::Vec3d(x, y, zmin), upVector);
|
||||
camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
|
||||
camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF_INHERIT_VIEWPOINT);
|
||||
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::PIXEL_BUFFER_RTT);
|
||||
camera->setClearColor(osg::Vec4(0.f, 0.f, 0.f, 1.f));
|
||||
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -360,11 +359,6 @@ void LocalMap::requestExteriorMap(const MWWorld::CellStore* cell)
|
|||
|
||||
osg::ref_ptr<osg::Camera> camera = createOrthographicCamera(x*mMapWorldSize + mMapWorldSize/2.f, y*mMapWorldSize + mMapWorldSize/2.f, mMapWorldSize, mMapWorldSize,
|
||||
osg::Vec3d(0,1,0), zmin, zmax);
|
||||
camera->getOrCreateUserDataContainer()->addDescription("NoTerrainLod");
|
||||
std::ostringstream stream;
|
||||
stream << x << " " << y;
|
||||
camera->getOrCreateUserDataContainer()->addDescription(stream.str());
|
||||
|
||||
setupRenderToTexture(camera, cell->getCell()->getGridX(), cell->getCell()->getGridY());
|
||||
|
||||
MapSegment& segment = mSegments[std::make_pair(cell->getCell()->getGridX(), cell->getCell()->getGridY())];
|
||||
|
|
|
@ -128,28 +128,6 @@ void QuadTreeNode::traverseNodes(ViewData* vd, const osg::Vec3f& viewPoint, LodC
|
|||
}
|
||||
}
|
||||
|
||||
void QuadTreeNode::traverseTo(ViewData* vd, float size, const osg::Vec2f& center)
|
||||
{
|
||||
if (!hasValidBounds())
|
||||
return;
|
||||
|
||||
if (getCenter().x() + getSize()/2.f <= center.x() - size/2.f
|
||||
|| getCenter().x() - getSize()/2.f >= center.x() + size/2.f
|
||||
|| getCenter().y() + getSize()/2.f <= center.y() - size/2.f
|
||||
|| getCenter().y() - getSize()/2.f >= center.y() + size/2.f)
|
||||
return;
|
||||
|
||||
bool stopTraversal = (getSize() == size);
|
||||
|
||||
if (stopTraversal)
|
||||
vd->add(this);
|
||||
else
|
||||
{
|
||||
for (unsigned int i=0; i<getNumChildren(); ++i)
|
||||
getChild(i)->traverseTo(vd, size, center);
|
||||
}
|
||||
}
|
||||
|
||||
void QuadTreeNode::intersect(ViewData* vd, TerrainLineIntersector& intersector)
|
||||
{
|
||||
if (!hasValidBounds())
|
||||
|
|
|
@ -100,9 +100,6 @@ namespace Terrain
|
|||
/// Traverse nodes according to LOD selection.
|
||||
void traverseNodes(ViewData* vd, const osg::Vec3f& viewPoint, LodCallback* lodCallback, float maxDist);
|
||||
|
||||
/// Traverse to a specific node and add only that node.
|
||||
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);
|
||||
|
||||
/// Adds all leaf nodes which intersect the line from start to end
|
||||
void intersect(ViewData* vd, TerrainLineIntersector& intersector);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
float halfSize = node->getSize()/2;
|
||||
const osg::Vec2f& center = node->getCenter();
|
||||
osg::Vec4i nodeBounds (static_cast<int>(center.x() - halfSize), static_cast<int>(center.y() - halfSize), static_cast<int>(center.x() + halfSize), static_cast<int>(center.y() + halfSize));
|
||||
bool intersects = (std::max(nodeBounds.x(), mActiveGrid.x()) <= std::min(nodeBounds.z(), mActiveGrid.z()) && std::max(nodeBounds.y(), mActiveGrid.y()) <= std::min(nodeBounds.w(), mActiveGrid.w()));
|
||||
bool intersects = (std::max(nodeBounds.x(), mActiveGrid.x()) < std::min(nodeBounds.z(), mActiveGrid.z()) && std::max(nodeBounds.y(), mActiveGrid.y()) < std::min(nodeBounds.w(), mActiveGrid.w()));
|
||||
// to prevent making chunks who will cross the activegrid border
|
||||
if (intersects)
|
||||
return false;
|
||||
|
@ -430,21 +430,8 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
|||
if (isCullVisitor)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
|
||||
|
||||
osg::UserDataContainer* udc = cv->getCurrentCamera()->getUserDataContainer();
|
||||
if (udc && udc->getNumDescriptions() >= 2 && udc->getDescriptions()[0] == "NoTerrainLod")
|
||||
{
|
||||
std::istringstream stream(udc->getDescriptions()[1]);
|
||||
int x,y;
|
||||
stream >> x;
|
||||
stream >> y;
|
||||
mRootNode->traverseTo(vd, 1, osg::Vec2f(x+0.5,y+0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultLodCallback lodCallback(mLodFactor, MIN_SIZE, mActiveGrid);
|
||||
mRootNode->traverseNodes(vd, cv->getViewPoint(), &lodCallback, mViewDistance);
|
||||
}
|
||||
DefaultLodCallback lodCallback(mLodFactor, MIN_SIZE, mActiveGrid);
|
||||
mRootNode->traverseNodes(vd, cv->getViewPoint(), &lodCallback, mViewDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -517,23 +504,6 @@ void QuadTreeWorld::enable(bool enabled)
|
|||
mRootNode->setNodeMask(enabled ? ~0 : 0);
|
||||
}
|
||||
|
||||
void QuadTreeWorld::cacheCell(View *view, int x, int y)
|
||||
{
|
||||
ensureQuadTreeBuilt();
|
||||
osg::Vec4i grid (x,y,x+1,y+1);
|
||||
ViewData* vd = static_cast<ViewData*>(view);
|
||||
vd->setActiveGrid(grid);
|
||||
mRootNode->traverseTo(vd, 1, osg::Vec2f(x+0.5f,y+0.5f));
|
||||
|
||||
const float cellWorldSize = mStorage->getCellWorldSize();
|
||||
|
||||
for (unsigned int i=0; i<vd->getNumEntries(); ++i)
|
||||
{
|
||||
ViewData::Entry& entry = vd->getEntry(i);
|
||||
loadRenderingNode(entry, vd, mVertexLodMod, cellWorldSize, grid, mChunkManagers, true);
|
||||
}
|
||||
}
|
||||
|
||||
View* QuadTreeWorld::createView()
|
||||
{
|
||||
return new ViewData;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Terrain
|
|||
|
||||
virtual void setViewDistance(float distance) { mViewDistance = distance; }
|
||||
|
||||
void cacheCell(View *view, int x, int y);
|
||||
void cacheCell(View *view, int x, int y) {}
|
||||
/// @note Not thread safe.
|
||||
virtual void loadCell(int x, int y);
|
||||
/// @note Not thread safe.
|
||||
|
|
Loading…
Reference in a new issue