improved robustness of penetrations involving triangles and boxes, by adding their 'preferred' penetration directions.
added wireframe/solid mode for meshes updated solid penetration depth solver (comparison in Extras)
This commit is contained in:
@@ -255,6 +255,37 @@ public:
|
||||
return "Box";
|
||||
}
|
||||
|
||||
virtual int getNumPreferredPenetrationDirections() const
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
penetrationVector.setValue(1.f,0.f,0.f);
|
||||
break;
|
||||
case 1:
|
||||
penetrationVector.setValue(-1.f,0.f,0.f);
|
||||
break;
|
||||
case 2:
|
||||
penetrationVector.setValue(0.f,1.f,0.f);
|
||||
break;
|
||||
case 3:
|
||||
penetrationVector.setValue(0.f,-1.f,0.f);
|
||||
break;
|
||||
case 4:
|
||||
penetrationVector.setValue(0.f,0.f,1.f);
|
||||
break;
|
||||
case 5:
|
||||
penetrationVector.setValue(0.f,0.f,-1.f);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ subject to the following restrictions:
|
||||
|
||||
//todo: get rid of this btConvexCastResult thing!
|
||||
struct btConvexCastResult;
|
||||
|
||||
#define MAX_PREFERRED_PENETRATION_DIRECTIONS 10
|
||||
|
||||
/// btConvexShape is an abstract shape interface.
|
||||
/// The explicit part provides plane-equations, the implicit part provides GetClosestPoint interface.
|
||||
@@ -84,6 +84,17 @@ public:
|
||||
return m_collisionMargin;
|
||||
}
|
||||
|
||||
virtual int getNumPreferredPenetrationDirections() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -157,6 +157,18 @@ public:
|
||||
return "Triangle";
|
||||
}
|
||||
|
||||
virtual int getNumPreferredPenetrationDirections() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
virtual void getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
|
||||
{
|
||||
calcNormal(penetrationVector);
|
||||
if (index)
|
||||
penetrationVector *= -1.f;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user