assign proper index when removing a child shape from btCompoundShape

Thanks to sparkprime for the report and fix in Issue 354
See http://code.google.com/p/bullet/issues/detail?id=354
Fix a few warnings
This commit is contained in:
erwin.coumans
2010-03-12 05:32:57 +00:00
parent f250fd21c5
commit 192a2b38e9
3 changed files with 8 additions and 4 deletions

View File

@@ -114,7 +114,9 @@ public:
void ProcessChildShape(btCollisionShape* childShape,int index)
{
btAssert(index>=0);
btAssert(index<compoundShape->getNumChildShapes());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());

View File

@@ -110,6 +110,8 @@ void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
m_dynamicAabbTree->remove(m_children[childShapeIndex].m_node);
}
m_children.swap(childShapeIndex,m_children.size()-1);
if (m_dynamicAabbTree)
m_children[childShapeIndex].m_node->dataAsInt = childShapeIndex;
m_children.pop_back();
}

View File

@@ -216,7 +216,7 @@ void btKinematicCharacterController::stepUp ( btCollisionWorld* world)
{
// phase 1: up
btTransform start, end;
m_targetPosition = m_currentPosition + getUpAxisDirections()[m_upAxis] * (m_stepHeight + (m_verticalOffset > 0.0?m_verticalOffset:0.0));
m_targetPosition = m_currentPosition + getUpAxisDirections()[m_upAxis] * (m_stepHeight + (m_verticalOffset > btScalar(0.0)?m_verticalOffset:btScalar(0.0)));
start.setIdentity ();
end.setIdentity ();
@@ -381,9 +381,9 @@ void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld
btTransform start, end;
// phase 3: down
btScalar additionalDownStep = (m_wasOnGround /*&& !onGround()*/) ? m_stepHeight : 0.0;
btScalar additionalDownStep = (m_wasOnGround /*&& !onGround()*/) ? m_stepHeight : btScalar(0.0);
btVector3 step_drop = getUpAxisDirections()[m_upAxis] * (m_currentStepOffset + additionalDownStep);
btScalar downVelocity = (additionalDownStep == 0.0 && m_verticalVelocity<0.0?-m_verticalVelocity:0.0) * dt;
btScalar downVelocity = (additionalDownStep == btScalar(0.0) && m_verticalVelocity<btScalar(0.0)?-m_verticalVelocity:btScalar(0.0)) * dt;
btVector3 gravity_drop = getUpAxisDirections()[m_upAxis] * downVelocity;
m_targetPosition -= (step_drop + gravity_drop);