An exception when hit Heightfield with ConvexSweepTest

Post Reply
Chaz
Posts: 44
Joined: Mon Jan 12, 2015 1:36 pm

An exception when hit Heightfield with ConvexSweepTest

Post by Chaz »

Hello. Use JBullet. When performing convex sweep test got an error.
java.lang.ClassCastException: com.bulletphysics.collision.shapes.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.CollisionWorld.convexSweepTest(CollisionWorld.java:617)
I tried it without HeightfieldTerrainShape in the world and saw that it works nice with simple collision object like Box.
Here is simple code for using sweep test

Code: Select all

 Transform from = new Transform(new Matrix4f(new Quat4f(0,0,0,1), new Vector3f(0,100,0),1));
                        Transform to = new Transform(new Matrix4f(new Quat4f(0,0,0,1), new Vector3f(0,-100,0),1));
                        CollisionWorld.ClosestConvexResultCallback callback = new CollisionWorld.ClosestConvexResultCallback(from.origin, to.origin);

                        callback.collisionFilterGroup=2;

                        dynamicsWorld.convexSweepTest(new SphereShape(5),from,to,callback);

                        if(callback.hasHit())
                        {
                            System.out.println("Hit!"+" "+callback.hitCollisionObject.getCollisionShape().getName());
                        }
Someone knows why that error occures?
Post Reply