Open stephengold opened 5 years ago
The problem appears to be with HeightfieldTerrainShape.processAllTriangles()
in com.bulletphysics.dom
I tried adding my own triangle callback to the debug shape factory to count the triangles, and I can confirm that my callback is added but processTriangle() is never called.
in jme3-jbullet com.jme3.bullet.util.DebugShapeFactory
public static Mesh getDebugMesh(CollisionShape shape) {
Mesh mesh = null;
if (shape.getCShape() instanceof ConvexShape) {
mesh = new Mesh();
mesh.setBuffer(Type.Position, 3, getVertices((ConvexShape) shape.getCShape()));
mesh.getFloatBuffer(Type.Position).clear();
} else if (shape.getCShape() instanceof ConcaveShape) {
mesh = new Mesh();
mesh.setBuffer(Type.Position, 3, getVertices((ConcaveShape) shape.getCShape()));
mesh.getFloatBuffer(Type.Position).clear();
}
if(shape instanceof HeightfieldCollisionShape){
HeightfieldTerrainShape hts = (HeightfieldTerrainShape)shape.getCShape();
System.out.println("Heightfield "+shape+" is being processed");
hts.processAllTriangles(new TriangleCallback(){
int count = 0;
@Override
public void processTriangle(Vector3f[] vctrfs, int i, int i1) {
System.out.println(count++);
}
}, aabbMin, aabbMax);
}
return mesh;
}
This prints the following when run with @stephengold 's changes (truncated for clarification)
...
Jun 23, 2019 10:58:51 AM com.jme3.terrain.noise.filter.PerturbFilter filter
INFO: Found origSize : 147 and offset: 17 for workSize : 181 and magnitude : 0.119
Heightfield com.jme3.bullet.collision.shapes.HeightfieldCollisionShape@5f6a6954 is being processed
Heightfield com.jme3.bullet.collision.shapes.HeightfieldCollisionShape@7ae4f5d2 is being processed
Jun 23, 2019 10:58:51 AM com.jme3.terrain.noise.filter.PerturbFilter filter
INFO: Found origSize : 147 and offset: 17 for workSize : 181 and magnitude : 0.119
Jun 23, 2019 10:58:51 AM com.jme3.terrain.noise.filter.PerturbFilter filter
INFO: Found origSize : 147 and offset: 17 for workSize : 181 and magnitude : 0.119
Heightfield com.jme3.bullet.collision.shapes.HeightfieldCollisionShape@ff3be6c is being processed
Jun 23, 2019 10:58:51 AM com.jme3.terrain.noise.filter.PerturbFilter filter
INFO: Found origSize : 147 and offset: 17 for workSize : 181 and magnitude : 0.119
Heightfield com.jme3.bullet.collision.shapes.HeightfieldCollisionShape@68389924 is being processed
Jun 23, 2019 10:58:51 AM com.jme3.terrain.noise.filter.PerturbFilter filter
INFO: Found origSize : 147 and offset: 17 for workSize : 181 and magnitude : 0.119
...
Physics debug visualization works for
HeightfieldCollisionShape
injme3-bullet
but not injme3-jbullet
.To demonstrate this issue, modify
jme3test.terrain.TerrainGridAlphaMapTest
as follows:With
jme3-bullet
, theHeightfieldCollisionShape
is visualized as blue wireframe, overlaid on the grass/dirt/rock. Withjme3-jbullet
, only the grass/dirt/rock is visible.