more fixes for btCapsuleShape: its entire radius is collision margin, don't let the user override it (similar to a btSphereShape)
This commit is contained in:
@@ -19,10 +19,9 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
||||||
#include "LinearMath/btQuaternion.h"
|
#include "LinearMath/btQuaternion.h"
|
||||||
|
|
||||||
btCapsuleShape::btCapsuleShape(btScalar orgRadius, btScalar height) : btConvexInternalShape ()
|
btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape ()
|
||||||
{
|
{
|
||||||
m_collisionMargin = orgRadius;
|
m_collisionMargin = radius;
|
||||||
btScalar radius = 0.f;
|
|
||||||
m_shapeType = CAPSULE_SHAPE_PROXYTYPE;
|
m_shapeType = CAPSULE_SHAPE_PROXYTYPE;
|
||||||
m_upAxis = 1;
|
m_upAxis = 1;
|
||||||
m_implicitShapeDimensions.setValue(radius,0.5f*height,radius);
|
m_implicitShapeDimensions.setValue(radius,0.5f*height,radius);
|
||||||
@@ -98,7 +97,7 @@ btCapsuleShape::btCapsuleShape(btScalar orgRadius, btScalar height) : btConvexIn
|
|||||||
{
|
{
|
||||||
btVector3 pos(0,0,0);
|
btVector3 pos(0,0,0);
|
||||||
pos[getUpAxis()] = getHalfHeight();
|
pos[getUpAxis()] = getHalfHeight();
|
||||||
vtx = pos +vec*(radius) - vec * getMargin();
|
vtx = pos +vec*(radius);
|
||||||
newDot = vec.dot(vtx);
|
newDot = vec.dot(vtx);
|
||||||
if (newDot > maxDot)
|
if (newDot > maxDot)
|
||||||
{
|
{
|
||||||
@@ -109,7 +108,7 @@ btCapsuleShape::btCapsuleShape(btScalar orgRadius, btScalar height) : btConvexIn
|
|||||||
{
|
{
|
||||||
btVector3 pos(0,0,0);
|
btVector3 pos(0,0,0);
|
||||||
pos[getUpAxis()] = -getHalfHeight();
|
pos[getUpAxis()] = -getHalfHeight();
|
||||||
vtx = pos +vec*(radius) - vec * getMargin();
|
vtx = pos +vec*(radius);
|
||||||
newDot = vec.dot(vtx);
|
newDot = vec.dot(vtx);
|
||||||
if (newDot > maxDot)
|
if (newDot > maxDot)
|
||||||
{
|
{
|
||||||
@@ -151,10 +150,9 @@ void btCapsuleShape::calculateLocalInertia(btScalar mass,btVector3& inertia) con
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btCapsuleShapeX::btCapsuleShapeX(btScalar orgRadius,btScalar height)
|
btCapsuleShapeX::btCapsuleShapeX(btScalar radius,btScalar height)
|
||||||
{
|
{
|
||||||
m_collisionMargin = orgRadius;
|
m_collisionMargin = radius;
|
||||||
btScalar radius = 0.f;
|
|
||||||
m_upAxis = 0;
|
m_upAxis = 0;
|
||||||
m_implicitShapeDimensions.setValue(0.5f*height, radius,radius);
|
m_implicitShapeDimensions.setValue(0.5f*height, radius,radius);
|
||||||
}
|
}
|
||||||
@@ -164,10 +162,9 @@ btCapsuleShapeX::btCapsuleShapeX(btScalar orgRadius,btScalar height)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
btCapsuleShapeZ::btCapsuleShapeZ(btScalar orgRadius,btScalar height)
|
btCapsuleShapeZ::btCapsuleShapeZ(btScalar radius,btScalar height)
|
||||||
{
|
{
|
||||||
m_collisionMargin = orgRadius;
|
m_collisionMargin = radius;
|
||||||
btScalar radius = 0.f;
|
|
||||||
m_upAxis = 2;
|
m_upAxis = 2;
|
||||||
m_implicitShapeDimensions.setValue(radius,radius,0.5f*height);
|
m_implicitShapeDimensions.setValue(radius,radius,0.5f*height);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,14 +48,7 @@ public:
|
|||||||
|
|
||||||
virtual void setMargin(btScalar collisionMargin)
|
virtual void setMargin(btScalar collisionMargin)
|
||||||
{
|
{
|
||||||
//correct the m_implicitShapeDimensions for the margin
|
//don't override the margin for capsules, their entire radius == margin
|
||||||
btVector3 oldMargin(getMargin(),getMargin(),getMargin());
|
|
||||||
btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
|
|
||||||
|
|
||||||
btConvexInternalShape::setMargin(collisionMargin);
|
|
||||||
btVector3 newMargin(getMargin(),getMargin(),getMargin());
|
|
||||||
m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
|
virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
|
||||||
|
|||||||
Reference in New Issue
Block a user