Possible bug? IndexOutOfBoundsException in TerrainPatch.getMeshNormal

I was messing around with TerrainTestModifyHeight, and came across an IndexOutOfBoundsException. At first I thought it must be my code, but it happens in the stock jme3 class as well (using nightly jME3_2013-01-31).

Repro: start up TerrainTestModifyHeight, move the cursor / crosshairs to the “northwest” corner of the terrain (right around 620, -97, -620). The app crashes with:

com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkIndex(Buffer.java:512)
at java.nio.DirectFloatBufferU.get(DirectFloatBufferU.java:248)
at com.jme3.terrain.geomipmap.TerrainPatch.getMeshNormal(TerrainPatch.java:603)
at com.jme3.terrain.geomipmap.TerrainQuad.getMeshNormal(TerrainQuad.java:999)
at com.jme3.terrain.geomipmap.TerrainQuad.getMeshNormal(TerrainQuad.java:997)
at com.jme3.terrain.geomipmap.TerrainQuad.getMeshNormal(TerrainQuad.java:997)
at com.jme3.terrain.geomipmap.TerrainQuad.getNormal(TerrainQuad.java:1131)
at com.jme3.terrain.geomipmap.TerrainQuad.getNormal(TerrainQuad.java:1109)
at jme3test.terrain.TerrainTestModifyHeight.simpleUpdate(TerrainTestModifyHeight.java:125)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:242)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:680)

It looks like whatever worldIntersection is being obtained via TerrainQuad.collideWith() is (sometimes) not actually on the terrain, and causing a later error in TerrainQuad.getNormal(). Not sure if this is a bug in TerrainTestModifyHeight, or something deeper in the framework…

1 Like

Got the same Exceptions (jME3_2013-03-19).
TerrainQuad with patch size 64 (+1) and size 64 (+1).

(no matter which size used)
(no translation)

[java]

this.terrain.getNormal(new Vector2f( -this.halfTerrainSize, -this.halfTerrainSize ));

[/java]