This commit is contained in:
Andrew Meadows 2016-10-04 15:01:03 -07:00
parent cd61f55c4a
commit 9544c749ea
3 changed files with 7 additions and 13 deletions

View file

@ -870,9 +870,10 @@ void CharacterController::setMoveKinematically(bool kinematic) {
bool CharacterController::queryPenetration(const btTransform& transform) {
btVector3 minBox;
btVector3 maxBox;
_ghost.queryPenetration(transform, minBox, maxBox);
btVector3 penetration = maxBox;
penetration.setMax(minBox.absolute());
_ghost.setWorldTransform(transform);
_ghost.measurePenetration(minBox, maxBox);
btVector3 penetration = minBox;
penetration.setMax(maxBox.absolute());
const btScalar MIN_PENETRATION_SQUARED = 0.0016f; // 0.04^2
return penetration.length2() < MIN_PENETRATION_SQUARED;
}

View file

@ -242,17 +242,11 @@ bool CharacterGhostObject::sweepTest(
return false;
}
void CharacterGhostObject::queryPenetration(const btTransform& transform, btVector3& minBoxOut, btVector3& maxBoxOut) {
// place in world and refresh overlapping pairs
setWorldTransform(transform);
measurePenetration(minBoxOut, maxBoxOut);
}
void CharacterGhostObject::measurePenetration(btVector3& minBoxOut, btVector3& maxBoxOut) {
// minBoxOut and maxBoxOut will be updated with penetration envelope.
// If one of the points is at <0,0,0> then the penetration may be resolvable in a single step,
// but if the space spanned by those two corners extends in both directions along at least one
// component then this object is sandwiched between two opposing objects.
// If one of the corner points is <0,0,0> then the penetration is resolvable in a single step,
// but if the space spanned by the two corners extends in both directions along at least one
// component then we the object is sandwiched between two opposing objects.
// We assume this object has just been moved to its current location, or else objects have been
// moved around it since the last step so we must update the overlapping pairs.

View file

@ -59,7 +59,6 @@ public:
bool isSteppingUp() const { return _steppingUp; }
const btVector3& getFloorNormal() const { return _floorNormal; }
void queryPenetration(const btTransform& transform, btVector3& minBoxOut, btVector3& maxBoxOut);
void measurePenetration(btVector3& minBoxOut, btVector3& maxBoxOut);
protected: