forked from bartvdbraak/blender
BGE: When applying movement to an object with the Character physics type, use the btKinematicCharacterController's setWalkDirection() instead of moving the physics object ourselves. This reduces issues with tunneling (the character going through other objects).
This commit is contained in:
parent
c80c4c896a
commit
9fcb7cd520
@ -895,18 +895,22 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
|
||||
return;
|
||||
}
|
||||
|
||||
// btRigidBody* body = GetRigidBody(); // not used anymore
|
||||
|
||||
btVector3 dloc(dlocX,dlocY,dlocZ);
|
||||
btTransform xform = m_object->getWorldTransform();
|
||||
|
||||
if (local)
|
||||
{
|
||||
dloc = xform.getBasis()*dloc;
|
||||
}
|
||||
|
||||
xform.setOrigin(xform.getOrigin() + dloc);
|
||||
SetCenterOfMassTransform(xform);
|
||||
if (m_characterController)
|
||||
{
|
||||
m_characterController->setWalkDirection(dloc/GetPhysicsEnvironment()->getNumTimeSubSteps());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
xform.setOrigin(xform.getOrigin() + dloc);
|
||||
SetCenterOfMassTransform(xform);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -115,6 +115,11 @@ protected:
|
||||
virtual void setLinearAirDamping(float damping);
|
||||
virtual void setUseEpa(bool epa);
|
||||
|
||||
int getNumTimeSubSteps()
|
||||
{
|
||||
return m_numTimeSubSteps;
|
||||
}
|
||||
|
||||
virtual void beginFrame();
|
||||
virtual void endFrame() {}
|
||||
/// Perform an integration step of duration 'timeStep'.
|
||||
|
Loading…
Reference in New Issue
Block a user