From 04b90b7d14a13d3ac91a3996e5797f6938c7b5eb Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 30 Jul 2013 22:00:48 +0200 Subject: [PATCH] Other actors no longer collide with an actor that has collision disabled --- apps/openmw/mwworld/physicssystem.cpp | 7 +++++-- apps/openmw/mwworld/worldimp.cpp | 9 +-------- libs/openengine/bullet/physic.cpp | 4 ++-- libs/openengine/bullet/physic.hpp | 3 ++- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 9cf944656..a5b43b4fc 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -118,7 +118,8 @@ namespace MWWorld newPosition = trace.endpos; physicActor->setOnGround(hit && getSlope(trace.planenormal) <= sMaxSlope); - physicActor->enableCollisions(wasCollisionMode); + if (wasCollisionMode) + physicActor->enableCollisions(true); if (hit) return newPosition+Ogre::Vector3(0,0,4); @@ -148,6 +149,7 @@ namespace MWWorld float remainingTime = time; bool isInterior = !ptr.getCell()->isExterior(); Ogre::Vector3 halfExtents = physicActor->getHalfExtents();// + Vector3(1,1,1); + bool wasCollisionMode = physicActor->getCollisionMode(); physicActor->enableCollisions(false); Ogre::Quaternion orient = Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[2]), Ogre::Vector3::UNIT_Z); Ogre::Vector3 velocity; @@ -228,7 +230,8 @@ namespace MWWorld } physicActor->setOnGround(onground); physicActor->setVerticalForce(!onground ? clippedVelocity.z - time*627.2f : 0.0f); - physicActor->enableCollisions(true); + if (wasCollisionMode) + physicActor->enableCollisions(true); return newPosition; } }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 33d4719c0..2514a5dfe 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1764,14 +1764,7 @@ namespace MWWorld { OEngine::Physic::PhysicActor *physicActor = mPhysEngine->getCharacter(actor.getRefData().getHandle()); - if (enable) - { - physicActor->enableCollisionBody(); - } - else - { - physicActor->disableCollisionBody(); - } + physicActor->enableCollisions(enable); } bool World::findInteriorPosition(const std::string &name, ESM::Position &pos) diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 66ee077ee..048205dac 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -45,8 +45,8 @@ namespace Physic void PhysicActor::enableCollisions(bool collision) { assert(mBody); - if(collision && !collisionMode) mBody->translate(btVector3(0,0,-1000)); - if(!collision && collisionMode) mBody->translate(btVector3(0,0,1000)); + if(collision && !collisionMode) enableCollisionBody(); + if(!collision && collisionMode) disableCollisionBody(); collisionMode = collision; } diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index baeb31678..a1d4816d3 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -129,9 +129,10 @@ namespace Physic bool getOnGround() const; + private: void disableCollisionBody(); void enableCollisionBody(); - +public: //HACK: in Visual Studio 2010 and presumably above, this structures alignment // must be 16, but the built in operator new & delete don't properly // perform this alignment.