BulletAppState.setDebugEnabled(true) causes crash

I’m working on adding vehicles to a project I’m working on. The collision shape is acting funny, so I decided to try and enable the debug mode to figure out the problem. As soon as the car spawns (or any other rigid body with mass != 0), the game crashes. Here’s the stack trace when the car spawns:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
at com.jme3.scene.Geometry.setMesh(Geometry.java:193)
at com.jme3.bullet.util.DebugShapeFactory.createDebugShape(DebugShapeFactory.java:116)
at com.jme3.bullet.util.DebugShapeFactory.getDebugShape(DebugShapeFactory.java:85)
at com.jme3.bullet.debug.BulletRigidBodyDebugControl.<init>(BulletRigidBodyDebugControl.java:60)
at com.jme3.bullet.debug.BulletDebugAppState.updateRigidBodies(BulletDebugAppState.java:175)
at com.jme3.bullet.debug.BulletDebugAppState.update(BulletDebugAppState.java:118)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:287)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)

I’ve tried placing the .setDebugEnabled before the physics state’s initialization, after it, and even by manual activation and it still instantly crashes if there’s a rigid body with mass in the scene. Is there something I’m missing, or is the new debug state broken?

What kind of collision shape does the failing object have?

Seems like it’s not the right kind of shape… or is null or something.

Well, interesting change. I’m not sure what I did but now it only fails when the vehicle is added. Other dynamic meshes work fine, but only the vehicle is having trouble. Here’s the code I’m using to generate its collision shape:

//Sort out the wheels and body of the vehicles
ArrayList<Node> wheels = new ArrayList();
ArrayList<Node> body = new ArrayList();
for (Spatial child : ((Node) carModel).getChildren()) {
if (child.getName().contains(“Wheel”)) {
wheels.add((Node) child);
} else {
body.add((Node) child);

    //Create the collision shape of the vehicle
    CompoundCollisionShape ccs = new CompoundCollisionShape();
    for (Node child : body) {
        ccs.addChildShape(CollisionShapeFactory.createDynamicMeshShape(child), child.getLocalTranslation());

    //Initialize the vehicle physics
    VehicleControl vc = new VehicleControl(ccs, 500);


I had the method print out each model it was adding to the collision shape, so I know there are child shapes being added (or trying to be added anyway). Same with the wheels. But somehow the mesh being passed into Geometry.setMesh() is null.

I guess maybe the CompoundCollisionShape doesn’t work with debug shapes… it looks like there is supposed to be support for it but I don’t know enough about how it’s supposed to work to make it take that path. I’ve never used bullet so I don’t know.

I found what I did by looking at the source code and comparing it to your stack trace. You could do the same and investigate out further, I guess.

1 Like

I guess I could just attach all of the child shapes to a Node and do a dynamic shape for that whole thing.

I guess the issue is that you make a compound shape the child of another compound shape by using nodes to create the children.