From 6c1338821e6bf640a0d54f36effc943aa4d86c6a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 26 Feb 2011 16:34:43 +0100 Subject: [PATCH 1/3] de-Windonizing --- bullet/CMotionState.cpp | 4 ++-- bullet/CMotionState.h | 4 ++-- bullet/btKinematicCharacterController.h | 16 ++++++++-------- bullet/physic.cpp | 18 +++++++++--------- bullet/physic.hpp | 14 +++++++------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/bullet/CMotionState.cpp b/bullet/CMotionState.cpp index 9cb662caa4..3725fd77a8 100644 --- a/bullet/CMotionState.cpp +++ b/bullet/CMotionState.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include //#include namespace OEngine { @@ -42,4 +42,4 @@ namespace Physic } } -}} \ No newline at end of file +}} diff --git a/bullet/CMotionState.h b/bullet/CMotionState.h index 9ccc35adbb..3dfb3a05cf 100644 --- a/bullet/CMotionState.h +++ b/bullet/CMotionState.h @@ -1,7 +1,7 @@ #ifndef OENGINE_CMOTIONSTATE_H #define OENGINE_CMOTIONSTATE_H -#include +#include #include namespace OEngine { @@ -49,4 +49,4 @@ namespace Physic }; }} -#endif \ No newline at end of file +#endif diff --git a/bullet/btKinematicCharacterController.h b/bullet/btKinematicCharacterController.h index 8f32b32e98..96720dd7d6 100644 --- a/bullet/btKinematicCharacterController.h +++ b/bullet/btKinematicCharacterController.h @@ -4,8 +4,8 @@ Copyright (c) 2003-2008 Erwin Coumans http://bulletphysics.com This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. @@ -17,9 +17,9 @@ subject to the following restrictions: #define KINEMATIC_CHARACTER_CONTROLLER_H #include "LinearMath/btVector3.h" -#include "LinearMath\btQuickprof.h" +#include "LinearMath/btQuickprof.h" -#include "BulletDynamics\Character\btCharacterControllerInterface.h" +#include "BulletDynamics/Character/btCharacterControllerInterface.h" #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" @@ -46,7 +46,7 @@ public: private: btPairCachingGhostObject* externalGhostObject; // use this for querying collisions for sliding and move btPairCachingGhostObject* internalGhostObject; // and this for recoreving from penetrations - + btScalar m_verticalVelocity; btScalar m_verticalOffset; btScalar m_fallSpeed; @@ -100,15 +100,15 @@ public: btScalar recoveringFactor = btScalar( 0.2 ) ); ~btKinematicCharacterController (); - + ///btActionInterface interface virtual void updateAction( btCollisionWorld* collisionWorld, btScalar deltaTime ) { preStep( collisionWorld ); - playerStep( collisionWorld, deltaTime ); + playerStep( collisionWorld, deltaTime ); } - + ///btActionInterface interface void debugDraw( btIDebugDraw* debugDrawer ); diff --git a/bullet/physic.cpp b/bullet/physic.cpp index 76dabce5d9..2375d19e78 100644 --- a/bullet/physic.cpp +++ b/bullet/physic.cpp @@ -1,7 +1,7 @@ #include "physic.hpp" #include #include -#include +#include //#include #include "CMotionState.h" #include "OgreRoot.h" @@ -18,7 +18,7 @@ namespace Physic enum collisiontypes { COL_NOTHING = 0, //setWalkDirection( mvt ); } - void PhysicActor::Rotate(btQuaternion& quat) + void PhysicActor::Rotate(const btQuaternion& quat) { externalGhostObject->getWorldTransform().setRotation( externalGhostObject->getWorldTransform().getRotation() * quat ); internalGhostObject->getWorldTransform().setRotation( internalGhostObject->getWorldTransform().getRotation() * quat ); } - void PhysicActor::setRotation(btQuaternion& quat) + void PhysicActor::setRotation(const btQuaternion& quat) { externalGhostObject->getWorldTransform().setRotation( quat ); internalGhostObject->getWorldTransform().setRotation( quat ); @@ -96,7 +96,7 @@ namespace Physic return internalGhostObject->getWorldTransform().getRotation(); } - void PhysicActor::setPosition(btVector3& pos) + void PhysicActor::setPosition(const btVector3& pos) { internalGhostObject->getWorldTransform().setOrigin(pos); externalGhostObject->getWorldTransform().setOrigin(pos); @@ -179,7 +179,7 @@ namespace Physic delete solver; delete collisionConfiguration; delete dispatcher; - delete broadphase; + delete broadphase; delete ShapeLoader; } @@ -232,7 +232,7 @@ namespace Physic RigidBodyMap[name] = NULL; } } - + RigidBody* PhysicEngine::getRigidBody(std::string name) { RigidBody* body = RigidBodyMap[name]; @@ -301,4 +301,4 @@ namespace Physic } return std::pair(name,d); } -}}; \ No newline at end of file +}}; diff --git a/bullet/physic.hpp b/bullet/physic.hpp index 062e69e025..bc33143745 100644 --- a/bullet/physic.hpp +++ b/bullet/physic.hpp @@ -1,7 +1,7 @@ #ifndef OENGINE_BULLET_PHYSIC_H #define OENGINE_BULLET_PHYSIC_H -#include +#include #include "BulletCollision/CollisionDispatch/btGhostObject.h" #include #include @@ -35,7 +35,7 @@ namespace Physic struct PhysicEvent; /** - *This is just used to be able to name objects. + *This is just used to be able to name objects. */ class PairCachingGhostObject : public btPairCachingGhostObject { @@ -62,17 +62,17 @@ namespace Physic *I think it's also needed to take time into account. A typical call should look like this: *setWalkDirection( mvt * orientation * dt) */ - void setWalkDirection(btVector3& mvt); + void setWalkDirection(const btVector3& mvt); - void Rotate(btQuaternion& quat); + void Rotate(const btQuaternion& quat); - void setRotation(btQuaternion& quat); + void setRotation(const btQuaternion& quat); btVector3 getPosition(void); btQuaternion getRotation(void); - void setPosition(btVector3& pos); + void setPosition(const btVector3& pos); btKinematicCharacterController* mCharacter; @@ -208,4 +208,4 @@ namespace Physic }} -#endif \ No newline at end of file +#endif From aa0100bc08b59b27a681e872f6318c404e21edd4 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sun, 27 Feb 2011 00:44:52 +0100 Subject: [PATCH 2/3] Don't mix the enum type name in there --- bullet/physic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bullet/physic.cpp b/bullet/physic.cpp index 2375d19e78..d09d299268 100644 --- a/bullet/physic.cpp +++ b/bullet/physic.cpp @@ -57,7 +57,7 @@ namespace Physic internalGhostObject->setCollisionFlags( btCollisionObject::CF_CHARACTER_OBJECT ); mCharacter = new btKinematicCharacterController( externalGhostObject,internalGhostObject,btScalar( 0.4 ),1,0 ); - mCharacter->setUpAxis(btKinematicCharacterController::UpAxis::Z_AXIS); + mCharacter->setUpAxis(btKinematicCharacterController::Z_AXIS); } PhysicActor::~PhysicActor() From 3f0b610f2c5331fbc01617f993b77ead7e5261e8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 7 Mar 2011 14:55:18 +0100 Subject: [PATCH 3/3] throw an exception instead of crashing (ray test bug) --- bullet/physic.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bullet/physic.cpp b/bullet/physic.cpp index d09d299268..5974417713 100644 --- a/bullet/physic.cpp +++ b/bullet/physic.cpp @@ -219,6 +219,13 @@ namespace Physic RigidBody* body = RigidBodyMap[name]; if(body != NULL) { + broadphase->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(body->getBroadphaseProxy(),dispatcher); + std::map::iterator it = PhysicActorMap.begin(); + for(;it!=PhysicActorMap.end();it++) + { + it->second->internalGhostObject->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(body->getBroadphaseProxy(),dispatcher); + it->second->externalGhostObject->getOverlappingPairCache()->removeOverlappingPairsContainingProxy(body->getBroadphaseProxy(),dispatcher); + } dynamicsWorld->removeRigidBody(RigidBodyMap[name]); } } @@ -291,11 +298,11 @@ namespace Physic { if(resultCallback.m_collisionFilterGroup == COL_WORLD) { - name = static_cast(resultCallback.m_collisionObject)->mName; + name = dynamic_cast(*resultCallback.m_collisionObject).mName; } if(resultCallback.m_collisionFilterGroup == COL_ACTOR_EXTERNAL || resultCallback.m_collisionFilterGroup == COL_ACTOR_INTERNAL) { - name = static_cast(resultCallback.m_collisionObject)->mName; + name = dynamic_cast(*resultCallback.m_collisionObject).mName; } d = resultCallback.m_closestHitFraction; }