Browse Source

fixed terrain picking bug

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8138 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
bre..ns 14 years ago
parent
commit
3f6834d7c7

+ 12 - 1
engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java

@@ -1048,7 +1048,8 @@ public class TerrainPatch extends Geometry {
         
         Mesh regen = geomap.createMesh(stepScale, new Vector2f(1,1), offset, offsetAmount, totalSize, false);
         setMesh(regen);
-        TangentBinormalGenerator.generate(this); // note that this will be removed
+        //TangentBinormalGenerator.generate(this); // note that this will be removed
+        ensurePositiveVolumeBBox();
     }
 
     @Override
@@ -1072,6 +1073,16 @@ public class TerrainPatch extends Geometry {
         return clone;
     }
 
+    protected void ensurePositiveVolumeBBox() {
+        if (getModelBound() instanceof BoundingBox) {
+            if (((BoundingBox)getModelBound()).getYExtent() < 0.001f) {
+                // a correction so the box always has a volume
+                ((BoundingBox)getModelBound()).setYExtent(0.001f);
+                updateWorldBound();
+            }
+        }
+    }
+
 
 
 }

+ 1 - 6
engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java

@@ -1496,12 +1496,7 @@ public class TerrainQuad extends Node implements Terrain {
                 for (int i = 0; i < getQuantity(); i++) {
                     if (children.get(i) instanceof TerrainPatch) {
                         TerrainPatch tp = (TerrainPatch) children.get(i);
-                        if (tp.getModelBound() instanceof BoundingBox) {
-                            if (((BoundingBox)tp.getModelBound()).getYExtent() == 0) {
-                                // a correction so the box always has a volume
-                                ((BoundingBox)tp.getModelBound()).setYExtent(0.00001f);
-                            }
-                        }
+                        tp.ensurePositiveVolumeBBox();
                         if (tp.getWorldBound().intersects(toTest)) {
                             CollisionResults cr = new CollisionResults();
                             toTest.collideWith(tp.getWorldBound(), cr);