From f43b48015e487f80810e52c12f0d4f5b4f5df2bb Mon Sep 17 00:00:00 2001 From: Vincent Heuken Date: Thu, 27 Jun 2013 19:42:27 -0700 Subject: [PATCH] remove actor's collisionbox on death --- apps/openmw/mwworld/worldimp.cpp | 6 +++--- libs/openengine/bullet/physic.cpp | 10 ++++++++++ libs/openengine/bullet/physic.hpp | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 662d46a4ba..0a1e0ccdc9 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1756,13 +1756,13 @@ namespace MWWorld { OEngine::Physic::PhysicActor *physicActor = mPhysEngine->getCharacter(actor.getRefData().getHandle()); - if (!enable) + if (enable) { - physicActor->setScale(0.15); + physicActor->enableCollisionBody(); } else { - physicActor->setScale(1); + physicActor->disableCollisionBody(); } } } diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index bbe6338474..550e71b3c0 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -146,6 +146,16 @@ namespace Physic return collisionMode && onGround; } + void PhysicActor::disableCollisionBody() + { + mEngine->dynamicsWorld->removeRigidBody(mBody); + } + + void PhysicActor::enableCollisionBody() + { + mEngine->dynamicsWorld->addRigidBody(mBody); + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 80c681fe5b..baeb316785 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -129,6 +129,9 @@ namespace Physic bool getOnGround() const; + void disableCollisionBody(); + void enableCollisionBody(); + //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.