ClassCast Exception

Hello,



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(CollisionWorld.java:470)

at com.bulletphysics.collision.dispatch.GhostObject.convexSweepTest(GhostObject.java:119)

at com.bulletphysics.dynamics.character.KinematicCharacterController.stepUp(KinematicCharacterController.java:449)

at com.bulletphysics.dynamics.character.KinematicCharacterController.playerStep(KinematicCharacterController.java:235)

at com.bulletphysics.dynamics.character.KinematicCharacterController.updateAction(KinematicCharacterController.java:136)

at com.bulletphysics.dynamics.DiscreteDynamicsWorld.updateActions(DiscreteDynamicsWorld.java:455)

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

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

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

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

at com.jme3.app.SimpleBulletApplication.update(SimpleBulletApplication.java:301)

at jme3test.terrain.TerrainTestCollision.update(TerrainTestCollision.java:192)

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

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

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

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

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.

Cheers,

Normen

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 CollisionWorld.java… 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).

Cheers,

Normen

Yest it works, and i mostly use eclipse.

Thank you again Normen!