Problem: Terrain Collision with HeightfieldCollisionShape in Golf Simulation based on jME3 a4

Hey there,



got some problems with the physics/collision in my terrain from a golf simulation project.



I made an HeightfieldCollisionShape from Heightmap data of the golf terrain.

After that I made an SphereCollisionShape that represents the golf ball.



Collision works, but I think there are holes in the CollisionShape, so that the ball is not colliding at different positions.



The smaller I set the radius of the golf ball CollisionShape, the more often

the ball is falling through the terrain and does not collide with it.

It also depends on the angle I shot the ball how often it is not colliding.



So my question:

How can I debug that? What could be the Problem? Why isn’t the HeightfieldCollisionShape solid?

Is there a possibility to make the HeightfieldCollisionShape visible? Like a grid or something?



Here are the appropriate code extracts for creating terrain collision and golf ball collision:



Terrain:

terrain = new TerrainQuad(“Golfcourse”, 65, 1025, hmap.getHeightMap());



List cameras = new ArrayList();

cameras.add(getCamera());

this.getCamera().setLocation(new Vector3f(140f,25f,430f));

TerrainLodControl control = new TerrainLodControl(terrain, cameras);



terrain.addControl(control);

terrain.setMaterial(matTerrain);



terrain.setModelBound(new BoundingBox());

terrain.updateModelBound();

terrain.setLocalTranslation(0f, 0f, 0f);

terrain.setLocalScale(terrainScale);

terrain.setShadowMode(ShadowMode.Receive);



terrainCollisionShape = new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale());

terrain_phy = new RigidBodyControl(terrainCollisionShape, 0f);



terrain.addControl(terrain_phy);

rootNode.attachChild(terrain);



bulletAppState.getPhysicsSpace().add(terrain_phy);




Golf Ball Collision:

SphereCollisionShape BallCollisionShape = new SphereCollisionShape(0.4f);

Sphere sphere = new Sphere(32, 32, 0.2f, true, false);

sphere.setTextureMode(TextureMode.Projected);



Geometry ball_geo = new Geometry(“cannon ball”, sphere);

ball_geo.setMaterial(new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”));



rootNode.attachChild(ball_geo);



/** Position the golf ball and activate shadows /

ball_geo.setLocalTranslation(pos_x,terrain.getHeight(new Vector2f(pos_x,pos_z))+3,cam.getLocation().z);

ball_geo.setShadowMode(ShadowMode.Cast);



/
* Make the ball physcial with a mass > 0.0f /

ball_phy = new RigidBodyControl(BallCollisionShape);



/
* Add physical ball to physics space. /

ball_geo.addControl(ball_phy);

bulletAppState.getPhysicsSpace().add(ball_phy);



/
* Accelerate the physcial ball to shoot it. */

ball_phy.setLinearVelocity(cam.getDirection().mult(65));

ball_phy.setMass(0.8f);

ball_phy.setLinearDamping(0.2f);



curBallGeo = ball_geo;




Would be very thankful if someboy could help me with that



greetings mw

Nobody got some Tips or work arounds?

You’ve probably solved it, but you might want to have a look at this anyways:

http://www.panda3d.org/manual/index.php/Bullet_Continuous_Collision_Detection

I also saw @normen mentioning problems with jBullet and ccd, so native bullet could be benefitial.