From 16bc374921a8480625fccf3b0660b208ff760a3d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Jan 2012 14:33:06 +0100 Subject: [PATCH 1/3] animation updates were hooked up to the wrong update function --- apps/openmw/engine.cpp | 7 +++++-- apps/openmw/mwrender/actors.cpp | 21 ++++++++------------- apps/openmw/mwrender/actors.hpp | 8 ++++---- apps/openmw/mwrender/renderingmanager.cpp | 6 +----- apps/openmw/mwrender/renderingmanager.hpp | 4 +--- apps/openmw/mwworld/scene.cpp | 12 ++++++------ apps/openmw/mwworld/scene.hpp | 3 ++- apps/openmw/mwworld/world.cpp | 8 ++++++-- apps/openmw/mwworld/world.hpp | 2 ++ 9 files changed, 35 insertions(+), 36 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index e1a16accf..ee3a6181a 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -147,7 +147,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) mEnvironment.mWorld->advanceTime ( mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600); - + if (changed) // keep change flag for another frame, if cell changed happend in local script mEnvironment.mWorld->markCellAsUnchanged(); @@ -158,6 +158,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game) mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration); + // update world + mEnvironment.mWorld->update (evt.timeSinceLastFrame); + // report focus object (for debugging) if (mReportFocus) updateFocusReport (mEnvironment.mFrameDuration); @@ -343,7 +346,7 @@ void OMW::Engine::go() // Set up the GUI system mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, mCfgMgr.getLogPath().string() + std::string("/")); - + // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 3b94b19f7..acc655404 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -12,15 +12,11 @@ void Actors::setMwRoot(Ogre::SceneNode* root){ mMwRoot = root; } void Actors::insertNPC(const MWWorld::Ptr& ptr){ - + insertBegin(ptr, true, true); NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend); - - // - - mAllActors[ptr] = anim; - - + + mAllActors[ptr] = anim; } void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ Ogre::SceneNode* cellnode; @@ -61,7 +57,7 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ } void Actors::insertCreature (const MWWorld::Ptr& ptr){ - + insertBegin(ptr, true, true); CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend); //mAllActors.insert(std::pair(ptr,anim)); @@ -75,7 +71,7 @@ bool Actors::deleteObject (const MWWorld::Ptr& ptr) mAllActors.erase(ptr); if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode()) { - + Ogre::SceneNode *parent = base->getParentSceneNode(); for (std::map::const_iterator iter ( @@ -110,7 +106,7 @@ void Actors::removeCell(MWWorld::Ptr::CellStore* store){ mAllActors.erase(iter); } } - + } void Actors::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number){ @@ -121,10 +117,9 @@ void Actors::skipAnimation (const MWWorld::Ptr& ptr){ if(mAllActors.find(ptr) != mAllActors.end()) mAllActors[ptr]->stopScript(); } -void Actors::addTime(){ - //std::cout << "Adding time in actors\n"; +void Actors::update (float duration){ for(std::map::iterator iter = mAllActors.begin(); iter != mAllActors.end(); iter++) { - (iter->second)->runAnimation(mEnvironment.mFrameDuration); + (iter->second)->runAnimation(duration); } } diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 93ec07f98..7179c08fb 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -26,7 +26,7 @@ namespace MWRender{ MWWorld::Environment& mEnvironment; std::map mAllActors; - + public: Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){} @@ -52,8 +52,8 @@ namespace MWRender{ ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - void addTime(); - + void update (float duration); + }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 6215c1913..c5cf8be5d 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -121,7 +121,7 @@ void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Ve void RenderingManager::update (float duration){ - + mActors.update (duration); } void RenderingManager::skyEnable () @@ -240,9 +240,5 @@ void RenderingManager::skipAnimation (const MWWorld::Ptr& ptr) { mActors.skipAnimation(ptr); } -void RenderingManager::addTime(){ - mActors.addTime(); - //Notify each animation that time has passed -} } diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 747a3e0ee..084f89cb0 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -105,14 +105,12 @@ class RenderingManager: private RenderingInterface { ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - void addTime(); - private: void setAmbientMode(); SkyManager* mSkyManager; OEngine::Render::OgreRenderer &mRendering; - + MWRender::Objects mObjects; MWRender::Actors mActors; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index b08a52aac..2f0d33c97 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -52,8 +52,8 @@ void insertCellRefList(MWRender::RenderingManager& rendering, MWWorld::Environme namespace MWWorld { - void Scene::advanceTime(){ - mRendering.addTime(); + void Scene::update (float duration){ + mRendering.update (duration); } void Scene::unloadCell (CellStoreCollection::iterator iter) { @@ -61,9 +61,9 @@ namespace MWWorld ListHandles functor; MWWorld::Ptr::CellStore* active = *iter; - - - + + + active->forEach(functor); @@ -83,7 +83,7 @@ namespace MWWorld mEnvironment.mMechanicsManager->dropActors (active); mEnvironment.mSoundManager->stopSound (active); mActiveCells.erase(active); - + } void Scene::loadCell (Ptr::CellStore *cell) diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index d3df7c0f5..4d1bd6fb5 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -101,7 +101,8 @@ namespace MWWorld void markCellAsUnchanged(); void insertCell(ESMS::CellStore &cell, MWWorld::Environment& environment); - void advanceTime(); + + void update (float duration); }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 2232e8a1d..ce66861b8 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -348,14 +348,13 @@ namespace MWWorld void World::advanceTime (double hours) { hours += mGlobalVariables->getFloat ("gamehour"); - + setHour (hours); int days = hours / 24; if (days>0) mGlobalVariables->setInt ("dayspassed", days + mGlobalVariables->getInt ("dayspassed")); - mWorldScene->advanceTime(); } void World::setHour (double hour) @@ -691,4 +690,9 @@ namespace MWWorld void World::setObjectPhysicsPosition(const std::string& handle, Ogre::Vector3 vec){ mPhysics->moveObject(handle, vec); } + + void World::update (float duration) + { + mWorldScene->update (duration); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 235d203a6..a3daa16da 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -220,6 +220,8 @@ namespace MWWorld /// references that are currently not in the rendered scene should be ignored. void setObjectPhysicsRotation(const std::string& handle,Ogre::Quaternion quat); void setObjectPhysicsPosition(const std::string& handle,Ogre::Vector3 vector); + + void update (float duration); }; } From 26c328e73f8da4866105a7a7a0ac4429f4f09113 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Jan 2012 14:55:00 +0100 Subject: [PATCH 2/3] added some more comments to avoid further confusion --- apps/openmw/mwworld/world.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index a3daa16da..22860b883 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -140,12 +140,16 @@ namespace MWWorld void disable (Ptr reference); void advanceTime (double hours); + ///< Advance in-game time. void setHour (double hour); + ///< Set in-game time hour. void setMonth (int month); + ///< Set in-game time month. void setDay (int day); + ///< Set in-game time day. bool toggleSky(); ///< \return Resulting mode From 4b6cd582a7b2562a2c436981654f02c1960b51de Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 24 Jan 2012 10:45:40 +0100 Subject: [PATCH 3/3] removed some redundant (and misplaced) functions --- apps/openmw/mwrender/npcanimation.cpp | 18 +----------------- apps/openmw/mwworld/world.cpp | 6 ------ apps/openmw/mwworld/world.hpp | 2 -- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index ef5c10559..863f7577b 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -269,22 +269,6 @@ void NpcAnimation::runAnimation(float timepassed){ handleAnimationTransforms(); Ogre::Vector3 current = insert->_getWorldAABB().getCenter(); - //This is the attempt at npc physics - //mEnvironment.mWorld->setObjectPhysicsPosition(insert->getName(), current); - - - - /*if(base->hasSkeleton()) - { - - Ogre::Quaternion boneQuat = rotate; - Ogre::Vector3 boneTrans = trans; - mEnvironment.mWorld->setObjectPhysicsPosition(insert->getName(), boneTrans + insert->getPosition()); - //mEnvironment.mWorld->setObjectPhysicsRotation(insert->getName(), boneQuat * insert->getOrientation()); - - }*/ - - std::vector*>::iterator shapepartsiter = shapeparts.begin(); std::vector::iterator entitypartsiter = entityparts.begin(); while(shapepartsiter != shapeparts.end()) @@ -301,7 +285,7 @@ void NpcAnimation::runAnimation(float timepassed){ handleShapes(shapes, theentity, theentity->getSkeleton()); shapepartsiter++; entitypartsiter++; - } + } } } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index ce66861b8..e66dc01dc 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -684,12 +684,6 @@ namespace MWWorld { mRendering.skipAnimation (ptr); } - void World::setObjectPhysicsRotation(const std::string& handle, Ogre::Quaternion quat){ - mPhysics->rotateObject(handle, quat); - } - void World::setObjectPhysicsPosition(const std::string& handle, Ogre::Vector3 vec){ - mPhysics->moveObject(handle, vec); - } void World::update (float duration) { diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 22860b883..13e06cc39 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -222,8 +222,6 @@ namespace MWWorld void skipAnimation (const MWWorld::Ptr& ptr); ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - void setObjectPhysicsRotation(const std::string& handle,Ogre::Quaternion quat); - void setObjectPhysicsPosition(const std::string& handle,Ogre::Vector3 vector); void update (float duration); };