mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-27 06:55:54 -04:00
[Client] Add linear interpolation for DedicatedActors
This commit is contained in:
parent
2eaa25e7d4
commit
284f863292
@ -62,13 +62,13 @@ void Cell::updateLocal(bool forceUpdate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actorList->sendCellChangeActors();
|
||||||
actorList->sendPositionActors();
|
actorList->sendPositionActors();
|
||||||
actorList->sendAnimFlagsActors();
|
actorList->sendAnimFlagsActors();
|
||||||
actorList->sendAnimPlayActors();
|
actorList->sendAnimPlayActors();
|
||||||
actorList->sendSpeechActors();
|
actorList->sendSpeechActors();
|
||||||
actorList->sendStatsDynamicActors();
|
actorList->sendStatsDynamicActors();
|
||||||
actorList->sendAttackActors();
|
actorList->sendAttackActors();
|
||||||
actorList->sendCellChangeActors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cell::updateDedicated(float dt)
|
void Cell::updateDedicated(float dt)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "DedicatedActor.hpp"
|
#include "DedicatedActor.hpp"
|
||||||
#include "Main.hpp"
|
#include "Main.hpp"
|
||||||
#include "CellController.hpp"
|
#include "CellController.hpp"
|
||||||
|
#include "MechanicsHelper.hpp"
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -31,6 +32,8 @@ DedicatedActor::DedicatedActor()
|
|||||||
creatureStats = new ESM::CreatureStats();
|
creatureStats = new ESM::CreatureStats();
|
||||||
creatureStats->blank();
|
creatureStats->blank();
|
||||||
creatureStats->mDynamic[0].mBase = -1;
|
creatureStats->mDynamic[0].mBase = -1;
|
||||||
|
|
||||||
|
hasChangedCell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DedicatedActor::~DedicatedActor()
|
DedicatedActor::~DedicatedActor()
|
||||||
@ -52,13 +55,32 @@ void DedicatedActor::setCell(MWWorld::CellStore *cellStore)
|
|||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
ptr = world->moveObject(ptr, cellStore, position.pos[0], position.pos[1], position.pos[2]);
|
ptr = world->moveObject(ptr, cellStore, position.pos[0], position.pos[1], position.pos[2]);
|
||||||
|
|
||||||
|
hasChangedCell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DedicatedActor::move(float dt)
|
void DedicatedActor::move(float dt)
|
||||||
{
|
{
|
||||||
|
ESM::Position refPos = ptr.getRefData().getPosition();
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
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);
|
MWMechanics::Movement *move = &ptr.getClass().getMovementSettings(ptr);
|
||||||
move->mPosition[0] = direction.pos[0];
|
move->mPosition[0] = direction.pos[0];
|
||||||
|
@ -27,6 +27,8 @@ namespace mwmp
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MWWorld::Ptr ptr;
|
MWWorld::Ptr ptr;
|
||||||
|
|
||||||
|
bool hasChangedCell;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user