enableDebug() exception about CompoundShape (but I am not using any!) with tree model collision

Hi!

.

I am almost sure it happens when I create the tree model and add rigid body collision to it, with this code:

[patch] model.addControl(new RigidBodyControl(0));

bulletAppState.getPhysicsSpace().addAll(model);

model.getControl(RigidBodyControl.class).setCcdMotionThreshold(0.1f); //precise collision!

[/patch]

should I add some code to above? it dont happens always… only some times!

.

Despite I am not using any CompoundShape in my code, I get this exception below:

[patch]SEVERE: null

java.util.concurrent.ExecutionException: java.lang.ClassCastException: com.bulletphysics.collision.shapes.BvhTriangleMeshShape cannot be cast to com.bulletphysics.collision.shapes.CompoundShape

at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)

at java.util.concurrent.FutureTask.get(FutureTask.java:111)

at com.jme3.bullet.BulletAppState.postRender(BulletAppState.java:197)

at com.jme3.app.state.AppStateManager.postRender(AppStateManager.java:185)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:143)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:171)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:217)

at java.lang.Thread.run(Thread.java:636)

Caused by: java.lang.ClassCastException: com.bulletphysics.collision.shapes.BvhTriangleMeshShape cannot be cast to com.bulletphysics.collision.shapes.CompoundShape

at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.processCollision(CompoundCollisionAlgorithm.java:87)

at com.bulletphysics.collision.dispatch.DefaultNearCallback.handleCollision(DefaultNearCallback.java:55)

at com.bulletphysics.collision.dispatch.CollisionDispatcher$CollisionPairCallback.processOverlap(CollisionDispatcher.java:236)

at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.processAllOverlappingPairs(HashedOverlappingPairCache.java:190)

at com.bulletphysics.collision.dispatch.CollisionDispatcher.dispatchAllCollisionPairs(CollisionDispatcher.java:247)

at com.bulletphysics.collision.dispatch.CollisionWorld.performDiscreteCollisionDetection(CollisionWorld.java:150)

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(DiscreteDynamicsWorld.java:378)

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(DiscreteDynamicsWorld.java:339)

at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:342)

at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:329)

at com.jme3.bullet.BulletAppState$1.call(BulletAppState.java:102)

at com.jme3.bullet.BulletAppState$1.call(BulletAppState.java:1)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

at java.util.concurrent.FutureTask.run(FutureTask.java:166)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

… 1 more[/patch]

.

if I let it continue running, there is a time I update the tree collision and I get this exception below:

[patch]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at com.bulletphysics.collision.shapes.ByteBufferVertexData.getVertex(ByteBufferVertexData.java:59)

at com.bulletphysics.collision.shapes.VertexData.getTriangle(VertexData.java:53)

at com.bulletphysics.collision.shapes.BvhTriangleMeshShape$MyNodeOverlapCallback.processNode(BvhTriangleMeshShape.java:265)

at com.bulletphysics.collision.shapes.OptimizedBvh.walkStacklessQuantizedTree(OptimizedBvh.java:955)

at com.bulletphysics.collision.shapes.OptimizedBvh.reportAabbOverlappingNodex(OptimizedBvh.java:703)

at com.bulletphysics.collision.shapes.BvhTriangleMeshShape.processAllTriangles(BvhTriangleMeshShape.java:163)

at com.jme3.bullet.util.DebugShapeFactory.getVertices(DebugShapeFactory.java:148)

at com.jme3.bullet.util.DebugShapeFactory.getDebugMesh(DebugShapeFactory.java:133)

at com.jme3.bullet.util.DebugShapeFactory.createDebugShape(DebugShapeFactory.java:117)

at com.jme3.bullet.util.DebugShapeFactory.getDebugShape(DebugShapeFactory.java:86)

at com.jme3.bullet.collision.PhysicsCollisionObject.getDebugShape(PhysicsCollisionObject.java:227)

at com.jme3.bullet.objects.PhysicsRigidBody.getDebugShape(PhysicsRigidBody.java:630)

at com.jme3.bullet.collision.PhysicsCollisionObject.attachDebugShape(PhysicsCollisionObject.java:214)

at com.jme3.bullet.collision.PhysicsCollisionObject.attachDebugShape(PhysicsCollisionObject.java:178)

at com.jme3.bullet.control.RigidBodyControl.render(RigidBodyControl.java:217)

at com.jme3.scene.Spatial.runControlRender(Spatial.java:514)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:510)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:520)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:520)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:520)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:716)

at com.jme3.renderer.RenderManager.render(RenderManager.java:748)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:257)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:143)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:171)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:217)

at java.lang.Thread.run(Thread.java:636)[/patch]



EDIT: by disabling debug before changing tree physics collision, and re-enabling debug after it, the above exception does not happens, but the below still happens after some time…

[patch]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at com.bulletphysics.collision.shapes.ByteBufferVertexData.getIndex(ByteBufferVertexData.java:78)

at com.bulletphysics.collision.shapes.VertexData.getTriangle(VertexData.java:53)

at com.bulletphysics.collision.shapes.BvhTriangleMeshShape$MyNodeOverlapCallback.processNode(BvhTriangleMeshShape.java:265)

at com.bulletphysics.collision.shapes.OptimizedBvh.walkStacklessQuantizedTree(OptimizedBvh.java:955)

at com.bulletphysics.collision.shapes.OptimizedBvh.reportAabbOverlappingNodex(OptimizedBvh.java:703)

at com.bulletphysics.collision.shapes.BvhTriangleMeshShape.processAllTriangles(BvhTriangleMeshShape.java:163)

at com.jme3.bullet.util.DebugShapeFactory.getVertices(DebugShapeFactory.java:148)

at com.jme3.bullet.util.DebugShapeFactory.getDebugMesh(DebugShapeFactory.java:133)

at com.jme3.bullet.util.DebugShapeFactory.createDebugShape(DebugShapeFactory.java:117)

at com.jme3.bullet.util.DebugShapeFactory.getDebugShape(DebugShapeFactory.java:86)

at com.jme3.bullet.collision.PhysicsCollisionObject.getDebugShape(PhysicsCollisionObject.java:227)

at com.jme3.bullet.objects.PhysicsRigidBody.getDebugShape(PhysicsRigidBody.java:630)

at com.jme3.bullet.collision.PhysicsCollisionObject.attachDebugShape(PhysicsCollisionObject.java:214)

at com.jme3.bullet.collision.PhysicsCollisionObject.attachDebugShape(PhysicsCollisionObject.java:178)

at com.jme3.bullet.control.RigidBodyControl.render(RigidBodyControl.java:217)

at com.jme3.scene.Spatial.runControlRender(Spatial.java:514)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:510)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:520)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:520)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:520)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:716)

at com.jme3.renderer.RenderManager.render(RenderManager.java:748)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:257)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:143)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:171)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:217)

at java.lang.Thread.run(Thread.java:636)[/patch]

A tree with leafs is not a proper physics mesh… Use a hull collision shape for it.

Seems to be working,

Also instead of that, I am thinking on using a simple cylinder for the tree trunk, I need to see how to do this tho yet.

thx!