From fbec0d9443497d4124fdb1825b53cb0a24c83a85 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 4 Aug 2017 21:43:01 +0300 Subject: [PATCH] [Client] Remove inertia from players who are teleported via a packet --- apps/openmw/mwbase/world.hpp | 10 ++++++++++ apps/openmw/mwmp/LocalPlayer.cpp | 2 ++ apps/openmw/mwworld/worldimp.cpp | 13 +++++++++++++ apps/openmw/mwworld/worldimp.hpp | 10 ++++++++++ 4 files changed, 35 insertions(+) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 4070d76da..9a92f427e 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -297,6 +297,16 @@ namespace MWBase ///< Queues movement for \a ptr (in local space), to be applied in the next call to /// doPhysics. + /* + Start of tes3mp addition + + Make it possible to set the inertial force of a Ptr directly + */ + virtual void setInertialForce(const MWWorld::Ptr& ptr, const osg::Vec3f &force) = 0; + /* + End of tes3mp addition + */ + virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) = 0; ///< cast a Ray and return true if there is an object in the ray path. diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index ecd6cfdef..d09575267 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -801,8 +801,10 @@ void LocalPlayer::setPosition() else { world->getPlayer().setTeleported(true); + world->moveObject(ptrPlayer, position.pos[0], position.pos[1], position.pos[2]); world->rotateObject(ptrPlayer, position.rot[0], position.rot[1], position.rot[2]); + world->setInertialForce(ptrPlayer, osg::Vec3f(0.f, 0.f, 0.f)); } updatePosition(true); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 3ea887aa2..2e97e3ab7 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1512,6 +1512,19 @@ namespace MWWorld mPhysics->queueObjectMovement(ptr, velocity); } + /* + Start of tes3mp addition + + Make it possible to set the inertial force of a Ptr directly + */ + void World::setInertialForce(const Ptr& ptr, const osg::Vec3f &force) + { + mPhysics->getActor(ptr)->setInertialForce(force); + } + /* + End of tes3mp addition + */ + void World::doPhysics(float duration) { mPhysics->stepSimulation(duration); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 8dfa6b906..8fbcb88c2 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -398,6 +398,16 @@ namespace MWWorld ///< Queues movement for \a ptr (in local space), to be applied in the next call to /// doPhysics. + /* + Start of tes3mp addition + + Make it possible to set the inertial force of a Ptr directly + */ + void setInertialForce(const Ptr& ptr, const osg::Vec3f &force); + /* + End of tes3mp addition + */ + virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2); ///< cast a Ray and return true if there is an object in the ray path.