Commit f92f8598 authored by D-AIRY's avatar D-AIRY

Some fixes

parent b8b67cb6
......@@ -51,7 +51,7 @@ SIMD_FORCE_INLINE bool operator==(const btCompoundShapeChild& c1, const btCompou
/// It has an (optional) dynamic aabb tree to accelerate early rejection tests.
/// @todo: This aabb tree can also be use to speed up ray tests on btCompoundShape, see http://code.google.com/p/bullet/issues/detail?id=25
/// Currently, removal of child shapes is only supported when disabling the aabb tree (pass 'false' in the constructor of btCompoundShape)
ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape
ATTRIBUTE_ALIGNED16(class) BULLET_EXPORTS btCompoundShape : public btCollisionShape
{
protected:
btAlignedObjectArray<btCompoundShapeChild> m_children;
......
......@@ -32,9 +32,16 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& simp
(void)v;
(void)simplexSolver;
btVector3 BA = transformB.getOrigin() - transformA.getOrigin();
bool bSkipTwo = false;
if(BA.fuzzyZero())
{
bSkipTwo = true;
}
btVector3 guessVectors[] = {
btVector3(transformB.getOrigin() - transformA.getOrigin()).normalized(),
btVector3(transformA.getOrigin() - transformB.getOrigin()).normalized(),
bSkipTwo ? BA : BA.normalized(),
bSkipTwo ? BA : btVector3(transformA.getOrigin() - transformB.getOrigin()).normalized(),
btVector3(0, 0, 1),
btVector3(0, 1, 0),
btVector3(1, 0, 0),
......@@ -46,7 +53,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& simp
int numVectors = sizeof(guessVectors) / sizeof(btVector3);
for (int i = 0; i < numVectors; i++)
for(int i = bSkipTwo ? 2 : 0; i < numVectors; i++)
{
simplexSolver.reset();
btVector3 guessVector = guessVectors[i];
......
......@@ -209,15 +209,7 @@ bool btKinematicCharacterController::recoverFromPenetration ( btCollisionWorld*
m_manifoldArray.resize(0);
btBroadphasePair* collisionPair = &m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray()[i];
//for trigger filtering
if(!static_cast<btCollisionObject*>(collisionPair->m_pProxy0->m_clientObject)->hasContactResponse()
|| !static_cast<btCollisionObject*>(collisionPair->m_pProxy0->m_clientObject)->hasContactResponse()
)
{
continue;
}
btCollisionObject* obj0 = static_cast<btCollisionObject*>(collisionPair->m_pProxy0->m_clientObject);
btCollisionObject* obj1 = static_cast<btCollisionObject*>(collisionPair->m_pProxy1->m_clientObject);
......@@ -282,6 +274,11 @@ void btKinematicCharacterController::stepUp ( btCollisionWorld* world)
/* FIXME: Handle penetration properly */
start.setOrigin(m_currentPosition);
if(stepHeight <= 0.0f && m_verticalOffset <= 0.0f)
{
return;
}
m_targetPosition = m_currentPosition + m_up * (stepHeight) + m_jumpAxis * ((m_verticalOffset > 0.f ? m_verticalOffset : 0.f));
m_currentPosition = m_targetPosition;
......@@ -475,6 +472,35 @@ void btKinematicCharacterController::stepForwardAndStrafe ( btCollisionWorld* co
}
}
bool btKinematicCharacterController::canStandUp(float fDelta)
{
btTransform start, end;
start.setIdentity();
end.setIdentity();
start.setOrigin(m_currentPosition);
end.setOrigin(m_currentPosition + m_up * fDelta);
start.setRotation(m_currentOrientation);
end.setRotation(m_targetOrientation);
btKinematicClosestNotMeConvexResultCallback callback(m_ghostObject, -m_up, m_maxSlopeCosine);
callback.m_collisionFilterGroup = getGhostObject()->getBroadphaseHandle()->m_collisionFilterGroup;
callback.m_collisionFilterMask = getGhostObject()->getBroadphaseHandle()->m_collisionFilterMask;
m_ghostObject->convexSweepTest(m_convexShape, start, end, callback);
if(callback.hasHit() && m_ghostObject->hasContactResponse() && needsCollision(m_ghostObject, callback.m_hitCollisionObject))
{
if(callback.m_hitNormalWorld.dot(m_up) < 0.0)
{
return(false);
}
}
return(true);
}
void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld, btScalar dt)
{
btTransform start, end, end_double;
......
......@@ -199,6 +199,8 @@ public:
bool onGround () const;
void setUpInterpolate (bool value);
bool canStandUp(float fDelta);
};
#endif // BT_KINEMATIC_CHARACTER_CONTROLLER_H
......@@ -68,7 +68,7 @@ enum btSliderFlags
};
ATTRIBUTE_ALIGNED16(class) btSliderConstraint : public btTypedConstraint
ATTRIBUTE_ALIGNED16(class) BULLET_EXPORTS btSliderConstraint : public btTypedConstraint
{
protected:
///for backwards compatibility during the transition to 'getInfo/getInfo2'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment