From eb93ef68f11f7cd6b16b916e0892d034b4957745 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 13 Mar 2011 22:33:55 +0100 Subject: [PATCH 1/3] fixed collision mode interface and redirected collision mode script instruction from Player class to MWScene class --- apps/openmw/mwrender/mwscene.cpp | 2 +- apps/openmw/mwrender/mwscene.hpp | 4 ++-- apps/openmw/mwscript/controlextensions.cpp | 2 +- apps/openmw/mwworld/world.cpp | 5 +++++ apps/openmw/mwworld/world.hpp | 4 ++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index 34461666e1..09ee0e3e32 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -200,7 +200,7 @@ void MWScene::scaleObject (const std::string& handle, float scale) } -void MWScene::setCollsionMode (bool enabled) +void MWScene::toggleCollisionMode() { } diff --git a/apps/openmw/mwrender/mwscene.hpp b/apps/openmw/mwrender/mwscene.hpp index 3e1470e8da..fd3ef783ff 100644 --- a/apps/openmw/mwrender/mwscene.hpp +++ b/apps/openmw/mwrender/mwscene.hpp @@ -87,9 +87,9 @@ namespace MWRender /// Change object's scale. void scaleObject (const std::string& handle, float scale); - /// Set collision mode for player. If disabled player object should ignore + /// Toggle collision mode for player. If disabled player object should ignore /// collisions and gravity. - void setCollsionMode (bool enabled); + void toggleCollisionMode(); }; } diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 5020675d13..f5a5c08a43 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -46,7 +46,7 @@ namespace MWScript InterpreterContext& context = static_cast (runtime.getContext()); - context.getWorld().getPlayer().toggleCollisionMode(); + context.getWorld().toggleCollisionMode(); } }; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 9d975879e8..66f866b078 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -855,4 +855,9 @@ namespace MWWorld { mScene.doPhysics (duration, *this, actors); } + + void World::toggleCollisionMode() + { + mScene.toggleCollisionMode(); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index becdd70723..5cd99d9cd2 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -179,6 +179,10 @@ namespace MWWorld void doPhysics (const std::vector >& actors, float duration); ///< Run physics simulation and modify \a world accordingly. + + void toggleCollisionMode(); + ///< Toggle collision mode for player. If disabled player object should ignore + /// collisions and gravity. }; } From f1bfca7c7c48ffdc58cf98edae2e6140b7fdf119 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 13 Mar 2011 22:37:54 +0100 Subject: [PATCH 2/3] player class cleanup --- apps/openmw/mwworld/player.cpp | 23 +---------------------- apps/openmw/mwworld/player.hpp | 10 ---------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index c4b17f48fd..259348938f 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -9,7 +9,7 @@ namespace MWWorld { Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) : - mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), mCollisionMode (true), + mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), mAutoMove (false), mForwardBackward (0) { mPlayer.base = player; @@ -37,27 +37,6 @@ namespace MWWorld -mPlayer.ref.pos.pos[1])); } - void Player::moveRel (float &relX, float &relY, float &relZ) - { - // Move camera relative to its own direction - mRenderer->getCamera()->moveRelative (Ogre::Vector3(relX,0,relZ)); - - // Up/down movement is always done relative the world axis. - mRenderer->getCamera()->move (Ogre::Vector3(0,relY,0)); - - // Get new camera position, converting back to MW coords. - Ogre::Vector3 pos = mRenderer->getCamera()->getPosition(); - relX = pos[0]; - relY = -pos[2]; - relZ = pos[1]; - - // TODO: Collision detection must be used to find the REAL new - // position, if mCollisionMode==true - - // Set the position - setPos(relX, relY, relZ); - } - void Player::setClass (const ESM::Class& class_) { ESM::Class *new_class = new ESM::Class (class_); diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 1b28baf9b9..fc29286a91 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -29,7 +29,6 @@ namespace MWWorld std::string mRace; std::string mBirthsign; ESM::Class *mClass; - bool mCollisionMode; bool mAutoMove; int mForwardBackward; @@ -47,10 +46,6 @@ namespace MWWorld mCellStore = cellStore; } - /// Move the player relative to her own position and - /// orientation. After the call, the new position is returned. - void moveRel (float &relX, float &relY, float &relZ); - MWWorld::Ptr getPlayer() { MWWorld::Ptr ptr (&mPlayer, mCellStore); @@ -106,11 +101,6 @@ namespace MWWorld return *mClass; } - void toggleCollisionMode() - { - mCollisionMode = !mCollisionMode; - } - bool getAutoMove() { return mAutoMove; From 4100a72e8dab2c5371d60a90849fde30ed57b628 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 13 Mar 2011 22:39:44 +0100 Subject: [PATCH 3/3] don't do physics calculations while the GUI is up --- apps/openmw/engine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 7241573bf6..4aae0f91db 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -183,7 +183,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) focusFrameCounter = 0; } - mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration); + if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game) + mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration); } catch (const std::exception& e) {