diff --git a/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp b/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp index 2b476e4a4..4d6fa88f6 100644 --- a/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp +++ b/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp @@ -584,14 +584,15 @@ void btGImpactCollisionAlgorithm::gimpact_vs_shape(btCollisionObject * body0, if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) { btGImpactMeshShape * meshshape0 = static_cast(shape0); - m_part0 = meshshape0->getMeshPartCount(); + int& part = swapped ? m_part1 : m_part0; + part = meshshape0->getMeshPartCount(); - while(m_part0--) + while(part--) { gimpact_vs_shape(body0, body1, - meshshape0->getMeshPart(m_part0), + meshshape0->getMeshPart(part), shape1,swapped); } diff --git a/src/BulletDynamics/Character/btKinematicCharacterController.cpp b/src/BulletDynamics/Character/btKinematicCharacterController.cpp index 1df041779..5b3ba71bc 100644 --- a/src/BulletDynamics/Character/btKinematicCharacterController.cpp +++ b/src/BulletDynamics/Character/btKinematicCharacterController.cpp @@ -95,6 +95,7 @@ btVector3 btKinematicCharacterController::perpindicularComponent (const btVector btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight) { + m_addedMargin = 0.02f; m_walkDirection.setValue(0,0,0); m_useGhostObjectSweepTest = true; m_ghostObject = ghostObject; @@ -277,8 +278,9 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; - //btScalar margin = m_convexShape->getMargin(); - //m_convexShape->setMargin(margin - 0.06f); + btScalar margin = m_convexShape->getMargin(); + m_convexShape->setMargin(margin + m_addedMargin); + if (m_useGhostObjectSweepTest) { @@ -288,7 +290,7 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co collisionWorld->convexSweepTest (m_convexShape, start, end, callback); } - //m_convexShape->setMargin(margin); + m_convexShape->setMargin(margin); fraction -= callback.m_closestHitFraction; @@ -303,7 +305,7 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co } /* If the distance is farther than the collision margin, move */ - if (hitDistance > 0.05) + if (hitDistance > m_addedMargin) { // printf("callback.m_closestHitFraction=%f\n",callback.m_closestHitFraction); m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); diff --git a/src/BulletDynamics/Character/btKinematicCharacterController.h b/src/BulletDynamics/Character/btKinematicCharacterController.h index d03f8f9de..6d9aa09fb 100644 --- a/src/BulletDynamics/Character/btKinematicCharacterController.h +++ b/src/BulletDynamics/Character/btKinematicCharacterController.h @@ -45,6 +45,8 @@ protected: btScalar m_stepHeight; + btScalar m_addedMargin;//@todo: remove this and fix the code + ///this is the desired walk direction, set by the user btVector3 m_walkDirection;