2011-07-31 17:07:11 +02:00
|
|
|
#include "scene.hpp"
|
|
|
|
|
2012-08-12 14:36:46 +02:00
|
|
|
#include <components/esm_store/store.hpp>
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "../mwbase/world.hpp" /// FIXME
|
2012-08-09 14:33:21 +02:00
|
|
|
#include "../mwbase/soundmanager.hpp"
|
2012-08-11 17:30:55 +02:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2012-03-10 16:05:12 +01:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
#include "player.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "localscripts.hpp"
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
#include "cellfunctors.hpp"
|
|
|
|
|
2012-05-14 17:41:17 +02:00
|
|
|
namespace
|
2011-08-09 00:05:16 +02:00
|
|
|
{
|
|
|
|
|
2012-05-14 17:41:17 +02:00
|
|
|
template<typename T>
|
|
|
|
void insertCellRefList(MWRender::RenderingManager& rendering,
|
2012-06-29 18:54:23 +02:00
|
|
|
T& cellRefList, MWWorld::CellStore &cell, MWWorld::PhysicsSystem& physics)
|
2012-05-14 17:41:17 +02:00
|
|
|
{
|
|
|
|
if (!cellRefList.list.empty())
|
2011-08-09 00:05:16 +02:00
|
|
|
{
|
2012-05-14 17:41:17 +02:00
|
|
|
const MWWorld::Class& class_ =
|
|
|
|
MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell));
|
2011-11-15 23:31:18 -05:00
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
int numRefs = cellRefList.list.size();
|
|
|
|
int current = 0;
|
2012-05-14 17:41:17 +02:00
|
|
|
for (typename T::List::iterator it = cellRefList.list.begin();
|
|
|
|
it != cellRefList.list.end(); it++)
|
|
|
|
{
|
2012-09-11 16:37:54 +02:00
|
|
|
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, current, numRefs);
|
|
|
|
++current;
|
|
|
|
|
2012-05-14 17:41:17 +02:00
|
|
|
if (it->mData.getCount() || it->mData.isEnabled())
|
2011-11-15 23:31:18 -05:00
|
|
|
{
|
2012-05-14 17:41:17 +02:00
|
|
|
MWWorld::Ptr ptr (&*it, &cell);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
rendering.addObject(ptr);
|
|
|
|
class_.insertObject(ptr, physics);
|
|
|
|
}
|
|
|
|
catch (const std::exception& e)
|
|
|
|
{
|
|
|
|
std::string error ("error during rendering: ");
|
|
|
|
std::cerr << error + e.what() << std::endl;
|
|
|
|
}
|
2011-11-15 23:31:18 -05:00
|
|
|
}
|
2011-08-09 00:05:16 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-11 17:36:20 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, 0, 1);
|
|
|
|
}
|
2011-08-09 00:05:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2012-03-18 21:31:31 -04:00
|
|
|
|
2012-01-23 14:33:06 +01:00
|
|
|
void Scene::update (float duration){
|
|
|
|
mRendering.update (duration);
|
2011-12-26 19:23:46 -05:00
|
|
|
}
|
2012-03-18 21:31:31 -04:00
|
|
|
|
2011-11-15 23:31:18 -05:00
|
|
|
void Scene::unloadCell (CellStoreCollection::iterator iter)
|
2011-07-31 17:07:11 +02:00
|
|
|
{
|
2011-11-24 23:13:34 -05:00
|
|
|
std::cout << "Unloading cell\n";
|
2011-07-31 17:07:11 +02:00
|
|
|
ListHandles functor;
|
|
|
|
|
2012-01-23 14:33:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
|
|
|
|
|
2012-01-29 17:50:51 -05:00
|
|
|
(*iter)->forEach<ListHandles>(functor);
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
{
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2011-08-09 09:56:09 +02:00
|
|
|
|
2011-11-19 01:01:19 -05:00
|
|
|
// silence annoying g++ warning
|
2012-03-13 17:09:50 +01:00
|
|
|
for (std::vector<Ogre::SceneNode*>::const_iterator iter2 (functor.mHandles.begin());
|
|
|
|
iter2!=functor.mHandles.end(); ++iter2){
|
|
|
|
Ogre::SceneNode* node = *iter2;
|
2011-11-19 01:01:19 -05:00
|
|
|
mPhysics->removeObject (node->getName());
|
|
|
|
}
|
2012-03-13 17:09:50 +01:00
|
|
|
|
|
|
|
if (!((*iter)->cell->data.flags & ESM::Cell::Interior))
|
2012-05-17 18:11:34 +02:00
|
|
|
{
|
2012-07-03 12:30:50 +02:00
|
|
|
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search((*iter)->cell->data.gridX,(*iter)->cell->data.gridY);
|
2012-05-17 18:11:34 +02:00
|
|
|
if (land)
|
|
|
|
mPhysics->removeHeightField( (*iter)->cell->data.gridX, (*iter)->cell->data.gridY );
|
|
|
|
}
|
2011-11-19 01:01:19 -05:00
|
|
|
}
|
2012-03-18 21:31:31 -04:00
|
|
|
|
2012-01-29 17:50:51 -05:00
|
|
|
mRendering.removeCell(*iter);
|
2011-12-24 21:53:12 -05:00
|
|
|
//mPhysics->removeObject("Unnamed_43");
|
2012-01-23 14:33:06 +01:00
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::Environment::get().getWorld()->getLocalScripts().clearCell (*iter);
|
2012-04-23 15:27:03 +02:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->dropActors (*iter);
|
|
|
|
MWBase::Environment::get().getSoundManager()->stopSound (*iter);
|
2012-01-29 17:50:51 -05:00
|
|
|
mActiveCells.erase(*iter);
|
2012-03-18 21:31:31 -04:00
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
2011-08-01 03:33:02 +02:00
|
|
|
|
2011-11-13 23:14:18 -05:00
|
|
|
void Scene::loadCell (Ptr::CellStore *cell)
|
2011-07-31 17:07:11 +02:00
|
|
|
{
|
|
|
|
// register local scripts
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::Environment::get().getWorld()->getLocalScripts().addCell (cell);
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
|
2011-11-19 01:01:19 -05:00
|
|
|
|
|
|
|
std::pair<CellStoreCollection::iterator, bool> result =
|
2011-11-15 23:31:18 -05:00
|
|
|
mActiveCells.insert(cell);
|
2011-11-21 12:52:28 +01:00
|
|
|
|
2012-03-13 17:09:50 +01:00
|
|
|
if(result.second)
|
|
|
|
{
|
2012-04-30 18:46:51 +02:00
|
|
|
insertCell(*cell);
|
2012-03-13 17:09:50 +01:00
|
|
|
mRendering.cellAdded (cell);
|
|
|
|
|
|
|
|
float verts = ESM::Land::LAND_SIZE;
|
|
|
|
float worldsize = ESM::Land::REAL_SIZE;
|
|
|
|
|
|
|
|
if (!(cell->cell->data.flags & ESM::Cell::Interior))
|
2012-03-28 22:46:29 +02:00
|
|
|
{
|
2012-07-03 12:30:50 +02:00
|
|
|
ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cell->cell->data.gridX,cell->cell->data.gridY);
|
2012-05-17 18:11:34 +02:00
|
|
|
if (land)
|
|
|
|
mPhysics->addHeightField (land->landData->heights,
|
|
|
|
cell->cell->data.gridX, cell->cell->data.gridY,
|
|
|
|
0, ( worldsize/(verts-1) ), verts);
|
2012-03-28 22:46:29 +02:00
|
|
|
}
|
2012-03-28 21:46:52 +02:00
|
|
|
|
|
|
|
mRendering.configureAmbient(*cell);
|
|
|
|
mRendering.requestMap(cell);
|
|
|
|
mRendering.configureAmbient(*cell);
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
2011-11-21 12:52:28 +01:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
2011-08-01 03:33:02 +02:00
|
|
|
|
2012-07-31 19:30:24 +04:00
|
|
|
void
|
|
|
|
Scene::playerCellChange(
|
|
|
|
MWWorld::CellStore *cell,
|
|
|
|
const ESM::Position& pos,
|
2011-08-01 03:33:02 +02:00
|
|
|
bool adjustPlayerPos)
|
|
|
|
{
|
2012-04-18 00:13:38 -04:00
|
|
|
bool hasWater = cell->cell->data.flags & cell->cell->HasWater;
|
|
|
|
mPhysics->setCurrentWater(hasWater, cell->cell->water);
|
2012-07-31 19:30:24 +04:00
|
|
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
2012-08-11 12:13:16 +04:00
|
|
|
world->getPlayer().setCell(cell);
|
|
|
|
|
2012-07-31 19:30:24 +04:00
|
|
|
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
|
|
|
|
|
|
|
if (adjustPlayerPos) {
|
|
|
|
world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);
|
2012-08-11 13:23:54 +04:00
|
|
|
|
|
|
|
float x = Ogre::Radian(pos.rot[0]).valueDegrees();
|
|
|
|
float y = Ogre::Radian(pos.rot[1]).valueDegrees();
|
|
|
|
float z = Ogre::Radian(pos.rot[2]).valueDegrees();
|
|
|
|
world->rotateObject(player, x, y, z);
|
2012-05-30 15:52:39 +02:00
|
|
|
}
|
2011-08-01 03:33:02 +02:00
|
|
|
|
2012-08-11 17:30:55 +02:00
|
|
|
MWBase::MechanicsManager *mechMgr =
|
2012-07-31 19:30:24 +04:00
|
|
|
MWBase::Environment::get().getMechanicsManager();
|
2012-05-30 15:52:39 +02:00
|
|
|
|
2012-07-31 19:30:24 +04:00
|
|
|
mechMgr->addActor(player);
|
|
|
|
mechMgr->watchActor(player);
|
2012-03-10 16:05:12 +01:00
|
|
|
|
2012-07-31 19:30:24 +04:00
|
|
|
MWBase::Environment::get().getWindowManager()->changeCell(mCurrentCell);
|
2011-08-01 03:33:02 +02:00
|
|
|
}
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
|
|
|
|
{
|
2012-03-14 20:44:06 +01:00
|
|
|
mRendering.preCellChange(mCurrentCell);
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
// remove active
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::Environment::get().getMechanicsManager()->removeActor (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2011-11-15 23:31:18 -05:00
|
|
|
CellStoreCollection::iterator active = mActiveCells.begin();
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
// get the number of cells to unload
|
|
|
|
int numUnload = 0;
|
|
|
|
while (active!=mActiveCells.end())
|
|
|
|
{
|
|
|
|
if (!((*active)->cell->data.flags & ESM::Cell::Interior))
|
|
|
|
{
|
|
|
|
if (std::abs (X-(*active)->cell->data.gridX)<=1 &&
|
|
|
|
std::abs (Y-(*active)->cell->data.gridY)<=1)
|
|
|
|
{
|
|
|
|
// keep cells within the new 3x3 grid
|
|
|
|
++active;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++active;
|
|
|
|
++numUnload;
|
|
|
|
}
|
|
|
|
|
|
|
|
int current = 0;
|
|
|
|
active = mActiveCells.begin();
|
2011-07-31 17:07:11 +02:00
|
|
|
while (active!=mActiveCells.end())
|
|
|
|
{
|
2011-11-21 12:52:28 +01:00
|
|
|
if (!((*active)->cell->data.flags & ESM::Cell::Interior))
|
2011-07-31 17:07:11 +02:00
|
|
|
{
|
2011-11-21 12:52:28 +01:00
|
|
|
if (std::abs (X-(*active)->cell->data.gridX)<=1 &&
|
|
|
|
std::abs (Y-(*active)->cell->data.gridY)<=1)
|
2011-07-31 17:07:11 +02:00
|
|
|
{
|
|
|
|
// keep cells within the new 3x3 grid
|
|
|
|
++active;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
|
2011-07-31 17:07:11 +02:00
|
|
|
unloadCell (active++);
|
2012-09-11 16:37:54 +02:00
|
|
|
++current;
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
int numLoad = 0;
|
|
|
|
// get the number of cells to load
|
|
|
|
for (int x=X-1; x<=X+1; ++x)
|
|
|
|
for (int y=Y-1; y<=Y+1; ++y)
|
|
|
|
{
|
|
|
|
CellStoreCollection::iterator iter = mActiveCells.begin();
|
|
|
|
|
|
|
|
while (iter!=mActiveCells.end())
|
|
|
|
{
|
|
|
|
assert (!((*iter)->cell->data.flags & ESM::Cell::Interior));
|
|
|
|
|
|
|
|
if (x==(*iter)->cell->data.gridX &&
|
|
|
|
y==(*iter)->cell->data.gridY)
|
|
|
|
break;
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iter==mActiveCells.end())
|
|
|
|
++numLoad;
|
|
|
|
}
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
// Load cells
|
2012-09-11 16:37:54 +02:00
|
|
|
current = 0;
|
2011-07-31 17:07:11 +02:00
|
|
|
for (int x=X-1; x<=X+1; ++x)
|
|
|
|
for (int y=Y-1; y<=Y+1; ++y)
|
|
|
|
{
|
2011-11-15 23:31:18 -05:00
|
|
|
CellStoreCollection::iterator iter = mActiveCells.begin();
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
while (iter!=mActiveCells.end())
|
|
|
|
{
|
2011-11-21 12:52:28 +01:00
|
|
|
assert (!((*iter)->cell->data.flags & ESM::Cell::Interior));
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
if (x==(*iter)->cell->data.gridX &&
|
|
|
|
y==(*iter)->cell->data.gridY)
|
2011-07-31 17:07:11 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iter==mActiveCells.end())
|
|
|
|
{
|
2012-07-03 12:30:50 +02:00
|
|
|
CellStore *cell = MWBase::Environment::get().getWorld()->getExterior(x, y);
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, current, numLoad);
|
2011-11-13 23:14:18 -05:00
|
|
|
loadCell (cell);
|
2012-09-11 16:37:54 +02:00
|
|
|
++current;
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// find current cell
|
2011-11-15 23:31:18 -05:00
|
|
|
CellStoreCollection::iterator iter = mActiveCells.begin();
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
while (iter!=mActiveCells.end())
|
|
|
|
{
|
2011-11-21 12:52:28 +01:00
|
|
|
assert (!((*iter)->cell->data.flags & ESM::Cell::Interior));
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
if (X==(*iter)->cell->data.gridX &&
|
|
|
|
Y==(*iter)->cell->data.gridY)
|
2011-07-31 17:07:11 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert (iter!=mActiveCells.end());
|
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
mCurrentCell = *iter;
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
// adjust player
|
2012-08-08 14:51:33 +04:00
|
|
|
playerCellChange (mCurrentCell, position, adjustPlayerPos);
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
// Sky system
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::Environment::get().getWorld()->adjustSky();
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2012-04-19 20:59:57 +02:00
|
|
|
mRendering.switchToExterior();
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
mCellChanged = true;
|
2012-09-13 00:21:58 +02:00
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager ()->loadingDone ();
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
2011-08-01 03:33:02 +02:00
|
|
|
|
2011-11-21 12:52:28 +01:00
|
|
|
//We need the ogre renderer and a scene node.
|
2012-07-03 12:30:50 +02:00
|
|
|
Scene::Scene (MWRender::RenderingManager& rendering, PhysicsSystem *physics)
|
|
|
|
: mCurrentCell (0), mCellChanged (false), mPhysics(physics), mRendering(rendering)
|
2011-08-01 03:33:02 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Scene::~Scene()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Scene::hasCellChanged() const
|
|
|
|
{
|
|
|
|
return mCellChanged;
|
|
|
|
}
|
2011-08-09 09:56:09 +02:00
|
|
|
|
2011-11-15 23:31:18 -05:00
|
|
|
const Scene::CellStoreCollection& Scene::getActiveCells() const
|
2011-08-01 04:06:38 +02:00
|
|
|
{
|
|
|
|
return mActiveCells;
|
|
|
|
}
|
2011-08-09 09:56:09 +02:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
|
|
|
{
|
2011-11-17 19:38:52 -05:00
|
|
|
std::cout << "Changing to interior\n";
|
2012-05-17 17:13:41 +02:00
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName);
|
2012-05-17 17:13:41 +02:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
// remove active
|
2011-11-15 23:31:18 -05:00
|
|
|
CellStoreCollection::iterator active = mActiveCells.begin();
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
// count number of cells to unload
|
|
|
|
int numUnload = 0;
|
|
|
|
while (active!=mActiveCells.end())
|
|
|
|
{
|
|
|
|
++active;
|
|
|
|
++numUnload;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unload
|
|
|
|
int current = 0;
|
|
|
|
active = mActiveCells.begin();
|
2011-07-31 17:07:11 +02:00
|
|
|
while (active!=mActiveCells.end())
|
|
|
|
{
|
2012-09-11 16:37:54 +02:00
|
|
|
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload);
|
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
unloadCell (active++);
|
2012-09-11 16:37:54 +02:00
|
|
|
++current;
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load cell.
|
2011-08-01 04:53:06 +02:00
|
|
|
std::cout << "cellName:" << cellName << std::endl;
|
2011-07-31 17:07:11 +02:00
|
|
|
|
2012-09-11 16:37:54 +02:00
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1);
|
2011-11-13 23:14:18 -05:00
|
|
|
loadCell (cell);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
// adjust player
|
|
|
|
mCurrentCell = cell;
|
2011-08-01 03:33:02 +02:00
|
|
|
playerCellChange (cell, position);
|
2012-04-19 20:59:57 +02:00
|
|
|
|
2012-02-26 13:13:29 +01:00
|
|
|
// adjust fog
|
2012-04-19 20:59:57 +02:00
|
|
|
mRendering.switchToInterior();
|
2012-02-26 13:13:29 +01:00
|
|
|
mRendering.configureFog(*cell);
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
// Sky system
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::Environment::get().getWorld()->adjustSky();
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
mCellChanged = true;
|
2012-09-13 00:21:58 +02:00
|
|
|
|
|
|
|
MWBase::Environment::get().getWindowManager ()->loadingDone ();
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|
2011-08-01 03:33:02 +02:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
void Scene::changeToExteriorCell (const ESM::Position& position)
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
MWBase::Environment::get().getWorld()->positionToIndex (position.pos[0], position.pos[1], x, y);
|
2011-07-31 17:07:11 +02:00
|
|
|
|
|
|
|
changeCell (x, y, position, true);
|
|
|
|
}
|
2011-08-09 09:56:09 +02:00
|
|
|
|
2011-08-01 04:06:38 +02:00
|
|
|
Ptr::CellStore* Scene::getCurrentCell ()
|
|
|
|
{
|
|
|
|
return mCurrentCell;
|
|
|
|
}
|
2011-08-01 03:33:02 +02:00
|
|
|
|
|
|
|
void Scene::markCellAsUnchanged()
|
|
|
|
{
|
|
|
|
mCellChanged = false;
|
|
|
|
}
|
2011-08-27 10:30:38 +02:00
|
|
|
|
2012-06-29 16:48:50 +02:00
|
|
|
void Scene::insertCell (Ptr::CellStore &cell)
|
2012-05-14 17:41:17 +02:00
|
|
|
{
|
|
|
|
// Loop through all references in the cell
|
|
|
|
insertCellRefList(mRendering, cell.activators, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.potions, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.appas, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.armors, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.books, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.clothes, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.containers, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.creatures, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.doors, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.ingreds, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.creatureLists, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.itemLists, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.lights, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.lockpicks, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.miscItems, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.npcs, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.probes, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.repairs, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.statics, cell, *mPhysics);
|
|
|
|
insertCellRefList(mRendering, cell.weapons, cell, *mPhysics);
|
|
|
|
}
|
2011-08-09 00:05:16 +02:00
|
|
|
|
2012-05-25 17:28:27 +02:00
|
|
|
void Scene::addObjectToScene (const Ptr& ptr)
|
|
|
|
{
|
2012-07-26 16:14:11 +04:00
|
|
|
mRendering.addObject(ptr);
|
|
|
|
MWWorld::Class::get(ptr).insertObject(ptr, *mPhysics);
|
2012-05-25 17:28:27 +02:00
|
|
|
}
|
2012-08-09 14:33:21 +02:00
|
|
|
|
2012-05-25 17:28:27 +02:00
|
|
|
void Scene::removeObjectFromScene (const Ptr& ptr)
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->removeActor (ptr);
|
|
|
|
MWBase::Environment::get().getSoundManager()->stopSound3D (ptr);
|
|
|
|
mPhysics->removeObject (ptr.getRefData().getHandle());
|
|
|
|
mRendering.removeObject (ptr);
|
|
|
|
}
|
2012-07-26 16:14:11 +04:00
|
|
|
|
|
|
|
bool Scene::isCellActive(const CellStore &cell)
|
|
|
|
{
|
|
|
|
CellStoreCollection::iterator active = mActiveCells.begin();
|
|
|
|
while (active != mActiveCells.end()) {
|
2012-08-08 14:51:33 +04:00
|
|
|
if (**active == cell) {
|
2012-07-26 16:14:11 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
++active;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-07-31 17:07:11 +02:00
|
|
|
}
|