From 0342cceaaf858d24ca4c51f4d1a3e710907d5ba0 Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Mon, 14 Nov 2011 20:43:56 +0000 Subject: [PATCH] fixed bug with terrain grid and cached neighbours in terrainQuad not being reset git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8673 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/terrain/geomipmap/TerrainGrid.java | 2 +- .../jme3/terrain/geomipmap/TerrainQuad.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java index ff81bff8f..a387974fa 100644 --- a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java +++ b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java @@ -105,6 +105,7 @@ public class TerrainGrid extends TerrainQuad { public Object call() throws Exception { attachQuadAt(newQuad, quadrant, temp); + newQuad.resetCachedNeighbours(); return null; } }); @@ -255,7 +256,6 @@ public class TerrainGrid extends TerrainQuad { for (TerrainGridListener l : listeners.values()) { l.tileAttached(cam, q); } - System.err.println("attachQuadAt "+quadrant+", children: "+this.getChildren().size()); updateModelBound(); } diff --git a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java index 596355b72..501613266 100644 --- a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java +++ b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java @@ -545,6 +545,24 @@ public class TerrainQuad extends Node implements Terrain { } } + /** + * TerrainQuad caches neighbours for faster LOD checks. + * Sometimes you might want to reset this cache (for instance in TerrainGrid) + */ + protected void resetCachedNeighbours() { + if (children != null) { + for (int x = children.size(); --x >= 0;) { + Spatial child = children.get(x); + if (child instanceof TerrainQuad) { + ((TerrainQuad) child).resetCachedNeighbours(); + } else if (child instanceof TerrainPatch) { + TerrainPatch patch = (TerrainPatch) child; + patch.searchedForNeighboursAlready = false; + } + } + } + } + /** * Find any neighbours that should have their edges seamed because another neighbour * changed its LOD to a greater value (less detailed)