mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Make the code more compact by mean of std::min / max and ternary
operator.
This commit is contained in:
parent
b79f6ac808
commit
08e73a09ec
@ -1332,22 +1332,15 @@ namespace MWWorld
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float terrainHeight = -std::numeric_limits<float>::max();
|
const float terrainHeight = ptr.getCell()->isExterior() ? getTerrainHeightAt(pos) : -std::numeric_limits<float>::max();
|
||||||
if (ptr.getCell()->isExterior())
|
pos.z() = std::max(pos.z(), terrainHeight + 20); // place slightly above terrain. will snap down to ground with code below
|
||||||
terrainHeight = getTerrainHeightAt(pos);
|
|
||||||
|
|
||||||
if (pos.z() < terrainHeight)
|
|
||||||
pos.z() = terrainHeight;
|
|
||||||
|
|
||||||
pos.z() += 20; // place slightly above. will snap down to ground with code below
|
|
||||||
|
|
||||||
// We still should trace down dead persistent actors - they do not use the "swimdeath" animation.
|
// We still should trace down dead persistent actors - they do not use the "swimdeath" animation.
|
||||||
bool swims = ptr.getClass().isActor() && isSwimming(ptr) && !(ptr.getClass().isPersistent(ptr) && ptr.getClass().getCreatureStats(ptr).isDeathAnimationFinished());
|
bool swims = ptr.getClass().isActor() && isSwimming(ptr) && !(ptr.getClass().isPersistent(ptr) && ptr.getClass().getCreatureStats(ptr).isDeathAnimationFinished());
|
||||||
if (force || !ptr.getClass().isActor() || (!isFlying(ptr) && !swims && isActorCollisionEnabled(ptr)))
|
if (force || !ptr.getClass().isActor() || (!isFlying(ptr) && !swims && isActorCollisionEnabled(ptr)))
|
||||||
{
|
{
|
||||||
osg::Vec3f traced = mPhysics->traceDown(ptr, pos, Constants::CellSizeInUnits);
|
osg::Vec3f traced = mPhysics->traceDown(ptr, pos, Constants::CellSizeInUnits);
|
||||||
if (traced.z() < pos.z())
|
pos.z() = std::min(pos.z(), traced.z());
|
||||||
pos.z() = traced.z();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
moveObject(ptr, ptr.getCell(), pos.x(), pos.y(), pos.z());
|
moveObject(ptr, ptr.getCell(), pos.x(), pos.y(), pos.z());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user