From 3f6834d7c799864c27c8b3a0627f0933b0a9e708 Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Wed, 31 Aug 2011 15:49:53 +0000 Subject: [PATCH] fixed terrain picking bug git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8138 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/terrain/geomipmap/TerrainPatch.java | 13 ++++++++++++- .../com/jme3/terrain/geomipmap/TerrainQuad.java | 7 +------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java index fecebdd19..6024111c5 100644 --- a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java +++ b/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(); + } + } + } + } diff --git a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java b/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java index 66fbe4538..70e92569b 100644 --- a/engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.java +++ b/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);