Do not allow to place actors underground via SetPos (bug #3783)

This commit is contained in:
Andrei Kortunov 2017-12-10 14:38:02 +04:00
parent 9cee439e37
commit c908ad2fba

View file

@ -227,6 +227,17 @@ namespace MWScript
}
else if(axis == "z")
{
// We should not place actors under ground
if (ptr.getClass().isActor())
{
float terrainHeight = -std::numeric_limits<float>::max();
if (ptr.getCell()->isExterior())
terrainHeight = MWBase::Environment::get().getWorld()->getTerrainHeightAt(osg::Vec3f(ax, ay, az));
if (pos < terrainHeight)
pos = terrainHeight;
}
updated = MWBase::Environment::get().getWorld()->moveObject(ptr,ax,ay,pos);
}
else