1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-07-21 18:14:04 +00:00

Fog of war fix

This commit is contained in:
scrawl 2015-05-28 16:20:29 +02:00
parent f4ee805e3b
commit 5f7a82e0da

View file

@ -297,11 +297,14 @@ void LocalMap::requestExteriorMap(MWWorld::CellStore* cell)
setupRenderToTexture(camera, cell->getCell()->getGridX(), cell->getCell()->getGridY());
MapSegment& segment = mSegments[std::make_pair(cell->getCell()->getGridX(), cell->getCell()->getGridY())];
if (!segment.mFogOfWarImage)
{
if (cell->getFog())
segment.loadFogOfWar(cell->getFog()->mFogTextures.back());
else
segment.initFogOfWar();
}
}
void LocalMap::requestInteriorMap(MWWorld::CellStore* cell)
{
@ -414,6 +417,8 @@ void LocalMap::requestInteriorMap(MWWorld::CellStore* cell)
setupRenderToTexture(camera, x, y);
MapSegment& segment = mSegments[std::make_pair(x,y)];
if (!segment.mFogOfWarImage)
{
if (!cell->getFog())
segment.initFogOfWar();
else
@ -429,6 +434,7 @@ void LocalMap::requestInteriorMap(MWWorld::CellStore* cell)
segment.loadFogOfWar(fog->mFogTextures[i]);
}
}
++i;
}
}
@ -570,7 +576,8 @@ void LocalMap::MapSegment::createFogOfWarTexture()
if (mFogOfWarTexture)
return;
mFogOfWarTexture = new osg::Texture2D;
mFogOfWarTexture->setDataVariance(osg::Object::DYNAMIC);
// TODO: synchronize access? for now, the worst that could happen is the draw thread jumping a frame ahead.
//mFogOfWarTexture->setDataVariance(osg::Object::DYNAMIC);
mFogOfWarTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
mFogOfWarTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
mFogOfWarTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
@ -581,6 +588,8 @@ void LocalMap::MapSegment::createFogOfWarTexture()
void LocalMap::MapSegment::initFogOfWar()
{
mFogOfWarImage = new osg::Image;
// Assign a PixelBufferObject for asynchronous transfer of data to the GPU
mFogOfWarImage->setPixelBufferObject(new osg::PixelBufferObject);
mFogOfWarImage->allocateImage(sFogOfWarResolution, sFogOfWarResolution, 1, GL_RGBA, GL_UNSIGNED_BYTE);
assert(mFogOfWarImage->isDataContiguous());
std::vector<uint32_t> data;