pasing movement data from mwmechanics to mwscene and fixed a very stupid interface bug

actorid
Marc Zinnschlag 14 years ago
parent 40d772b33a
commit ca44b3640a

@ -6,6 +6,8 @@
#include <iostream>
#include <utility>
#include <OgreVector3.h>
#include "components/esm/records.hpp"
#include <components/esm_store/cell_store.hpp>
#include <components/misc/fileops.hpp>
@ -158,7 +160,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
mEnvironment.mWorld->markCellAsUnchanged();
// update actors
mEnvironment.mMechanicsManager->update();
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
mEnvironment.mMechanicsManager->update (movement);
if (focusFrameCounter++ == focusUpdateFrame)
{
@ -180,7 +183,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
focusFrameCounter = 0;
}
mEnvironment.mWorld->doPhysics (mEnvironment.mFrameDuration);
mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration);
}
catch (const std::exception& e)
{

@ -255,7 +255,7 @@ namespace MWMechanics
mWatched = ptr;
}
void MechanicsManager::update()
void MechanicsManager::update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement)
{
if (!mWatched.isEmpty())
{

@ -2,12 +2,19 @@
#define GAME_MWMECHANICS_MECHANICSMANAGER_H
#include <set>
#include <vector>
#include <string>
#include "../mwworld/ptr.hpp"
#include "creaturestats.hpp"
#include "npcstats.hpp"
namespace Ogre
{
class Vector3;
}
namespace MWWorld
{
class Environment;
@ -53,8 +60,8 @@ namespace MWMechanics
///< On each update look for changes in a previously registered actor and update the
/// GUI accordingly.
void update();
///< Update actor stats
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement);
///< Update actor stats and store desired velocity vectors in \a movement
void setPlayerName (const std::string& name);
///< Set player name.

@ -106,7 +106,7 @@ void MWScene::doPhysics (float duration, MWWorld::World& world)
}
void MWScene::setMovement (const std::vector<std::string, Ogre::Vector3>& actors)
void MWScene::setMovement (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
{
}

@ -64,7 +64,7 @@ namespace MWRender
/// Inform phyiscs system about desired velocity vectors for actors
/// (in Morrowind coordinates).
void setMovement (const std::vector<std::string, Ogre::Vector3>& actors);
void setMovement (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors);
/// Add object to physics system.
void addObject (const std::string& handle, const std::string& mesh,

@ -834,8 +834,10 @@ namespace MWWorld
--cellY;
}
void World::doPhysics (float duration)
void World::doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
float duration)
{
mScene.setMovement (actors);
mScene.doPhysics (duration, *this);
}
}

@ -14,6 +14,11 @@
#include "ptr.hpp"
#include "globals.hpp"
namespace Ogre
{
class Vector3;
}
namespace ESM
{
struct Position;
@ -163,7 +168,8 @@ namespace MWWorld
void positionToIndex (float x, float y, int &cellX, int &cellY) const;
///< Convert position to cell numbers
void doPhysics (float duration);
void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
float duration);
///< Run physics simulation and modify \a world accordingly.
};
}

Loading…
Cancel
Save