tweak character margin for smoother sliding (needs to be fixed properly)
This commit is contained in:
erwin.coumans
2008-11-08 21:33:37 +00:00
parent f9aa7f3b53
commit 5dac27e694
3 changed files with 12 additions and 7 deletions

View File

@@ -584,14 +584,15 @@ void btGImpactCollisionAlgorithm::gimpact_vs_shape(btCollisionObject * body0,
if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE) if(shape0->getGImpactShapeType()==CONST_GIMPACT_TRIMESH_SHAPE)
{ {
btGImpactMeshShape * meshshape0 = static_cast<btGImpactMeshShape *>(shape0); btGImpactMeshShape * meshshape0 = static_cast<btGImpactMeshShape *>(shape0);
m_part0 = meshshape0->getMeshPartCount(); int& part = swapped ? m_part1 : m_part0;
part = meshshape0->getMeshPartCount();
while(m_part0--) while(part--)
{ {
gimpact_vs_shape(body0, gimpact_vs_shape(body0,
body1, body1,
meshshape0->getMeshPart(m_part0), meshshape0->getMeshPart(part),
shape1,swapped); shape1,swapped);
} }

View File

@@ -95,6 +95,7 @@ btVector3 btKinematicCharacterController::perpindicularComponent (const btVector
btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight) btKinematicCharacterController::btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight)
{ {
m_addedMargin = 0.02f;
m_walkDirection.setValue(0,0,0); m_walkDirection.setValue(0,0,0);
m_useGhostObjectSweepTest = true; m_useGhostObjectSweepTest = true;
m_ghostObject = ghostObject; m_ghostObject = ghostObject;
@@ -277,8 +278,9 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask; callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask;
//btScalar margin = m_convexShape->getMargin(); btScalar margin = m_convexShape->getMargin();
//m_convexShape->setMargin(margin - 0.06f); m_convexShape->setMargin(margin + m_addedMargin);
if (m_useGhostObjectSweepTest) if (m_useGhostObjectSweepTest)
{ {
@@ -288,7 +290,7 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
collisionWorld->convexSweepTest (m_convexShape, start, end, callback); collisionWorld->convexSweepTest (m_convexShape, start, end, callback);
} }
//m_convexShape->setMargin(margin); m_convexShape->setMargin(margin);
fraction -= callback.m_closestHitFraction; fraction -= callback.m_closestHitFraction;
@@ -303,7 +305,7 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
} }
/* If the distance is farther than the collision margin, move */ /* 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); // printf("callback.m_closestHitFraction=%f\n",callback.m_closestHitFraction);
m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction); m_currentPosition.setInterpolate3 (m_currentPosition, m_targetPosition, callback.m_closestHitFraction);

View File

@@ -45,6 +45,8 @@ protected:
btScalar m_stepHeight; btScalar m_stepHeight;
btScalar m_addedMargin;//@todo: remove this and fix the code
///this is the desired walk direction, set by the user ///this is the desired walk direction, set by the user
btVector3 m_walkDirection; btVector3 m_walkDirection;