Things are not clear in the btCapsuleShape, and I'm not sure to understand how it is used in collision algorithm as GJK.
I'm looking at the constructor first :
Code: Select all
btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape ()
{
m_shapeType = CAPSULE_SHAPE_PROXYTYPE;
m_upAxis = 1;
m_implicitShapeDimensions.setValue(radius,0.5f*height,radius);
}
Now I'm looking to this implementation :
Code: Select all
virtual void setMargin(btScalar collisionMargin)
{
//correct the m_implicitShapeDimensions for the margin
btVector3 oldMargin(getMargin(),getMargin(),getMargin());
btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
btConvexInternalShape::setMargin(collisionMargin);
btVector3 newMargin(getMargin(),getMargin(),getMargin());
m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
}
Finally it seems that constructor is invalid, shouldn't it be as for the boxShape (implicitShapeDimensions = shapeSize - margin) ?
Code: Select all
btBoxShape( const btVector3& boxHalfExtents)
: btPolyhedralConvexShape()
{
m_shapeType = BOX_SHAPE_PROXYTYPE;
btVector3 margin(getMargin(),getMargin(),getMargin());
m_implicitShapeDimensions = (boxHalfExtents * m_localScaling) - margin;
};
Can you explain how GJK handles those different values ? Margin should be an extra radius in all case, shouldn't it ? Why implicitShapeDimension are not defined as shapeSize - margin in all case ? Maybe margin is an intra radius and not extra radius ? So why not putting capsule margin as its radius (like sphere) ? Sorry if I'm a bit confused...
Thanks a lot.
Romain