mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
don't create terrain if there is no land data, also fixes a water disappearing issue and a sound exception if cells with no region
This commit is contained in:
parent
375c198ebd
commit
c9aa0ca1f4
3 changed files with 29 additions and 32 deletions
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include <components/esm/loadstat.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
|
@ -229,7 +230,10 @@ void RenderingManager::update (float duration){
|
|||
mWater->update();
|
||||
}
|
||||
void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
|
||||
if(store->cell->data.flags & store->cell->HasWater){
|
||||
if(store->cell->data.flags & store->cell->HasWater
|
||||
|| ((!(store->cell->data.flags & ESM::Cell::Interior))
|
||||
&& !MWBase::Environment::get().getWorld()->getStore().lands.search(store->cell->data.gridX,store->cell->data.gridY) )) // always use water, if the cell does not have land.
|
||||
{
|
||||
if(mWater == 0)
|
||||
mWater = new MWRender::Water(mRendering.getCamera(), mSkyManager, store->cell);
|
||||
else
|
||||
|
@ -238,7 +242,6 @@ void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
|
|||
}
|
||||
else
|
||||
removeWater();
|
||||
|
||||
}
|
||||
|
||||
void RenderingManager::setWaterHeight(const float height)
|
||||
|
|
|
@ -110,12 +110,12 @@ namespace MWRender
|
|||
const int cellY = store->cell->getGridY();
|
||||
|
||||
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY);
|
||||
if ( land != NULL )
|
||||
if (land == NULL) // no land data means we're not going to create any terrain.
|
||||
return;
|
||||
|
||||
if (!land->dataLoaded)
|
||||
{
|
||||
if (!land->dataLoaded)
|
||||
{
|
||||
land->loadData();
|
||||
}
|
||||
land->loadData();
|
||||
}
|
||||
|
||||
//split the cell terrain into four segments
|
||||
|
@ -138,25 +138,18 @@ namespace MWRender
|
|||
mLandSize*mLandSize,
|
||||
MEMCATEGORY_GEOMETRY);
|
||||
|
||||
if ( land != NULL )
|
||||
//copy the height data row by row
|
||||
for ( int terrainCopyY = 0; terrainCopyY < mLandSize; terrainCopyY++ )
|
||||
{
|
||||
//copy the height data row by row
|
||||
for ( int terrainCopyY = 0; terrainCopyY < mLandSize; terrainCopyY++ )
|
||||
{
|
||||
//the offset of the current segment
|
||||
const size_t yOffset = y * (mLandSize-1) * ESM::Land::LAND_SIZE +
|
||||
//offset of the row
|
||||
terrainCopyY * ESM::Land::LAND_SIZE;
|
||||
const size_t xOffset = x * (mLandSize-1);
|
||||
//the offset of the current segment
|
||||
const size_t yOffset = y * (mLandSize-1) * ESM::Land::LAND_SIZE +
|
||||
//offset of the row
|
||||
terrainCopyY * ESM::Land::LAND_SIZE;
|
||||
const size_t xOffset = x * (mLandSize-1);
|
||||
|
||||
memcpy(&terrainData.inputFloat[terrainCopyY*mLandSize],
|
||||
&land->landData->heights[yOffset + xOffset],
|
||||
mLandSize*sizeof(float));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(terrainData.inputFloat, 0, mLandSize*mLandSize*sizeof(float));
|
||||
memcpy(&terrainData.inputFloat[terrainCopyY*mLandSize],
|
||||
&land->landData->heights[yOffset + xOffset],
|
||||
mLandSize*sizeof(float));
|
||||
}
|
||||
|
||||
std::map<uint16_t, int> indexes;
|
||||
|
@ -179,7 +172,7 @@ namespace MWRender
|
|||
terrain->setVisibilityFlags(RV_Terrain);
|
||||
terrain->setRenderQueueGroup(RQG_Main);
|
||||
|
||||
if ( land && land->landData->usingColours )
|
||||
if ( land->landData->usingColours )
|
||||
{
|
||||
// disable or enable global colour map (depends on available vertex colours)
|
||||
mActiveProfile->setGlobalColourMapEnabled(true);
|
||||
|
@ -196,10 +189,6 @@ namespace MWRender
|
|||
//mat = terrain->_getCompositeMapMaterial();
|
||||
//mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mActiveProfile->setGlobalColourMapEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -215,8 +204,10 @@ namespace MWRender
|
|||
{
|
||||
for ( int y = 0; y < 2; y++ )
|
||||
{
|
||||
mTerrainGroup.unloadTerrain(store->cell->getGridX() * 2 + x,
|
||||
store->cell->getGridY() * 2 + y);
|
||||
int terrainX = store->cell->getGridX() * 2 + x;
|
||||
int terrainY = store->cell->getGridY() * 2 + y;
|
||||
if (mTerrainGroup.getTerrain(terrainX, terrainY) != NULL)
|
||||
mTerrainGroup.unloadTerrain(terrainX, terrainY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -433,7 +433,10 @@ namespace MWSound
|
|||
total = 0;
|
||||
}
|
||||
|
||||
const ESM::Region *regn = MWBase::Environment::get().getWorld()->getStore().regions.find(regionName);
|
||||
const ESM::Region *regn = MWBase::Environment::get().getWorld()->getStore().regions.search(regionName);
|
||||
if (regn == NULL)
|
||||
return;
|
||||
|
||||
std::vector<ESM::Region::SoundRef>::const_iterator soundIter;
|
||||
if(total == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue