getTerrainAtCell(getCurrentCell()) returns null

I have a spot of difficulty getting getTerrainAtCell running. I get null as return value from getTerrainAtCell(cell) when I would expect it to not be null.



I poll the following method each 500 ms.

[java]

public TerrainQuadInformation getTerrainQuadInformation() {



final Vector3f cell = this.terrainGrid.getCurrentCell();

if (cell != null) {

final Terrain terrain =

this.terrainGrid.getTerrainAtCell(cell);

if (terrain != null) {

// Do some processing

} else {

log.log(Level.WARNING, "Grid returned null for cell {0}", cell);

return null;

}

} else {

log.log(Level.WARNING, "Grid returned null for current cell");

return null;

}

}

[/java]



I also have a grid listener contributing to the trace:

[java]

public void tileAttached(Vector3f cell, TerrainQuad quad) {

log.log(Level.FINE, "Tile attached, cell: {0} Quad: {1}", new Object{cell, quad});



[/java]



This is an excerpt from the log, when the camera starts at 0,0,0 I get values back. When I move the camera the terrain attached another cell and then I get null back. Even if I let it run for quite some time (to let background threads finish loading terrain).



FINE: Tile attached, cell: (1.0, 0.0, 0.0) Quad: Frozen Quad: (1.0, 0.0, 0.0) (TerrainQuad)
FINE: Tile attached, cell: (0.0, 0.0, 1.0) Quad: Frozen Quad: (0.0, 0.0, 1.0) (TerrainQuad)
FINE: Tile attached, cell: (1.0, 0.0, 1.0) Quad: Frozen Quad: (1.0, 0.0, 1.0) (TerrainQuad)
fixed normals (0.0, 0.0, 0.0)
FINE: Grid moved: (0.0, 0.0, -1.0)
WARNING: Grid returned null for cell (0.0, 0.0, -1.0)
FINE: Tile attached, cell: (0.0, 0.0, -1.0) Quad: Frozen Quad: (0.0, 0.0, -1.0) (TerrainQuad)
FINE: Tile attached, cell: (1.0, 0.0, -1.0) Quad: Frozen Quad: (1.0, 0.0, -1.0) (TerrainQuad)
fixed normals (0.0, 0.0, -1025.0)
FINE: Tile detached, cell: (-0.49902534, 0.0, 0.49902534) Quad: Frozen Quad: (0.0, 0.0, 1.0) (TerrainQuad)
FINE: Tile detached, cell: (0.49902534, 0.0, 0.49902534) Quad: Frozen Quad: (1.0, 0.0, 1.0) (TerrainQuad)
WARNING: Grid returned null for cell (0.0, 0.0, -1.0)
WARNING: Grid returned null for cell (0.0, 0.0, -1.0)

Sorry about that, fix is in SVN.

1 Like