mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 03:40:24 +00:00
load/unload cells while player is moving around in the exteriors
This commit is contained in:
parent
0d20719158
commit
033c771be8
2 changed files with 40 additions and 1 deletions
18
apps/openmw/mwrender/playerpos.cpp
Normal file
18
apps/openmw/mwrender/playerpos.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
#include "playerpos.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
void PlayerPos::setPos(float x, float y, float z, bool updateCamera)
|
||||||
|
{
|
||||||
|
mWorld.moveObject (getPlayer(), x, y, z);
|
||||||
|
|
||||||
|
if (updateCamera)
|
||||||
|
camera->setPosition (Ogre::Vector3 (
|
||||||
|
mPlayer.ref.pos.pos[0],
|
||||||
|
mPlayer.ref.pos.pos[2],
|
||||||
|
-mPlayer.ref.pos.pos[1]));
|
||||||
|
}
|
||||||
|
}
|
|
@ -692,7 +692,28 @@ namespace MWWorld
|
||||||
ptr.getCellRef().pos.pos[1] = y;
|
ptr.getCellRef().pos.pos[1] = y;
|
||||||
ptr.getCellRef().pos.pos[2] = z;
|
ptr.getCellRef().pos.pos[2] = z;
|
||||||
|
|
||||||
|
if (ptr==mPlayerPos->getPlayer())
|
||||||
|
{
|
||||||
|
CellRenderCollection::iterator active = mActiveCells.begin();
|
||||||
|
|
||||||
|
if (active!=mActiveCells.end())
|
||||||
|
{
|
||||||
|
if (!(active->first->cell->data.flags & ESM::Cell::Interior))
|
||||||
|
{
|
||||||
|
// exterior -> adjust loaded cells
|
||||||
|
const int cellSize = 8192;
|
||||||
|
|
||||||
|
int cellX = static_cast<int> (x/cellSize);
|
||||||
|
int cellY = static_cast<int> (y/cellSize);
|
||||||
|
|
||||||
|
if (active->first->cell->data.gridX!=cellX || active->first->cell->data.gridY!=cellY)
|
||||||
|
{
|
||||||
|
changeCell (cellX, cellY, mPlayerPos->getPlayer().getCellRef().pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO cell change for non-player ref
|
// TODO cell change for non-player ref
|
||||||
// TODO cell change for player ref
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue