diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 90c090f59..316e57b78 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -110,7 +110,7 @@ namespace MWWorld float remainingTime = time; bool isInterior = !ptr.getCell()->isExterior(); Ogre::Vector3 halfExtents = physicActor->getHalfExtents();// + Vector3(1,1,1); - physicActor->mBody->translate(btVector3(0,0,1000)); + physicActor->enableCollisions(false); Ogre::Vector3 velocity; if(!gravity) @@ -147,7 +147,6 @@ namespace MWWorld // trace to where character would go if there were no obstructions newtrace(&trace, newPosition, newPosition+clippedVelocity*remainingTime, halfExtents, isInterior, engine); newPosition = trace.endpos; - //std::cout << newPosition.x << " "; remainingTime = remainingTime * (1.0f-trace.fraction); // check for obstructions @@ -191,8 +190,7 @@ namespace MWWorld } physicActor->setOnGround(onground); physicActor->setVerticalForce(!onground ? clippedVelocity.z - time*627.2f : 0.0f); - physicActor->mBody->translate(btVector3(0,0,-1000)); - //std::cout << position.x << " " << newPosition.x << " " << position.y << " " << newPosition.y << std::endl; + physicActor->enableCollisions(true); return newPosition; } }; diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index f993ce68e..677d75f33 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -37,6 +37,8 @@ namespace Physic Ogre::Quaternion inverse = mBoxRotation.Inverse(); mBoxRotationInverse = btQuaternion(inverse.x, inverse.y, inverse.z,inverse.w); mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map + //mBody->setCollisionFlags(COL_NOTHING); + //mBody->setMas } PhysicActor::~PhysicActor() @@ -50,6 +52,8 @@ namespace Physic void PhysicActor::enableCollisions(bool collision) { + if(collision && !collisionMode) mBody->translate(btVector3(0,0,-1000)); + if(!collision && collisionMode) mBody->translate(btVector3(0,0,1000)); collisionMode = collision; } diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 6a7150fca..e579e3546 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -129,10 +129,10 @@ namespace Physic void operator delete (void * Data) { _aligned_free (Data); } #endif - OEngine::Physic::RigidBody* mBody; private: - + + OEngine::Physic::RigidBody* mBody; Ogre::Vector3 mBoxScaledTranslation; btQuaternion mBoxRotationInverse; Ogre::Quaternion mBoxRotation;