forked from mirror/openmw-tes3mp
[Client] Update DedicatedActors every frame to allow interpolation
This commit is contained in:
parent
ae92117d21
commit
1101ff1e28
7 changed files with 37 additions and 15 deletions
|
@ -68,6 +68,18 @@ void Cell::updateLocal()
|
||||||
Main::get().getNetworking()->getWorldPacket(ID_ACTOR_FRAME)->Send();
|
Main::get().getNetworking()->getWorldPacket(ID_ACTOR_FRAME)->Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cell::updateDedicated(float dt)
|
||||||
|
{
|
||||||
|
if (dedicatedActors.empty()) return;
|
||||||
|
|
||||||
|
for (std::map<std::string, DedicatedActor *>::iterator it = dedicatedActors.begin(); it != dedicatedActors.end(); ++it)
|
||||||
|
{
|
||||||
|
DedicatedActor *actor = it->second;
|
||||||
|
|
||||||
|
actor->update(dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Cell::initializeLocalActors()
|
void Cell::initializeLocalActors()
|
||||||
{
|
{
|
||||||
ESM::Cell esmCell = *store->getCell();
|
ESM::Cell esmCell = *store->getCell();
|
||||||
|
@ -137,12 +149,6 @@ void Cell::readCellFrame(WorldEvent& worldEvent)
|
||||||
actor->direction = worldObject.direction;
|
actor->direction = worldObject.direction;
|
||||||
actor->drawState = worldObject.drawState;
|
actor->drawState = worldObject.drawState;
|
||||||
actor->movementFlags = worldObject.movementFlags;
|
actor->movementFlags = worldObject.movementFlags;
|
||||||
actor->headPitch = worldObject.headPitch;
|
|
||||||
actor->headYaw = worldObject.headYaw;
|
|
||||||
actor->move();
|
|
||||||
actor->setDrawState();
|
|
||||||
actor->setMovementFlags();
|
|
||||||
actor->setAnimation();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace mwmp
|
||||||
~Cell();
|
~Cell();
|
||||||
|
|
||||||
void updateLocal();
|
void updateLocal();
|
||||||
|
void updateDedicated(float dt);
|
||||||
void initializeLocalActors();
|
void initializeLocalActors();
|
||||||
void uninitializeLocalActors();
|
void uninitializeLocalActors();
|
||||||
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
||||||
|
|
|
@ -45,6 +45,14 @@ void CellController::updateLocal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CellController::updateDedicated(float dt)
|
||||||
|
{
|
||||||
|
for (std::map<std::string, mwmp::Cell *>::iterator it = cellsActive.begin(); it != cellsActive.end(); ++it)
|
||||||
|
{
|
||||||
|
it->second->updateDedicated(dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CellController::initializeCellLocal(const ESM::Cell& cell)
|
void CellController::initializeCellLocal(const ESM::Cell& cell)
|
||||||
{
|
{
|
||||||
MWWorld::CellStore *cellStore = getCell(cell);
|
MWWorld::CellStore *cellStore = getCell(cell);
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace mwmp
|
||||||
~CellController();
|
~CellController();
|
||||||
|
|
||||||
void updateLocal();
|
void updateLocal();
|
||||||
|
void updateDedicated(float dt);
|
||||||
|
|
||||||
void initializeCellLocal(const ESM::Cell& cell);
|
void initializeCellLocal(const ESM::Cell& cell);
|
||||||
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwmechanics/mechanicsmanagerimp.hpp"
|
||||||
#include "../mwmechanics/movement.hpp"
|
#include "../mwmechanics/movement.hpp"
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
#include "../mwrender/animation.hpp"
|
#include "../mwrender/animation.hpp"
|
||||||
|
@ -20,21 +21,24 @@ DedicatedActor::~DedicatedActor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DedicatedActor::update()
|
void DedicatedActor::update(float dt)
|
||||||
{
|
{
|
||||||
|
move(dt);
|
||||||
|
setDrawState();
|
||||||
|
setMovementFlags();
|
||||||
|
setAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DedicatedActor::move()
|
void DedicatedActor::move(float dt)
|
||||||
{
|
{
|
||||||
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]);
|
world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]);
|
||||||
|
|
||||||
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];
|
||||||
move->mPosition[1] = direction.pos[1];
|
move.mPosition[1] = direction.pos[1];
|
||||||
move->mPosition[2] = direction.pos[2];
|
move.mPosition[2] = direction.pos[2];
|
||||||
|
|
||||||
world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]);
|
world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace mwmp
|
||||||
DedicatedActor();
|
DedicatedActor();
|
||||||
virtual ~DedicatedActor();
|
virtual ~DedicatedActor();
|
||||||
|
|
||||||
void update();
|
void update(float dt);
|
||||||
void move();
|
void move(float dt);
|
||||||
void setDrawState();
|
void setDrawState();
|
||||||
void setMovementFlags();
|
void setMovementFlags();
|
||||||
void setAnimation();
|
void setAnimation();
|
||||||
|
|
|
@ -182,6 +182,7 @@ void Main::frame(float dt)
|
||||||
get().getNetworking()->update();
|
get().getNetworking()->update();
|
||||||
|
|
||||||
Players::update(dt);
|
Players::update(dt);
|
||||||
|
get().getCellController()->updateDedicated(dt);
|
||||||
get().updateWorld(dt);
|
get().updateWorld(dt);
|
||||||
|
|
||||||
get().getGUIController()->update(dt);
|
get().getGUIController()->update(dt);
|
||||||
|
|
Loading…
Reference in a new issue