mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
Avoid null dereference for objects without cells
This commit is contained in:
parent
d984d13b1c
commit
3b9f8b5fa2
1 changed files with 12 additions and 0 deletions
|
@ -1337,6 +1337,12 @@ namespace MWWorld
|
||||||
|
|
||||||
void World::adjustPosition(const Ptr &ptr, bool force)
|
void World::adjustPosition(const Ptr &ptr, bool force)
|
||||||
{
|
{
|
||||||
|
if (ptr.isEmpty())
|
||||||
|
{
|
||||||
|
Log(Debug::Warning) << "Unable to adjust position for empty object";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
osg::Vec3f pos (ptr.getRefData().getPosition().asVec3());
|
osg::Vec3f pos (ptr.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
if(!ptr.getRefData().getBaseNode())
|
if(!ptr.getRefData().getBaseNode())
|
||||||
|
@ -1345,6 +1351,12 @@ namespace MWWorld
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ptr.isInCell())
|
||||||
|
{
|
||||||
|
Log(Debug::Warning) << "Unable to adjust position for object '" << ptr.getCellRef().getRefId() << "' - it has no cell";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const float terrainHeight = ptr.getCell()->isExterior() ? getTerrainHeightAt(pos) : -std::numeric_limits<float>::max();
|
const float terrainHeight = ptr.getCell()->isExterior() ? getTerrainHeightAt(pos) : -std::numeric_limits<float>::max();
|
||||||
pos.z() = std::max(pos.z(), terrainHeight) + 20; // place slightly above terrain. will snap down to ground with code below
|
pos.z() = std::max(pos.z(), terrainHeight) + 20; // place slightly above terrain. will snap down to ground with code below
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue