diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index 29cf1f5ef..72aaae89f 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -62,13 +62,13 @@ void Cell::updateLocal(bool forceUpdate) } } + actorList->sendCellChangeActors(); actorList->sendPositionActors(); actorList->sendAnimFlagsActors(); actorList->sendAnimPlayActors(); actorList->sendSpeechActors(); actorList->sendStatsDynamicActors(); actorList->sendAttackActors(); - actorList->sendCellChangeActors(); } void Cell::updateDedicated(float dt) diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index b82507a19..003d4ea52 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -17,6 +17,7 @@ #include "DedicatedActor.hpp" #include "Main.hpp" #include "CellController.hpp" +#include "MechanicsHelper.hpp" using namespace mwmp; using namespace std; @@ -31,6 +32,8 @@ DedicatedActor::DedicatedActor() creatureStats = new ESM::CreatureStats(); creatureStats->blank(); creatureStats->mDynamic[0].mBase = -1; + + hasChangedCell = true; } DedicatedActor::~DedicatedActor() @@ -52,13 +55,32 @@ void DedicatedActor::setCell(MWWorld::CellStore *cellStore) MWBase::World *world = MWBase::Environment::get().getWorld(); ptr = world->moveObject(ptr, cellStore, position.pos[0], position.pos[1], position.pos[2]); + + hasChangedCell = true; } void DedicatedActor::move(float dt) { + ESM::Position refPos = ptr.getRefData().getPosition(); MWBase::World *world = MWBase::Environment::get().getWorld(); - world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]); + // Don't apply linear interpolation if the DedicatedActor has just gone through a cell change, because + // the interpolated position will be invalid, causing a slight hopping glitch + if (!hasChangedCell) + { + static const int timeMultiplier = 15; + osg::Vec3f lerp = Main::get().getMechanicsHelper()->getLinearInterpolation(refPos.asVec3(), position.asVec3(), dt * timeMultiplier); + refPos.pos[0] = lerp.x(); + refPos.pos[1] = lerp.y(); + refPos.pos[2] = lerp.z(); + + world->moveObject(ptr, refPos.pos[0], refPos.pos[1], refPos.pos[2]); + } + else + { + world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]); + hasChangedCell = false; + } MWMechanics::Movement *move = &ptr.getClass().getMovementSettings(ptr); move->mPosition[0] = direction.pos[0]; diff --git a/apps/openmw/mwmp/DedicatedActor.hpp b/apps/openmw/mwmp/DedicatedActor.hpp index 7dc5c67c0..d2623c543 100644 --- a/apps/openmw/mwmp/DedicatedActor.hpp +++ b/apps/openmw/mwmp/DedicatedActor.hpp @@ -27,6 +27,8 @@ namespace mwmp private: MWWorld::Ptr ptr; + + bool hasChangedCell; }; }