I’m modifying a Terrain in realtime, while some CharacterControl are walking on it. I’m using jbullet (native bullet instead crashes without exception).
This is the exception:
java.lang.NullPointerException
at com.bulletphysics.collision.dispatch.SimulationIslandManager.buildAndProcessIslands(SimulationIslandManager.java:284)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.solveConstraints(DiscreteDynamicsWorld.java:641)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(DiscreteDynamicsWorld.java:385)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(DiscreteDynamicsWorld.java:339)
at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:330)
at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:317)
at com.jme3.bullet.BulletAppState.render(BulletAppState.java:257)
at com.jme3.app.state.AppStateManager.render(AppStateManager.java:300)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)
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)
After changing the TerrainQuad’s geometry, I update the collisionShape this way:
initLevelAppState.terrain.removeControl(initLevelAppState.landscape);
bulletAppState.getPhysicsSpace().remove(initLevelAppState.landscape);
CollisionShape terrainShape =
CollisionShapeFactory.createMeshShape(initLevelAppState.sceneModel);
initLevelAppState.landscape = new RigidBodyControl(terrainShape, 0);
initLevelAppState.terrain.addControl(initLevelAppState.landscape);
bulletAppState.getPhysicsSpace().add(initLevelAppState.landscape);