fixed terrain picking bug

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8138 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent eef34897be
commit 3f6834d7c7
  1. 13
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainPatch.java
  2. 7
      engine/src/terrain/com/jme3/terrain/geomipmap/TerrainQuad.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();
}
}
}
}

@ -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);

Loading…
Cancel
Save