mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Merge branch 'fix_spawn' into 'master'
Fix spawn #5724 See merge request OpenMW/openmw!439
This commit is contained in:
commit
b22418d053
@ -1332,25 +1332,20 @@ 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());
|
||||||
|
if (force) // force physics to use the new position
|
||||||
|
mPhysics->getActor(ptr)->resetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::fixPosition()
|
void World::fixPosition()
|
||||||
@ -1449,17 +1444,11 @@ namespace MWWorld
|
|||||||
ipos.pos[1] = spawnPoint.y();
|
ipos.pos[1] = spawnPoint.y();
|
||||||
ipos.pos[2] = spawnPoint.z();
|
ipos.pos[2] = spawnPoint.z();
|
||||||
|
|
||||||
if (!referenceObject.getClass().isActor())
|
if (referenceObject.getClass().isActor())
|
||||||
{
|
|
||||||
ipos.rot[0] = referenceObject.getRefData().getPosition().rot[0];
|
|
||||||
ipos.rot[1] = referenceObject.getRefData().getPosition().rot[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ipos.rot[0] = 0;
|
ipos.rot[0] = 0;
|
||||||
ipos.rot[1] = 0;
|
ipos.rot[1] = 0;
|
||||||
}
|
}
|
||||||
ipos.rot[2] = referenceObject.getRefData().getPosition().rot[2];
|
|
||||||
|
|
||||||
MWWorld::Ptr placed = copyObjectToCell(ptr, referenceCell, ipos, ptr.getRefData().getCount(), false);
|
MWWorld::Ptr placed = copyObjectToCell(ptr, referenceCell, ipos, ptr.getRefData().getCount(), false);
|
||||||
adjustPosition(placed, true); // snap to ground
|
adjustPosition(placed, true); // snap to ground
|
||||||
|
Loading…
x
Reference in New Issue
Block a user