FloatBuffer positions = terrainBlock.getFloatBuffer(Type.Position);
// Prepare to cast rays
Vector3f pos = new Vector3f();
Vector3f dir = new Vector3f(0, -1, 0);
Ray ray = new Ray(pos, dir);
// Prepare collision results
CollisionResults results = new CollisionResults();
// Set the LOD indices on the block
VertexBuffer originalIndices = terrainBlock.getBuffer(Type.Index);
terrainBlock.clearBuffer(Type.Index);
if (lodIndices instanceof IntBuffer)
terrainBlock.setBuffer(Type.Index, 3, (IntBuffer)lodIndices);
else if (lodIndices instanceof ShortBuffer) {
terrainBlock.setBuffer(Type.Index, 3, (ShortBuffer) lodIndices);
}
// Recalculate collision mesh
terrainBlock.createCollisionData();
float entropy = 0;
for (int i = 0; i < positions.limit() / 3; i++){
BufferUtils.populateFromBuffer(pos, positions, i);
float realHeight = pos.y;
pos.addLocal(0, bbox.getYExtent(), 0);
ray.setOrigin(pos);
results.clear();
terrainBlock.collideWith(ray, Matrix4f.IDENTITY, bbox, results);
if (results.size() > 0){