Hello, Im using bullet to determine collision on static meshes. I have some troubles, so I generated points of two cubes, if I create btConvexTriangleMeshShape from them, bullet finds collision, but if I create btBvhTriangleMeshShape, there is no collision... I need to use btBvhTriangleMeshShape, because I have to work with concave shapes.
Is there anything I can do wrong?
my world is initialized like this:
btVector3 worldAabbMin(-500, -500, -500);
btVector3 worldAabbMax(500, 500, 500);
_configuration = new btDefaultCollisionConfiguration();
_dispatcher = new btCollisionDispatcher(_configuration);
_broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax);
_world = new btDiscreteDynamicsWorld(_dispatcher, _broadphase, new btSequentialImpulseConstraintSolver(), _configuration);
my collision objects like this:
btTriangleMesh* trimesh = new btTriangleMesh();
for(int i = 0; i < _points.size(); i += 3)
{
trimesh->addTriangle(btVector3(_points.x , _points.y, _points.z),
btVector3(_points[i+1].x, _points[i+1].y, _points[i+1].z),
btVector3(_points[i+2].x, _points[i+2].y, _points[i+2].z), true); }
btCollisionObject * object = new btCollisionObject();
object->setCollisionShape(new btBvhTriangleMeshShape(trimesh, false));
Please help...
btBvhTriangleMeshShape problem?
-
- Posts: 32
- Joined: Fri Dec 19, 2008 2:51 pm
Re: btBvhTriangleMeshShape problem?
If I understand you correctly, you create two seperate cubes with BvhTriangleMeshShape and check those two for collision?
This does not work since both are static, and thus are not checked for collision.
If you have to use concave shapes, either manually decompose them into convex objects and use a compound shape, or check the GIMPACT demo.
This does not work since both are static, and thus are not checked for collision.
If you have to use concave shapes, either manually decompose them into convex objects and use a compound shape, or check the GIMPACT demo.
-
- Posts: 14
- Joined: Thu May 15, 2008 6:09 pm
Re: btBvhTriangleMeshShape problem?
I tried replace btBvhTriangleMeshShape with btGImpactConvexDecompositionShape, but nothing changed...
-
- Posts: 32
- Joined: Fri Dec 19, 2008 2:51 pm
Re: btBvhTriangleMeshShape problem?
hmmm... did you register the Gimpact algorithm? (btGImpactCollisionAlgorithm::registerAlgorithm( pBtCollisionDisplatcher ); )
If that's not the prob, could you post some more code?
If that's not the prob, could you post some more code?
-
- Posts: 14
- Joined: Thu May 15, 2008 6:09 pm
Re: btBvhTriangleMeshShape problem?
yes btGImpactCollisionAlgorithm::registerAlgorithm( pBtCollisionDisplatcher ); makes it work. but, if I use btGImpactConvexDecompositionShape, I get null pointer exception for some of my objects...
in cd_hull.cpp:
btHullTriangle *extrudable(float epsilon)
{
int i;
btHullTriangle *t=NULL;
for(i=0;i<tris.count;i++)
{
if(!t || (tris && t->rise<tris->rise))
{
t = tris;
}
}
return (t->rise > epsilon) ? t : NULL;
}
Exception is throwen when tris.count is zero.
Does ConvexDecompositionDemo do the same as btGImpactConvexDecompositionShape ? I don't exactly understand the source, can somebody give me little explanation? pls
in cd_hull.cpp:
btHullTriangle *extrudable(float epsilon)
{
int i;
btHullTriangle *t=NULL;
for(i=0;i<tris.count;i++)
{
if(!t || (tris && t->rise<tris->rise))
{
t = tris;
}
}
return (t->rise > epsilon) ? t : NULL;
}
Exception is throwen when tris.count is zero.
Does ConvexDecompositionDemo do the same as btGImpactConvexDecompositionShape ? I don't exactly understand the source, can somebody give me little explanation? pls
-
- Posts: 14
- Joined: Thu May 15, 2008 6:09 pm
Re: btBvhTriangleMeshShape problem?
If I use btTriangleIndexVertexArray instead of btTriangleMesh to create btGImpactMeshShape everything is ok, so I assume there has to be some bug