StepSimulation causes segfault when I add a static rigidbody

Post Reply
X14U2NVX
Posts: 4
Joined: Fri Jun 17, 2016 10:00 pm

StepSimulation causes segfault when I add a static rigidbody

Post by X14U2NVX »

I couldn't find a tutorial for this, but essentially what I am trying to do is create a static rigidbody with mass zero from a btBvhTriangleMeshShape.
Code snippet below:

(triMesh is a functioning triangle mesh that I have rendered to authenticate is not the problem).
mass = 0
all other variables have been properly declared in scope

Code: Select all

triangleMeshShape = new btBvhTriangleMeshShape(&triMesh, false);
motionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0,0,0)));
btVector3 fallInertia(0,0,0);
triangleMeshShape->calculateLocalInertia(mass, fallInertia);
btRigidBody::btRigidBodyConstructionInfo customRigidBodyCI1(mass, motionState, triangleMeshShape, fallInertia);
rigidBody = new btRigidBody(customRigidBodyCI1);
dynamicsWorld->addRigidBody(rigidBody);
All of this code compiles and executes, but the program now segfaults on stepSimulation(). If I comment out the last line where the rigid body is added, the program runs fine again. Am I missing a step, taking too many steps, or going about creating a static rigidBody the wrong way?
X14U2NVX
Posts: 4
Joined: Fri Jun 17, 2016 10:00 pm

Re: StepSimulation causes segfault when I add a static rigid

Post by X14U2NVX »

I've discovered why the program was segfaulting: apparently btBvhTriangleMeshShape has an upper bound on the number of triangles you can feed into it and still simulate somewhere in the region of 150000-200000. This seems kind of low to me, I think I still may have another issue.

Also, even though reducing the number of triangles made my program run, the object that should have collision appears to not have collision. Dynamic objects are falling straight through it like it's not there. So I still think there's a better way to go about doing this. Any ideas?

EDIT: The dynamic objects falling through it are of the ConvexHullType. So this is not a case of non-existent concave-concave collision. Is there something I need to do in order to enable convex-concave collision?

EDIT2: Okay so after a series of discoveries, I've figured out that it's not crashing because of anything above. It's crashing *on* the concave to convex collision. Again, I'm using btConvexHulls for my convex shapes (literally boxes at this point for simplicity) and a single, large btBvhTriangleMeshShape for my concave "terrain" object.

EDIT3: Narrowed the issue further to btConvexHull to btBvhTriangleMeshShape collision. Using any of Bullet's predefined meshes instead will allow collision with both of my meshes with no issues. It is only when these meshes collide that I see the crash.
Post Reply