[SOLVED] TerrainQuad issues

Hello !
I’m actually working on the TerrainQuad

new TerrainQuad("Main", patchSize, totalSize + 1, data);

but I have some missing triangles and the question is … how it’s possible :smile:

Thanks for your help

I encountered such a problem when I created a heightfield dynamically and by error some values in the heigthfield (the height array) was ‘NaN’. So maybe your ‘data’ is broken somehow.

how float can be NaN ?

public FloatBuffer writeVertexArray(FloatBuffer store, Vector3f scale,
boolean center) {

	if (store != null) {
		if (store.remaining() < width * height * 3)
			throw new BufferUnderflowException();
	} else {
		store = BufferUtils.createFloatBuffer(width * height * 3);
	}

	assert hdata.length == height * width;

	Vector3f offset = new Vector3f(-getWidth() * scale.x * 0.5f, 0,
			-getWidth() * scale.z * 0.5f);
	if (!center)
		offset.zero();

	int i = 0;
	for (int z = 0; z < height; z++) {
		for (int x = 0; x < width; x++) {
			store.put((float) x * scale.x + offset.x);
			float value = (float) hdata[i++] * scale.y;
			if (Float.NaN == value) {
				System.out.println("NaN value occured !");
			}
			store.put(value);
			store.put((float) z * scale.z + offset.z);
		}
	}

	return store;
}

values are never NaN ( the class is GeoMap.java )

if(Float.isNaN(value)){
System.out.println(“NaN occured !”);
}

and effectivly NaN occured !

Nice :slight_smile: