mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 14:45:37 +00:00
Use bigger hammer to set Actor's position after teleporting. Otherwise traceDown() would use old collision object transform and gives incorrect results, making the Actor "fall" in the new position.
This commit is contained in:
parent
0a566dbce7
commit
bb5213670c
4 changed files with 17 additions and 16 deletions
|
@ -74,11 +74,8 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
|
|||
|
||||
updateRotation();
|
||||
updateScale();
|
||||
updatePosition();
|
||||
setPosition(mWorldPosition, true);
|
||||
|
||||
resetPosition();
|
||||
addCollisionMask(getCollisionMask());
|
||||
updateCollisionObjectPosition();
|
||||
}
|
||||
|
||||
Actor::~Actor()
|
||||
|
@ -160,15 +157,9 @@ osg::Vec3f Actor::getCollisionObjectPosition() const
|
|||
return Misc::Convert::toOsg(mLocalTransform.getOrigin());
|
||||
}
|
||||
|
||||
void Actor::setPosition(const osg::Vec3f& position, bool reset)
|
||||
void Actor::setPosition(const osg::Vec3f& position)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
mPreviousPosition = position;
|
||||
mNextPosition = position;
|
||||
}
|
||||
else
|
||||
mPreviousPosition = mPosition;
|
||||
mPreviousPosition = mPosition;
|
||||
mPosition = position;
|
||||
}
|
||||
|
||||
|
@ -178,6 +169,15 @@ void Actor::adjustPosition(const osg::Vec3f& offset)
|
|||
mPreviousPosition += offset;
|
||||
}
|
||||
|
||||
void Actor::resetPosition()
|
||||
{
|
||||
updatePosition();
|
||||
mPreviousPosition = mWorldPosition;
|
||||
mPosition = mWorldPosition;
|
||||
mNextPosition = mWorldPosition;
|
||||
updateCollisionObjectPosition();
|
||||
}
|
||||
|
||||
osg::Vec3f Actor::getPosition() const
|
||||
{
|
||||
return mPosition;
|
||||
|
|
|
@ -91,7 +91,8 @@ namespace MWPhysics
|
|||
/**
|
||||
* Store the current position into mPreviousPosition, then move to this position.
|
||||
*/
|
||||
void setPosition(const osg::Vec3f& position, bool reset=false);
|
||||
void setPosition(const osg::Vec3f& position);
|
||||
void resetPosition();
|
||||
void adjustPosition(const osg::Vec3f& offset);
|
||||
|
||||
osg::Vec3f getPosition() const;
|
||||
|
|
|
@ -253,7 +253,7 @@ namespace MWPhysics
|
|||
for (const auto& m : mActorsFrameData)
|
||||
{
|
||||
m.mActorRaw->setStandingOnPtr(nullptr);
|
||||
m.mActorRaw->setPosition(m.mActorRaw->getWorldPosition(), true);
|
||||
m.mActorRaw->resetPosition();
|
||||
mMovementResults[m.mPtr] = m.mActorRaw->getWorldPosition();
|
||||
}
|
||||
return mMovementResults;
|
||||
|
|
|
@ -433,8 +433,8 @@ namespace MWPhysics
|
|||
ActorMap::iterator found = mActors.find(ptr);
|
||||
if (found == mActors.end())
|
||||
return ptr.getRefData().getPosition().asVec3();
|
||||
else
|
||||
return MovementSolver::traceDown(ptr, position, found->second.get(), mCollisionWorld.get(), maxHeight);
|
||||
found->second->resetPosition();
|
||||
return MovementSolver::traceDown(ptr, position, found->second.get(), mCollisionWorld.get(), maxHeight);
|
||||
}
|
||||
|
||||
void PhysicsSystem::addHeightField (const float* heights, int x, int y, float triSize, float sqrtVerts, float minH, float maxH, const osg::Object* holdObject)
|
||||
|
|
Loading…
Reference in a new issue