mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 06:45:35 +00:00
Fix crash when moving npcs to an inactive cell
This commit is contained in:
parent
48a88f1917
commit
2e7d5377f4
4 changed files with 28 additions and 16 deletions
|
@ -235,7 +235,7 @@ void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store)
|
||||||
mObjects.buildStaticGeometry (*store);
|
mObjects.buildStaticGeometry (*store);
|
||||||
mDebugging->cellAdded(store);
|
mDebugging->cellAdded(store);
|
||||||
if (store->mCell->isExterior())
|
if (store->mCell->isExterior())
|
||||||
mTerrainManager->cellAdded(store);
|
mTerrainManager->cellAdded(store);
|
||||||
waterAdded(store);
|
waterAdded(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->adjustPosition(ptr);
|
MWWorld::Class::get(ptr).adjustPosition(ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -343,7 +343,7 @@ namespace MWScript
|
||||||
zRot = zRot/60.;
|
zRot = zRot/60.;
|
||||||
}
|
}
|
||||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
|
||||||
MWBase::Environment::get().getWorld()->adjustPosition(ptr);
|
MWWorld::Class::get(ptr).adjustPosition(ptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,6 @@ namespace MWWorld
|
||||||
|
|
||||||
if(result.second)
|
if(result.second)
|
||||||
{
|
{
|
||||||
/// \todo rescale depending on the state of a new GMST
|
|
||||||
insertCell (*cell, true);
|
|
||||||
|
|
||||||
mRendering.cellAdded (cell);
|
|
||||||
|
|
||||||
float verts = ESM::Land::LAND_SIZE;
|
float verts = ESM::Land::LAND_SIZE;
|
||||||
float worldsize = ESM::Land::REAL_SIZE;
|
float worldsize = ESM::Land::REAL_SIZE;
|
||||||
|
|
||||||
|
@ -142,6 +137,11 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \todo rescale depending on the state of a new GMST
|
||||||
|
insertCell (*cell, true);
|
||||||
|
|
||||||
|
mRendering.cellAdded (cell);
|
||||||
|
|
||||||
mRendering.configureAmbient(*cell);
|
mRendering.configureAmbient(*cell);
|
||||||
mRendering.requestMap(cell);
|
mRendering.requestMap(cell);
|
||||||
mRendering.configureAmbient(*cell);
|
mRendering.configureAmbient(*cell);
|
||||||
|
@ -166,7 +166,7 @@ namespace MWWorld
|
||||||
float z = Ogre::Radian(pos.rot[2]).valueDegrees();
|
float z = Ogre::Radian(pos.rot[2]).valueDegrees();
|
||||||
world->rotateObject(player, x, y, z);
|
world->rotateObject(player, x, y, z);
|
||||||
|
|
||||||
world->adjustPosition(player);
|
MWWorld::Class::get(player).adjustPosition(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::MechanicsManager *mechMgr =
|
MWBase::MechanicsManager *mechMgr =
|
||||||
|
@ -358,7 +358,7 @@ namespace MWWorld
|
||||||
float z = Ogre::Radian(position.rot[2]).valueDegrees();
|
float z = Ogre::Radian(position.rot[2]).valueDegrees();
|
||||||
world->rotateObject(world->getPlayer().getPlayer(), x, y, z);
|
world->rotateObject(world->getPlayer().getPlayer(), x, y, z);
|
||||||
|
|
||||||
world->adjustPosition(world->getPlayer().getPlayer());
|
MWWorld::Class::get(world->getPlayer().getPlayer()).adjustPosition(world->getPlayer().getPlayer());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -706,6 +706,7 @@ namespace MWWorld
|
||||||
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
|
void World::moveObject(const Ptr &ptr, CellStore &newCell, float x, float y, float z)
|
||||||
{
|
{
|
||||||
ESM::Position &pos = ptr.getRefData().getPosition();
|
ESM::Position &pos = ptr.getRefData().getPosition();
|
||||||
|
|
||||||
pos.pos[0] = x;
|
pos.pos[0] = x;
|
||||||
pos.pos[1] = y;
|
pos.pos[1] = y;
|
||||||
pos.pos[2] = z;
|
pos.pos[2] = z;
|
||||||
|
@ -718,7 +719,7 @@ namespace MWWorld
|
||||||
|
|
||||||
if (*currCell != newCell)
|
if (*currCell != newCell)
|
||||||
{
|
{
|
||||||
removeContainerScripts(ptr);
|
removeContainerScripts(ptr);
|
||||||
|
|
||||||
if (isPlayer)
|
if (isPlayer)
|
||||||
{
|
{
|
||||||
|
@ -750,7 +751,7 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWWorld::Ptr copy =
|
MWWorld::Ptr copy =
|
||||||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
MWWorld::Class::get(ptr).copyToCell(ptr, newCell, pos);
|
||||||
|
|
||||||
mRendering->updateObjectCell(ptr, copy);
|
mRendering->updateObjectCell(ptr, copy);
|
||||||
|
|
||||||
|
@ -780,12 +781,14 @@ namespace MWWorld
|
||||||
bool World::moveObjectImp(const Ptr& ptr, float x, float y, float z)
|
bool World::moveObjectImp(const Ptr& ptr, float x, float y, float z)
|
||||||
{
|
{
|
||||||
CellStore *cell = ptr.getCell();
|
CellStore *cell = ptr.getCell();
|
||||||
|
|
||||||
if (cell->isExterior()) {
|
if (cell->isExterior()) {
|
||||||
int cellX, cellY;
|
int cellX, cellY;
|
||||||
positionToIndex(x, y, cellX, cellY);
|
positionToIndex(x, y, cellX, cellY);
|
||||||
|
|
||||||
cell = getExterior(cellX, cellY);
|
cell = getExterior(cellX, cellY);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveObject(ptr, *cell, x, y, z);
|
moveObject(ptr, *cell, x, y, z);
|
||||||
|
|
||||||
return cell != ptr.getCell();
|
return cell != ptr.getCell();
|
||||||
|
@ -827,6 +830,19 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos (ptr.getRefData().getPosition().pos[0], ptr.getRefData().getPosition().pos[1], ptr.getRefData().getPosition().pos[2]);
|
Ogre::Vector3 pos (ptr.getRefData().getPosition().pos[0], ptr.getRefData().getPosition().pos[1], ptr.getRefData().getPosition().pos[2]);
|
||||||
|
|
||||||
|
if(!ptr.getRefData().getBaseNode())
|
||||||
|
{
|
||||||
|
// will be adjusted when Ptr's cell becomes active
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float terrainHeight = mRendering->getTerrainHeightAt(pos);
|
||||||
|
|
||||||
|
if (pos.z < terrainHeight)
|
||||||
|
pos.z = terrainHeight+400; // place slightly above. will snap down to ground with code below
|
||||||
|
|
||||||
|
ptr.getRefData().getPosition().pos[2] = pos.z;
|
||||||
|
|
||||||
if (!isFlying(ptr))
|
if (!isFlying(ptr))
|
||||||
{
|
{
|
||||||
Ogre::Vector3 traced = mPhysics->traceDown(ptr);
|
Ogre::Vector3 traced = mPhysics->traceDown(ptr);
|
||||||
|
@ -834,10 +850,6 @@ namespace MWWorld
|
||||||
pos.z = traced.z;
|
pos.z = traced.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
float terrainHeight = mRendering->getTerrainHeightAt(pos);
|
|
||||||
if (pos.z < terrainHeight)
|
|
||||||
pos.z = terrainHeight;
|
|
||||||
|
|
||||||
moveObject(ptr, pos.x, pos.y, pos.z);
|
moveObject(ptr, pos.x, pos.y, pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue