From ca44b3640a747536221118d48139a0d03d9696aa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 1 Feb 2011 10:11:41 +0100 Subject: [PATCH] pasing movement data from mwmechanics to mwscene and fixed a very stupid interface bug --- apps/openmw/engine.cpp | 7 +++++-- apps/openmw/mwmechanics/mechanicsmanager.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanager.hpp | 11 +++++++++-- apps/openmw/mwrender/mwscene.cpp | 2 +- apps/openmw/mwrender/mwscene.hpp | 2 +- apps/openmw/mwworld/world.cpp | 4 +++- apps/openmw/mwworld/world.hpp | 8 +++++++- 7 files changed, 27 insertions(+), 9 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2f0d52772..5c3da5d2b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include "components/esm/records.hpp" #include #include @@ -158,7 +160,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) mEnvironment.mWorld->markCellAsUnchanged(); // update actors - mEnvironment.mMechanicsManager->update(); + std::vector > 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) { diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index 05219d6aa..c2cb8218f 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -255,7 +255,7 @@ namespace MWMechanics mWatched = ptr; } - void MechanicsManager::update() + void MechanicsManager::update (std::vector >& movement) { if (!mWatched.isEmpty()) { diff --git a/apps/openmw/mwmechanics/mechanicsmanager.hpp b/apps/openmw/mwmechanics/mechanicsmanager.hpp index 26d3621ab..2e2192638 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.hpp @@ -2,12 +2,19 @@ #define GAME_MWMECHANICS_MECHANICSMANAGER_H #include +#include +#include #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 >& movement); + ///< Update actor stats and store desired velocity vectors in \a movement void setPlayerName (const std::string& name); ///< Set player name. diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index 6a0920b94..7eb50693f 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -106,7 +106,7 @@ void MWScene::doPhysics (float duration, MWWorld::World& world) } -void MWScene::setMovement (const std::vector& actors) +void MWScene::setMovement (const std::vector >& actors) { } diff --git a/apps/openmw/mwrender/mwscene.hpp b/apps/openmw/mwrender/mwscene.hpp index e408738af..d98aa6fb4 100644 --- a/apps/openmw/mwrender/mwscene.hpp +++ b/apps/openmw/mwrender/mwscene.hpp @@ -64,7 +64,7 @@ namespace MWRender /// Inform phyiscs system about desired velocity vectors for actors /// (in Morrowind coordinates). - void setMovement (const std::vector& actors); + void setMovement (const std::vector >& actors); /// Add object to physics system. void addObject (const std::string& handle, const std::string& mesh, diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 38e553286..d67cc1459 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -834,8 +834,10 @@ namespace MWWorld --cellY; } - void World::doPhysics (float duration) + void World::doPhysics (const std::vector >& actors, + float duration) { + mScene.setMovement (actors); mScene.doPhysics (duration, *this); } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index e44bdf27c..6930589f4 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -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 >& actors, + float duration); ///< Run physics simulation and modify \a world accordingly. }; }