From 5a1a0b7338f9c4f8bafb2b65d82c649c95c12a65 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 18 Feb 2013 22:39:43 -0800 Subject: [PATCH] Add and use an MWWorld::isFlying method --- apps/openmw/mwbase/world.hpp | 1 + apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 11 +++++++++++ apps/openmw/mwworld/worldimp.hpp | 1 + libs/openengine/bullet/physic.cpp | 5 ----- libs/openengine/bullet/physic.hpp | 6 +++++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index da670cf23..cc23e035e 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -286,6 +286,7 @@ namespace MWBase virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0; + virtual bool isFlying(const MWWorld::Ptr &ptr) const = 0; virtual bool isSwimming(const MWWorld::Ptr &object) const = 0; virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) const = 0; virtual bool isOnGround(const MWWorld::Ptr &ptr) const = 0; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index d135d2683..998b90e19 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -336,7 +336,7 @@ namespace MWClass float moveSpeed; if(normalizedEncumbrance > 1.0f) moveSpeed = 0.0f; - else if(0/*world->isFlying(ptr)*/) + else if(world->isFlying(ptr)) { float flySpeed = 0.01f*(npcdata->mCreatureStats.getAttribute(ESM::Attribute::Speed).getModified() + 0.0f/*levitationBonus*/); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index a80f083b5..1a6630232 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1382,6 +1382,17 @@ namespace MWWorld mRendering->getTriangleBatchCount(triangles, batches); } + bool + World::isFlying(const MWWorld::Ptr &ptr) const + { + RefData &refdata = ptr.getRefData(); + /// \todo check for levitation effects + const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle()); + if(physactor && physactor->getCollisionMode()) + return false; + return true; + } + bool World::isSwimming(const MWWorld::Ptr &object) const { diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 8b9b39617..d347570fe 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -314,6 +314,7 @@ namespace MWWorld virtual void processChangedSettings(const Settings::CategorySettingVector& settings); + virtual bool isFlying(const MWWorld::Ptr &ptr) const; virtual bool isSwimming(const MWWorld::Ptr &object) const; virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) const; virtual bool isOnGround(const MWWorld::Ptr &ptr) const; diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 220ba5d51..e5045eee6 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -54,11 +54,6 @@ namespace Physic collisionMode = collision; } - bool PhysicActor::getCollisionMode() - { - return collisionMode; - } - void PhysicActor::setRotation(const Ogre::Quaternion &quat) { diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 559bf032e..8ea9657e6 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -78,7 +78,11 @@ namespace Physic void enableCollisions(bool collision); - bool getCollisionMode(); + bool getCollisionMode() const + { + return collisionMode; + } + /** * This returns the visual position of the PhysicActor (used to position a scenenode).