mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 16:45:34 +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();
|
updateRotation();
|
||||||
updateScale();
|
updateScale();
|
||||||
updatePosition();
|
resetPosition();
|
||||||
setPosition(mWorldPosition, true);
|
|
||||||
|
|
||||||
addCollisionMask(getCollisionMask());
|
addCollisionMask(getCollisionMask());
|
||||||
updateCollisionObjectPosition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor::~Actor()
|
Actor::~Actor()
|
||||||
|
@ -160,14 +157,8 @@ osg::Vec3f Actor::getCollisionObjectPosition() const
|
||||||
return Misc::Convert::toOsg(mLocalTransform.getOrigin());
|
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;
|
mPosition = position;
|
||||||
}
|
}
|
||||||
|
@ -178,6 +169,15 @@ void Actor::adjustPosition(const osg::Vec3f& offset)
|
||||||
mPreviousPosition += offset;
|
mPreviousPosition += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Actor::resetPosition()
|
||||||
|
{
|
||||||
|
updatePosition();
|
||||||
|
mPreviousPosition = mWorldPosition;
|
||||||
|
mPosition = mWorldPosition;
|
||||||
|
mNextPosition = mWorldPosition;
|
||||||
|
updateCollisionObjectPosition();
|
||||||
|
}
|
||||||
|
|
||||||
osg::Vec3f Actor::getPosition() const
|
osg::Vec3f Actor::getPosition() const
|
||||||
{
|
{
|
||||||
return mPosition;
|
return mPosition;
|
||||||
|
|
|
@ -91,7 +91,8 @@ namespace MWPhysics
|
||||||
/**
|
/**
|
||||||
* Store the current position into mPreviousPosition, then move to this position.
|
* 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);
|
void adjustPosition(const osg::Vec3f& offset);
|
||||||
|
|
||||||
osg::Vec3f getPosition() const;
|
osg::Vec3f getPosition() const;
|
||||||
|
|
|
@ -253,7 +253,7 @@ namespace MWPhysics
|
||||||
for (const auto& m : mActorsFrameData)
|
for (const auto& m : mActorsFrameData)
|
||||||
{
|
{
|
||||||
m.mActorRaw->setStandingOnPtr(nullptr);
|
m.mActorRaw->setStandingOnPtr(nullptr);
|
||||||
m.mActorRaw->setPosition(m.mActorRaw->getWorldPosition(), true);
|
m.mActorRaw->resetPosition();
|
||||||
mMovementResults[m.mPtr] = m.mActorRaw->getWorldPosition();
|
mMovementResults[m.mPtr] = m.mActorRaw->getWorldPosition();
|
||||||
}
|
}
|
||||||
return mMovementResults;
|
return mMovementResults;
|
||||||
|
|
|
@ -433,7 +433,7 @@ namespace MWPhysics
|
||||||
ActorMap::iterator found = mActors.find(ptr);
|
ActorMap::iterator found = mActors.find(ptr);
|
||||||
if (found == mActors.end())
|
if (found == mActors.end())
|
||||||
return ptr.getRefData().getPosition().asVec3();
|
return ptr.getRefData().getPosition().asVec3();
|
||||||
else
|
found->second->resetPosition();
|
||||||
return MovementSolver::traceDown(ptr, position, found->second.get(), mCollisionWorld.get(), maxHeight);
|
return MovementSolver::traceDown(ptr, position, found->second.get(), mCollisionWorld.get(), maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue