From dfc19a1ff7968e547c33ef3304849f69ddf76f4f Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 28 May 2012 21:36:29 +0000 Subject: BGE patch #28476: Character object physics type =============================================== This patch adds a new "Character" BGE physics type which uses Bullet's btKinematicCharacter for simulation instead of full-blown dynamics. It is appropiate for (player-controlled) characters, for which the other physics types often result unexpected results (bouncing off walls, sliding etc.) and for which simple kinematics offers much more precision. "Character" can be chosen like any other physics type in the "Physics" section of the properties window. Current settings for tweaking are "Step Height" (to make the object automatically climb small steps if it collides with them), "Fall Speed" (the maximum speed that the object can have when falling) and "Jump Speed", which is currently not used. See http://projects.blender.org/tracker/?func=detail&atid=127&aid=28476&group_id=9 for sample blends and a discussion on the patch: how to use it and what influences the behavior of the character object. Known problem: there is a crash if the "compound" option is set in the physics panel of the Character object. --- extern/bullet2/CMakeLists.txt | 4 ++-- .../bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h | 2 +- .../src/BulletDynamics/Character/btKinematicCharacterController.cpp | 2 +- extern/bullet2/src/SConscript | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'extern') diff --git a/extern/bullet2/CMakeLists.txt b/extern/bullet2/CMakeLists.txt index 51b295e897f..ae7d282ca55 100644 --- a/extern/bullet2/CMakeLists.txt +++ b/extern/bullet2/CMakeLists.txt @@ -118,6 +118,7 @@ set(SRC src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp + src/BulletDynamics/Character/btKinematicCharacterController.cpp src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp @@ -154,7 +155,6 @@ set(SRC # src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp # src/BulletCollision/CollisionShapes/btBox2dShape.cpp # src/BulletCollision/CollisionShapes/btConvex2dShape.cpp - # src/BulletDynamics/Character/btKinematicCharacterController.cpp # src/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp # src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp @@ -274,6 +274,7 @@ set(SRC src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h src/BulletDynamics/Character/btCharacterControllerInterface.h + src/BulletDynamics/Character/btKinematicCharacterController.h src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h src/BulletDynamics/ConstraintSolver/btConstraintSolver.h src/BulletDynamics/ConstraintSolver/btContactConstraint.h @@ -343,7 +344,6 @@ set(SRC # src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.h # src/BulletCollision/CollisionShapes/btBox2dShape.h # src/BulletCollision/CollisionShapes/btConvex2dShape.h - # src/BulletDynamics/Character/btKinematicCharacterController.h # src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h # src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h ) diff --git a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h index 51b27afe686..9e247d125f5 100644 --- a/extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h +++ b/extern/bullet2/src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h @@ -339,7 +339,7 @@ public: ///***************************************** expert/internal use only ************************* - void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0)); + void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.5)); QuantizedNodeArray& getLeafNodeArray() { return m_quantizedLeafNodes; } ///buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized void buildInternal(); diff --git a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp index 9732553130d..f733dc0cd22 100644 --- a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp +++ b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp @@ -84,7 +84,7 @@ public: } else { ///need to transform normal into worldspace - hitNormalWorld = m_hitCollisionObject->getWorldTransform().getBasis()*convexResult.m_hitNormalLocal; + hitNormalWorld = convexResult.m_hitCollisionObject->getWorldTransform().getBasis()*convexResult.m_hitNormalLocal; } btScalar dotUp = m_up.dot(hitNormalWorld); diff --git a/extern/bullet2/src/SConscript b/extern/bullet2/src/SConscript index f59bcba9fa6..cd94df257ec 100644 --- a/extern/bullet2/src/SConscript +++ b/extern/bullet2/src/SConscript @@ -23,7 +23,7 @@ elif sys.platform=='darwin': linearmath_src = env.Glob("LinearMath/*.cpp") -bulletdyn_src = env.Glob("BulletDynamics/Vehicle/*.cpp") + env.Glob("BulletDynamics/ConstraintSolver/*.cpp") + env.Glob("BulletDynamics/Dynamics/*.cpp") +bulletdyn_src = env.Glob("BulletDynamics/Vehicle/*.cpp") + env.Glob("BulletDynamics/ConstraintSolver/*.cpp") + env.Glob("BulletDynamics/Dynamics/*.cpp") + env.Glob("BulletDynamics/Character/*.cpp") collision_broadphase_src = env.Glob("BulletCollision/BroadphaseCollision/*.cpp") collision_dispatch_src = env.Glob("BulletCollision/CollisionDispatch/*.cpp") -- cgit v1.2.3