ClassCast Exception


Im having issues when adding a PhysicsCharacterNode, im getting a collision shape class cast exception. I searched for an answer on monkey’s jbullet svn repository and since i don’t fully understand how nodes work, and how dose the collision shapes get so oddly messed up i couldn’t fix it or come up with a fix.

The only thing i know is that HeightfieldTerrainShape extends ConcaveShape and also BvhTriangleMeshShape extends TriangleMeshShape witch also extends ConcaveShape. The thing that i wander is how come the terrain shape gets casted to the players shape.

Stack Trace:

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

java.lang.ClassCastException: com.bulletphysics.dom.HeightfieldTerrainShape cannot be cast to com.bulletphysics.collision.shapes.BvhTriangleMeshShape

at com.bulletphysics.collision.dispatch.CollisionWorld.objectQuerySingle(

at com.bulletphysics.collision.dispatch.GhostObject.convexSweepTest(

at com.bulletphysics.dynamics.character.KinematicCharacterController.stepUp(

at com.bulletphysics.dynamics.character.KinematicCharacterController.playerStep(

at com.bulletphysics.dynamics.character.KinematicCharacterController.updateAction(

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.updateActions(

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(

at com.jme3.bullet.PhysicsSpace.update(

at com.jme3.bullet.PhysicsSpace.update(


at jme3test.terrain.TerrainTestCollision.update(

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(



Hm, this is not a problem within jme3, seems like the heightfield shape is not working too well with the character node in jbullet, I will have to dig into this and fix it in jbullet.



Thank you Normen,

I’ll try to do it on my self too… tho ill need to study jbullet more. >.<

The problem is here, in… I think this should be working in the native c++ version of bullet, I will have a look at how its done there and port it over to the java version.

This exception occurs only when i add the player to the physics space, and yeah thats where the class cast is being made… can’t it be fixed with a ‘instanceof’ boolean check ?

Its more complicated than that, there has to be a collision check for this kind of collision, otherwise the character would fall right through the floor.

oh! i see.

Ok, I think I fixed the character on terrain, I put a new version of jbullet.jar in svn. I also just triggered a build for jMP, so you should be able to get the latest version by updating jMP in some minutes (if you have the nightly updates activated in Tools->Plugins).



Yest it works, and i mostly use eclipse.

Thank you again Normen!