AbstractHeightMap.flatten() bug & optimization curiosities


I don’t know if this has been reported already, but “flatten()” doesn’t work.

It uses “normalizeTerrain( 1f )” then does its flattening, but doesn’t “normalizeTerrain( 255f )” back.

Also, about optimization :

  • why are those algorithms working in two dimensions “heightData[i + j * size]” when only one dimension is required : "for (int i = 0; i < heightData.length() ; i++)

    Thanks :slight_smile:

Yeh that method does kind of bork things doesn’t it. I just committed a fix for it that normalizes it back when it is done.

However the algorithm seems to work a little backwards: really flattening the already flat areas, and not flattening the high areas.

I think it is code from jme2 that hasn’t been used much.

I found another bug, in smooth().

[java] if (i < 0 || i > size) {



if (j < 0 || j > size) {




It should be " >= size " instead of " > size "

Thanks ozonegrif, I just committed the fix.