forked from mirror/openmw-tes3mp
Use a full Movement to hand off to the world physics update
This commit is contained in:
parent
0ce188b7cc
commit
466c0086b8
7 changed files with 29 additions and 12 deletions
|
@ -44,6 +44,11 @@ namespace MWRender
|
|||
class Animation;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class Movement;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Fallback;
|
||||
|
@ -54,7 +59,7 @@ namespace MWWorld
|
|||
class ESMStore;
|
||||
class RefData;
|
||||
|
||||
typedef std::vector<std::pair<MWWorld::Ptr,Ogre::Vector3> > PtrMovementList;
|
||||
typedef std::vector<std::pair<MWWorld::Ptr,MWMechanics::Movement> > PtrMovementList;
|
||||
}
|
||||
|
||||
namespace MWBase
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <OgreVector3.h>
|
||||
|
||||
#include "movement.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
|
@ -57,7 +59,7 @@ void Activators::update(float duration, bool paused)
|
|||
{
|
||||
for(PtrControllerMap::iterator iter(mActivators.begin());iter != mActivators.end();++iter)
|
||||
{
|
||||
Ogre::Vector3 movement(0.0f);
|
||||
Movement movement;
|
||||
iter->second.update(duration, movement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "creaturestats.hpp"
|
||||
#include "movement.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
@ -266,7 +267,7 @@ namespace MWMechanics
|
|||
|
||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
{
|
||||
Ogre::Vector3 movement(0.0f);
|
||||
Movement movement;
|
||||
iter->second.update(duration, movement);
|
||||
mMovement.push_back(std::make_pair(iter->first, movement));
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <map>
|
||||
|
||||
#include "character.hpp"
|
||||
#include "movement.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
namespace Ogre
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include <OgreStringConverter.h>
|
||||
|
||||
#include "movement.hpp"
|
||||
|
||||
#include "../mwrender/animation.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -168,7 +170,7 @@ void CharacterController::markerEvent(float time, const std::string &evt)
|
|||
}
|
||||
|
||||
|
||||
void CharacterController::update(float duration, Ogre::Vector3 &movement)
|
||||
void CharacterController::update(float duration, Movement &movement)
|
||||
{
|
||||
float speed = 0.0f;
|
||||
if(!(getState() >= CharState_Death1))
|
||||
|
@ -190,14 +192,14 @@ void CharacterController::update(float duration, Ogre::Vector3 &movement)
|
|||
float x = cls.getJump(mPtr);
|
||||
|
||||
if(vec.x == 0 && vec.y == 0)
|
||||
movement.z += x*duration;
|
||||
movement.mPosition[2] += x*duration;
|
||||
else
|
||||
{
|
||||
/* FIXME: this would be more correct if we were going into a jumping state,
|
||||
* rather than normal walking/idle states. */
|
||||
//Ogre::Vector3 lat = Ogre::Vector3(vec.x, vec.y, 0.0f).normalisedCopy();
|
||||
//movement += Ogre::Vector3(lat.x, lat.y, 1.0f) * x * 0.707f * duration;
|
||||
movement.z += x * 0.707f * duration;
|
||||
movement.mPosition[2] += x * 0.707f * duration;
|
||||
}
|
||||
|
||||
//decrease fatigue by fFatigueJumpBase + (1 - normalizedEncumbrance) * fFatigueJumpMult;
|
||||
|
@ -214,7 +216,7 @@ void CharacterController::update(float duration, Ogre::Vector3 &movement)
|
|||
: (sneak ? CharState_SneakLeft : (isrunning ? CharState_RunLeft : CharState_WalkLeft)), true);
|
||||
|
||||
// Apply any forward/backward movement manually
|
||||
movement.y += vec.y * (speed*duration);
|
||||
movement.mPosition[1] += vec.y * (speed*duration);
|
||||
}
|
||||
else if(vec.y != 0.0f && speed > 0.0f)
|
||||
{
|
||||
|
@ -226,7 +228,7 @@ void CharacterController::update(float duration, Ogre::Vector3 &movement)
|
|||
setState(inwater ? (isrunning ? CharState_SwimRunBack : CharState_SwimWalkBack)
|
||||
: (sneak ? CharState_SneakBack : (isrunning ? CharState_RunBack : CharState_WalkBack)), true);
|
||||
// Apply any sideways movement manually
|
||||
movement.x += vec.x * (speed*duration);
|
||||
movement.mPosition[0] += vec.x * (speed*duration);
|
||||
}
|
||||
else if(mAnimQueue.size() == 0)
|
||||
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
|
||||
|
@ -235,7 +237,10 @@ void CharacterController::update(float duration, Ogre::Vector3 &movement)
|
|||
if(mAnimation && !mSkipAnim)
|
||||
{
|
||||
mAnimation->setSpeed(speed);
|
||||
movement += mAnimation->runAnimation(duration);
|
||||
Ogre::Vector3 moved = mAnimation->runAnimation(duration);
|
||||
movement.mPosition[0] += moved.x;
|
||||
movement.mPosition[1] += moved.y;
|
||||
movement.mPosition[2] += moved.z;
|
||||
}
|
||||
mSkipAnim = false;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace MWRender
|
|||
namespace MWMechanics
|
||||
{
|
||||
|
||||
class Movement;
|
||||
|
||||
enum CharacterState {
|
||||
CharState_SpecialIdle,
|
||||
CharState_Idle,
|
||||
|
@ -87,7 +89,7 @@ public:
|
|||
|
||||
void updatePtr(const MWWorld::Ptr &ptr);
|
||||
|
||||
void update(float duration, Ogre::Vector3 &movement);
|
||||
void update(float duration, Movement &movement);
|
||||
|
||||
void playGroup(const std::string &groupname, int mode, int count);
|
||||
void skipAnim();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "../mwbase/scriptmanager.hpp"
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
|
||||
#include "../mwrender/sky.hpp"
|
||||
#include "../mwrender/player.hpp"
|
||||
|
@ -875,13 +876,13 @@ namespace MWWorld
|
|||
player = iter;
|
||||
continue;
|
||||
}
|
||||
Ogre::Vector3 vec = mPhysics->move(iter->first, iter->second, duration,
|
||||
Ogre::Vector3 vec = mPhysics->move(iter->first, Ogre::Vector3(iter->second.mPosition), duration,
|
||||
!isSwimming(iter->first) && !isFlying(iter->first));
|
||||
moveObjectImp(iter->first, vec.x, vec.y, vec.z);
|
||||
}
|
||||
if(player != actors.end())
|
||||
{
|
||||
Ogre::Vector3 vec = mPhysics->move(player->first, player->second, duration,
|
||||
Ogre::Vector3 vec = mPhysics->move(player->first, Ogre::Vector3(player->second.mPosition), duration,
|
||||
!isSwimming(player->first) && !isFlying(player->first));
|
||||
moveObjectImp(player->first, vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue