2
0
Эх сурвалжийг харах

added TerrainGrid.getTerrainAtCell(Vector3f cellCoordinate) to get the terrain tile from cell coordinates

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9953 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
bre..om 13 жил өмнө
parent
commit
fa29b95c39

+ 11 - 0
engine/src/terrain/com/jme3/terrain/geomipmap/TerrainGrid.java

@@ -321,6 +321,17 @@ public class TerrainGrid extends TerrainQuad {
         return cache.get(tileCell);
     }
     
+    /**
+     * Get the terrain tile at the specified XZ cell coordinate (not world coordinate).
+     * @param cellCoordinate integer cell coordinates
+     * @return the terrain tile at that location
+     */
+    public Terrain getTerrainAtCell(Vector3f cellCoordinate) {
+        Vector3f gridLocation = cellCoordinate.mult(getLocalScale()).multLocal(quadSize - 1);
+        Vector3f tileCell = getTileCell(gridLocation);
+        return cache.get(tileCell);
+    }
+    
     protected void removeQuad(TerrainQuad q) {
         if (q != null && ( (q.getQuadrant() > 0 && q.getQuadrant()<5) || q.getParent() != null) ) {
             for (TerrainGridListener l : listeners) {